]> 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>
Sat, 9 Mar 2013 11:48:53 +0000 (11:48 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sat, 9 Mar 2013 11:48:53 +0000 (11:48 +0000)
/cp
2013-03-09  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-09  Paolo Carlini  <paolo.carlini@oracle.com>

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

From-SVN: r196573

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 3c6c818aebcf8861c46fea1d19ba18640d4037a7..a32b69ee5554d7c161232538b36c5913c6ff43a8 100644 (file)
@@ -1,3 +1,10 @@
+2013-03-09  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 f200483afef51c66f8d9ae56c472751789d6ec66..dd6f7fbf465488be9ce978ce85c0d2efd23bdb46 100644 (file)
@@ -11461,9 +11461,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 fa82cf2c823c7e33164f04821925f462c9781a50..cdb524e2f0334fa831572246429330799daf7c64 100644 (file)
@@ -14035,12 +14035,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 ca8c8f011d08c75bb8578d9f62ce1c6578003f5b..896b043b2eb882b400dc6238a926a7aae560eb60 100644 (file)
@@ -1,3 +1,8 @@
+2013-03-09  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/56534
+       * g++.dg/template/crash115.C: New.
+
 2013-03-06  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/56543
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" }