From 7835afaf39f098db96b33870f71dc69786355191 Mon Sep 17 00:00:00 2001 From: mmitchel Date: Mon, 24 May 2004 02:22:18 +0000 Subject: [PATCH] PR c++/15044 * parser.c (cp_parser_class_head): Robustify. PR c++/15317 * parser.c (cp_parser_decl_specifier_seq): Correct error in comment. (cp_parser_constructor_declarator_p): Treat attributes as decl-specifiers. PR c++/15329 * typeck.c (build_unary_op): Do not attempt to resolve casts to base classes in templates. PR c++/15044 * g++.dg/template/error12.C: New test. PR c++/15317 * g++.dg/ext/attrib14.C: New test. PR c++/15329 * g++.dg/template/ptrmem9.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-3_4-branch@82188 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 13 +++++++++++++ gcc/cp/parser.c | 11 ++++++++--- gcc/cp/typeck.c | 6 +++++- gcc/testsuite/ChangeLog | 9 +++++++++ gcc/testsuite/g++.dg/ext/attrib14.C | 16 ++++++---------- gcc/testsuite/g++.dg/template/error12.C | 4 ++++ gcc/testsuite/g++.dg/template/ptrmem9.C | 9 +++++++++ 7 files changed, 54 insertions(+), 14 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/error12.C create mode 100644 gcc/testsuite/g++.dg/template/ptrmem9.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3c890f3763e..d4e58bf9841 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,18 @@ 2004-05-23 Mark Mitchell + PR c++/15044 + * parser.c (cp_parser_class_head): Robustify. + + PR c++/15317 + * parser.c (cp_parser_decl_specifier_seq): Correct error in + comment. + (cp_parser_constructor_declarator_p): Treat attributes + as decl-specifiers. + + PR c++/15329 + * typeck.c (build_unary_op): Do not attempt to resolve casts to + base classes in templates. + PR c++/15165 * pt.c (instantiate_template): Robustify. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 0a8c63501c3..2093ad89db1 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -6570,8 +6570,8 @@ cp_parser_simple_declaration (cp_parser* parser, GNU Extension: - decl-specifier-seq: - decl-specifier-seq [opt] attributes + decl-specifier: + attributes Returns a TREE_LIST, giving the decl-specifiers in the order they appear in the source code. The TREE_VALUE of each node is the @@ -12014,7 +12014,8 @@ cp_parser_class_head (cp_parser* parser, pop_deferring_access_checks (); - cp_parser_check_for_invalid_template_id (parser, id); + if (id) + cp_parser_check_for_invalid_template_id (parser, id); /* If it's not a `:' or a `{' then we can't really be looking at a class-head, since a class-head only appears as part of a @@ -14061,6 +14062,10 @@ cp_parser_constructor_declarator_p (cp_parser *parser, bool friend_p) { if (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN) && cp_lexer_next_token_is_not (parser->lexer, CPP_ELLIPSIS) + /* A parameter declaration begins with a decl-specifier, + which is either the "attribute" keyword, a storage class + specifier, or (usually) a type-specifier. */ + && !cp_lexer_next_token_is_keyword (parser->lexer, RID_ATTRIBUTE) && !cp_parser_storage_class_specifier_opt (parser)) { tree type; diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 3521a151e94..46efd570b37 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -4063,7 +4063,11 @@ build_unary_op (enum tree_code code, tree xarg, int noconvert) { tree addr; - if (TREE_CODE (arg) != COMPONENT_REF) + if (TREE_CODE (arg) != COMPONENT_REF + /* Inside a template, we are processing a non-dependent + expression so we can just form an ADDR_EXPR with the + correct type. */ + || processing_template_decl) addr = build_address (arg); else if (TREE_CODE (TREE_OPERAND (arg, 1)) == BASELINK) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bea4c281f37..6c1b70cf03d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,14 @@ 2004-05-23 Mark Mitchell + PR c++/15044 + * g++.dg/template/error12.C: New test. + + PR c++/15317 + * g++.dg/ext/attrib14.C: New test. + + PR c++/15329 + * g++.dg/template/ptrmem9.C: New test. + PR c++/15165 * g++.dg/template/crash19.C: New test. diff --git a/gcc/testsuite/g++.dg/ext/attrib14.C b/gcc/testsuite/g++.dg/ext/attrib14.C index 3a819e01d82..05de12ccecb 100644 --- a/gcc/testsuite/g++.dg/ext/attrib14.C +++ b/gcc/testsuite/g++.dg/ext/attrib14.C @@ -1,13 +1,9 @@ -// PR c++/13170 -// The bogus attribute is ignored, but was in TYPE_ATTRIBUTES during -// parsing of the class, causing some variants to have it and some not. +// PR c++/15317 -struct __attribute__((bogus)) A +struct A { - virtual ~A(); - void foo(const A&); - void bar(const A&); -}; // { dg-warning "ignored" "" } + A(char); +}; +A::A(__attribute__((unused)) char i2) +{} -void A::foo(const A&) {} -void A::bar(const A& a) { foo(a); } diff --git a/gcc/testsuite/g++.dg/template/error12.C b/gcc/testsuite/g++.dg/template/error12.C new file mode 100644 index 00000000000..c15961fc33e --- /dev/null +++ b/gcc/testsuite/g++.dg/template/error12.C @@ -0,0 +1,4 @@ +// PR c++/15044 + +template class class a { num_t n; } // { dg-error "" } + diff --git a/gcc/testsuite/g++.dg/template/ptrmem9.C b/gcc/testsuite/g++.dg/template/ptrmem9.C new file mode 100644 index 00000000000..55e88159935 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/ptrmem9.C @@ -0,0 +1,9 @@ +// PR c++/15329 + +struct S {}; + +template struct X { + S s; + void foo (void (S::*p)()) + { (s.*p)(); } +}; -- 2.11.4.GIT