diff options
author | Volker Reichelt <reichelt@igpm.rwth-aachen.de> | 2006-04-19 22:03:24 +0000 |
---|---|---|
committer | Volker Reichelt <reichelt@gcc.gnu.org> | 2006-04-19 22:03:24 +0000 |
commit | 94d285a53ceab450cbc35e0673c36cd7fc6dd2ea (patch) | |
tree | 6e28879b33c91241ff9907dd1372a56ea1b73fcb | |
parent | 51e8f10cf6fd8c4c739d7504523c6c294f951200 (diff) | |
download | gcc-94d285a53ceab450cbc35e0673c36cd7fc6dd2ea.zip gcc-94d285a53ceab450cbc35e0673c36cd7fc6dd2ea.tar.gz gcc-94d285a53ceab450cbc35e0673c36cd7fc6dd2ea.tar.bz2 |
re PR c++/26558 (segfault on syntax error)
PR c++/26558
* parser.c (cp_parser_class_name): Check for invalid typenames.
Rearrange code.
* g++.dg/parse/template19.C: New test.
From-SVN: r113096
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/parser.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/template19.C | 11 |
4 files changed, 28 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c3df66d..7c1311d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2006-04-19 Volker Reichelt <reichelt@igpm.rwth-aachen.de> + PR c++/26558 + * parser.c (cp_parser_class_name): Check for invalid typenames. + Rearrange code. + PR c++/26739 * pt.c (tsubst_friend_function): Return early if pushdecl_namespace_level fails. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 13c7362..f673c16 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -12830,15 +12830,18 @@ cp_parser_class_name (cp_parser *parser, standard does not seem to be definitive, but there is no other valid interpretation of the following `::'. Therefore, those names are considered class-names. */ - decl = TYPE_NAME (make_typename_type (scope, decl, tag_type, tf_error)); - else if (decl == error_mark_node - || TREE_CODE (decl) != TYPE_DECL - || TREE_TYPE (decl) == error_mark_node - || !IS_AGGR_TYPE (TREE_TYPE (decl))) { - cp_parser_error (parser, "expected class-name"); - return error_mark_node; + decl = make_typename_type (scope, decl, tag_type, tf_error); + if (decl != error_mark_node) + decl = TYPE_NAME (decl); } + else if (TREE_CODE (decl) != TYPE_DECL + || TREE_TYPE (decl) == error_mark_node + || !IS_AGGR_TYPE (TREE_TYPE (decl))) + decl = error_mark_node; + + if (decl == error_mark_node) + cp_parser_error (parser, "expected class-name"); return decl; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 381ed85..e55cee8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2006-04-19 Volker Reichelt <reichelt@igpm.rwth-aachen.de> + PR c++/26558 + * g++.dg/parse/template19.C: New test. + PR c++/26739 * g++.old-deja/g++.pt/friend36.C: Adjust error markers. diff --git a/gcc/testsuite/g++.dg/parse/template19.C b/gcc/testsuite/g++.dg/parse/template19.C new file mode 100644 index 0000000..dc1a673 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/template19.C @@ -0,0 +1,11 @@ +// PR c++/26558 +// Origin: Jan Gorski <slimak@yk74.internetdsl.tpnet.pl> +// { dg-do compile } + +template<int> struct A +{ + template<int> void foo() + { + foo<0>::; // { dg-error "before" } + } +}; |