]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/51586 (ICE with invalid union)
authorJason Merrill <jason@redhat.com>
Sat, 17 Dec 2011 20:15:39 +0000 (15:15 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Sat, 17 Dec 2011 20:15:39 +0000 (15:15 -0500)
PR c++/51586
* parser.c (cp_parser_check_class_key): Handle error_mark_node.

From-SVN: r182442

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/nested2.C [new file with mode: 0644]

index a63aa163dd477fbaf654eb887023bb0f76f819f2..898a6bf973c69825ea93ac6e19c441d5f9bf23de 100644 (file)
@@ -1,5 +1,8 @@
 2011-12-17  Jason Merrill  <jason@redhat.com>
 
+       PR c++/51586
+       * parser.c (cp_parser_check_class_key): Handle error_mark_node.
+
        PR c++/51587
        * decl.c (start_enum): Avoid using ENUM_UNDERLYING_TYPE on a
        non-enum.
index 30c7745caab21d6873a0e8e930234faf98b01152..ac7427e5e85ce70409182994458879da9d04b604 100644 (file)
@@ -22624,6 +22624,8 @@ cp_parser_token_is_class_key (cp_token* token)
 static void
 cp_parser_check_class_key (enum tag_types class_key, tree type)
 {
+  if (type == error_mark_node)
+    return;
   if ((TREE_CODE (type) == UNION_TYPE) != (class_key == union_type))
     {
       permerror (input_location, "%qs tag used in naming %q#T",
index 71194f56be3cc0671ad670c124f9684edcece036..066121dcd36f1e9e8b226371deb515a67b616900 100644 (file)
@@ -1,5 +1,8 @@
 2011-12-17  Jason Merrill  <jason@redhat.com>
 
+       PR c++/51586
+       * g++.dg/lookup/nested2.C: New.
+
        PR c++/51587
        * g++.dg/parse/enum6.C: New.
 
diff --git a/gcc/testsuite/g++.dg/lookup/nested2.C b/gcc/testsuite/g++.dg/lookup/nested2.C
new file mode 100644 (file)
index 0000000..361a0c7
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/51586
+
+union U
+{
+  union U { int i; };          // { dg-error "same name" }
+};