diff options
| author | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-01-16 17:08:54 +0000 |
|---|---|---|
| committer | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-01-16 17:08:54 +0000 |
| commit | 5ea97769677de48e435b230f6d5a470db6b374bc (patch) | |
| tree | e4c9854954916b9a5ca7f242911869bdc1e5220c | |
| parent | 259277e02dc20bae37b8cd96b576a729ead9d2a0 (diff) | |
| download | ppe42-gcc-5ea97769677de48e435b230f6d5a470db6b374bc.tar.gz ppe42-gcc-5ea97769677de48e435b230f6d5a470db6b374bc.zip | |
cp:
PR C++/9212
* parser.c (cp_parser_direct_declarator): If accepting either
abstract or named, the name must be an unqualified-id.
testsuite:
* g++.dg/parse/ambig2.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@61399 138bc75d-0d04-0410-961f-82ee72b054a4
| -rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
| -rw-r--r-- | gcc/cp/parser.c | 18 | ||||
| -rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
| -rw-r--r-- | gcc/testsuite/g++.dg/parse/ambig2.C | 27 |
4 files changed, 50 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 826d7366593..39b294dc3f8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-01-16 Nathan Sidwell <nathan@codesourcery.com> + + PR c++/9212 + * parser.c (cp_parser_direct_declarator): If accepting either + abstract or named, the name must be an unqualified-id. + 2003-01-16 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> * class.c (layout_virtual_bases): Avoid signed/unsigned warning. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 68997ad170b..07b35a28fb5 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -1150,7 +1150,7 @@ typedef enum cp_parser_declarator_kind CP_PARSER_DECLARATOR_ABSTRACT, /* We want a named declarator. */ CP_PARSER_DECLARATOR_NAMED, - /* We don't mind. */ + /* We don't mind, but the name must be an unqualified-id */ CP_PARSER_DECLARATOR_EITHER } cp_parser_declarator_kind; @@ -10168,16 +10168,24 @@ cp_parser_direct_declarator (parser, dcl_kind, ctor_dtor_or_conv_p) if (dcl_kind == CP_PARSER_DECLARATOR_EITHER) cp_parser_parse_tentatively (parser); declarator = cp_parser_declarator_id (parser); - if (dcl_kind == CP_PARSER_DECLARATOR_EITHER - && !cp_parser_parse_definitely (parser)) - declarator = error_mark_node; + if (dcl_kind == CP_PARSER_DECLARATOR_EITHER) + { + if (!cp_parser_parse_definitely (parser)) + declarator = error_mark_node; + else if (TREE_CODE (declarator) != IDENTIFIER_NODE) + { + cp_parser_error (parser, "expected unqualified-id"); + declarator = error_mark_node; + } + } + if (declarator == error_mark_node) break; if (TREE_CODE (declarator) == SCOPE_REF) { tree scope = TREE_OPERAND (declarator, 0); - + /* In the declaration of a member of a template class outside of the class itself, the SCOPE will sometimes be a TYPENAME_TYPE. For example, given: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4beef4fad6d..f40783f0488 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2003-01-16 Nathan Sidwell <nathan@codesourcery.com> + + * g++.dg/parse/ambig2.C: New test. + 2003-01-15 Richard Henderson <rth@redhat.com> * g++.dg/tls/init-2.C: Update error message string. diff --git a/gcc/testsuite/g++.dg/parse/ambig2.C b/gcc/testsuite/g++.dg/parse/ambig2.C new file mode 100644 index 00000000000..7b000c6201e --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/ambig2.C @@ -0,0 +1,27 @@ +// { dg-do compile } + +// Copyright (C) 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 6 Jan 2003 <nathan@codesourcery.com> + +// PR 9212. We erroneously accepted an ill-formed +// function-declaration, rather than a variable initializer. + + +struct A +{ + enum E { e }; + A(E); +}; + +struct B +{ + enum F { f }; + B(F); +}; + +struct C +{ + C(A, B, A); +}; + +C c(A(A::e), B(B::f), A(A::e)); // This is not a function declaration |

