aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/semantics.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2003-06-20 02:40:37 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2003-06-20 02:40:37 +0000
commitf139561cce27d9b662b0a3b22d3dd6aa56ae1854 (patch)
treef39921e4f96d4b307cb115c1a2e04b29f5a15ee4 /gcc/cp/semantics.c
parent170b020fe4be4eadea27d389257778d952fb5a13 (diff)
downloadgcc-f139561cce27d9b662b0a3b22d3dd6aa56ae1854.zip
gcc-f139561cce27d9b662b0a3b22d3dd6aa56ae1854.tar.gz
gcc-f139561cce27d9b662b0a3b22d3dd6aa56ae1854.tar.bz2
re PR c++/9649 (ICE in finish_member_declaration at cp/semantics.c:1850 when redeclaring a static member variable)
PR c++/9649 * cp-tree.h (pushdecl_class_level): Change prototype. (push_class_level_binding): Likewise. * decl.c (add_binding): Reject duplicate static data members. (pushdecl_class_level): Return a value indicating whether or not the binding was valid. (push_class_level_binding): Likewise. * semantics.c (finish_member_declaration): Don't keep invalid declarations. PR c++/9649 * g++.dg/template/static4.C: New test. * g++.old-deja/g++.other/anon7.C: Remove spurious error messages. From-SVN: r68240
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r--gcc/cp/semantics.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index b400e4d..a95c957 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -1862,8 +1862,6 @@ finish_member_declaration (tree decl)
if (DECL_LANG_SPECIFIC (decl) && DECL_LANGUAGE (decl) == lang_c)
SET_DECL_LANGUAGE (decl, lang_cplusplus);
- maybe_add_class_template_decl_list (current_class_type, decl, /*friend_p=*/0);
-
/* Put functions on the TYPE_METHODS list and everything else on the
TYPE_FIELDS list. Note that these are built up in reverse order.
We reverse them (to obtain declaration order) in finish_struct. */
@@ -1876,8 +1874,12 @@ finish_member_declaration (tree decl)
TREE_CHAIN (decl) = TYPE_METHODS (current_class_type);
TYPE_METHODS (current_class_type) = decl;
+
+ maybe_add_class_template_decl_list (current_class_type, decl,
+ /*friend_p=*/0);
}
- else
+ /* Enter the DECL into the scope of the class. */
+ else if (TREE_CODE (decl) == USING_DECL || pushdecl_class_level (decl))
{
/* All TYPE_DECLs go at the end of TYPE_FIELDS. Ordinary fields
go at the beginning. The reason is that lookup_field_1
@@ -1905,9 +1907,8 @@ finish_member_declaration (tree decl)
TYPE_FIELDS (current_class_type) = decl;
}
- /* Enter the DECL into the scope of the class. */
- if (TREE_CODE (decl) != USING_DECL)
- pushdecl_class_level (decl);
+ maybe_add_class_template_decl_list (current_class_type, decl,
+ /*friend_p=*/0);
}
}