mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-14 19:40:54 +08:00
re PR c++/43126 ("at this point in file" warnings are upside down)
2010-02-22 Manuel López-Ibáñez <manu@gcc.gnu.org> PR c++/43126 * c-typeck.c (convert_arguments): Print declaration location. * c-common.c (validate_nargs): Rename as builtin_function_validate_nargs. (check_builtin_function_arguments): Update. cp/ * typeck.c (convert_arguments): Update error message. testsuite/ * gcc.dg/cleanup-1.c: Update. * gcc.dg/func-args-1.c: Update. * gcc.dg/format/sentinel-1.c: Update. * g++.old-deja/g++.jason/scoping10.C: Update. * g++.old-deja/g++.ns/lookup5.C: Update. * g++.dg/ext/cleanup-1.C: Update. * g++.dg/parse/varmod1.C: Update. * g++.dg/parse/error33.C: Update. * g++.dg/expr/call3.C: Update. * g++.dg/func-args-1.C: New. From-SVN: r156979
This commit is contained in:
parent
3a7ba0405d
commit
a98c281937
@ -1,3 +1,11 @@
|
||||
2010-02-22 Manuel López-Ibáñez <manu@gcc.gnu.org>
|
||||
|
||||
PR c++/43126
|
||||
* c-typeck.c (convert_arguments): Print declaration location.
|
||||
* c-common.c (validate_nargs): Rename as
|
||||
builtin_function_validate_nargs.
|
||||
(check_builtin_function_arguments): Update.
|
||||
|
||||
2010-02-22 Richard Guenther <rguenther@suse.de>
|
||||
|
||||
PR lto/43045
|
||||
|
@ -7980,21 +7980,24 @@ check_function_arguments_recurse (void (*callback)
|
||||
(*callback) (ctx, param, param_num);
|
||||
}
|
||||
|
||||
/* Checks the number of arguments NARGS against the required number
|
||||
REQUIRED and issues an error if there is a mismatch. Returns true
|
||||
if the number of arguments is correct, otherwise false. */
|
||||
/* Checks for a builtin function FNDECL that the number of arguments
|
||||
NARGS against the required number REQUIRED and issues an error if
|
||||
there is a mismatch. Returns true if the number of arguments is
|
||||
correct, otherwise false. */
|
||||
|
||||
static bool
|
||||
validate_nargs (tree fndecl, int nargs, int required)
|
||||
builtin_function_validate_nargs (tree fndecl, int nargs, int required)
|
||||
{
|
||||
if (nargs < required)
|
||||
{
|
||||
error ("not enough arguments to function %qE", fndecl);
|
||||
error_at (input_location,
|
||||
"not enough arguments to function %qE", fndecl);
|
||||
return false;
|
||||
}
|
||||
else if (nargs > required)
|
||||
{
|
||||
error ("too many arguments to function %qE", fndecl);
|
||||
error_at (input_location,
|
||||
"too many arguments to function %qE", fndecl);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -8013,14 +8016,14 @@ check_builtin_function_arguments (tree fndecl, int nargs, tree *args)
|
||||
switch (DECL_FUNCTION_CODE (fndecl))
|
||||
{
|
||||
case BUILT_IN_CONSTANT_P:
|
||||
return validate_nargs (fndecl, nargs, 1);
|
||||
return builtin_function_validate_nargs (fndecl, nargs, 1);
|
||||
|
||||
case BUILT_IN_ISFINITE:
|
||||
case BUILT_IN_ISINF:
|
||||
case BUILT_IN_ISINF_SIGN:
|
||||
case BUILT_IN_ISNAN:
|
||||
case BUILT_IN_ISNORMAL:
|
||||
if (validate_nargs (fndecl, nargs, 1))
|
||||
if (builtin_function_validate_nargs (fndecl, nargs, 1))
|
||||
{
|
||||
if (TREE_CODE (TREE_TYPE (args[0])) != REAL_TYPE)
|
||||
{
|
||||
@ -8038,7 +8041,7 @@ check_builtin_function_arguments (tree fndecl, int nargs, tree *args)
|
||||
case BUILT_IN_ISLESSEQUAL:
|
||||
case BUILT_IN_ISLESSGREATER:
|
||||
case BUILT_IN_ISUNORDERED:
|
||||
if (validate_nargs (fndecl, nargs, 2))
|
||||
if (builtin_function_validate_nargs (fndecl, nargs, 2))
|
||||
{
|
||||
enum tree_code code0, code1;
|
||||
code0 = TREE_CODE (TREE_TYPE (args[0]));
|
||||
@ -8056,7 +8059,7 @@ check_builtin_function_arguments (tree fndecl, int nargs, tree *args)
|
||||
return false;
|
||||
|
||||
case BUILT_IN_FPCLASSIFY:
|
||||
if (validate_nargs (fndecl, nargs, 6))
|
||||
if (builtin_function_validate_nargs (fndecl, nargs, 6))
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
|
@ -2814,7 +2814,10 @@ convert_arguments (tree typelist, VEC(tree,gc) *values,
|
||||
|
||||
if (type == void_type_node)
|
||||
{
|
||||
error ("too many arguments to function %qE", function);
|
||||
error_at (input_location,
|
||||
"too many arguments to function %qE", function);
|
||||
if (fundecl && !DECL_BUILT_IN (fundecl))
|
||||
inform (DECL_SOURCE_LOCATION (fundecl), "declared here");
|
||||
return parmnum;
|
||||
}
|
||||
|
||||
@ -3038,7 +3041,10 @@ convert_arguments (tree typelist, VEC(tree,gc) *values,
|
||||
|
||||
if (typetail != 0 && TREE_VALUE (typetail) != void_type_node)
|
||||
{
|
||||
error ("too few arguments to function %qE", function);
|
||||
error_at (input_location,
|
||||
"too few arguments to function %qE", function);
|
||||
if (fundecl && !DECL_BUILT_IN (fundecl))
|
||||
inform (DECL_SOURCE_LOCATION (fundecl), "declared here");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,9 @@
|
||||
2010-02-22 Manuel López-Ibáñez <manu@gcc.gnu.org>
|
||||
|
||||
PR c++/43126
|
||||
* typeck.c (convert_arguments): Update error message.
|
||||
|
||||
|
||||
2010-02-22 Mike Stump <mikestump@comcast.net>
|
||||
|
||||
PR c++/43125
|
||||
|
@ -3304,9 +3304,10 @@ convert_arguments (tree typelist, VEC(tree,gc) **values, tree fndecl,
|
||||
{
|
||||
if (fndecl)
|
||||
{
|
||||
error ("too many arguments to %s %q+#D",
|
||||
error_at (input_location, "too many arguments to %s %q#D",
|
||||
called_thing, fndecl);
|
||||
error ("at this point in file");
|
||||
inform (DECL_SOURCE_LOCATION (fndecl),
|
||||
"declared here");
|
||||
}
|
||||
else
|
||||
error ("too many arguments to function");
|
||||
@ -3417,9 +3418,10 @@ convert_arguments (tree typelist, VEC(tree,gc) **values, tree fndecl,
|
||||
{
|
||||
if (fndecl)
|
||||
{
|
||||
error ("too few arguments to %s %q+#D",
|
||||
error_at (input_location, "too few arguments to %s %q#D",
|
||||
called_thing, fndecl);
|
||||
error ("at this point in file");
|
||||
inform (DECL_SOURCE_LOCATION (fndecl),
|
||||
"declared here");
|
||||
}
|
||||
else
|
||||
error ("too few arguments to function");
|
||||
|
@ -1,3 +1,17 @@
|
||||
2010-02-22 Manuel López-Ibáñez <manu@gcc.gnu.org>
|
||||
|
||||
PR c++/43126
|
||||
* gcc.dg/cleanup-1.c: Update.
|
||||
* gcc.dg/func-args-1.c: Update.
|
||||
* gcc.dg/format/sentinel-1.c: Update.
|
||||
* g++.old-deja/g++.jason/scoping10.C: Update.
|
||||
* g++.old-deja/g++.ns/lookup5.C: Update.
|
||||
* g++.dg/ext/cleanup-1.C: Update.
|
||||
* g++.dg/parse/varmod1.C: Update.
|
||||
* g++.dg/parse/error33.C: Update.
|
||||
* g++.dg/expr/call3.C: Update.
|
||||
* g++.dg/func-args-1.C: New.
|
||||
|
||||
2010-02-22 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
PR c/43125
|
||||
|
@ -7,6 +7,6 @@ struct A
|
||||
int i;
|
||||
};
|
||||
|
||||
A foo(int); // { dg-error "too few arguments" }
|
||||
A foo(int); /* { dg-message "note: declared here" } */
|
||||
|
||||
int j = foo().i; // { dg-error "at this point" }
|
||||
int j = foo().i; // { dg-error "too few arguments" }
|
||||
|
@ -6,25 +6,25 @@
|
||||
#define C(x) __attribute__((cleanup(x)))
|
||||
|
||||
static int f1(void *x U) { return 0; }
|
||||
static void f2() { } /* { dg-error "too many arguments" } */
|
||||
static void f3(void) { } /* { dg-error "too many arguments" } */
|
||||
static void f2() { } /* { dg-message "note: declared here" } */
|
||||
static void f3(void) { } /* { dg-message "note: declared here" } */
|
||||
static void f4(void *x U) { }
|
||||
static void f5(int *x U) { }
|
||||
static void f6(double *x U) { }
|
||||
static void f7(const int *x U) { }
|
||||
static void f8(const int *x U, int y U) { } /* { dg-error "too few arguments" } */
|
||||
static void f8(const int *x U, int y U) { } /* { dg-message "note: declared here" } */
|
||||
static void f9(int x U) { }
|
||||
|
||||
void test(void)
|
||||
{
|
||||
int o1 C(f1);
|
||||
int o2 C(f2); /* { dg-error "at this point" } */
|
||||
int o3 C(f3); /* { dg-error "at this point" } */
|
||||
int o2 C(f2); /* { dg-error "too many arguments" } */
|
||||
int o3 C(f3); /* { dg-error "too many arguments" } */
|
||||
int o4 C(f4);
|
||||
int o5 C(f5);
|
||||
int o6 C(f6); /* { dg-error "cannot convert" } */
|
||||
int o7 C(f7);
|
||||
int o8 C(f8); /* { dg-error "at this point" } */
|
||||
int o8 C(f8); /* { dg-error "too few arguments" } */
|
||||
int o9 C(f9); /* { dg-error "conversion" } */
|
||||
int o10 U C(undef); /* { dg-error "not a function" } */
|
||||
int o11 U C(o1); /* { dg-error "not a function" } */
|
||||
|
53
gcc/testsuite/g++.dg/func-args-1.C
Normal file
53
gcc/testsuite/g++.dg/func-args-1.C
Normal file
@ -0,0 +1,53 @@
|
||||
/* Test messages for wrong number of arguments to function. */
|
||||
/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "" } */
|
||||
|
||||
void f0(void); /* { dg-message "note: declared here" } */
|
||||
void f1(int); /* { dg-message "note: declared here" } */
|
||||
void f1v(int, ...); /* { dg-message "note: declared here" } */
|
||||
void f2(int, int); /* { dg-message "note: declared here" } */
|
||||
void f2v(int, int, ...); /* { dg-message "note: declared here" } */
|
||||
|
||||
struct s {
|
||||
void (*f0)(void);
|
||||
void (*f1)(int);
|
||||
void (*f1v)(int, ...);
|
||||
void (*f2)(int, int);
|
||||
void (*f2v)(int, int, ...);
|
||||
} x;
|
||||
|
||||
void
|
||||
g (int a)
|
||||
{
|
||||
f0();
|
||||
x.f0();
|
||||
f0(a); /* { dg-error "too many arguments to function" } */
|
||||
x.f0(a); /* { dg-error "too many arguments to function" } */
|
||||
f0(a, a); /* { dg-error "too many arguments to function" } */
|
||||
x.f0(a, a); /* { dg-error "too many arguments to function" } */
|
||||
f1(); /* { dg-error "too few arguments to function" } */
|
||||
x.f1(); /* { dg-error "too few arguments to function" } */
|
||||
f1(a);
|
||||
x.f1(a);
|
||||
f1(a, a); /* { dg-error "too many arguments to function" } */
|
||||
x.f1(a, a); /* { dg-error "too many arguments to function" } */
|
||||
f1v(); /* { dg-error "too few arguments to function" } */
|
||||
x.f1v(); /* { dg-error "too few arguments to function" } */
|
||||
f1v(a);
|
||||
x.f1v(a);
|
||||
f1v(a, a);
|
||||
x.f1v(a, a);
|
||||
f2(a); /* { dg-error "too few arguments to function" } */
|
||||
x.f2(a); /* { dg-error "too few arguments to function" } */
|
||||
f2(a, a);
|
||||
x.f2(a, a);
|
||||
f2(a, a, a); /* { dg-error "too many arguments to function" } */
|
||||
x.f2(a, a, a); /* { dg-error "too many arguments to function" } */
|
||||
f2v(a); /* { dg-error "too few arguments to function" } */
|
||||
x.f2v(a); /* { dg-error "too few arguments to function" } */
|
||||
f2v(a, a);
|
||||
x.f2v(a, a);
|
||||
f2v(a, a, a);
|
||||
x.f2v(a, a, a);
|
||||
}
|
@ -8,9 +8,9 @@ struct A
|
||||
|
||||
typedef void (A::T)(); /* { dg-error "typedef name may not be a nested" } */
|
||||
|
||||
void bar(T); /* { dg-error "too many arguments" } */
|
||||
void bar(T); /* { dg-message "note: declared here" } */
|
||||
|
||||
void baz()
|
||||
{
|
||||
bar(&A::foo); /* { dg-error "at this point" } */
|
||||
bar(&A::foo); /* { dg-error "too many arguments" } */
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
int main(int argc, char** argv) {
|
||||
int nx = 2;
|
||||
void theerror(double a[][nx+1]); // { dg-error "" }
|
||||
void theerror(double a[][nx+1]); // { dg-message "" }
|
||||
double** a;
|
||||
theerror(a); // { dg-error "" }
|
||||
return 0;
|
||||
|
@ -8,7 +8,7 @@ struct A {
|
||||
struct B : public A {
|
||||
void g (char *);
|
||||
void h () {
|
||||
extern void g (); // { dg-error "" }
|
||||
extern void g (); // { dg-message "" }
|
||||
f("foo"); // { dg-error "" } hidden
|
||||
g("foo"); // { dg-error "" } hidden
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ namespace A{
|
||||
|
||||
namespace B{
|
||||
using namespace A;
|
||||
void f(int); // { dg-error "" } referenced below
|
||||
void f(int); /* { dg-message "note: declared here" } */
|
||||
}
|
||||
|
||||
using namespace B;
|
||||
|
@ -7,12 +7,12 @@
|
||||
|
||||
static int f1(void *x U) { return 0; }
|
||||
static void f2() { }
|
||||
static void f3(void) { }
|
||||
static void f3(void) { } /* { dg-message "note: declared here" } */
|
||||
static void f4(void *x U) { }
|
||||
static void f5(int *x U) { }
|
||||
static void f6(double *x U) { } /* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" } */
|
||||
static void f7(const int *x U) { }
|
||||
static void f8(const int *x U, int y U) { }
|
||||
static void f8(const int *x U, int y U) { } /* { dg-message "note: declared here" } */
|
||||
static void f9(int x U) { } /* { dg-message "note: expected '\[^\n'\]*' but argument is of type '\[^\n'\]*'" "note: expected" } */
|
||||
|
||||
void test(void)
|
||||
|
@ -14,7 +14,7 @@ extern char *envp[];
|
||||
|
||||
extern int a ATTR; /* { dg-warning "applies to function types" "sentinel" } */
|
||||
|
||||
extern void foo1 (const char *, ...) ATTR;
|
||||
extern void foo1 (const char *, ...) ATTR; /* { dg-message "note: declared here" } */
|
||||
extern void foo2 (...) ATTR; /* { dg-error "ISO C requires|named arguments" "sentinel" } */
|
||||
extern void foo3 () ATTR; /* { dg-warning "named arguments" "sentinel" } */
|
||||
extern void foo4 (const char *, int) ATTR; /* { dg-warning "variadic functions" "sentinel" } */
|
||||
|
@ -3,11 +3,11 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "" } */
|
||||
|
||||
void f0(void);
|
||||
void f1(int);
|
||||
void f1v(int, ...);
|
||||
void f2(int, int);
|
||||
void f2v(int, int, ...);
|
||||
void f0(void); /* { dg-message "note: declared here" } */
|
||||
void f1(int); /* { dg-message "note: declared here" } */
|
||||
void f1v(int, ...); /* { dg-message "note: declared here" } */
|
||||
void f2(int, int); /* { dg-message "note: declared here" } */
|
||||
void f2v(int, int, ...); /* { dg-message "note: declared here" } */
|
||||
|
||||
struct s {
|
||||
void (*f0)(void);
|
||||
|
Loading…
Reference in New Issue
Block a user