diff options
author | Eric Botcazou <ebotcazou@libertysurf.fr> | 2004-02-23 13:41:43 +0100 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2004-02-23 12:41:43 +0000 |
commit | bba745c19d4fa3c59a9233f7e7e3b0b92977e662 (patch) | |
tree | 2e44e37a0e7aecf9918a26fd85248ec003ba70c1 /gcc | |
parent | 29f4ceab97334d8e361a103dae4254766414acf5 (diff) | |
download | gcc-bba745c19d4fa3c59a9233f7e7e3b0b92977e662.zip gcc-bba745c19d4fa3c59a9233f7e7e3b0b92977e662.tar.gz gcc-bba745c19d4fa3c59a9233f7e7e3b0b92977e662.tar.bz2 |
re PR c/14188 (Suggestion: improve warning message for call through incompatible type)
PR c/14188
* builtins.c (expand_builtin_va_arg): Emit an informative message
if a trap is generated.
* c-typeck.c (build_function_call): Likewise.
Co-Authored-By: Falk Hueffner <falk@debian.org>
From-SVN: r78294
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/builtins.c | 1 | ||||
-rw-r--r-- | gcc/c-typeck.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cast-function-1.c | 26 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/va-arg-1.c | 6 |
6 files changed, 34 insertions, 16 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9e18f30..e73f7b2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2004-02-23 Eric Botcazou <ebotcazou@libertysurf.fr> + Falk Hueffner <falk@debian.org> + + PR c/14188 + * builtins.c (expand_builtin_va_arg): Emit an informative message + if a trap is generated. + * c-typeck.c (build_function_call): Likewise. + 2004-02-22 Jakub Jelinek <jakub@redhat.com> * gcov-io.c (gcov_open) [GCOV_LOCKED]: Use open + fdopen instead of diff --git a/gcc/builtins.c b/gcc/builtins.c index 7e5953a..895c835 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -4134,6 +4134,7 @@ expand_builtin_va_arg (tree valist, tree type) /* We can, however, treat "undefined" any way we please. Call abort to encourage the user to fix the program. */ + inform ("if this code is reached, the program will abort"); expand_builtin_trap (); /* This is dead code, but go ahead and finish so that the diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index ff37fea..2f6216c 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -1709,6 +1709,10 @@ build_function_call (tree function, tree params) executions of the program must execute the code. */ warning ("function called through a non-compatible type"); + /* We can, however, treat "undefined" any way we please. + Call abort to encourage the user to fix the program. */ + inform ("if this code is reached, the program will abort"); + if (VOID_TYPE_P (return_type)) return trap; else diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a941126..f62f294 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-02-23 Eric Botcazou <ebotcazou@libertysurf.fr> + + * gcc.dg/cast-function-1.c: Adjust for new informative message. + * gcc.dg/va-arg-1.c: Likewise. + 2004-02-23 Giovanni Bajo <giovannibajo@gcc.gnu.org> PR c++/14143 diff --git a/gcc/testsuite/gcc.dg/cast-function-1.c b/gcc/testsuite/gcc.dg/cast-function-1.c index 44cb183..8ed7d5d 100644 --- a/gcc/testsuite/gcc.dg/cast-function-1.c +++ b/gcc/testsuite/gcc.dg/cast-function-1.c @@ -22,19 +22,19 @@ void bar(void) int i; str_t s; - d = ((double (*) (int)) foo1) (i); /* { dg-warning "non-compatible" } */ - i = ((int (*) (double)) foo1) (d); /* { dg-warning "non-compatible" } */ - s = ((str_t (*) (int)) foo1) (i); /* { dg-warning "non-compatible" } */ - ((void (*) (int)) foo1) (d); /* { dg-warning "non-compatible" } */ - i = ((int (*) (int)) foo1) (i); /* { dg-bogus "non-compatible" } */ - (void) foo1 (i); /* { dg-bogus "non-compatible" } */ - - d = ((double (*) (int)) foo2) (i); /* { dg-warning "non-compatible" } */ - i = ((int (*) (double)) foo2) (d); /* { dg-bogus "non-compatible" } */ - s = ((str_t (*) (int)) foo2) (i); /* { dg-warning "non-compatible" } */ - ((void (*) (int)) foo2) (d); /* { dg-warning "non-compatible" } */ - i = ((int (*) (int)) foo2) (i); /* { dg-bogus "non-compatible" } */ - (void) foo2 (i); /* { dg-bogus "non-compatible" } */ + d = ((double (*) (int)) foo1) (i); /* { dg-warning "non-compatible|abort" } */ + i = ((int (*) (double)) foo1) (d); /* { dg-warning "non-compatible|abort" } */ + s = ((str_t (*) (int)) foo1) (i); /* { dg-warning "non-compatible|abort" } */ + ((void (*) (int)) foo1) (d); /* { dg-warning "non-compatible|abort" } */ + i = ((int (*) (int)) foo1) (i); /* { dg-bogus "non-compatible|abort" } */ + (void) foo1 (i); /* { dg-bogus "non-compatible|abort" } */ + + d = ((double (*) (int)) foo2) (i); /* { dg-warning "non-compatible|abort" } */ + i = ((int (*) (double)) foo2) (d); /* { dg-bogus "non-compatible|abort" } */ + s = ((str_t (*) (int)) foo2) (i); /* { dg-warning "non-compatible|abort" } */ + ((void (*) (int)) foo2) (d); /* { dg-warning "non-compatible|abort" } */ + i = ((int (*) (int)) foo2) (i); /* { dg-bogus "non-compatible|abort" } */ + (void) foo2 (i); /* { dg-bogus "non-compatible|abort" } */ } int foo1(int arg) diff --git a/gcc/testsuite/gcc.dg/va-arg-1.c b/gcc/testsuite/gcc.dg/va-arg-1.c index a148237..ecd0e4d 100644 --- a/gcc/testsuite/gcc.dg/va-arg-1.c +++ b/gcc/testsuite/gcc.dg/va-arg-1.c @@ -7,7 +7,7 @@ volatile int i; void foo() { - i = va_arg(v, char); /* { dg-warning "is promoted to|so you should" "char" } */ - i = va_arg(v, short); /* { dg-warning "is promoted to" "short" } */ - i = va_arg(v, float); /* { dg-warning "is promoted to" "float" } */ + i = va_arg(v, char); /* { dg-warning "is promoted to|so you should|abort" "char" } */ + i = va_arg(v, short); /* { dg-warning "is promoted to|abort" "short" } */ + i = va_arg(v, float); /* { dg-warning "is promoted to|abort" "float" } */ } |