+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
(*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;
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)
{
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]));
return false;
case BUILT_IN_FPCLASSIFY:
- if (validate_nargs (fndecl, nargs, 6))
+ if (builtin_function_validate_nargs (fndecl, nargs, 6))
{
unsigned i;
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;
}
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;
}
+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
{
if (fndecl)
{
- error ("too many arguments to %s %q+#D",
- called_thing, fndecl);
- error ("at this point in file");
+ error_at (input_location, "too many arguments to %s %q#D",
+ called_thing, fndecl);
+ inform (DECL_SOURCE_LOCATION (fndecl),
+ "declared here");
}
else
error ("too many arguments to function");
{
if (fndecl)
{
- error ("too few arguments to %s %q+#D",
- called_thing, fndecl);
- error ("at this point in file");
+ error_at (input_location, "too few arguments to %s %q#D",
+ called_thing, fndecl);
+ inform (DECL_SOURCE_LOCATION (fndecl),
+ "declared here");
}
else
error ("too few arguments to function");
+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
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" }
#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" } */
--- /dev/null
+/* 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);
+}
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" } */
}
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;
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
}
namespace B{
using namespace A;
- void f(int); // { dg-error "" } referenced below
+ void f(int); /* { dg-message "note: declared here" } */
}
using namespace B;
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)
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" } */
/* { 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);