diff options
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r-- | gcc/cp/semantics.c | 60 |
1 files changed, 22 insertions, 38 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 9589b47dd64..f56d00fd8f3 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -41,6 +41,7 @@ along with GCC; see the file COPYING3. If not see #include "omp-general.h" #include "convert.h" #include "gomp-constants.h" +#include "predict.h" /* There routines provide a modular interface to perform many parsing operations. They may therefore be used during actual parsing, or @@ -630,6 +631,7 @@ finish_goto_stmt (tree destination) check_goto (destination); + add_stmt (build_predict_expr (PRED_GOTO, NOT_TAKEN)); return add_stmt (build_stmt (input_location, GOTO_EXPR, destination)); } @@ -3037,9 +3039,9 @@ finish_member_declaration (tree decl) if (DECL_LANG_SPECIFIC (decl) && DECL_LANGUAGE (decl) == lang_c) SET_DECL_LANGUAGE (decl, lang_cplusplus); - /* 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. */ + /* Put the decl on the TYPE_FIELDS list. Note that this is built up + in reverse order. We reverse it (to obtain declaration order) in + finish_struct. */ if (DECL_DECLARES_FUNCTION_P (decl)) { /* We also need to add this function to the @@ -3047,8 +3049,8 @@ finish_member_declaration (tree decl) if (add_method (current_class_type, decl, false)) { gcc_assert (TYPE_MAIN_VARIANT (current_class_type) == current_class_type); - DECL_CHAIN (decl) = TYPE_METHODS (current_class_type); - TYPE_METHODS (current_class_type) = decl; + DECL_CHAIN (decl) = TYPE_FIELDS (current_class_type); + TYPE_FIELDS (current_class_type) = decl; maybe_add_class_template_decl_list (current_class_type, decl, /*friend_p=*/0); @@ -5794,7 +5796,7 @@ finish_omp_declare_simd_methods (tree t) if (processing_template_decl) return; - for (tree x = TYPE_METHODS (t); x; x = DECL_CHAIN (x)) + for (tree x = TYPE_FIELDS (t); x; x = DECL_CHAIN (x)) { if (TREE_CODE (TREE_TYPE (x)) != METHOD_TYPE) continue; @@ -9072,52 +9074,34 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p, } /* Called from trait_expr_value to evaluate either __has_nothrow_assign or - __has_nothrow_copy, depending on assign_p. */ + __has_nothrow_copy, depending on assign_p. Returns true iff all + the copy {ctor,assign} fns are nothrow. */ static bool classtype_has_nothrow_assign_or_copy_p (tree type, bool assign_p) { - tree fns; + tree fns = NULL_TREE; if (assign_p) - { - int ix; - ix = lookup_fnfields_1 (type, cp_assignment_operator_id (NOP_EXPR)); - if (ix < 0) - return false; - fns = (*CLASSTYPE_METHOD_VEC (type))[ix]; - } + fns = lookup_fnfields_slot (type, cp_assignment_operator_id (NOP_EXPR)); else if (TYPE_HAS_COPY_CTOR (type)) - { - /* If construction of the copy constructor was postponed, create - it now. */ - if (CLASSTYPE_LAZY_COPY_CTOR (type)) - lazily_declare_fn (sfk_copy_constructor, type); - if (CLASSTYPE_LAZY_MOVE_CTOR (type)) - lazily_declare_fn (sfk_move_constructor, type); - fns = CLASSTYPE_CONSTRUCTORS (type); - } - else - return false; + fns = lookup_fnfields_slot (type, ctor_identifier); + bool saw_copy = false; for (ovl_iterator iter (fns); iter; ++iter) { tree fn = *iter; - - if (assign_p) + + if (copy_fn_p (fn) > 0) { - if (copy_fn_p (fn) == 0) - continue; + saw_copy = true; + maybe_instantiate_noexcept (fn); + if (!TYPE_NOTHROW_P (TREE_TYPE (fn))) + return false; } - else if (copy_fn_p (fn) <= 0) - continue; - - maybe_instantiate_noexcept (fn); - if (!TYPE_NOTHROW_P (TREE_TYPE (fn))) - return false; } - return true; + return saw_copy; } /* Actually evaluates the trait. */ @@ -9401,7 +9385,7 @@ apply_deduced_return_type (tree fco, tree return_type) } if (DECL_CONV_FN_P (fco)) - DECL_NAME (fco) = mangle_conv_op_name_for_type (return_type); + DECL_NAME (fco) = make_conv_op_name (return_type); TREE_TYPE (fco) = change_return_type (return_type, TREE_TYPE (fco)); |