diff options
author | Mark Mitchell <mark@codesourcery.com> | 2005-02-10 00:34:46 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2005-02-10 00:34:46 +0000 |
commit | 88e95ee3851180cf033b254ed3fc671751b572ad (patch) | |
tree | db8f6d8142bd2c42ccac2bf7325075e8df87ea99 /gcc/cp/decl.c | |
parent | ca4c3169913c944780c4c0945c626eb9d47f12ad (diff) | |
download | gcc-88e95ee3851180cf033b254ed3fc671751b572ad.zip gcc-88e95ee3851180cf033b254ed3fc671751b572ad.tar.gz gcc-88e95ee3851180cf033b254ed3fc671751b572ad.tar.bz2 |
re PR c++/19787 (Internal compiler error with ambiguous conversion functions)
PR c++/19787
* call.c (initialize_reference): Robustify.
PR ++/19732
* decl.c (grokdeclarator): Check for invalid use of destructor
names.
PR c++/19762
* parser.c (cp_parser_unqualified_id): Avoid creating destructor
names with invalid types.
PR c++/19826
* parser.c (cp_parser_direct_declarator): Allow type-dependent
expressions as array bounds.
PR c++/19739
* parser.c (cp_parser_attributes_list): Allow empty lists.
PR c++/19787
* g++.dg/conversion/ambig1.C: New test.
PR c++/19739
* g++.dg/ext/attrib19.C: New test.
PR c++/19732
* g++.dg/parse/dtor5.C: New test.
PR c++/19762
* g++.dg/template/dtor3.C: New test.
PR c++/19826
* g++.dg/template/static11.C: New test.
* g++.dg/template/crash2.C: Remove dg-error marker.
From-SVN: r94788
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r-- | gcc/cp/decl.c | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 4d8059f..05918f5 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -6553,9 +6553,22 @@ grokdeclarator (const cp_declarator *declarator, { case BIT_NOT_EXPR: { - tree type = TREE_OPERAND (decl, 0); - type = constructor_name (type); - name = IDENTIFIER_POINTER (type); + tree type; + + if (innermost_code != cdk_function) + { + error ("declaration of %qD as non-function", decl); + return error_mark_node; + } + else if (!qualifying_scope + && !(current_class_type && at_class_scope_p ())) + { + error ("declaration of %qD as non-member", decl); + return error_mark_node; + } + + type = TREE_OPERAND (decl, 0); + name = IDENTIFIER_POINTER (constructor_name (type)); } break; @@ -7803,15 +7816,6 @@ grokdeclarator (const cp_declarator *declarator, int publicp = 0; tree function_context; - /* We catch the others as conflicts with the builtin - typedefs. */ - if (friendp && unqualified_id == ridpointers[(int) RID_SIGNED]) - { - error ("function %qD cannot be declared friend", - unqualified_id); - friendp = 0; - } - if (friendp == 0) { if (ctype == NULL_TREE) @@ -7849,6 +7853,18 @@ grokdeclarator (const cp_declarator *declarator, TYPE_ARG_TYPES (type)); } + /* Check that the name used for a destructor makes sense. */ + if (sfk == sfk_destructor + && !same_type_p (TREE_OPERAND + (id_declarator->u.id.unqualified_name, 0), + ctype)) + { + error ("declaration of %qD as member of %qT", + id_declarator->u.id.unqualified_name, + ctype); + return error_mark_node; + } + /* Tell grokfndecl if it needs to set TREE_PUBLIC on the node. */ function_context = (ctype != NULL_TREE) ? decl_function_context (TYPE_MAIN_DECL (ctype)) : NULL_TREE; |