aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@redhat.com>2011-12-06 10:06:49 +0000
committerDodji Seketeli <dodji@gcc.gnu.org>2011-12-06 11:06:49 +0100
commit230f834641d980c3a31aeebb7971719721d26831 (patch)
tree08a64bf90ae9d91a94103ca9eb7af6b9e28efa0a
parentaa383ddaea7adb6800953a89ec3eb201da320613 (diff)
downloadgcc-230f834641d980c3a31aeebb7971719721d26831.zip
gcc-230f834641d980c3a31aeebb7971719721d26831.tar.gz
gcc-230f834641d980c3a31aeebb7971719721d26831.tar.bz2
PR c++/51427 - Better diagnostic when union/struct tags conflicts
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
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/parser.c12
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/diagnostic/wrong-tag-1.C4
4 files changed, 23 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 25e381a..4391a47 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 9e7a398..daf2ded 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 12709b7..e920bf7 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..2cf75f8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/diagnostic/wrong-tag-1.C
@@ -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" }