From: Mark Mitchell Date: Tue, 3 Feb 2004 20:00:47 +0000 (+0000) Subject: re PR c++/13950 ([DR176] lookup of dependent base name) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4bfb8bbaf6294daa459f1f0d8216796001998afd;p=gcc.git re PR c++/13950 ([DR176] lookup of dependent base name) PR c++/13950 * parser.c (cp_parser_class_name): Robustify. PR c++/13970 * parser.c (cp_parser_cache_group): Do not consume the EOF token. PR c++/13950 * g++.dg/template/lookup4.C: New test. PR c++/13970 * g++.dg/parse/error14.C: New test. From-SVN: r77186 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a4c9c816ae3..7a398cba59f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 2004-02-03 Mark Mitchell + PR c++/13950 + * parser.c (cp_parser_class_name): Robustify. + + PR c++/13970 + * parser.c (cp_parser_cache_group): Do not consume the EOF token. + PR c++/14002 * semantics.c (finish_id_expression): Do not return an IDENTIFIER_NODE when lookup finds a PARM_DECL. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 2857468f20f..4905b9415c9 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -11622,8 +11622,11 @@ cp_parser_class_name (cp_parser *parser, /* If this is a typename, create a TYPENAME_TYPE. */ if (typename_p && decl != error_mark_node) - decl = TYPE_NAME (make_typename_type (scope, decl, - /*complain=*/1)); + { + decl = make_typename_type (scope, decl, /*complain=*/1); + if (decl != error_mark_node) + decl = TYPE_NAME (decl); + } /* Check to see that it is really the name of a class. */ if (TREE_CODE (decl) == TEMPLATE_ID_EXPR @@ -15069,11 +15072,11 @@ cp_parser_cache_group (cp_parser *parser, if ((end == CPP_CLOSE_PAREN || depth == 0) && cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON)) return; - /* Consume the next token. */ - token = cp_lexer_consume_token (parser->lexer); /* If we've reached the end of the file, stop. */ - if (token->type == CPP_EOF) + if (cp_lexer_next_token_is (parser->lexer, CPP_EOF)) return; + /* Consume the next token. */ + token = cp_lexer_consume_token (parser->lexer); /* Add this token to the tokens we are saving. */ cp_token_cache_push_token (cache, token); /* See if it starts a new group. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b08666a3ba1..00c0b7138d3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,11 @@ 2004-02-03 Mark Mitchell + PR c++/13950 + * g++.dg/template/lookup4.C: New test. + + PR c++/13970 + * g++.dg/parse/error14.C: New test. + PR c++/14002 * g++.dg/parse/template13.C: New test. diff --git a/gcc/testsuite/g++.dg/parse/error14.C b/gcc/testsuite/g++.dg/parse/error14.C new file mode 100644 index 00000000000..4b230453867 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/error14.C @@ -0,0 +1,22 @@ +// PR c++/13970 + +struct X +{ + template< typename Z > Z Zunc() + { + return Z(); + } + + template< typename Z > void Zinc() + { + } + + void tst() + { + Zunc(); + + Zinc( //); + // } + +}; // { dg-error "" } + diff --git a/gcc/testsuite/g++.dg/template/lookup4.C b/gcc/testsuite/g++.dg/template/lookup4.C new file mode 100644 index 00000000000..d64006133c3 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/lookup4.C @@ -0,0 +1,6 @@ +// PR c++/13950 + +template struct Base {}; +template struct Derived: public Base { + typename Derived::template Base* p1; // { dg-error "" } +};