]> gcc.gnu.org Git - gcc.git/commitdiff
PR c++/51427 - Better diagnostic when union/struct tags conflicts
authorDodji Seketeli <dodji@redhat.com>
Tue, 6 Dec 2011 10:06:49 +0000 (10:06 +0000)
committerDodji Seketeli <dodji@gcc.gnu.org>
Tue, 6 Dec 2011 10:06:49 +0000 (11:06 +0100)
gcc/cp/

PR c++/51427
* parser.c (cp_parser_check_class_key): Add note about earlier
declaration.

gcc/testsuite/

PR c++/51427
* g++.dg/diagnostic/wrong-tag-1.C

From-SVN: r182043

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/diagnostic/wrong-tag-1.C [new file with mode: 0644]

index 25e381a0b842796260967641a85227aa532c83da..4391a478e9ada4ba4f1bfcbd3ae5ae97b80ee4c5 100644 (file)
@@ -1,3 +1,9 @@
+2011-12-06  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/51427
+       * parser.c (cp_parser_check_class_key): Add note about earlier
+       declaration.
+
 2011-12-05  Fabien ChĂȘne  <fabien@gcc.gnu.org>
 
        PR c++/51319
index 9e7a398cb3f8a45a9cca9a8ce96e6f1a91c2ed11..daf2ded45dc26976306f1e337b6d9f0501323b85 100644 (file)
@@ -22544,10 +22544,14 @@ static void
 cp_parser_check_class_key (enum tag_types class_key, tree type)
 {
   if ((TREE_CODE (type) == UNION_TYPE) != (class_key == union_type))
-    permerror (input_location, "%qs tag used in naming %q#T",
-           class_key == union_type ? "union"
-            : class_key == record_type ? "struct" : "class",
-            type);
+    {
+      permerror (input_location, "%qs tag used in naming %q#T",
+                class_key == union_type ? "union"
+                : class_key == record_type ? "struct" : "class",
+                type);
+      inform (DECL_SOURCE_LOCATION (TYPE_NAME (type)),
+             "%q#T was previously declared here", type);
+    }
 }
 
 /* Issue an error message if DECL is redeclared with different
index 12709b770b77ed08d2b7d2a772aa06f4e1620bbf..e920bf7e27591de7884f6edd8384fb5e7b9a5d7f 100644 (file)
@@ -1,3 +1,8 @@
+2011-12-06  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/51427
+       * g++.dg/diagnostic/wrong-tag-1.C
+
 2011-12-05  Fabien ChĂȘne  <fabien@gcc.gnu.org>
 
        PR c++/51319
diff --git a/gcc/testsuite/g++.dg/diagnostic/wrong-tag-1.C b/gcc/testsuite/g++.dg/diagnostic/wrong-tag-1.C
new file mode 100644 (file)
index 0000000..2cf75f8
--- /dev/null
@@ -0,0 +1,4 @@
+// Origin PR c++/51427
+
+typedef struct _GMutex GMutex; // { dg-message "previously declared here"}
+typedef union _GMutex GMutex; // { dg-error "tag used in naming" }
This page took 0.114504 seconds and 5 git commands to generate.