diff mbox

c/70883 - inconsistent error message for calls to __builtin_add_overflow with too few arguments

Message ID 574F4EF6.2080507@gmail.com
State New
Headers show

Commit Message

Martin Sebor June 1, 2016, 9:09 p.m. UTC
Jakub,

As you requested in the discussion of my arithmetic overflow
built-in patch, attached is the subset of the patch to make
consistent with other such diagnostics the text of the error
message issued for insufficient numbers of arguments in calls
to built-in functions such as __builtin_add_overflow,
__builtin_constant_p, and others.

Thanks
Martin

Comments

Martin Sebor June 8, 2016, 2:44 a.m. UTC | #1
Ping: This is a trivial patch to make the text of an error message
for an insufficient number of arguments to a built-in consistent
across different built-ins.  Rather that sometimes saying "not
enough arguments" and others "too few arguments" the patch makes
GCC print "too few" in all cases.

   https://gcc.gnu.org/ml/gcc-patches/2016-06/msg00093.html

On 06/01/2016 03:09 PM, Martin Sebor wrote:
> Jakub,
>
> As you requested in the discussion of my arithmetic overflow
> built-in patch, attached is the subset of the patch to make
> consistent with other such diagnostics the text of the error
> message issued for insufficient numbers of arguments in calls
> to built-in functions such as __builtin_add_overflow,
> __builtin_constant_p, and others.
>
> Thanks
> Martin
Jeff Law June 9, 2016, 3:56 p.m. UTC | #2
On 06/07/2016 08:44 PM, Martin Sebor wrote:
> Ping: This is a trivial patch to make the text of an error message
> for an insufficient number of arguments to a built-in consistent
> across different built-ins.  Rather that sometimes saying "not
> enough arguments" and others "too few arguments" the patch makes
> GCC print "too few" in all cases.
>
>   https://gcc.gnu.org/ml/gcc-patches/2016-06/msg00093.html
OK.
jeff
diff mbox

Patch

PR c/70883 - inconsistent error message for calls to __builtin_add_overflow
  with too few arguments

gcc/c-family/ChangeLog:
2016-06-01  Martin Sebor  <msebor@redhat.com>

	PR c/70883
	* c-common.c (builtin_function_validate_nargs): Make text of error
	message consistent with others like it.

gcc/testsuite/ChangeLog:
2016-06-01  Martin Sebor  <msebor@redhat.com>

	PR c/70883
	* c-c++-common/builtin-arith-overflow-1.c: Adjust diagnostic text.
	* gcc.dg/builtin-constant_p-1.c: Same.
	* gcc.dg/builtins-error.c: Same.
	* gcc.dg/pr70859.c: Same.

Index: gcc/c-family/c-common.c
===================================================================
--- gcc/c-family/c-common.c	(revision 237007)
+++ gcc/c-family/c-common.c	(working copy)
@@ -9805,7 +9805,7 @@  builtin_function_validate_nargs (locatio
 {
   if (nargs < required)
     {
-      error_at (loc, "not enough arguments to function %qE", fndecl);
+      error_at (loc, "too few arguments to function %qE", fndecl);
       return false;
     }
   else if (nargs > required)
Index: gcc/testsuite/c-c++-common/builtin-arith-overflow-1.c
===================================================================
--- gcc/testsuite/c-c++-common/builtin-arith-overflow-1.c	(revision 237007)
+++ gcc/testsuite/c-c++-common/builtin-arith-overflow-1.c	(working copy)
@@ -3,9 +3,9 @@ 
 int
 f1 (void)
 {
-  int x = __builtin_add_overflow ();	/* { dg-error "not enough arguments to function" } */
-  x += __builtin_sub_overflow ();	/* { dg-error "not enough arguments to function" } */
-  x += __builtin_mul_overflow ();	/* { dg-error "not enough arguments to function" } */
+  int x = __builtin_add_overflow ();	/* { dg-error "too few arguments to function" } */
+  x += __builtin_sub_overflow ();	/* { dg-error "too few arguments to function" } */
+  x += __builtin_mul_overflow ();	/* { dg-error "too few arguments to function" } */
   return x;
 }
 
Index: gcc/testsuite/gcc.dg/builtin-constant_p-1.c
===================================================================
--- gcc/testsuite/gcc.dg/builtin-constant_p-1.c	(revision 237007)
+++ gcc/testsuite/gcc.dg/builtin-constant_p-1.c	(working copy)
@@ -2,9 +2,9 @@ 
 
 int main()
 {
-  if (__builtin_constant_p ()) /* { dg-error "not enough" } */
+  if (__builtin_constant_p ()) /* { dg-error "too few arguments" } */
     return 0;
-  if (__builtin_constant_p (5, 6)) /* { dg-error "too many" } */
+  if (__builtin_constant_p (5, 6)) /* { dg-error "too many arguments" } */
     return 1;
   return 0;
 }
Index: gcc/testsuite/gcc.dg/builtins-error.c
===================================================================
--- gcc/testsuite/gcc.dg/builtins-error.c	(revision 237007)
+++ gcc/testsuite/gcc.dg/builtins-error.c	(working copy)
@@ -23,19 +23,19 @@  int test1(struct X x)
 
 int test2(double x)
 {
-  if (x ==  1) return __builtin_fpclassify(1,2,3,4,5); /* { dg-error "not enough arguments" } */
-  if (x ==  2) return __builtin_isfinite(); /* { dg-error "not enough arguments" } */
-  if (x ==  3) return __builtin_isinf_sign(); /* { dg-error "not enough arguments" } */
-  if (x ==  4) return __builtin_isinf(); /* { dg-error "not enough arguments" } */
-  if (x ==  5) return __builtin_isnan(); /* { dg-error "not enough arguments" } */
-  if (x ==  6) return __builtin_isnormal(); /* { dg-error "not enough arguments" } */
-  if (x ==  7) return __builtin_isgreater(x); /* { dg-error "not enough arguments" } */
-  if (x ==  8) return __builtin_isgreaterequal(x); /* { dg-error "not enough arguments" } */
-  if (x ==  9) return __builtin_isless(x); /* { dg-error "not enough arguments" } */
-  if (x == 10) return __builtin_islessequal(x); /* { dg-error "not enough arguments" } */
-  if (x == 11) return __builtin_islessgreater(x); /* { dg-error "not enough arguments" } */
-  if (x == 12) return __builtin_isunordered(x); /* { dg-error "not enough arguments" } */
-  if (x == 13) return __builtin_signbit(); /* { dg-error "not enough arguments" } */
+  if (x ==  1) return __builtin_fpclassify(1,2,3,4,5); /* { dg-error "too few arguments" } */
+  if (x ==  2) return __builtin_isfinite(); /* { dg-error "too few arguments" } */
+  if (x ==  3) return __builtin_isinf_sign(); /* { dg-error "too few arguments" } */
+  if (x ==  4) return __builtin_isinf(); /* { dg-error "too few arguments" } */
+  if (x ==  5) return __builtin_isnan(); /* { dg-error "too few arguments" } */
+  if (x ==  6) return __builtin_isnormal(); /* { dg-error "too few arguments" } */
+  if (x ==  7) return __builtin_isgreater(x); /* { dg-error "too few arguments" } */
+  if (x ==  8) return __builtin_isgreaterequal(x); /* { dg-error "too few arguments" } */
+  if (x ==  9) return __builtin_isless(x); /* { dg-error "too few arguments" } */
+  if (x == 10) return __builtin_islessequal(x); /* { dg-error "too few arguments" } */
+  if (x == 11) return __builtin_islessgreater(x); /* { dg-error "too few arguments" } */
+  if (x == 12) return __builtin_isunordered(x); /* { dg-error "too few arguments" } */
+  if (x == 13) return __builtin_signbit(); /* { dg-error "too few arguments" } */
   return 0;
 }
 
Index: gcc/testsuite/gcc.dg/pr70859.c
===================================================================
--- gcc/testsuite/gcc.dg/pr70859.c	(revision 237007)
+++ gcc/testsuite/gcc.dg/pr70859.c	(working copy)
@@ -41,19 +41,19 @@  fn0 (int n)
 int
 fn1 (void)
 {
-  if (__builtin_constant_p ()) /* { dg-error "7:not enough" } */
+  if (__builtin_constant_p ()) /* { dg-error "7:too few" } */
     return 0;
   if (__builtin_constant_p (1, 2)) /* { dg-error "7:too many" } */
     return 1;
-  if (__builtin_isfinite ()) /* { dg-error "7:not enough" } */
+  if (__builtin_isfinite ()) /* { dg-error "7:too few" } */
     return 3;
   if (__builtin_isfinite (1, 2)) /* { dg-error "7:too many" } */
     return 4;
-  if (__builtin_isless (0)) /* { dg-error "7:not enough" } */
+  if (__builtin_isless (0)) /* { dg-error "7:too few" } */
     return 5;
   if (__builtin_isless (1, 2, 3)) /* { dg-error "7:too many" } */
     return 6;
-  if (__builtin_fpclassify (1, 2, 3, 4, 5)) /* { dg-error "7:not enough" } */
+  if (__builtin_fpclassify (1, 2, 3, 4, 5)) /* { dg-error "7:too few" } */
     return 7;
   if (__builtin_fpclassify (1, 2, 3, 4, 5, r, 6)) /* { dg-error "7:too many" } */
     return 8;
@@ -61,7 +61,7 @@  fn1 (void)
     return 9;
   if (__builtin_assume_aligned (p, r, p, p)) /* { dg-error "7:too many" } */
     return 10;
-  if (__builtin_add_overflow ()) /* { dg-error "7:not enough" } */
+  if (__builtin_add_overflow ()) /* { dg-error "7:too few" } */
     return 11;
   if (__builtin_add_overflow (1, 2, 3, &r)) /* { dg-error "7:too many" } */
     return 12;