aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2016-05-20 22:23:10 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2016-05-20 16:23:10 -0600
commit79063edd747d348be1a86a5df5d4df046735d8fe (patch)
treeac73cfdeb4c5483ac27c5fdb146e58e30f7020d0 /gcc/c
parent55c8849f5d8ca231dba2e4ed2c40c4d435c84ae3 (diff)
downloadgcc-79063edd747d348be1a86a5df5d4df046735d8fe.zip
gcc-79063edd747d348be1a86a5df5d4df046735d8fe.tar.gz
gcc-79063edd747d348be1a86a5df5d4df046735d8fe.tar.bz2
PR c/71115 - [4.9/5/6/7 Regression] Missing warning: excess elements
PR c/71115 - [4.9/5/6/7 Regression] Missing warning: excess elements in struct initializer gcc/c/ChangeLog: 2016-05-20 Martin Sebor <msebor@redhat.com> PR c/71115 * c-typeck.c (error_init): Use expansion_point_location_if_in_system_header. (warning_init): Same. gcc/testsuite/ChangeLog: 2016-05-20 Martin Sebor <msebor@redhat.com> PR c/71115 * gcc.dg/init-excess-2.c: New test. From-SVN: r236549
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog7
-rw-r--r--gcc/c/c-typeck.c20
2 files changed, 22 insertions, 5 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 5731048..c65f2e9 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,10 @@
+2016-05-20 Martin Sebor <msebor@redhat.com>
+
+ PR c/71115
+ * c-typeck.c (error_init): Use
+ expansion_point_location_if_in_system_header.
+ (warning_init): Same.
+
2016-05-19 David Malcolm <dmalcolm@redhat.com>
PR c/71171
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 3010240..7c9b078 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -5879,16 +5879,21 @@ error_init (location_t loc, const char *gmsgid)
component name is taken from the spelling stack. */
static void
-pedwarn_init (location_t location, int opt, const char *gmsgid)
+pedwarn_init (location_t loc, int opt, const char *gmsgid)
{
char *ofwhat;
bool warned;
+ /* Use the location where a macro was expanded rather than where
+ it was defined to make sure macros defined in system headers
+ but used incorrectly elsewhere are diagnosed. */
+ source_location exploc = expansion_point_location_if_in_system_header (loc);
+
/* The gmsgid may be a format string with %< and %>. */
- warned = pedwarn (location, opt, gmsgid);
+ warned = pedwarn (exploc, opt, gmsgid);
ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
if (*ofwhat && warned)
- inform (location, "(near initialization for %qs)", ofwhat);
+ inform (exploc, "(near initialization for %qs)", ofwhat);
}
/* Issue a warning for a bad initializer component.
@@ -5903,11 +5908,16 @@ warning_init (location_t loc, int opt, const char *gmsgid)
char *ofwhat;
bool warned;
+ /* Use the location where a macro was expanded rather than where
+ it was defined to make sure macros defined in system headers
+ but used incorrectly elsewhere are diagnosed. */
+ source_location exploc = expansion_point_location_if_in_system_header (loc);
+
/* The gmsgid may be a format string with %< and %>. */
- warned = warning_at (loc, opt, gmsgid);
+ warned = warning_at (exploc, opt, gmsgid);
ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
if (*ofwhat && warned)
- inform (loc, "(near initialization for %qs)", ofwhat);
+ inform (exploc, "(near initialization for %qs)", ofwhat);
}
/* If TYPE is an array type and EXPR is a parenthesized string