aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel López-Ibáñez <manu@gcc.gnu.org>2010-02-22 22:30:45 +0000
committerManuel López-Ibáñez <manu@gcc.gnu.org>2010-02-22 22:30:45 +0000
commit1f1df902bf0a5837c152a207d00e5c025facdeeb (patch)
tree83af312d2bb69101bf71d922763360c32afd84cf
parentdf09d5f2a165179e1900ffde7674eb52073f363c (diff)
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. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@156979 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/c-common.c23
-rw-r--r--gcc/c-typeck.c10
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/typeck.c14
-rw-r--r--gcc/testsuite/ChangeLog14
-rw-r--r--gcc/testsuite/g++.dg/expr/call3.C4
-rw-r--r--gcc/testsuite/g++.dg/ext/cleanup-1.C12
-rw-r--r--gcc/testsuite/g++.dg/func-args-1.C53
-rw-r--r--gcc/testsuite/g++.dg/parse/error33.C4
-rw-r--r--gcc/testsuite/g++.dg/parse/varmod1.C2
-rw-r--r--gcc/testsuite/g++.old-deja/g++.jason/scoping10.C2
-rw-r--r--gcc/testsuite/g++.old-deja/g++.ns/lookup5.C2
-rw-r--r--gcc/testsuite/gcc.dg/cleanup-1.c4
-rw-r--r--gcc/testsuite/gcc.dg/format/sentinel-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/func-args-1.c10
16 files changed, 131 insertions, 39 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b0ab9cd9132..195d69c571d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 1039e24e0d4..0bee9376b04 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -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;
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 567c2a51282..a7a5f8632bd 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -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;
}
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 3c967b3622e..a4a5cc2498d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 01384de9263..b9ef78f2b49 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -3304,9 +3304,10 @@ convert_arguments (tree typelist, VEC(tree,gc) **values, tree fndecl,
{
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");
@@ -3417,9 +3418,10 @@ convert_arguments (tree typelist, VEC(tree,gc) **values, tree fndecl,
{
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");
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8f496471dd8..7ca5442277e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/testsuite/g++.dg/expr/call3.C b/gcc/testsuite/g++.dg/expr/call3.C
index 01f354a669c..13bca7170d6 100644
--- a/gcc/testsuite/g++.dg/expr/call3.C
+++ b/gcc/testsuite/g++.dg/expr/call3.C
@@ -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" }
diff --git a/gcc/testsuite/g++.dg/ext/cleanup-1.C b/gcc/testsuite/g++.dg/ext/cleanup-1.C
index 383c64eb79f..8e835375495 100644
--- a/gcc/testsuite/g++.dg/ext/cleanup-1.C
+++ b/gcc/testsuite/g++.dg/ext/cleanup-1.C
@@ -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" } */
diff --git a/gcc/testsuite/g++.dg/func-args-1.C b/gcc/testsuite/g++.dg/func-args-1.C
new file mode 100644
index 00000000000..4b2efd83d61
--- /dev/null
+++ b/gcc/testsuite/g++.dg/func-args-1.C
@@ -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);
+}
diff --git a/gcc/testsuite/g++.dg/parse/error33.C b/gcc/testsuite/g++.dg/parse/error33.C
index 411dc920cc4..ac18c209812 100644
--- a/gcc/testsuite/g++.dg/parse/error33.C
+++ b/gcc/testsuite/g++.dg/parse/error33.C
@@ -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" } */
}
diff --git a/gcc/testsuite/g++.dg/parse/varmod1.C b/gcc/testsuite/g++.dg/parse/varmod1.C
index bf64507ae9b..8f7b4eb1419 100644
--- a/gcc/testsuite/g++.dg/parse/varmod1.C
+++ b/gcc/testsuite/g++.dg/parse/varmod1.C
@@ -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;
diff --git a/gcc/testsuite/g++.old-deja/g++.jason/scoping10.C b/gcc/testsuite/g++.old-deja/g++.jason/scoping10.C
index 9e6ae0f6898..bc14974acca 100644
--- a/gcc/testsuite/g++.old-deja/g++.jason/scoping10.C
+++ b/gcc/testsuite/g++.old-deja/g++.jason/scoping10.C
@@ -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
}
diff --git a/gcc/testsuite/g++.old-deja/g++.ns/lookup5.C b/gcc/testsuite/g++.old-deja/g++.ns/lookup5.C
index 914f3b3d8d6..95af00ffd7a 100644
--- a/gcc/testsuite/g++.old-deja/g++.ns/lookup5.C
+++ b/gcc/testsuite/g++.old-deja/g++.ns/lookup5.C
@@ -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;
diff --git a/gcc/testsuite/gcc.dg/cleanup-1.c b/gcc/testsuite/gcc.dg/cleanup-1.c
index dd571635baf..48b82646e48 100644
--- a/gcc/testsuite/gcc.dg/cleanup-1.c
+++ b/gcc/testsuite/gcc.dg/cleanup-1.c
@@ -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)
diff --git a/gcc/testsuite/gcc.dg/format/sentinel-1.c b/gcc/testsuite/gcc.dg/format/sentinel-1.c
index 1dc090870e4..0c8a2ac7737 100644
--- a/gcc/testsuite/gcc.dg/format/sentinel-1.c
+++ b/gcc/testsuite/gcc.dg/format/sentinel-1.c
@@ -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" } */
diff --git a/gcc/testsuite/gcc.dg/func-args-1.c b/gcc/testsuite/gcc.dg/func-args-1.c
index 2f9d8b80b42..5f7b2453551 100644
--- a/gcc/testsuite/gcc.dg/func-args-1.c
+++ b/gcc/testsuite/gcc.dg/func-args-1.c
@@ -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);