diff options
author | Mark Mitchell <mark@codesourcery.com> | 2005-02-10 00:34:46 +0000 |
---|---|---|
committer | Mark Mitchell <mark@codesourcery.com> | 2005-02-10 00:34:46 +0000 |
commit | 60fc923765ae852f0efa84a689597276afc69aee (patch) | |
tree | db8f6d8142bd2c42ccac2bf7325075e8df87ea99 /gcc/cp/decl.c | |
parent | 9f6f92008e6e2b35a075ee973c3dc0e4eddce3a7 (diff) |
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.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@94788 138bc75d-0d04-0410-961f-82ee72b054a4
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 4d8059fc46a..05918f553f9 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; |