diff options
author | Marek Polacek <polacek@redhat.com> | 2015-10-02 18:01:50 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2015-10-02 18:01:50 +0000 |
commit | 1c7485afda66c17e00d3dcdce2ef9bf9106d3cda (patch) | |
tree | d5d60aff6ad3a5769953eceda32f81ad7a05817c /gcc | |
parent | 12651878c680a8568e4d6c03b72d05728f0637fc (diff) | |
download | gcc-1c7485afda66c17e00d3dcdce2ef9bf9106d3cda.zip gcc-1c7485afda66c17e00d3dcdce2ef9bf9106d3cda.tar.gz gcc-1c7485afda66c17e00d3dcdce2ef9bf9106d3cda.tar.bz2 |
re PR c/67730 (No warning when returning NULL in void function)
PR c/67730
* c-typeck.c (convert_for_assignment): Use the expansion point
location throughout.
* gcc.dg/pr67730-1.c: New test.
* gcc.dg/pr67730-2.c: New test.
* gcc.dg/pr67730.h: New test.
From-SVN: r228408
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c/c-typeck.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr67730-1.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr67730-2.c | 22 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr67730.h | 32 |
6 files changed, 87 insertions, 0 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 7c0051f..c6eab4e 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,5 +1,11 @@ 2015-10-02 Marek Polacek <polacek@redhat.com> + PR c/67730 + * c-typeck.c (convert_for_assignment): Use the expansion point + location throughout. + +2015-10-02 Marek Polacek <polacek@redhat.com> + PR c/64249 * c-parser.c (c_parser_statement_after_labels): Add CHAIN parameter and pass it down to c_parser_if_statement. diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 11e487c..ad02d6c 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -5718,6 +5718,10 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, tree rname = NULL_TREE; bool objc_ok = false; + /* Use the expansion point location to handle cases such as user's + function returning a wrong-type macro defined in a system header. */ + location = expansion_point_location_if_in_system_header (location); + if (errtype == ic_argpass) { tree selector; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8211e03..e671952 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,12 @@ 2015-10-02 Marek Polacek <polacek@redhat.com> + PR c/67730 + * gcc.dg/pr67730-1.c: New test. + * gcc.dg/pr67730-2.c: New test. + * gcc.dg/pr67730.h: New test. + +2015-10-02 Marek Polacek <polacek@redhat.com> + * c-c++-common/Wduplicated-cond-2.c: Skip until PR67819 is resolved. 2015-10-02 Sebastian Pop <s.pop@samsung.com> diff --git a/gcc/testsuite/gcc.dg/pr67730-1.c b/gcc/testsuite/gcc.dg/pr67730-1.c new file mode 100644 index 0000000..bb82f6d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr67730-1.c @@ -0,0 +1,16 @@ +/* PR c/67730 */ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ + +#include "pr67730.h" + +extern void bar (unsigned char *); + +unsigned char * +f (void *p) +{ + unsigned char *uc = ONEP; /* { dg-warning "request for implicit conversion" } */ + uc = ONEP; /* { dg-warning "request for implicit conversion" } */ + bar (ONEP); /* { dg-warning "request for implicit conversion" } */ + return ONEP; /* { dg-warning "request for implicit conversion" } */ +} diff --git a/gcc/testsuite/gcc.dg/pr67730-2.c b/gcc/testsuite/gcc.dg/pr67730-2.c new file mode 100644 index 0000000..29d7267 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr67730-2.c @@ -0,0 +1,22 @@ +/* PR c/67730 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +#include "pr67730.h" + +extern void bar (int); + +int +fn1 (void) +{ + int a = NULL; /* { dg-warning "initialization makes integer from pointer" } */ + a = NULL; /* { dg-warning "assignment makes integer from pointer" } */ + bar (NULL); /* { dg-warning "passing argument 1" } */ + return NULL; /* { dg-warning "return makes integer from pointer" } */ +} + +int +fn2 (void) +{ + RETURN; /* { dg-warning "return makes integer from pointer" } */ +} diff --git a/gcc/testsuite/gcc.dg/pr67730.h b/gcc/testsuite/gcc.dg/pr67730.h new file mode 100644 index 0000000..9a9afc9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr67730.h @@ -0,0 +1,32 @@ +#pragma GCC system_header +#define NULL (void *) 0 +#define ONEP (void *) 1 +#define RETURN return NULL + +extern void sysbar (unsigned char *); + +unsigned char * +sysfn1 (void *p) +{ + unsigned char *uc = ONEP; + uc = ONEP; + sysbar (ONEP); + return ONEP; +} + +extern void sysbar2 (int); + +int +sysfn2 (void) +{ + int a = NULL; + a = NULL; + sysbar2 (NULL); + return NULL; +} + +int +sysfn3 (void) +{ + RETURN; +} |