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
This commit is contained in:
Martin Sebor 2016-06-09 16:32:25 +00:00 committed by Martin Sebor
parent 386a87e4f1
commit e01b4e1693
7 changed files with 42 additions and 28 deletions

View File

@ -1,3 +1,9 @@
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>
Jakub Jelinek <jakub@redhat.com>

View File

@ -9828,7 +9828,7 @@ builtin_function_validate_nargs (location_t loc, tree fndecl, int nargs,
{
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)

View File

@ -1,3 +1,11 @@
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>
* gcc.c-torture/execute/bswap-2.c: Require int32plus.

View File

@ -3,12 +3,12 @@
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" } */
x += __builtin_add_overflow_p (); /* { dg-error "not enough arguments to function" } */
x += __builtin_sub_overflow_p (); /* { dg-error "not enough arguments to function" } */
x += __builtin_mul_overflow_p (); /* { 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" } */
x += __builtin_add_overflow_p (); /* { dg-error "too few arguments to function" } */
x += __builtin_sub_overflow_p (); /* { dg-error "too few arguments to function" } */
x += __builtin_mul_overflow_p (); /* { dg-error "too few arguments to function" } */
return x;
}
@ -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_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" } */
return x;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;