diff options
author | Jason Merrill <jason@yorick.cygnus.com> | 1998-10-26 11:59:09 +0000 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 1998-10-26 06:59:09 -0500 |
commit | 1eb0072d903cc740b71d452d611f9ffb59cf472f (patch) | |
tree | 539b807a659c1fa42b10fcfcca02cce43e7627b7 /gcc | |
parent | 26f63a7785248ef733ab3a89c56bede58860472c (diff) | |
download | gcc-1eb0072d903cc740b71d452d611f9ffb59cf472f.zip gcc-1eb0072d903cc740b71d452d611f9ffb59cf472f.tar.gz gcc-1eb0072d903cc740b71d452d611f9ffb59cf472f.tar.bz2 |
decl.c (grokdeclarator): Complain about a variable using constructor syntax coming back null from start_decl.
* decl.c (grokdeclarator): Complain about a variable using
constructor syntax coming back null from start_decl.
Fixes g++.other/decl2.C
* friend.c (make_friend_class): Complain about trying to make
a non-class type a friend.
Fixes g++.other/friend5.C
* decl.c (grokfndecl): Set DECL_INITIAL for a defn here.
(start_function): Not here.
Fixes g++.law/friend4.C
From-SVN: r23353
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/cp/decl.c | 22 | ||||
-rw-r--r-- | gcc/cp/friend.c | 5 |
3 files changed, 27 insertions, 11 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8926b98..5506568 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,14 @@ +1998-10-26 Jason Merrill <jason@yorick.cygnus.com> + + * decl.c (grokdeclarator): Complain about a variable using + constructor syntax coming back null from start_decl. + + * friend.c (make_friend_class): Complain about trying to make + a non-class type a friend. + + * decl.c (grokfndecl): Set DECL_INITIAL for a defn here. + (start_function): Not here. + 1998-10-26 Brendan Kehoe <brendan@cygnus.com> * decl.c (grokdeclarator): Disallow `explicit' in a friend declaration. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 983b2d0..f516746 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -8181,6 +8181,11 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals, && (! DECL_USE_TEMPLATE (decl) || name_mangling_version < 1)) set_mangled_name_for_decl (decl); + if (funcdef_flag) + /* Make the init_value nonzero so pushdecl knows this is not + tentative. error_mark_node is replaced later with the BLOCK. */ + DECL_INITIAL (decl) = error_mark_node; + /* Caller will do the rest of this. */ if (check < 0) return decl; @@ -8641,10 +8646,15 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) init = TREE_OPERAND (decl, 1); decl = start_decl (declarator, declspecs, 1, NULL_TREE, NULL_TREE); - /* Look for __unused__ attribute */ - if (TREE_USED (TREE_TYPE (decl))) - TREE_USED (decl) = 1; - finish_decl (decl, init, NULL_TREE); + if (decl) + { + /* Look for __unused__ attribute */ + if (TREE_USED (TREE_TYPE (decl))) + TREE_USED (decl) = 1; + finish_decl (decl, init, NULL_TREE); + } + else + cp_error ("invalid declarator"); return 0; } innermost_code = TREE_CODE (decl); @@ -12505,10 +12515,6 @@ start_function (declspecs, declarator, attrs, pre_parsed_p) && TREE_CODE (TREE_TYPE (fntype)) == VOID_TYPE) cp_warning ("`operator=' should return a reference to `*this'"); - /* Make the init_value nonzero so pushdecl knows this is not tentative. - error_mark_node is replaced below (in poplevel) with the BLOCK. */ - DECL_INITIAL (decl1) = error_mark_node; - #ifdef SET_DEFAULT_DECL_ATTRIBUTES SET_DEFAULT_DECL_ATTRIBUTES (decl1, attrs); #endif diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index a3d198a..c98fd4e 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -255,10 +255,9 @@ make_friend_class (type, friend_type) error ("`friend' declaration in signature definition"); return; } - if (IS_SIGNATURE (friend_type)) + if (IS_SIGNATURE (friend_type) || ! IS_AGGR_TYPE (friend_type)) { - error ("signature type `%s' declared `friend'", - IDENTIFIER_POINTER (TYPE_IDENTIFIER (friend_type))); + cp_error ("invalid type `%T' declared `friend'", friend_type); return; } |