diff options
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r-- | gcc/cp/class.c | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c index d2cf63c7d0f..3cb76de60aa 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -304,8 +304,13 @@ build_base_path (enum tree_code code, virtual_access = (v_binfo && fixed_type_p <= 0); /* Don't bother with the calculations inside sizeof; they'll ICE if the - source type is incomplete and the pointer value doesn't matter. */ - if (cp_unevaluated_operand != 0) + source type is incomplete and the pointer value doesn't matter. In a + template (even in fold_non_dependent_expr), we don't have vtables set + up properly yet, and the value doesn't matter there either; we're just + interested in the result of overload resolution. */ + if (cp_unevaluated_operand != 0 + || (current_function_decl + && uses_template_parms (current_function_decl))) { expr = build_nop (ptr_target_type, expr); if (!want_pointer) @@ -333,7 +338,7 @@ build_base_path (enum tree_code code, /* Now that we've saved expr, build the real null test. */ if (null_test) { - tree zero = cp_convert (TREE_TYPE (expr), integer_zero_node); + tree zero = cp_convert (TREE_TYPE (expr), nullptr_node); null_test = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, expr, zero); } @@ -359,11 +364,6 @@ build_base_path (enum tree_code code, V_BINFO. That offset is an entry in D_BINFO's vtable. */ tree v_offset; - /* In a constructor template, current_in_charge_parm isn't set, - and we might end up here via fold_non_dependent_expr. */ - if (fixed_type_p < 0 && !(cfun && current_in_charge_parm)) - fixed_type_p = 0; - if (fixed_type_p < 0 && in_base_initializer) { /* In a base member initializer, we cannot rely on the @@ -1058,11 +1058,6 @@ add_method (tree type, tree method, tree using_decl) if (DECL_CONTEXT (fn) == type) /* Defer to the local function. */ return false; - if (DECL_CONTEXT (fn) == DECL_CONTEXT (method)) - error ("repeated using declaration %q+D", using_decl); - else - error ("using declaration %q+D conflicts with a previous using declaration", - using_decl); } else { @@ -2726,6 +2721,13 @@ add_implicitly_declared_members (tree t, int cant_have_const_cctor, int cant_have_const_assignment) { + bool move_ok = false; + + if (cxx_dialect >= cxx0x && !CLASSTYPE_DESTRUCTORS (t) + && !TYPE_HAS_COPY_CTOR (t) && !TYPE_HAS_COPY_ASSIGN (t) + && !type_has_move_constructor (t) && !type_has_move_assign (t)) + move_ok = true; + /* Destructor. */ if (!CLASSTYPE_DESTRUCTORS (t)) { @@ -2763,7 +2765,7 @@ add_implicitly_declared_members (tree t, TYPE_HAS_COPY_CTOR (t) = 1; TYPE_HAS_CONST_COPY_CTOR (t) = !cant_have_const_cctor; CLASSTYPE_LAZY_COPY_CTOR (t) = 1; - if (cxx_dialect >= cxx0x && !type_has_move_constructor (t)) + if (move_ok) CLASSTYPE_LAZY_MOVE_CTOR (t) = 1; } @@ -2776,7 +2778,7 @@ add_implicitly_declared_members (tree t, TYPE_HAS_COPY_ASSIGN (t) = 1; TYPE_HAS_CONST_COPY_ASSIGN (t) = !cant_have_const_assignment; CLASSTYPE_LAZY_COPY_ASSIGN (t) = 1; - if (cxx_dialect >= cxx0x && !type_has_move_assign (t)) + if (move_ok) CLASSTYPE_LAZY_MOVE_ASSIGN (t) = 1; } @@ -3039,15 +3041,8 @@ check_field_decls (tree t, tree *access_decls, if (TREE_CODE (x) == USING_DECL) { - /* Prune the access declaration from the list of fields. */ - *field = DECL_CHAIN (x); - /* Save the access declarations for our caller. */ *access_decls = tree_cons (NULL_TREE, x, *access_decls); - - /* Since we've reset *FIELD there's no reason to skip to the - next field. */ - next = field; continue; } |