diff options
author | Mark Mitchell <mark@codesourcery.com> | 2007-01-11 03:24:33 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2007-01-11 03:24:33 +0000 |
commit | 50ef2c18a91c06d941997b642afa1eb35168ea33 (patch) | |
tree | fe8b2af8964b498a3cfd237e8fc13295dd11510a | |
parent | ca15e36529c220d2293207797c6e20e5e88beb14 (diff) | |
download | gcc-50ef2c18a91c06d941997b642afa1eb35168ea33.zip gcc-50ef2c18a91c06d941997b642afa1eb35168ea33.tar.gz gcc-50ef2c18a91c06d941997b642afa1eb35168ea33.tar.bz2 |
re PR c++/28999 (ICE on invalid use of typename)
PR c++/28999
* decl.c (make_typename_type): If the qualified name is not a
type, issue an error.
* parser.c (cp_parser_elaborated_type_specifier): Fix comment
formatting.
From-SVN: r120663
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/decl.c | 5 | ||||
-rw-r--r-- | gcc/cp/parser.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/typename11.C | 11 |
5 files changed, 33 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f97f7d9..74af04c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2007-01-10 Mark Mitchell <mark@codesourcery.com> + + PR c++/28999 + * decl.c (make_typename_type): If the qualified name is not a + type, issue an error. + * parser.c (cp_parser_elaborated_type_specifier): Fix comment + formatting. + 2007-01-08 Geoffrey Keating <geoffk@apple.com> * rtti.c: Include target.h. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 1ed8afc..a100c9d 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -2820,6 +2820,11 @@ make_typename_type (tree context, tree name, enum tag_types tag_type, name = TREE_OPERAND (name, 0); if (TREE_CODE (name) == TEMPLATE_DECL) name = TREE_OPERAND (fullname, 0) = DECL_NAME (name); + else if (TREE_CODE (name) == OVERLOAD) + { + error ("%qD is not a type", name); + return error_mark_node; + } } if (TREE_CODE (name) == TEMPLATE_DECL) { diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 82cb796..8183913 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -6093,6 +6093,7 @@ cp_parser_constant_expression (cp_parser* parser, parser->integral_constant_expression_p = true; parser->allow_non_integral_constant_expression_p = allow_non_constant_p; parser->non_integral_constant_expression_p = false; + integral_constant_expr_p = true; /* Although the grammar says "conditional-expression", we parse an "assignment-expression", which also permits "throw-expression" and the use of assignment operators. In the case that @@ -6104,6 +6105,7 @@ cp_parser_constant_expression (cp_parser* parser, constant. */ expression = cp_parser_assignment_expression (parser, /*cast_p=*/false); /* Restore the old settings. */ + integral_constant_expr_p = false; parser->integral_constant_expression_p = saved_integral_constant_expression_p; parser->allow_non_integral_constant_expression_p @@ -10311,8 +10313,8 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, /*check_dependency_p=*/true, /*type_p=*/true, is_declaration); - /* For everything but enumeration types, consider a template-id. */ - /* For an enumeration type, consider only a plain identifier. */ + /* For everything but enumeration types, consider a template-id. + For an enumeration type, consider only a plain identifier. */ if (tag_type != enum_type) { bool template_p = false; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 04dd13a..9f52d10 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-01-10 Mark Mitchell <mark@codesourcery.com> + + PR c++/28999 + * g++.dg/template/typename11.C: New test. + 2007-01-10 Robert Kennedy <jimbob@google.com> * gcc.dg/fold-compare-2.c: New test case for fold_comparison. diff --git a/gcc/testsuite/g++.dg/template/typename11.C b/gcc/testsuite/g++.dg/template/typename11.C new file mode 100644 index 0000000..fb77610 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/typename11.C @@ -0,0 +1,11 @@ +// PR c++/28999 + +namespace N +{ + template<int> void foo(); +} + +template<int> struct A +{ + friend void typename N::foo<0>(); // { dg-error "type|expected" } +}; |