aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/class.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2018-02-27 20:52:15 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2018-02-27 20:52:15 +0000
commit10b5c9829b7e162342e8e730b6ed072bcd0dc7b2 (patch)
treed4a3fcaa4ea60a66ebc04d0669d289cb6662db27 /gcc/cp/class.c
parent7f7e718d9cfeab9a3ee4aea4dd2d9d565462c185 (diff)
downloadgcc-10b5c9829b7e162342e8e730b6ed072bcd0dc7b2.zip
gcc-10b5c9829b7e162342e8e730b6ed072bcd0dc7b2.tar.gz
gcc-10b5c9829b7e162342e8e730b6ed072bcd0dc7b2.tar.bz2
[PR c++/84426] ICE after conflicting member decl
https://gcc.gnu.org/ml/gcc-patches/2018-02/msg01529.html PR c++/84426 * name-lookup.h (get_member_slot): Rename ... (find_member_slot): ... here. (add_member_slot): New. * name-lookup.c (member_vec_linear_search): No need to check for NULL slot. (get_member_slot): Rename ... (find_member_slot): ... here. Don't add slot for incomplete class. (add_member_slot): New. * class.c (add_method): Adjust get_member_slot rename. Bail out if push_class_level_binding fails. Create slot and grok properties once we're committed to insertion. PR c++/84426 * g++.dg/lookup/pr84426.C: New. From-SVN: r258042
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r--gcc/cp/class.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index afa5c41..8348552 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -993,14 +993,11 @@ add_method (tree type, tree method, bool via_using)
if (method == error_mark_node)
return false;
- /* Maintain TYPE_HAS_USER_CONSTRUCTOR, etc. */
- grok_special_member_properties (method);
-
- tree *slot = get_member_slot (type, DECL_NAME (method));
- tree current_fns = *slot;
-
gcc_assert (!DECL_EXTERN_C_P (method));
+ tree *slot = find_member_slot (type, DECL_NAME (method));
+ tree current_fns = slot ? *slot : NULL_TREE;
+
/* Check to see if we've already got this method. */
for (ovl_iterator iter (current_fns); iter; ++iter)
{
@@ -1146,8 +1143,15 @@ add_method (tree type, tree method, bool via_using)
current_fns = ovl_insert (method, current_fns, via_using);
- if (!DECL_CONV_FN_P (method) && !COMPLETE_TYPE_P (type))
- push_class_level_binding (DECL_NAME (method), current_fns);
+ if (!COMPLETE_TYPE_P (type) && !DECL_CONV_FN_P (method)
+ && !push_class_level_binding (DECL_NAME (method), current_fns))
+ return false;
+
+ if (!slot)
+ slot = add_member_slot (type, DECL_NAME (method));
+
+ /* Maintain TYPE_HAS_USER_CONSTRUCTOR, etc. */
+ grok_special_member_properties (method);
*slot = current_fns;