From e1483fe6a94f0819e4b00d5e5515cc5c8b09f45e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Sun, 11 Dec 2011 19:56:23 +0100
Subject: [PATCH] Type-checker: CALL_NOT_LAST_ARG gives a super-set for
 get_first_arg_type().

---
 src/las.c        | 6 ++----
 src/pike_types.c | 6 ++++--
 src/pike_types.h | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/las.c b/src/las.c
index ecc0438d25..18929a432a 100644
--- a/src/las.c
+++ b/src/las.c
@@ -3590,8 +3590,7 @@ void fix_type_field(node *n)
       /* Too few arguments or similar. */
       copy_pike_type(n->type, mixed_type_string);
 
-      if ((s = get_first_arg_type(dmalloc_touch(struct pike_type *, f), 0)) ||
-	  (s = get_first_arg_type(dmalloc_touch(struct pike_type *, f),
+      if ((s = get_first_arg_type(dmalloc_touch(struct pike_type *, f),
 				  CALL_NOT_LAST_ARG))) {
 	yytype_report(REPORT_ERROR, NULL, 0, s,
 		      NULL, 0, NULL,
@@ -4199,8 +4198,7 @@ void fix_type_field(node *n)
       if (sscanf_type) {
 	if (!(n->type = new_get_return_type(sscanf_type, 0))) {
 	  struct pike_type *expected;
-	  if ((expected = get_first_arg_type(sscanf_type, 0)) ||
-	      (expected = get_first_arg_type(sscanf_type, CALL_NOT_LAST_ARG))) {
+	  if ((expected = get_first_arg_type(sscanf_type, CALL_NOT_LAST_ARG))) {
 	    yytype_report(REPORT_ERROR,
 			  NULL, 0, expected,
 			  NULL, 0, NULL,
diff --git a/src/pike_types.c b/src/pike_types.c
index dc7a250410..93060633a7 100644
--- a/src/pike_types.c
+++ b/src/pike_types.c
@@ -61,6 +61,8 @@
 
 /*
  * Flags used by low_get_first_arg_type()
+ *
+ * Note that these differ for the flags to get_first_arg_type().
  */
 #define FILTER_KEEP_VOID 1	/* Keep void during the filtering. */
 
@@ -5212,7 +5214,7 @@ static struct pike_type *debug_low_key_type(struct pike_type *t, node *n)
 	{
 	  /* Get the type of the first argument of the function. */
 	  struct pike_type *res =
-	    get_first_arg_type(ID_FROM_INT(p, i)->type, 0);
+	    get_first_arg_type(ID_FROM_INT(p, i)->type, CALL_NOT_LAST_ARG);
 	  if (res) return res;
 	  /* FIXME: Warn? */
 	  add_ref(string_type_string);
@@ -5225,7 +5227,7 @@ static struct pike_type *debug_low_key_type(struct pike_type *t, node *n)
 	{
 	  /* Get the type of the first argument of the function. */
 	  struct pike_type *res =
-	    get_first_arg_type(ID_FROM_INT(p, i)->type, 0);
+	    get_first_arg_type(ID_FROM_INT(p, i)->type, CALL_NOT_LAST_ARG);
 	  if (res) return res;
 	  /* FIXME: Warn? */
 	  add_ref(mixed_type_string);
diff --git a/src/pike_types.h b/src/pike_types.h
index 8ed036d034..005e8b1c62 100644
--- a/src/pike_types.h
+++ b/src/pike_types.h
@@ -73,7 +73,7 @@ BLOCK_ALLOC(pike_type, n/a);
 #define PT_FLAG_MARK_ASSIGN	0x3ff3ff	/* Assigns AND Markers. */
 
 /*
- * new_check_call() and check_splice_call() flags
+ * new_check_call(), check_splice_call() and get_first_arg_type() flags
  */
 #define CALL_STRICT		0x0001	/* Strict checking. */
 #define CALL_NOT_LAST_ARG	0x0002	/* This is not the last argument. */
-- 
GitLab