diff options
author | synergydev <synergye@codefi.re> | 2013-10-17 18:16:42 -0700 |
---|---|---|
committer | synergydev <synergye@codefi.re> | 2013-10-17 18:16:42 -0700 |
commit | 61c0330cc243abf13fdd01f377a7f80bd3989eb1 (patch) | |
tree | 119b08ae76294f23e2b1b7e72ff9a06afa9e8509 /gcc-4.8/gcc/cp | |
parent | 1c712bf7621f3859c33fd3afaa61fdcaf3fdfd76 (diff) | |
download | toolchain_gcc-61c0330cc243abf13fdd01f377a7f80bd3989eb1.tar.gz toolchain_gcc-61c0330cc243abf13fdd01f377a7f80bd3989eb1.tar.bz2 toolchain_gcc-61c0330cc243abf13fdd01f377a7f80bd3989eb1.zip |
[4.8] Merge GCC 4.8.2
Change-Id: I0f1fcf69c5076d8534c5c45562745e1a37adb197
Diffstat (limited to 'gcc-4.8/gcc/cp')
-rw-r--r-- | gcc-4.8/gcc/cp/ChangeLog | 148 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/call.c | 6 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/class.c | 51 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/cp-tree.h | 24 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/cvt.c | 26 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/decl.c | 23 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/init.c | 3 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/method.c | 3 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/name-lookup.c | 6 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/parser.c | 23 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/pt.c | 98 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/semantics.c | 36 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/tree.c | 2 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/typeck.c | 6 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/typeck2.c | 2 |
15 files changed, 374 insertions, 83 deletions
diff --git a/gcc-4.8/gcc/cp/ChangeLog b/gcc-4.8/gcc/cp/ChangeLog index ffc0ccd8b..f6249680f 100644 --- a/gcc-4.8/gcc/cp/ChangeLog +++ b/gcc-4.8/gcc/cp/ChangeLog @@ -1,3 +1,151 @@ +2013-10-16 Release Manager + + * GCC 4.8.2 released. + +2013-10-08 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/58568 + * semantics.c (begin_lambda_type): Check return value of xref_tag + for error_mark_node; tidy. + * decl.c (grokdeclarator): Tweak error message. + +2013-10-02 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/58535 + * parser.c (cp_parser_function_specifier_opt): Upon error about + virtual templates don't set ds_virtual. + +2013-09-18 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/58457 + * class.c (instantiate_type): Loosen a bit the gcc_assert. + +2013-09-13 Jason Merrill <jason@redhat.com> + + PR c++/58273 + * pt.c (any_type_dependent_elements_p): Actually check for + type-dependence, not value-dependence. + +2013-09-09 Jakub Jelinek <jakub@redhat.com> + + PR c++/58325 + * init.c (build_vec_delete): Call mark_rvalue_use on base. + +2013-08-20 Jason Merrill <jason@redhat.com> + + PR c++/58119 + * cp-tree.h (WILDCARD_TYPE_P): Split out from... + (MAYBE_CLASS_TYPE_P): ...here. + * cvt.c (build_expr_type_conversion): Don't complain about a + template that can't match the desired type category. + +2013-08-17 Jason Merrill <jason@redhat.com> + + PR c++/58083 + * name-lookup.c (push_class_level_binding_1): It's OK to push a + lambda type after the enclosing type is complete. + +2013-08-06 Jason Merrill <jason@redhat.com> + + PR c++/57825 + * tree.c (strip_typedefs) [METHOD_TYPE]: Preserve ref-qualifier. + +2013-07-29 Jason Merrill <jason@redhat.com> + + PR c++/57901 + * semantics.c (build_data_member_initialization, constexpr_fn_retval): + Use break_out_target_exprs instead of unshare_expr. + + PR c++/58022 + * typeck2.c (abstract_virtuals_error_sfinae): Don't remember + lookup in SFINAE context. + +2013-07-25 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/57981 + * decl.c (check_default_argument): Take a tsubst_flags_t parameter. + (grokparms): Adjust. + * parser.c (cp_parser_late_parse_one_default_arg): Likewise. + * pt.c (tsubst_default_argument, tsubst_default_arguments): Take + a tsubst_flags_t parameter. + (tsubst_decl): Adjust. + * call.c (convert_default_arg): Likewise. + * cp-tree.h (check_default_argument, tsubst_default_argument): + Update declarations. + +2013-07-12 Jason Merrill <jason@redhat.com> + + * init.c (build_vec_init): Value-initialize the rest of the array. + +2013-07-09 Jason Merrill <jason@redhat.com> + + PR c++/57526 + * semantics.c (lambda_capture_field_type): Build a DECLTYPE_TYPE + if the variable type uses 'auto'. + + PR c++/57437 + * typeck.c (check_return_expr): Lambda proxies aren't eligible + for nrv or return by move. + + PR c++/57532 + * parser.c (cp_parser_ref_qualifier_opt): Don't tentatively parse + a ref-qualifier in C++98 mode. + + PR c++/57545 + * pt.c (convert_nontype_argument) [INTEGER_CST]: Force the + argument to have the exact type of the parameter. + + PR c++/57551 + * semantics.c (cxx_eval_indirect_ref): Don't try to look through + a POINTER_PLUS_EXPR for type punning diagnostic. + + PR c++/57831 + * pt.c (tsubst_copy): Handle USING_DECL. + +2013-07-08 Jason Merrill <jason@redhat.com> + + PR c++/57550 + * pt.c (fn_type_unification): Only defer during substitution. + (type_unification_real): Defer during defarg substitution, + add checks parm to pass back deferred checks. + (unify, do_auto_deduction): Adjust. + * semantics.c (reopen_deferring_access_checks): New. + * cp-tree.h: Declare it. + +2013-07-05 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/57645 + * class.c (deduce_noexcept_on_destructors): Save, set, and restore + TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t) around the main loop over the + destructors. + +2013-07-03 Jakub Jelinek <jakub@redhat.com> + + PR c++/57771 + * parser.c (cp_parser_postfix_expression) <case RID_STATCAST> + Temporarily set parser->greater_than_is_operator_p for + cp_parser_expression and restore from saved value afterwards. + +2013-06-21 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/53211 + * pt.c (type_dependent_expression_p): Handle an array of unknown + bound depending on a variadic parameter. + * parser.c (cp_parser_range_for): Revert PR56794 changes. + +2013-05-31 Jason Merrill <jason@redhat.com> + + PR c++/57319 + * class.c (vbase_has_user_provided_move_assign): New. + * method.c (synthesized_method_walk): Check it. + * cp-tree.h: Declare it. + + PR c++/56930 + * call.c (convert_like_real): Use cp_convert_and_check. + * cvt.c (cp_convert_and_check): Use maybe_constant_value. + * semantics.c (cxx_eval_constant_expression): Handle LTGT_EXPR. + (potential_constant_expression_1): Handle OMP_ATOMIC*. + 2013-05-31 Release Manager * GCC 4.8.1 released. diff --git a/gcc-4.8/gcc/cp/call.c b/gcc-4.8/gcc/cp/call.c index 72c1dac25..a5be421fe 100644 --- a/gcc-4.8/gcc/cp/call.c +++ b/gcc-4.8/gcc/cp/call.c @@ -6195,8 +6195,8 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, if (convs->check_narrowing) check_narrowing (totype, expr); - if (issue_conversion_warnings && (complain & tf_warning)) - expr = convert_and_check (totype, expr); + if (issue_conversion_warnings) + expr = cp_convert_and_check (totype, expr, complain); else expr = convert (totype, expr); @@ -6390,7 +6390,7 @@ convert_default_arg (tree type, tree arg, tree fn, int parmnum, push_defarg_context (fn); if (fn && DECL_TEMPLATE_INFO (fn)) - arg = tsubst_default_argument (fn, type, arg); + arg = tsubst_default_argument (fn, type, arg, complain); /* Due to: diff --git a/gcc-4.8/gcc/cp/class.c b/gcc-4.8/gcc/cp/class.c index 37aea5c27..578c92bc6 100644 --- a/gcc-4.8/gcc/cp/class.c +++ b/gcc-4.8/gcc/cp/class.c @@ -4574,15 +4574,20 @@ deduce_noexcept_on_destructor (tree dtor) static void deduce_noexcept_on_destructors (tree t) { - tree fns; - /* If for some reason we don't have a CLASSTYPE_METHOD_VEC, we bail out now. */ if (!CLASSTYPE_METHOD_VEC (t)) return; - for (fns = CLASSTYPE_DESTRUCTORS (t); fns; fns = OVL_NEXT (fns)) + bool saved_nontrivial_dtor = TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t); + + /* Avoid early exit from synthesized_method_walk (c++/57645). */ + TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t) = true; + + for (tree fns = CLASSTYPE_DESTRUCTORS (t); fns; fns = OVL_NEXT (fns)) deduce_noexcept_on_destructor (OVL_CURRENT (fns)); + + TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t) = saved_nontrivial_dtor; } /* Subroutine of set_one_vmethod_tm_attributes. Search base classes @@ -4833,6 +4838,44 @@ type_has_user_provided_default_constructor (tree t) return false; } +/* TYPE is being used as a virtual base, and has a non-trivial move + assignment. Return true if this is due to there being a user-provided + move assignment in TYPE or one of its subobjects; if there isn't, then + multiple move assignment can't cause any harm. */ + +bool +vbase_has_user_provided_move_assign (tree type) +{ + /* Does the type itself have a user-provided move assignment operator? */ + for (tree fns + = lookup_fnfields_slot_nolazy (type, ansi_assopname (NOP_EXPR)); + fns; fns = OVL_NEXT (fns)) + { + tree fn = OVL_CURRENT (fns); + if (move_fn_p (fn) && user_provided_p (fn)) + return true; + } + + /* Do any of its bases? */ + tree binfo = TYPE_BINFO (type); + tree base_binfo; + for (int i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); ++i) + if (vbase_has_user_provided_move_assign (BINFO_TYPE (base_binfo))) + return true; + + /* Or non-static data members? */ + for (tree field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field)) + { + if (TREE_CODE (field) == FIELD_DECL + && CLASS_TYPE_P (TREE_TYPE (field)) + && vbase_has_user_provided_move_assign (TREE_TYPE (field))) + return true; + } + + /* Seems not. */ + return false; +} + /* If default-initialization leaves part of TYPE uninitialized, returns a DECL for the field or TYPE itself (DR 253). */ @@ -7465,7 +7508,7 @@ instantiate_type (tree lhstype, tree rhs, tsubst_flags_t flags) dependent on overload resolution. */ gcc_assert (TREE_CODE (rhs) == ADDR_EXPR || TREE_CODE (rhs) == COMPONENT_REF - || really_overloaded_fn (rhs) + || is_overloaded_fn (rhs) || (flag_ms_extensions && TREE_CODE (rhs) == FUNCTION_DECL)); /* This should really only be used when attempting to distinguish diff --git a/gcc-4.8/gcc/cp/cp-tree.h b/gcc-4.8/gcc/cp/cp-tree.h index b8080833b..71b5bf6c9 100644 --- a/gcc-4.8/gcc/cp/cp-tree.h +++ b/gcc-4.8/gcc/cp/cp-tree.h @@ -1211,17 +1211,20 @@ enum languages { lang_c, lang_cplusplus, lang_java }; /* The _DECL for this _TYPE. */ #define TYPE_MAIN_DECL(NODE) (TYPE_STUB_DECL (TYPE_MAIN_VARIANT (NODE))) -/* Nonzero if T is a class (or struct or union) type. Also nonzero - for template type parameters, typename types, and instantiated - template template parameters. Keep these checks in ascending code - order. */ -#define MAYBE_CLASS_TYPE_P(T) \ +/* Nonzero if T is a type that could resolve to any kind of concrete type + at instantiation time. */ +#define WILDCARD_TYPE_P(T) \ (TREE_CODE (T) == TEMPLATE_TYPE_PARM \ || TREE_CODE (T) == TYPENAME_TYPE \ || TREE_CODE (T) == TYPEOF_TYPE \ || TREE_CODE (T) == BOUND_TEMPLATE_TEMPLATE_PARM \ - || TREE_CODE (T) == DECLTYPE_TYPE \ - || CLASS_TYPE_P (T)) + || TREE_CODE (T) == DECLTYPE_TYPE) + +/* Nonzero if T is a class (or struct or union) type. Also nonzero + for template type parameters, typename types, and instantiated + template template parameters. Keep these checks in ascending code + order. */ +#define MAYBE_CLASS_TYPE_P(T) (WILDCARD_TYPE_P (T) || CLASS_TYPE_P (T)) /* Set CLASS_TYPE_P for T to VAL. T must be a class, struct, or union type. */ @@ -5057,6 +5060,7 @@ extern tree in_class_defaulted_default_constructor (tree); extern bool user_provided_p (tree); extern bool type_has_user_provided_constructor (tree); extern bool type_has_user_provided_default_constructor (tree); +extern bool vbase_has_user_provided_move_assign (tree); extern tree default_init_uninitialized_part (tree); extern bool trivial_default_constructor_is_constexpr (tree); extern bool type_has_constexpr_default_constructor (tree); @@ -5177,7 +5181,7 @@ extern tree static_fn_type (tree); extern void revert_static_member_fn (tree); extern void fixup_anonymous_aggr (tree); extern tree compute_array_index_type (tree, tree, tsubst_flags_t); -extern tree check_default_argument (tree, tree); +extern tree check_default_argument (tree, tree, tsubst_flags_t); typedef int (*walk_namespaces_fn) (tree, void *); extern int walk_namespaces (walk_namespaces_fn, void *); @@ -5452,7 +5456,8 @@ extern tree maybe_process_partial_specialization (tree); extern tree most_specialized_instantiation (tree); extern void print_candidates (tree); extern void instantiate_pending_templates (int); -extern tree tsubst_default_argument (tree, tree, tree); +extern tree tsubst_default_argument (tree, tree, tree, + tsubst_flags_t); extern tree tsubst (tree, tree, tsubst_flags_t, tree); extern tree tsubst_copy_and_build (tree, tree, tsubst_flags_t, tree, bool, bool); @@ -5585,6 +5590,7 @@ extern void resume_deferring_access_checks (void); extern void stop_deferring_access_checks (void); extern void pop_deferring_access_checks (void); extern vec<deferred_access_check, va_gc> *get_deferred_access_checks (void); +extern void reopen_deferring_access_checks (vec<deferred_access_check, va_gc> *); extern void pop_to_parent_deferring_access_checks (void); extern bool perform_access_checks (vec<deferred_access_check, va_gc> *, tsubst_flags_t); diff --git a/gcc-4.8/gcc/cp/cvt.c b/gcc-4.8/gcc/cp/cvt.c index 348e6082c..8c03e2086 100644 --- a/gcc-4.8/gcc/cp/cvt.c +++ b/gcc-4.8/gcc/cp/cvt.c @@ -620,6 +620,9 @@ cp_convert_and_check (tree type, tree expr, tsubst_flags_t complain) if (TREE_TYPE (expr) == type) return expr; + + if (TREE_CODE (expr) == SIZEOF_EXPR) + expr = maybe_constant_value (expr); result = cp_convert (type, expr, complain); @@ -1580,17 +1583,6 @@ build_expr_type_conversion (int desires, tree expr, bool complain) if (DECL_NONCONVERTING_P (cand)) continue; - if (TREE_CODE (cand) == TEMPLATE_DECL) - { - if (complain) - { - error ("ambiguous default type conversion from %qT", - basetype); - error (" candidate conversions include %qD", cand); - } - return error_mark_node; - } - candidate = non_reference (TREE_TYPE (TREE_TYPE (cand))); switch (TREE_CODE (candidate)) @@ -1624,11 +1616,23 @@ build_expr_type_conversion (int desires, tree expr, bool complain) break; default: + /* A wildcard could be instantiated to match any desired + type, but we can't deduce the template argument. */ + if (WILDCARD_TYPE_P (candidate)) + win = true; break; } if (win) { + if (TREE_CODE (cand) == TEMPLATE_DECL) + { + if (complain) + error ("default type conversion can't deduce template" + " argument for %qD", cand); + return error_mark_node; + } + if (winner) { if (complain) diff --git a/gcc-4.8/gcc/cp/decl.c b/gcc-4.8/gcc/cp/decl.c index 09296debe..893fbd161 100644 --- a/gcc-4.8/gcc/cp/decl.c +++ b/gcc-4.8/gcc/cp/decl.c @@ -8780,8 +8780,8 @@ grokdeclarator (const cp_declarator *declarator, && !uniquely_derived_from_p (ctype, current_class_type)) { - error ("type %qT is not derived from type %qT", - ctype, current_class_type); + error ("invalid use of qualified-name %<%T::%D%>", + qualifying_scope, decl); return error_mark_node; } } @@ -10878,7 +10878,7 @@ local_variable_p_walkfn (tree *tp, int *walk_subtrees, DECL, if there is no DECL available. */ tree -check_default_argument (tree decl, tree arg) +check_default_argument (tree decl, tree arg, tsubst_flags_t complain) { tree var; tree decl_type; @@ -10910,13 +10910,14 @@ check_default_argument (tree decl, tree arg) A default argument expression is implicitly converted to the parameter type. */ ++cp_unevaluated_operand; - perform_implicit_conversion_flags (decl_type, arg, tf_warning_or_error, + perform_implicit_conversion_flags (decl_type, arg, complain, LOOKUP_IMPLICIT); --cp_unevaluated_operand; if (warn_zero_as_null_pointer_constant && TYPE_PTR_OR_PTRMEM_P (decl_type) && null_ptr_cst_p (arg) + && (complain & tf_warning) && maybe_warn_zero_as_null_pointer_constant (arg, input_location)) return nullptr_node; @@ -10930,10 +10931,14 @@ check_default_argument (tree decl, tree arg) var = cp_walk_tree_without_duplicates (&arg, local_variable_p_walkfn, NULL); if (var) { - if (DECL_NAME (var) == this_identifier) - permerror (input_location, "default argument %qE uses %qD", arg, var); - else - error ("default argument %qE uses local variable %qD", arg, var); + if (complain & tf_warning_or_error) + { + if (DECL_NAME (var) == this_identifier) + permerror (input_location, "default argument %qE uses %qD", + arg, var); + else + error ("default argument %qE uses local variable %qD", arg, var); + } return error_mark_node; } @@ -11084,7 +11089,7 @@ grokparms (tree parmlist, tree *parms) if (any_error) init = NULL_TREE; else if (init && !processing_template_decl) - init = check_default_argument (decl, init); + init = check_default_argument (decl, init, tf_warning_or_error); } DECL_CHAIN (decl) = decls; diff --git a/gcc-4.8/gcc/cp/init.c b/gcc-4.8/gcc/cp/init.c index a0efbbce4..ea40caa8f 100644 --- a/gcc-4.8/gcc/cp/init.c +++ b/gcc-4.8/gcc/cp/init.c @@ -3524,6 +3524,8 @@ build_vec_init (tree base, tree maxindex, tree init, /* Clear out INIT so that we don't get confused below. */ init = NULL_TREE; + /* Any elements without explicit initializers get {}. */ + explicit_value_init_p = true; } else if (from_array) { @@ -4062,6 +4064,7 @@ build_vec_delete (tree base, tree maxindex, tree cookie_addr; tree size_ptr_type = build_pointer_type (sizetype); + base = mark_rvalue_use (base); if (TREE_SIDE_EFFECTS (base)) { base_init = get_target_expr (base); diff --git a/gcc-4.8/gcc/cp/method.c b/gcc-4.8/gcc/cp/method.c index ff29b5968..023f80e01 100644 --- a/gcc-4.8/gcc/cp/method.c +++ b/gcc-4.8/gcc/cp/method.c @@ -1340,7 +1340,8 @@ synthesized_method_walk (tree ctype, special_function_kind sfk, bool const_p, if (diag && assign_p && move_p && BINFO_VIRTUAL_P (base_binfo) && rval && TREE_CODE (rval) == FUNCTION_DECL - && move_fn_p (rval) && !trivial_fn_p (rval)) + && move_fn_p (rval) && !trivial_fn_p (rval) + && vbase_has_user_provided_move_assign (basetype)) warning (OPT_Wvirtual_move_assign, "defaulted move assignment for %qT calls a non-trivial " "move assignment operator for virtual base %qT", diff --git a/gcc-4.8/gcc/cp/name-lookup.c b/gcc-4.8/gcc/cp/name-lookup.c index 2a47331ea..c121a4163 100644 --- a/gcc-4.8/gcc/cp/name-lookup.c +++ b/gcc-4.8/gcc/cp/name-lookup.c @@ -3015,8 +3015,10 @@ push_class_level_binding_1 (tree name, tree x) if (name == error_mark_node) return false; - /* Check for invalid member names. */ - gcc_assert (TYPE_BEING_DEFINED (current_class_type)); + /* Check for invalid member names. But don't worry about a default + argument-scope lambda being pushed after the class is complete. */ + gcc_assert (TYPE_BEING_DEFINED (current_class_type) + || LAMBDA_TYPE_P (TREE_TYPE (decl))); /* Check that we're pushing into the right binding level. */ gcc_assert (current_class_type == class_binding_level->this_entity); diff --git a/gcc-4.8/gcc/cp/parser.c b/gcc-4.8/gcc/cp/parser.c index 50b3e2239..b6322788f 100644 --- a/gcc-4.8/gcc/cp/parser.c +++ b/gcc-4.8/gcc/cp/parser.c @@ -5438,11 +5438,18 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, /* Restore the old message. */ parser->type_definition_forbidden_message = saved_message; + bool saved_greater_than_is_operator_p + = parser->greater_than_is_operator_p; + parser->greater_than_is_operator_p = true; + /* And the expression which is being cast. */ cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN); expression = cp_parser_expression (parser, /*cast_p=*/true, & idk); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN); + parser->greater_than_is_operator_p + = saved_greater_than_is_operator_p; + /* Only type conversions to integral or enumeration types can be used in constant-expressions. */ if (!cast_valid_in_integral_constant_expression_p (type) @@ -9595,10 +9602,7 @@ cp_parser_range_for (cp_parser *parser, tree scope, tree init, tree range_decl) range_expr = error_mark_node; stmt = begin_range_for_stmt (scope, init); finish_range_for_decl (stmt, range_decl, range_expr); - if (range_expr != error_mark_node - && !type_dependent_expression_p (range_expr) - /* The length of an array might be dependent. */ - && COMPLETE_TYPE_P (complete_type (TREE_TYPE (range_expr))) + if (!type_dependent_expression_p (range_expr) /* do_auto_deduction doesn't mess with template init-lists. */ && !BRACE_ENCLOSED_INITIALIZER_P (range_expr)) do_range_for_auto_deduction (range_decl, range_expr); @@ -11135,7 +11139,8 @@ cp_parser_function_specifier_opt (cp_parser* parser, A member function template shall not be virtual. */ if (PROCESSING_REAL_TEMPLATE_DECL_P ()) error_at (token->location, "templates may not be %<virtual%>"); - set_and_check_decl_spec_loc (decl_specs, ds_virtual, token); + else + set_and_check_decl_spec_loc (decl_specs, ds_virtual, token); break; case RID_EXPLICIT: @@ -16982,6 +16987,11 @@ cp_parser_ref_qualifier_seq_opt (cp_parser* parser) { cp_ref_qualifier ref_qual = REF_QUAL_NONE; cp_token *token = cp_lexer_peek_token (parser->lexer); + + /* Don't try to parse bitwise '&' as a ref-qualifier (c++/57532). */ + if (cxx_dialect < cxx11 && cp_parser_parsing_tentatively (parser)) + return ref_qual; + switch (token->type) { case CPP_AND: @@ -22557,7 +22567,8 @@ cp_parser_late_parse_one_default_arg (cp_parser *parser, tree decl, /* In a non-template class, check conversions now. In a template, we'll wait and instantiate these as needed. */ if (TREE_CODE (decl) == PARM_DECL) - parsed_arg = check_default_argument (parmtype, parsed_arg); + parsed_arg = check_default_argument (parmtype, parsed_arg, + tf_warning_or_error); else { int flags = LOOKUP_IMPLICIT; diff --git a/gcc-4.8/gcc/cp/pt.c b/gcc-4.8/gcc/cp/pt.c index 65bce34c7..e3968ec42 100644 --- a/gcc-4.8/gcc/cp/pt.c +++ b/gcc-4.8/gcc/cp/pt.c @@ -138,6 +138,7 @@ static int maybe_adjust_types_for_deduction (unification_kind_t, tree*, tree*, tree); static int type_unification_real (tree, tree, tree, const tree *, unsigned int, int, unification_kind_t, int, + vec<deferred_access_check, va_gc> **, bool); static void note_template_header (int); static tree convert_nontype_argument_function (tree, tree); @@ -183,7 +184,7 @@ static int coerce_template_template_parms (tree, tree, tsubst_flags_t, tree, tree); static bool template_template_parm_bindings_ok_p (tree, tree); static int template_args_equal (tree, tree); -static void tsubst_default_arguments (tree); +static void tsubst_default_arguments (tree, tsubst_flags_t); static tree for_each_template_parm_r (tree *, int *, void *); static tree copy_default_args_to_explicit_spec_1 (tree, tree); static void copy_default_args_to_explicit_spec (tree); @@ -5612,6 +5613,10 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) else return NULL_TREE; } + + /* Avoid typedef problems. */ + if (TREE_TYPE (expr) != type) + expr = fold_convert (type, expr); } /* [temp.arg.nontype]/5, bullet 2 @@ -9859,7 +9864,7 @@ tsubst_aggr_type (tree t, FN), which has the indicated TYPE. */ tree -tsubst_default_argument (tree fn, tree type, tree arg) +tsubst_default_argument (tree fn, tree type, tree arg, tsubst_flags_t complain) { tree saved_class_ptr = NULL_TREE; tree saved_class_ref = NULL_TREE; @@ -9899,7 +9904,7 @@ tsubst_default_argument (tree fn, tree type, tree arg) stack. */ ++function_depth; arg = tsubst_expr (arg, DECL_TI_ARGS (fn), - tf_warning_or_error, NULL_TREE, + complain, NULL_TREE, /*integral_constant_expression_p=*/false); --function_depth; pop_deferring_access_checks(); @@ -9911,12 +9916,13 @@ tsubst_default_argument (tree fn, tree type, tree arg) cp_function_chain->x_current_class_ref = saved_class_ref; } - if (errorcount+sorrycount > errs) + if (errorcount+sorrycount > errs + && (complain & tf_warning_or_error)) inform (input_location, " when instantiating default argument for call to %D", fn); /* Make sure the default argument is reasonable. */ - arg = check_default_argument (type, arg); + arg = check_default_argument (type, arg, complain); pop_access_scope (fn); @@ -9926,7 +9932,7 @@ tsubst_default_argument (tree fn, tree type, tree arg) /* Substitute into all the default arguments for FN. */ static void -tsubst_default_arguments (tree fn) +tsubst_default_arguments (tree fn, tsubst_flags_t complain) { tree arg; tree tmpl_args; @@ -9947,7 +9953,8 @@ tsubst_default_arguments (tree fn) if (TREE_PURPOSE (arg)) TREE_PURPOSE (arg) = tsubst_default_argument (fn, TREE_VALUE (arg), - TREE_PURPOSE (arg)); + TREE_PURPOSE (arg), + complain); } /* Substitute the ARGS into the T, which is a _DECL. Return the @@ -10298,7 +10305,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) if (!member && !PRIMARY_TEMPLATE_P (gen_tmpl) && !uses_template_parms (argvec)) - tsubst_default_arguments (r); + tsubst_default_arguments (r, complain); } else DECL_TEMPLATE_INFO (r) = NULL_TREE; @@ -12507,6 +12514,9 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl) case TYPE_DECL: return tsubst (t, args, complain, in_decl); + case USING_DECL: + t = DECL_NAME (t); + /* Fall through. */ case IDENTIFIER_NODE: if (IDENTIFIER_TYPENAME_P (t)) { @@ -14974,7 +14984,6 @@ fn_type_unification (tree fn, return error_mark_node; tinst = build_tree_list (fn, NULL_TREE); ++deduction_depth; - push_deferring_access_checks (dk_deferred); gcc_assert (TREE_CODE (fn) == TEMPLATE_DECL); @@ -15066,8 +15075,13 @@ fn_type_unification (tree fn, } processing_template_decl += incomplete; input_location = DECL_SOURCE_LOCATION (fn); + /* Ignore any access checks; we'll see them again in + instantiate_template and they might have the wrong + access path at this point. */ + push_deferring_access_checks (dk_deferred); fntype = tsubst (TREE_TYPE (fn), explicit_targs, complain | tf_partial, NULL_TREE); + pop_deferring_access_checks (); input_location = loc; processing_template_decl -= incomplete; pop_tinst_level (); @@ -15075,12 +15089,6 @@ fn_type_unification (tree fn, if (fntype == error_mark_node) goto fail; - /* Throw away these access checks; we'll see them again in - instantiate_template and they might have the wrong - access path at this point. */ - pop_deferring_access_checks (); - push_deferring_access_checks (dk_deferred); - /* Place the explicitly specified arguments in TARGS. */ for (i = NUM_TMPL_ARGS (explicit_targs); i--;) TREE_VEC_ELT (targs, i) = TREE_VEC_ELT (explicit_targs, i); @@ -15106,9 +15114,15 @@ fn_type_unification (tree fn, callers must be ready to deal with unification failures in any event. */ + /* type_unification_real will pass back any access checks from default + template argument substitution. */ + vec<deferred_access_check, va_gc> *checks; + checks = NULL; + ok = !type_unification_real (DECL_INNERMOST_TEMPLATE_PARMS (fn), targs, parms, args, nargs, /*subr=*/0, - strict, flags, explain_p); + strict, flags, &checks, explain_p); + if (!ok) goto fail; @@ -15155,16 +15169,23 @@ fn_type_unification (tree fn, excessive_deduction_depth = true; goto fail; } + + /* Also collect access checks from the instantiation. */ + reopen_deferring_access_checks (checks); + decl = instantiate_template (fn, targs, complain); + + checks = get_deferred_access_checks (); + pop_deferring_access_checks (); + pop_tinst_level (); if (decl == error_mark_node) goto fail; - /* Now perform any access checks encountered during deduction, such as - for default template arguments. */ + /* Now perform any access checks encountered during substitution. */ push_access_scope (decl); - ok = perform_deferred_access_checks (complain); + ok = perform_access_checks (checks, complain); pop_access_scope (decl); if (!ok) goto fail; @@ -15193,7 +15214,6 @@ fn_type_unification (tree fn, r = decl; fail: - pop_deferring_access_checks (); --deduction_depth; if (excessive_deduction_depth) { @@ -15454,7 +15474,10 @@ unify_one_argument (tree tparms, tree targs, tree parm, tree arg, If SUBR is 1, we're being called recursively (to unify the arguments of a function or method parameter of a function - template). */ + template). + + CHECKS is a pointer to a vector of access checks encountered while + substituting default template arguments. */ static int type_unification_real (tree tparms, @@ -15465,6 +15488,7 @@ type_unification_real (tree tparms, int subr, unification_kind_t strict, int flags, + vec<deferred_access_check, va_gc> **checks, bool explain_p) { tree parm, arg; @@ -15604,6 +15628,7 @@ type_unification_real (tree tparms, { tree parm = TREE_VALUE (TREE_VEC_ELT (tparms, i)); tree arg = TREE_PURPOSE (TREE_VEC_ELT (tparms, i)); + reopen_deferring_access_checks (*checks); location_t save_loc = input_location; if (DECL_P (parm)) input_location = DECL_SOURCE_LOCATION (parm); @@ -15611,6 +15636,8 @@ type_unification_real (tree tparms, arg = convert_template_argument (parm, arg, targs, complain, i, NULL_TREE); input_location = save_loc; + *checks = get_deferred_access_checks (); + pop_deferring_access_checks (); if (arg == error_mark_node) return 1; else @@ -17078,7 +17105,7 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, return type_unification_real (tparms, targs, TYPE_ARG_TYPES (parm), args, nargs, 1, DEDUCE_EXACT, - LOOKUP_NORMAL, explain_p); + LOOKUP_NORMAL, NULL, explain_p); } case OFFSET_TYPE: @@ -19888,6 +19915,29 @@ type_dependent_expression_p (tree expression) && VAR_HAD_UNKNOWN_BOUND (expression)) return true; + /* An array of unknown bound depending on a variadic parameter, eg: + + template<typename... Args> + void foo (Args... args) + { + int arr[] = { args... }; + } + + template<int... vals> + void bar () + { + int arr[] = { vals... }; + } + + If the array has no length and has an initializer, it must be that + we couldn't determine its length in cp_complete_array_type because + it is dependent. */ + if (TREE_CODE (expression) == VAR_DECL + && TREE_CODE (TREE_TYPE (expression)) == ARRAY_TYPE + && !TYPE_DOMAIN (TREE_TYPE (expression)) + && DECL_INITIAL (expression)) + return true; + if (TREE_TYPE (expression) == unknown_type_node) { if (TREE_CODE (expression) == ADDR_EXPR) @@ -20077,7 +20127,7 @@ bool any_type_dependent_elements_p (const_tree list) { for (; list; list = TREE_CHAIN (list)) - if (value_dependent_expression_p (TREE_VALUE (list))) + if (type_dependent_expression_p (TREE_VALUE (list))) return true; return false; @@ -20626,7 +20676,7 @@ do_auto_deduction (tree type, tree init, tree auto_node) = build_tree_list (NULL_TREE, TYPE_NAME (auto_node)); val = type_unification_real (tparms, targs, parms, args, 1, 0, DEDUCE_CALL, LOOKUP_NORMAL, - /*explain_p=*/false); + NULL, /*explain_p=*/false); if (val > 0) { if (processing_template_decl) diff --git a/gcc-4.8/gcc/cp/semantics.c b/gcc-4.8/gcc/cp/semantics.c index 8a7fe3807..580c609ac 100644 --- a/gcc-4.8/gcc/cp/semantics.c +++ b/gcc-4.8/gcc/cp/semantics.c @@ -155,6 +155,17 @@ push_deferring_access_checks (deferring_kind deferring) } } +/* Save the current deferred access states and start deferred access + checking, continuing the set of deferred checks in CHECKS. */ + +void +reopen_deferring_access_checks (vec<deferred_access_check, va_gc> * checks) +{ + push_deferring_access_checks (dk_deferred); + if (!deferred_access_no_check) + deferred_access_stack->last().deferred_access_checks = checks; +} + /* Resume deferring access checks again after we stopped doing this previously. */ @@ -5945,7 +5956,7 @@ build_data_member_initialization (tree t, vec<constructor_elt, va_gc> **vec) || TREE_CODE (t) == MODIFY_EXPR) { member = TREE_OPERAND (t, 0); - init = unshare_expr (TREE_OPERAND (t, 1)); + init = break_out_target_exprs (TREE_OPERAND (t, 1)); } else if (TREE_CODE (t) == CALL_EXPR) { @@ -5953,7 +5964,7 @@ build_data_member_initialization (tree t, vec<constructor_elt, va_gc> **vec) /* We don't use build_cplus_new here because it complains about abstract bases. Leaving the call unwrapped means that it has the wrong type, but cxx_eval_constant_expression doesn't care. */ - init = unshare_expr (t); + init = break_out_target_exprs (t); } else if (TREE_CODE (t) == DECL_EXPR) /* Declaring a temporary, don't add it to the CONSTRUCTOR. */ @@ -6190,7 +6201,7 @@ constexpr_fn_retval (tree body) } case RETURN_EXPR: - return unshare_expr (TREE_OPERAND (body, 0)); + return break_out_target_exprs (TREE_OPERAND (body, 0)); case DECL_EXPR: if (TREE_CODE (DECL_EXPR_DECL (body)) == USING_DECL) @@ -7635,11 +7646,6 @@ cxx_eval_indirect_ref (const constexpr_call *call, tree t, { tree sub = op0; STRIP_NOPS (sub); - if (TREE_CODE (sub) == POINTER_PLUS_EXPR) - { - sub = TREE_OPERAND (sub, 0); - STRIP_NOPS (sub); - } if (TREE_CODE (sub) == ADDR_EXPR) { /* We couldn't fold to a constant value. Make sure it's not @@ -7990,6 +7996,7 @@ cxx_eval_constant_expression (const constexpr_call *call, tree t, case UNGT_EXPR: case UNGE_EXPR: case UNEQ_EXPR: + case LTGT_EXPR: case RANGE_EXPR: case COMPLEX_EXPR: r = cxx_eval_binary_expression (call, t, allow_non_constant, addr, @@ -8846,6 +8853,12 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags) } return false; + case OMP_ATOMIC: + case OMP_ATOMIC_READ: + case OMP_ATOMIC_CAPTURE_OLD: + case OMP_ATOMIC_CAPTURE_NEW: + return false; + default: if (objc_is_property_ref (t)) return false; @@ -8994,6 +9007,8 @@ begin_lambda_type (tree lambda) name, /*scope=*/ts_lambda, /*template_header_p=*/false); + if (type == error_mark_node) + return error_mark_node; } /* Designate it as a struct so that we can use aggregate initialization. */ @@ -9008,8 +9023,6 @@ begin_lambda_type (tree lambda) /* Start the class. */ type = begin_class_definition (type); - if (type == error_mark_node) - return error_mark_node; return type; } @@ -9065,7 +9078,8 @@ lambda_capture_field_type (tree expr) { tree type; if (type_dependent_expression_p (expr) - && !(TREE_TYPE (expr) && TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE)) + && !(TREE_TYPE (expr) && TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE + && !type_uses_auto (TREE_TYPE (expr)))) { type = cxx_make_type (DECLTYPE_TYPE); DECLTYPE_TYPE_EXPR (type) = expr; diff --git a/gcc-4.8/gcc/cp/tree.c b/gcc-4.8/gcc/cp/tree.c index a75663406..c7502d620 100644 --- a/gcc-4.8/gcc/cp/tree.c +++ b/gcc-4.8/gcc/cp/tree.c @@ -1220,6 +1220,8 @@ strip_typedefs (tree t) result = build_method_type_directly (class_type, type, TREE_CHAIN (arg_types)); + result + = build_ref_qualified_type (result, type_memfn_rqual (t)); } else { diff --git a/gcc-4.8/gcc/cp/typeck.c b/gcc-4.8/gcc/cp/typeck.c index 21b5d414b..1a64b6890 100644 --- a/gcc-4.8/gcc/cp/typeck.c +++ b/gcc-4.8/gcc/cp/typeck.c @@ -8307,7 +8307,8 @@ check_return_expr (tree retval, bool *no_warning) && TREE_CODE (retval) == VAR_DECL && DECL_CONTEXT (retval) == current_function_decl && ! TREE_STATIC (retval) - && ! DECL_ANON_UNION_VAR_P (retval) + /* And not a lambda or anonymous union proxy. */ + && !DECL_HAS_VALUE_EXPR_P (retval) && (DECL_ALIGN (retval) >= DECL_ALIGN (result)) /* The cv-unqualified type of the returned value must be the same as the cv-unqualified return type of the @@ -8352,7 +8353,8 @@ check_return_expr (tree retval, bool *no_warning) Note that these conditions are similar to, but not as strict as, the conditions for the named return value optimization. */ if ((cxx_dialect != cxx98) - && (TREE_CODE (retval) == VAR_DECL + && ((TREE_CODE (retval) == VAR_DECL + && !DECL_HAS_VALUE_EXPR_P (retval)) || TREE_CODE (retval) == PARM_DECL) && DECL_CONTEXT (retval) == current_function_decl && !TREE_STATIC (retval) diff --git a/gcc-4.8/gcc/cp/typeck2.c b/gcc-4.8/gcc/cp/typeck2.c index 9b7db6218..9c9f0751f 100644 --- a/gcc-4.8/gcc/cp/typeck2.c +++ b/gcc-4.8/gcc/cp/typeck2.c @@ -262,7 +262,7 @@ abstract_virtuals_error_sfinae (tree decl, tree type, tsubst_flags_t complain) so that we can check again once it is completed. This makes sense only for objects for which we have a declaration or at least a name. */ - if (!COMPLETE_TYPE_P (type)) + if (!COMPLETE_TYPE_P (type) && (complain & tf_error)) { void **slot; struct pending_abstract_type *pat; |