diff options
author | Lee Millward <lee.millward@codesourcery.com> | 2006-12-07 19:16:38 +0000 |
---|---|---|
committer | Lee Millward <lmillward@gcc.gnu.org> | 2006-12-07 19:16:38 +0000 |
commit | baa5bf1141c3d697abe54c6e1a8ee87a33f67015 (patch) | |
tree | 1d996afa86f04647fbe2996fbfe60de993cc6ad1 | |
parent | f4ab8916060b271dcfaf2936af09dfd8af44df7e (diff) | |
download | gcc-baa5bf1141c3d697abe54c6e1a8ee87a33f67015.zip gcc-baa5bf1141c3d697abe54c6e1a8ee87a33f67015.tar.gz gcc-baa5bf1141c3d697abe54c6e1a8ee87a33f67015.tar.bz2 |
re PR c++/29980 (ICE using attribute in invalid declaration)
PR c++/29980
* cp_parser_elaborated_type_specifier: Check
the return value of check_elaborated_type_specifier.
* g++.dg/ext/attrib27.C: New test.
* g++.dg/parse/struct-as-enum1.C: Adjust error markers.
* g++.dg/parse/typedef5.C: Likewise.
From-SVN: r119633
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/parser.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/attrib27.C | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/struct-as-enum1.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/typedef5.C | 2 |
6 files changed, 29 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 07e6b63..2135508 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2006-12-07 Lee Millward <lee.millward@codesourcery.com> + + PR c++/29980 + * cp_parser_elaborated_type_specifier: Check + the return value of check_elaborated_type_specifier. + 2006-12-06 Mark Mitchell <mark@codesourcery.com> PR c++/29730 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index cdb60f6..a0a6a17 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -10311,10 +10311,15 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, } if (TREE_CODE (TREE_TYPE (decl)) != TYPENAME_TYPE) - check_elaborated_type_specifier - (tag_type, decl, - (parser->num_template_parameter_lists - || DECL_SELF_REFERENCE_P (decl))); + { + bool allow_template = (parser->num_template_parameter_lists + || DECL_SELF_REFERENCE_P (decl)); + type = check_elaborated_type_specifier (tag_type, decl, + allow_template); + + if (type == error_mark_node) + return error_mark_node; + } type = TREE_TYPE (decl); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e2a5c46..77c3bf1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2006-12-07 Lee Millward <lee.millward@codesourcery.com> + + PR c++/29980 + * g++.dg/ext/attrib27.C: New test. + * g++.dg/parse/struct-as-enum1.C: Adjust error markers. + * g++.dg/parse/typedef5.C: Likewise. + 2006-12-07 Mike Stump <mrs@apple.com> * treelang/compile/var_defs.tree: Adjust. diff --git a/gcc/testsuite/g++.dg/ext/attrib27.C b/gcc/testsuite/g++.dg/ext/attrib27.C new file mode 100644 index 0000000..4f629aa --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attrib27.C @@ -0,0 +1,5 @@ +//PR c++/29980 + +struct A { typedef int X; }; // { dg-error "previous declaration" } + +struct __attribute__((unused)) A::X; // { dg-error "typedef-name" } diff --git a/gcc/testsuite/g++.dg/parse/struct-as-enum1.C b/gcc/testsuite/g++.dg/parse/struct-as-enum1.C index bc8c5b5..f58c738 100644 --- a/gcc/testsuite/g++.dg/parse/struct-as-enum1.C +++ b/gcc/testsuite/g++.dg/parse/struct-as-enum1.C @@ -7,4 +7,4 @@ namespace N struct A {}; // { dg-error "previous declaration" } } -typedef enum N::A B; // { dg-error "enum" } +typedef enum N::A B; // { dg-error "enum|invalid type" } diff --git a/gcc/testsuite/g++.dg/parse/typedef5.C b/gcc/testsuite/g++.dg/parse/typedef5.C index 22ba85e..7079f37 100644 --- a/gcc/testsuite/g++.dg/parse/typedef5.C +++ b/gcc/testsuite/g++.dg/parse/typedef5.C @@ -3,4 +3,4 @@ namespace A typedef int T; // { dg-error "previous declaration" } } -class A::T x; // { dg-error "using typedef-name" } +class A::T x; // { dg-error "using typedef-name|invalid type" } |