Commit e01b4e16 by Martin Sebor Committed by Martin Sebor

PR c/70883 - inconsistent error message for calls to __builtin_add_overflow

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

gcc/c-family/ChangeLog:
2016-06-09  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-09  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.

From-SVN: r237268
parent 386a87e4
2016-06-09 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.
2016-06-08 Martin Sebor <msebor@redhat.com> 2016-06-08 Martin Sebor <msebor@redhat.com>
Jakub Jelinek <jakub@redhat.com> Jakub Jelinek <jakub@redhat.com>
......
...@@ -9828,7 +9828,7 @@ builtin_function_validate_nargs (location_t loc, tree fndecl, int nargs, ...@@ -9828,7 +9828,7 @@ builtin_function_validate_nargs (location_t loc, tree fndecl, int nargs,
{ {
if (nargs < required) 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; return false;
} }
else if (nargs > required) else if (nargs > required)
......
2016-06-09 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.
2016-06-09 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com> 2016-06-09 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
* gcc.c-torture/execute/bswap-2.c: Require int32plus. * gcc.c-torture/execute/bswap-2.c: Require int32plus.
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
int int
f1 (void) f1 (void)
{ {
int x = __builtin_add_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 "not enough arguments to function" } */ x += __builtin_sub_overflow (); /* { dg-error "too few arguments to function" } */
x += __builtin_mul_overflow (); /* { dg-error "not enough arguments to function" } */ x += __builtin_mul_overflow (); /* { dg-error "too few arguments to function" } */
x += __builtin_add_overflow_p (); /* { dg-error "not enough arguments to function" } */ x += __builtin_add_overflow_p (); /* { dg-error "too few arguments to function" } */
x += __builtin_sub_overflow_p (); /* { dg-error "not enough arguments to function" } */ x += __builtin_sub_overflow_p (); /* { dg-error "too few arguments to function" } */
x += __builtin_mul_overflow_p (); /* { dg-error "not enough arguments to function" } */ x += __builtin_mul_overflow_p (); /* { dg-error "too few arguments to function" } */
return x; return x;
} }
...@@ -21,7 +21,7 @@ f2 (int a, int b, int *c, int d) ...@@ -21,7 +21,7 @@ f2 (int a, int b, int *c, int d)
x += __builtin_add_overflow_p (a, b, d, d); /* { dg-error "too many arguments to function" } */ x += __builtin_add_overflow_p (a, b, d, d); /* { dg-error "too many arguments to function" } */
x += __builtin_sub_overflow_p (a, b, d, d, 1, d); /* { dg-error "too many arguments to function" } */ x += __builtin_sub_overflow_p (a, b, d, d, 1, d); /* { dg-error "too many arguments to function" } */
x += __builtin_mul_overflow_p (a, b, d, d); /* { dg-error "too many arguments to function" } */ x += __builtin_mul_overflow_p (a, b, d, d); /* { dg-error "too many arguments to function" } */
return x; return x;
} }
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
int main() int main()
{ {
if (__builtin_constant_p ()) /* { dg-error "not enough" } */ if (__builtin_constant_p ()) /* { dg-error "too few arguments" } */
return 0; 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 1;
return 0; return 0;
} }
...@@ -23,19 +23,19 @@ int test1(struct X x) ...@@ -23,19 +23,19 @@ int test1(struct X x)
int test2(double x) int test2(double x)
{ {
if (x == 1) return __builtin_fpclassify(1,2,3,4,5); /* { 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 "not enough arguments" } */ if (x == 2) return __builtin_isfinite(); /* { dg-error "too few arguments" } */
if (x == 3) return __builtin_isinf_sign(); /* { dg-error "not enough arguments" } */ if (x == 3) return __builtin_isinf_sign(); /* { dg-error "too few arguments" } */
if (x == 4) return __builtin_isinf(); /* { dg-error "not enough arguments" } */ if (x == 4) return __builtin_isinf(); /* { dg-error "too few arguments" } */
if (x == 5) return __builtin_isnan(); /* { dg-error "not enough arguments" } */ if (x == 5) return __builtin_isnan(); /* { dg-error "too few arguments" } */
if (x == 6) return __builtin_isnormal(); /* { dg-error "not enough arguments" } */ if (x == 6) return __builtin_isnormal(); /* { dg-error "too few arguments" } */
if (x == 7) return __builtin_isgreater(x); /* { dg-error "not enough arguments" } */ if (x == 7) return __builtin_isgreater(x); /* { dg-error "too few arguments" } */
if (x == 8) return __builtin_isgreaterequal(x); /* { dg-error "not enough arguments" } */ if (x == 8) return __builtin_isgreaterequal(x); /* { dg-error "too few arguments" } */
if (x == 9) return __builtin_isless(x); /* { dg-error "not enough arguments" } */ if (x == 9) return __builtin_isless(x); /* { dg-error "too few arguments" } */
if (x == 10) return __builtin_islessequal(x); /* { dg-error "not enough arguments" } */ if (x == 10) return __builtin_islessequal(x); /* { dg-error "too few arguments" } */
if (x == 11) return __builtin_islessgreater(x); /* { dg-error "not enough arguments" } */ if (x == 11) return __builtin_islessgreater(x); /* { dg-error "too few arguments" } */
if (x == 12) return __builtin_isunordered(x); /* { dg-error "not enough arguments" } */ if (x == 12) return __builtin_isunordered(x); /* { dg-error "too few arguments" } */
if (x == 13) return __builtin_signbit(); /* { dg-error "not enough arguments" } */ if (x == 13) return __builtin_signbit(); /* { dg-error "too few arguments" } */
return 0; return 0;
} }
......
...@@ -41,19 +41,19 @@ fn0 (int n) ...@@ -41,19 +41,19 @@ fn0 (int n)
int int
fn1 (void) fn1 (void)
{ {
if (__builtin_constant_p ()) /* { dg-error "7:not enough" } */ if (__builtin_constant_p ()) /* { dg-error "7:too few" } */
return 0; return 0;
if (__builtin_constant_p (1, 2)) /* { dg-error "7:too many" } */ if (__builtin_constant_p (1, 2)) /* { dg-error "7:too many" } */
return 1; return 1;
if (__builtin_isfinite ()) /* { dg-error "7:not enough" } */ if (__builtin_isfinite ()) /* { dg-error "7:too few" } */
return 3; return 3;
if (__builtin_isfinite (1, 2)) /* { dg-error "7:too many" } */ if (__builtin_isfinite (1, 2)) /* { dg-error "7:too many" } */
return 4; return 4;
if (__builtin_isless (0)) /* { dg-error "7:not enough" } */ if (__builtin_isless (0)) /* { dg-error "7:too few" } */
return 5; return 5;
if (__builtin_isless (1, 2, 3)) /* { dg-error "7:too many" } */ if (__builtin_isless (1, 2, 3)) /* { dg-error "7:too many" } */
return 6; 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; return 7;
if (__builtin_fpclassify (1, 2, 3, 4, 5, r, 6)) /* { dg-error "7:too many" } */ if (__builtin_fpclassify (1, 2, 3, 4, 5, r, 6)) /* { dg-error "7:too many" } */
return 8; return 8;
...@@ -61,7 +61,7 @@ fn1 (void) ...@@ -61,7 +61,7 @@ fn1 (void)
return 9; return 9;
if (__builtin_assume_aligned (p, r, p, p)) /* { dg-error "7:too many" } */ if (__builtin_assume_aligned (p, r, p, p)) /* { dg-error "7:too many" } */
return 10; return 10;
if (__builtin_add_overflow ()) /* { dg-error "7:not enough" } */ if (__builtin_add_overflow ()) /* { dg-error "7:too few" } */
return 11; return 11;
if (__builtin_add_overflow (1, 2, 3, &r)) /* { dg-error "7:too many" } */ if (__builtin_add_overflow (1, 2, 3, &r)) /* { dg-error "7:too many" } */
return 12; return 12;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment