]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/56534 (ICE Segfault on invalid code in check_elaborated_type_specifier)
authorPaolo Carlini <paolo.carlini@oracle.com>
Wed, 6 Mar 2013 23:47:20 +0000 (23:47 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 6 Mar 2013 23:47:20 +0000 (23:47 +0000)
/cp
2013-03-06  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/56534
* parser.c (cp_parser_elaborated_type_specifier): Don't call
check_elaborated_type_specifier when TREE_CODE (decl) != TYPE_DECL.
* decl.c (check_elaborated_type_specifier): Tidy.

/testsuite
2013-03-06  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/56534
* g++.dg/template/crash115.C: New.

From-SVN: r196513

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

index 8a592345910736c303ddbf33501f4914f77f0eea..49e0f51bdec708016c31217dc975e3142e1013c0 100644 (file)
@@ -1,3 +1,10 @@
+2013-03-06  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/56534
+       * parser.c (cp_parser_elaborated_type_specifier): Don't call
+       check_elaborated_type_specifier when TREE_CODE (decl) != TYPE_DECL.
+       * decl.c (check_elaborated_type_specifier): Tidy.
+
 2013-03-06  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/56543
index 40ab0bdee986557f3dc9c18df1d690e6cd4d0b44..150e8662a5e28ba192aafaf6fb2fcec213135d6a 100644 (file)
@@ -11712,9 +11712,6 @@ check_elaborated_type_specifier (enum tag_types tag_code,
 {
   tree type;
 
-  if (decl == error_mark_node)
-    return error_mark_node;
-
   /* In the case of:
 
        struct S { struct S *p; };
index 97e610ce79f9f303ca47bae6d5b53127af9d1fbd..ff4faa32d3c79d6538566cc5f4cc7b9c730c1b3d 100644 (file)
@@ -14248,12 +14248,14 @@ cp_parser_elaborated_type_specifier (cp_parser* parser,
                                   typename_type,
                                   /*complain=*/tf_error);
       /* If the `typename' keyword is in effect and DECL is not a type
-        decl. Then type is non existant.   */
+        decl, then type is non existent.   */
       else if (tag_type == typename_type && TREE_CODE (decl) != TYPE_DECL)
-        type = NULL_TREE
-      else 
-       type = check_elaborated_type_specifier (tag_type, decl,
+        ; 
+      else if (TREE_CODE (decl) == TYPE_DECL)
+        type = check_elaborated_type_specifier (tag_type, decl,
                                                /*allow_template_p=*/true);
+      else if (decl == error_mark_node)
+       type = error_mark_node; 
     }
 
   if (!type)
index 7e6886367798328d838afbb747f7ebddfd9bd5a5..1979d3247268545027d4afcf40b967abe9a616a2 100644 (file)
@@ -1,3 +1,8 @@
+2013-03-06  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/56534
+       * g++.dg/template/crash115.C: New.
+
 2013-03-06  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/56539
diff --git a/gcc/testsuite/g++.dg/template/crash115.C b/gcc/testsuite/g++.dg/template/crash115.C
new file mode 100644 (file)
index 0000000..5c9f525
--- /dev/null
@@ -0,0 +1,3 @@
+// PR c++/56534
+
+template < struct template rebind < > // { dg-error "expected" }