]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/70791 (-Wnested-externs prints inconsistent column number)
authorMarek Polacek <polacek@redhat.com>
Tue, 26 Apr 2016 15:01:09 +0000 (15:01 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Tue, 26 Apr 2016 15:01:09 +0000 (15:01 +0000)
PR c/70791
* c-decl.c (pushdecl): Pass LOCUS down to warning.

* gcc.dg/Wnested-externs-2.c: New test.

From-SVN: r235447

gcc/c/ChangeLog
gcc/c/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/Wnested-externs-2.c [new file with mode: 0644]

index 139d770f82a9ee540460b7b73155e52840847b8e..b59d69092c944019df3f6ae422c120bc79515d5c 100644 (file)
@@ -8,6 +8,9 @@
        (c_parser_switch_statement): Use it.
        (c_parser_while_statement): Use it.
 
+       PR c/70791
+       * c-decl.c (pushdecl): Pass LOCUS down to warning.
+
 2016-04-20  Ilya Verbin  <ilya.verbin@intel.com>
 
        PR c++/69363
index f0c677b1cef1d3f284847323ae50f5afbb290175..16e4250194a8eee026e502c480ec53f2b59e65f5 100644 (file)
@@ -2949,7 +2949,8 @@ pushdecl (tree x)
        }
       if (scope != file_scope
          && !DECL_IN_SYSTEM_HEADER (x))
-       warning (OPT_Wnested_externs, "nested extern declaration of %qD", x);
+       warning_at (locus, OPT_Wnested_externs,
+                   "nested extern declaration of %qD", x);
 
       while (b && !B_IN_EXTERNAL_SCOPE (b))
        {
index c4be021d6f38d0169724477b418ddbf3cc13bb4e..70baf06056171baa222388e8eb4d3a68bc52cb4a 100644 (file)
@@ -5,6 +5,9 @@
        * gcc.dg/pr67784-4.c: New test.
        * gcc.dg/pr67784-5.c: New test.
 
+       PR c/70791
+       * gcc.dg/Wnested-externs-2.c: New test.
+
 2016-04-26  Marc Glisse  <marc.glisse@inria.fr>
 
        * gcc.dg/fold-plusmult.c: Adjust.
diff --git a/gcc/testsuite/gcc.dg/Wnested-externs-2.c b/gcc/testsuite/gcc.dg/Wnested-externs-2.c
new file mode 100644 (file)
index 0000000..77bed5f
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR c/70791 */
+/* { dg-do compile } */
+/* { dg-options "-Wnested-externs" } */
+
+void
+bar (void)
+{
+  extern int i; /* { dg-warning "14:nested extern declaration of 'i'" } */
+  extern short foo (void); /* { dg-warning "16:nested extern declaration of 'foo'" } */
+  extern struct S *s; /* { dg-warning "20:nested extern declaration of 's'" } */
+}