diff options
Diffstat (limited to 'gcc-4.8/gcc/cp')
-rw-r--r-- | gcc-4.8/gcc/cp/ChangeLog | 262 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/call.c | 44 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/cvt.c | 7 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/decl.c | 21 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/decl2.c | 32 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/except.c | 3 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/mangle.c | 4 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/name-lookup.c | 24 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/parser.c | 31 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/pt.c | 88 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/semantics.c | 35 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/typeck.c | 21 | ||||
-rw-r--r-- | gcc-4.8/gcc/cp/typeck2.c | 13 |
13 files changed, 495 insertions, 90 deletions
diff --git a/gcc-4.8/gcc/cp/ChangeLog b/gcc-4.8/gcc/cp/ChangeLog index 2ee24e21e..c4d2dee85 100644 --- a/gcc-4.8/gcc/cp/ChangeLog +++ b/gcc-4.8/gcc/cp/ChangeLog @@ -1,3 +1,197 @@ +2014-05-22 Release Manager + + * GCC 4.8.3 released. + +2014-05-13 Jason Merrill <jason@redhat.com> + + PR c++/60708 + * call.c (build_array_conv): Call complete_type. + + PR c++/60713 + * typeck2.c (PICFLAG_SIDE_EFFECTS): New. + (picflag_from_initializer): Return it. + (process_init_constructor): Handle it. + + PR c++/60628 + * decl.c (create_array_type_for_decl): Complain about array of auto. + + PR c++/60367 + * call.c (convert_default_arg): Remove special handling for + CONSTRUCTOR. + +2014-04-28 Daniel Gutson <daniel.gutson@tallertechnologies.com> + + * typeck.c (build_reinterpret_cast_1): Pass proper argument to + warn() in pedantic. + +2014-02-28 Jason Merrill <jason@redhat.com> + + PR c++/58845 + * typeck.c (cp_build_binary_op): Sorry on vector&&vector. + +2014-02-26 Jason Merrill <jason@redhat.com> + + PR c++/60182 + * pt.c (unify): Ignore alias templates when deducing a template + template parameter. + +2014-02-24 Jason Merrill <jason@redhat.com> + + PR c++/60146 + * pt.c (tsubst_omp_for_iterator): Don't let substitution of the + DECL_EXPR initialize a non-class iterator. + +2014-02-24 Fabien ChĂȘne <fabien@gcc.gnu.org> + PR c++/37140 + * parser.c (cp_parser_nonclass_name): Call strip_using_decl and + move the code handling dependent USING_DECLs... + * name-lookup.c (strip_using_decl): ...Here. + +2014-02-21 Jason Merrill <jason@redhat.com> + + PR c++/60108 + * semantics.c (expand_or_defer_fn_1): Check DECL_DEFAULTED_FN. + + PR c++/60187 + * parser.c (cp_parser_enum_specifier): Call + check_for_bare_parameter_packs. + + PR c++/60216 + * pt.c (register_specialization): Copy DECL_DELETED_FN to clones. + + PR c++/60219 + * pt.c (coerce_template_parms): Bail if argument packing fails. + + PR c++/60248 + * mangle.c (mangle_decl): Don't make an alias for a TYPE_DECL. + +2014-02-20 Jason Merrill <jason@redhat.com> + + PR c++/60274 + Revert: + PR c++/58606 + * pt.c (template_parm_to_arg): Call convert_from_reference. + (tsubst_template_arg): Don't strip reference refs. + +2014-02-20 Kai Tietz <ktietz@redhat.com> + + PR c++/58873 + * parser.c (cp_parser_functional_cast): Treat NULL_TREE + valued type argument as error_mark_node. + + PR c++/58835 + * semantics.c (finish_fname): Handle error_mark_node. + +2014-02-19 Jason Merrill <jason@redhat.com> + + PR c++/60046 + * pt.c (maybe_instantiate_noexcept): Don't instantiate exception + spec from template context. + +2014-01-31 Jason Merrill <jason@redhat.com> + + PR c++/58672 + * decl2.c (handle_tls_init): Handle null init fn. + + PR c++/55800 + * decl2.c (get_tls_init_fn): Copy DECL_EXTERNAL from the variable. + + PR c++/59646 + * call.c (convert_like_real) [ck_aggr]: Set TARGET_EXPR_LIST_INIT_P. + [ck_list]: Check for error_mark_node. + + PR c++/57043 + * pt.c (fn_type_unification): Don't do DEDUCE_EXACT check + during partial ordering. + +2014-01-30 Jason Merrill <jason@redhat.com> + + PR c++/57899 + * pt.c (instantiate_template_1): Save/restore local_specializations. + +2014-01-29 Jason Merrill <jason@redhat.com> + + PR c++/59989 + * pt.c (expand_template_argument_pack): Correct + non_default_args_count calculation. + + PR c++/58466 + * pt.c (unify_pack_expansion): Call expand_template_argument_pack. + +2014-01-28 Jason Merrill <jason@redhat.com> + + PR c++/58632 + * decl.c (lookup_and_check_tag): Ignore template parameters if + scope == ts_current. + * pt.c (check_template_shadow): Don't complain about the injected + class name. + +2014-01-27 Jason Merrill <jason@redhat.com> + + PR c++/54652 + * decl.c (duplicate_decls): Always use oldtype for TYPE_DECL. + + PR c++/58504 + * pt.c (tsubst_copy_and_build) [TRAIT_EXPR]: Use tsubst for + types. + + PR c++/58606 + * pt.c (template_parm_to_arg): Call convert_from_reference. + (tsubst_template_arg): Don't strip reference refs. + + PR c++/58639 + * call.c (build_aggr_conv): Reject value-initialization of reference. + + PR c++/58812 + * call.c (convert_like_real): Give helpful error about excess braces + for reference binding, too. + + PR c++/58814 + * typeck.c (cp_build_modify_expr): Make the RHS an rvalue before + stabilizing. + + PR c++/58837 + * typeck.c (cp_truthvalue_conversion): Use explicit comparison for + FUNCTION_DECL. + + PR c++/59097 + * decl.c (compute_array_index_type): Don't call + maybe_constant_value for a non-integral expression. + + PR c++/58965 + * mangle.c (write_guarded_var_name): Handle null DECL_NAME. + +2014-01-24 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/57524 + * name-lookup.c (push_using_directive): Use timevar_cond_start. + +2014-01-23 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/58809 + * semantics.c (finish_omp_clauses): Reject MIN_EXPR, MAX_EXPR, + BIT_AND_EXPR, BIT_IOR_EXPR and BIT_XOR_EXPR on COMPLEX_TYPEs. + +2014-01-20 Marek Polacek <polacek@redhat.com> + + Backported from mainline + 2014-01-17 Marek Polacek <polacek@redhat.com> + + PR c++/59838 + * cvt.c (ocp_convert): Don't segfault on non-existing + ENUM_UNDERLYING_TYPE. + +2014-01-10 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/56060 + PR c++/59730 + * pt.c (type_dependent_expression_p): Handle EXPR_PACK_EXPANSION. + +2013-12-12 Jason Merrill <jason@redhat.com> + + PR c++/58954 + * pt.c (resolve_overloaded_unification): Discard access checks. + 2013-12-05 Jason Merrill <jason@redhat.com> PR c++/59044 @@ -5,6 +199,74 @@ * pt.c (most_specialized_class): Use the partially instantiated template for deduction. Drop the TMPL parameter. +2013-12-04 Jakub Jelinek <jakub@redhat.com> + + PR c++/59268 + * pt.c (tsubst_copy_and_build): Handle POINTER_PLUS_EXPR. + +2013-11-27 Tom de Vries <tom@codesourcery.com> + Marc Glisse <marc.glisse@inria.fr> + + PR c++/59032 + * typeck.c (cp_build_unary_op): Allow vector increment and decrement. + +2013-11-27 Tom de Vries <tom@codesourcery.com> + Marc Glisse <marc.glisse@inria.fr> + + PR middle-end/59037 + * semantics.c (cxx_fold_indirect_ref): Don't create out-of-bounds + BIT_FIELD_REF. + +2013-11-28 Jakub Jelinek <jakub@redhat.com> + + PR c++/59297 + * semantics.c (finish_omp_atomic): Call finish_expr_stmt + rather than add_stmt. + +2013-11-23 Easwaran Raman <eraman@google.com> + + PR c++/59031 + * call.c (build_new_method_call_1): Comnpare function context + with BASELINK_BINFO type rather than instance type before + marking the call with LOOKUP_NONVIRTUAL. + +2013-10-31 Jason Merrill <jason@redhat.com> + + PR c++/58162 + * parser.c (cp_parser_late_parse_one_default_arg): Set + TARGET_EXPR_DIRECT_INIT_P. + +2013-11-11 Paolo Carlini <paolo.carlini@oracle.com> + + * cvt.c (cp_convert_to_pointer): Call build_ptrmemfunc before + maybe_warn_zero_as_null_pointer_constant to avoid duplicate + -Wzero-as-null-pointer-constant diagnostics. + + * typeck.c (build_ptrmemfunc): Use cp_build_c_cast. + +2013-10-25 Tom de Vries <tom@codesourcery.com> + + PR c++/58282 + * except.c (build_must_not_throw_expr): Handle + flag_exceptions. + +2013-10-17 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/58596 + * semantics.c (lambda_expr_this_capture): Handle NSDMIs in the + cp_unevaluated_operand case. + +2013-10-16 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/58633 + * parser.c (cp_parser_pseudo_destructor_name): Revert r174385 changes. + +2013-10-16 Jason Merrill <jason@redhat.com> + + PR c++/57850 + * decl2.c (dump_tu): Split out from... + (cp_write_global_declarations): ...here. Call it in PCH mode. + 2013-10-16 Release Manager * GCC 4.8.2 released. diff --git a/gcc-4.8/gcc/cp/call.c b/gcc-4.8/gcc/cp/call.c index a5be421fe..7c46cb5f4 100644 --- a/gcc-4.8/gcc/cp/call.c +++ b/gcc-4.8/gcc/cp/call.c @@ -892,6 +892,9 @@ build_aggr_conv (tree type, tree ctor, int flags, tsubst_flags_t complain) if (i < CONSTRUCTOR_NELTS (ctor)) val = CONSTRUCTOR_ELT (ctor, i)->value; + else if (TREE_CODE (ftype) == REFERENCE_TYPE) + /* Value-initialization of reference is ill-formed. */ + return NULL; else { if (empty_ctor == NULL_TREE) @@ -940,6 +943,9 @@ build_array_conv (tree type, tree ctor, int flags, tsubst_flags_t complain) bool user = false; enum conversion_rank rank = cr_exact; + /* We might need to propagate the size from the element to the array. */ + complete_type (type); + if (TYPE_DOMAIN (type)) { unsigned HOST_WIDE_INT alen = tree_low_cst (array_type_nelts_top (type), 1); @@ -5806,9 +5812,11 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, && convs->kind != ck_ambig && (convs->kind != ck_ref_bind || convs->user_conv_p) - && convs->kind != ck_rvalue + && (convs->kind != ck_rvalue + || SCALAR_TYPE_P (totype)) && convs->kind != ck_base) { + bool complained = false; conversion *t = convs; /* Give a helpful error if this is bad because of excess braces. */ @@ -5816,7 +5824,14 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, && SCALAR_TYPE_P (totype) && CONSTRUCTOR_NELTS (expr) > 0 && BRACE_ENCLOSED_INITIALIZER_P (CONSTRUCTOR_ELT (expr, 0)->value)) - permerror (loc, "too many braces around initializer for %qT", totype); + { + complained = true; + permerror (loc, "too many braces around initializer " + "for %qT", totype); + while (BRACE_ENCLOSED_INITIALIZER_P (expr) + && CONSTRUCTOR_NELTS (expr) == 1) + expr = CONSTRUCTOR_ELT (expr, 0)->value; + } for (; t ; t = next_conversion (t)) { @@ -5853,6 +5868,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, break; } + if (!complained) permerror (loc, "invalid conversion from %qT to %qT", TREE_TYPE (expr), totype); if (fn) @@ -5999,6 +6015,8 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, to avoid the error about taking the address of a temporary. */ array = cp_build_addr_expr (array, complain); array = cp_convert (build_pointer_type (elttype), array, complain); + if (array == error_mark_node) + return error_mark_node; /* Build up the initializer_list object. */ totype = complete_type (totype); @@ -6023,8 +6041,11 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, return fold_if_not_in_template (expr); } expr = reshape_init (totype, expr, complain); - return get_target_expr_sfinae (digest_init (totype, expr, complain), + expr = get_target_expr_sfinae (digest_init (totype, expr, complain), complain); + if (expr != error_mark_node) + TARGET_EXPR_LIST_INIT_P (expr) = true; + return expr; default: break; @@ -6405,20 +6426,10 @@ convert_default_arg (tree type, tree arg, tree fn, int parmnum, /* We must make a copy of ARG, in case subsequent processing alters any part of it. */ arg = break_out_target_exprs (arg); - if (TREE_CODE (arg) == CONSTRUCTOR) - { - arg = digest_init (type, arg, complain); - arg = convert_for_initialization (0, type, arg, LOOKUP_IMPLICIT, - ICR_DEFAULT_ARGUMENT, fn, parmnum, - complain); - } - else - { arg = convert_for_initialization (0, type, arg, LOOKUP_IMPLICIT, ICR_DEFAULT_ARGUMENT, fn, parmnum, complain); arg = convert_for_arg_passing (type, arg, complain); - } pop_deferring_access_checks(); pop_defarg_context (); @@ -7414,7 +7425,7 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args, struct z_candidate *candidates = 0, *cand; tree explicit_targs = NULL_TREE; tree basetype = NULL_TREE; - tree access_binfo; + tree access_binfo, binfo; tree optype; tree first_mem_arg = NULL_TREE; tree instance_ptr; @@ -7454,6 +7465,7 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args, if (!conversion_path) conversion_path = BASELINK_BINFO (fns); access_binfo = BASELINK_ACCESS_BINFO (fns); + binfo = BASELINK_BINFO (fns); optype = BASELINK_OPTYPE (fns); fns = BASELINK_FUNCTIONS (fns); if (TREE_CODE (fns) == TEMPLATE_ID_EXPR) @@ -7697,13 +7709,13 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args, { /* Optimize away vtable lookup if we know that this function can't be overridden. We need to check if - the context and the instance type are the same, + the context and the type where we found fn are the same, actually FN might be defined in a different class type because of a using-declaration. In this case, we do not want to perform a non-virtual call. */ if (DECL_VINDEX (fn) && ! (flags & LOOKUP_NONVIRTUAL) && same_type_ignoring_top_level_qualifiers_p - (DECL_CONTEXT (fn), TREE_TYPE (instance)) + (DECL_CONTEXT (fn), BINFO_TYPE (binfo)) && resolves_to_fixed_type_p (instance, 0)) flags |= LOOKUP_NONVIRTUAL; if (explicit_targs) diff --git a/gcc-4.8/gcc/cp/cvt.c b/gcc-4.8/gcc/cp/cvt.c index 8c03e2086..179650711 100644 --- a/gcc-4.8/gcc/cp/cvt.c +++ b/gcc-4.8/gcc/cp/cvt.c @@ -203,13 +203,13 @@ cp_convert_to_pointer (tree type, tree expr, tsubst_flags_t complain) if (null_ptr_cst_p (expr)) { - if (complain & tf_warning) - maybe_warn_zero_as_null_pointer_constant (expr, loc); - if (TYPE_PTRMEMFUNC_P (type)) return build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), expr, 0, /*c_cast_p=*/false, complain); + if (complain & tf_warning) + maybe_warn_zero_as_null_pointer_constant (expr, loc); + /* A NULL pointer-to-data-member is represented by -1, not by zero. */ tree val = (TYPE_PTRDATAMEM_P (type) @@ -743,6 +743,7 @@ ocp_convert (tree type, tree expr, int convtype, int flags, unspecified. */ if ((complain & tf_warning) && TREE_CODE (e) == INTEGER_CST + && ENUM_UNDERLYING_TYPE (type) && !int_fits_type_p (e, ENUM_UNDERLYING_TYPE (type))) warning_at (loc, OPT_Wconversion, "the result of the conversion is unspecified because " diff --git a/gcc-4.8/gcc/cp/decl.c b/gcc-4.8/gcc/cp/decl.c index 893fbd161..e487f887d 100644 --- a/gcc-4.8/gcc/cp/decl.c +++ b/gcc-4.8/gcc/cp/decl.c @@ -1867,9 +1867,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) /* Merge the data types specified in the two decls. */ newtype = merge_types (TREE_TYPE (newdecl), TREE_TYPE (olddecl)); - /* If merge_types produces a non-typedef type, just use the old type. */ - if (TREE_CODE (newdecl) == TYPE_DECL - && newtype == DECL_ORIGINAL_TYPE (newdecl)) + /* For typedefs use the old type, as the new type's DECL_NAME points + at newdecl, which will be ggc_freed. */ + if (TREE_CODE (newdecl) == TYPE_DECL) newtype = oldtype; if (TREE_CODE (newdecl) == VAR_DECL) @@ -8193,7 +8193,9 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain) abi_1_itype = error_mark_node; } + if (INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (type)) size = maybe_constant_value (size); + if (!TREE_CONSTANT (size)) size = osize; } @@ -8473,6 +8475,14 @@ create_array_type_for_decl (tree name, tree type, tree size) return error_mark_node; } + /* 8.3.4p1: ...if the type of the identifier of D contains the auto + type-specifier, the program is ill-formed. */ + if (type_uses_auto (type)) + { + error ("%qD declared as array of %qT", name, type); + return error_mark_node; + } + /* Figure out the index type for the array. */ if (size) itype = compute_array_index_type (name, size, tf_warning_or_error); @@ -11891,7 +11901,10 @@ lookup_and_check_tag (enum tag_types tag_code, tree name, if (decl && (DECL_CLASS_TEMPLATE_P (decl) - || DECL_TEMPLATE_TEMPLATE_PARM_P (decl))) + /* If scope is ts_current we're defining a class, so ignore a + template template parameter. */ + || (scope != ts_current + && DECL_TEMPLATE_TEMPLATE_PARM_P (decl)))) decl = DECL_TEMPLATE_RESULT (decl); if (decl && TREE_CODE (decl) == TYPE_DECL) diff --git a/gcc-4.8/gcc/cp/decl2.c b/gcc-4.8/gcc/cp/decl2.c index 628be934b..7dd98c07e 100644 --- a/gcc-4.8/gcc/cp/decl2.c +++ b/gcc-4.8/gcc/cp/decl2.c @@ -2884,7 +2884,7 @@ get_tls_init_fn (tree var) TREE_PUBLIC (fn) = TREE_PUBLIC (var); DECL_ARTIFICIAL (fn) = true; DECL_COMDAT (fn) = DECL_COMDAT (var); - DECL_EXTERNAL (fn) = true; + DECL_EXTERNAL (fn) = DECL_EXTERNAL (var); if (DECL_ONE_ONLY (var)) make_decl_one_only (fn, cxx_comdat_group (fn)); if (TREE_PUBLIC (var)) @@ -3946,6 +3946,8 @@ handle_tls_init (void) if (TREE_PUBLIC (var)) { tree single_init_fn = get_tls_init_fn (var); + if (single_init_fn == NULL_TREE) + continue; cgraph_node *alias = cgraph_same_body_alias (cgraph_get_create_node (fn), single_init_fn, fn); @@ -3960,6 +3962,22 @@ handle_tls_init (void) expand_or_defer_fn (finish_function (0)); } +/* The entire file is now complete. If requested, dump everything + to a file. */ + +static void +dump_tu (void) +{ + int flags; + FILE *stream = dump_begin (TDI_tu, &flags); + + if (stream) + { + dump_node (global_namespace, flags & ~TDF_SLIM, stream); + dump_end (TDI_tu, stream); + } +} + /* This routine is called at the end of compilation. Its job is to create all the code needed to initialize and destroy the global aggregates. We do the destruction @@ -3990,6 +4008,7 @@ cp_write_global_declarations (void) if (pch_file) { c_common_write_pch (); + dump_tu (); return; } @@ -4359,16 +4378,7 @@ cp_write_global_declarations (void) /* The entire file is now complete. If requested, dump everything to a file. */ - { - int flags; - FILE *stream = dump_begin (TDI_tu, &flags); - - if (stream) - { - dump_node (global_namespace, flags & ~TDF_SLIM, stream); - dump_end (TDI_tu, stream); - } - } + dump_tu (); if (flag_detailed_statistics) { diff --git a/gcc-4.8/gcc/cp/except.c b/gcc-4.8/gcc/cp/except.c index 216ec103f..604f274fb 100644 --- a/gcc-4.8/gcc/cp/except.c +++ b/gcc-4.8/gcc/cp/except.c @@ -380,6 +380,9 @@ build_must_not_throw_expr (tree body, tree cond) { tree type = body ? TREE_TYPE (body) : void_type_node; + if (!flag_exceptions) + return body; + if (cond && !value_dependent_expression_p (cond)) { cond = cxx_constant_value (cond); diff --git a/gcc-4.8/gcc/cp/mangle.c b/gcc-4.8/gcc/cp/mangle.c index dd5ed8d0d..26d360396 100644 --- a/gcc-4.8/gcc/cp/mangle.c +++ b/gcc-4.8/gcc/cp/mangle.c @@ -3480,6 +3480,7 @@ mangle_decl (const tree decl) if (G.need_abi_warning /* Don't do this for a fake symbol we aren't going to emit anyway. */ + && TREE_CODE (decl) != TYPE_DECL && !DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (decl) && !DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (decl)) { @@ -3775,7 +3776,8 @@ mangle_conv_op_name_for_type (const tree type) static void write_guarded_var_name (const tree variable) { - if (strncmp (IDENTIFIER_POINTER (DECL_NAME (variable)), "_ZGR", 4) == 0) + if (DECL_NAME (variable) + && strncmp (IDENTIFIER_POINTER (DECL_NAME (variable)), "_ZGR", 4) == 0) /* The name of a guard variable for a reference temporary should refer to the reference, not the temporary. */ write_string (IDENTIFIER_POINTER (DECL_NAME (variable)) + 4); diff --git a/gcc-4.8/gcc/cp/name-lookup.c b/gcc-4.8/gcc/cp/name-lookup.c index c121a4163..da167ec41 100644 --- a/gcc-4.8/gcc/cp/name-lookup.c +++ b/gcc-4.8/gcc/cp/name-lookup.c @@ -394,7 +394,8 @@ pop_binding (tree id, tree decl) } } -/* Strip non dependent using declarations. */ +/* Strip non dependent using declarations. If DECL is dependent, + surreptitiously create a typename_type and return it. */ tree strip_using_decl (tree decl) @@ -404,6 +405,23 @@ strip_using_decl (tree decl) while (TREE_CODE (decl) == USING_DECL && !DECL_DEPENDENT_P (decl)) decl = USING_DECL_DECLS (decl); + + if (TREE_CODE (decl) == USING_DECL && DECL_DEPENDENT_P (decl) + && USING_DECL_TYPENAME_P (decl)) + { + /* We have found a type introduced by a using + declaration at class scope that refers to a dependent + type. + + using typename :: [opt] nested-name-specifier unqualified-id ; + */ + decl = make_typename_type (TREE_TYPE (decl), + DECL_NAME (decl), + typename_type, tf_error); + if (decl != error_mark_node) + decl = TYPE_NAME (decl); + } + return decl; } @@ -5605,9 +5623,9 @@ static tree push_using_directive (tree used) { tree ret; - timevar_start (TV_NAME_LOOKUP); + bool subtime = timevar_cond_start (TV_NAME_LOOKUP); ret = push_using_directive_1 (used); - timevar_stop (TV_NAME_LOOKUP); + timevar_cond_stop (TV_NAME_LOOKUP, subtime); return ret; } diff --git a/gcc-4.8/gcc/cp/parser.c b/gcc-4.8/gcc/cp/parser.c index b6322788f..3c1dec529 100644 --- a/gcc-4.8/gcc/cp/parser.c +++ b/gcc-4.8/gcc/cp/parser.c @@ -6421,10 +6421,6 @@ cp_parser_pseudo_destructor_name (cp_parser* parser, /* Look for the `~'. */ cp_parser_require (parser, CPP_COMPL, RT_COMPL); - /* Once we see the ~, this has to be a pseudo-destructor. */ - if (!processing_template_decl && !cp_parser_error_occurred (parser)) - cp_parser_commit_to_tentative_parse (parser); - /* Look for the type-name again. We are not responsible for checking that it matches the first type-name. */ *type = cp_parser_nonclass_name (parser); @@ -14168,25 +14164,7 @@ cp_parser_nonclass_name (cp_parser* parser) /* Look up the type-name. */ type_decl = cp_parser_lookup_name_simple (parser, identifier, token->location); - if (TREE_CODE (type_decl) == USING_DECL) - { - if (!DECL_DEPENDENT_P (type_decl)) type_decl = strip_using_decl (type_decl); - else if (USING_DECL_TYPENAME_P (type_decl)) - { - /* We have found a type introduced by a using - declaration at class scope that refers to a dependent - type. - - using typename :: [opt] nested-name-specifier unqualified-id ; - */ - type_decl = make_typename_type (TREE_TYPE (type_decl), - DECL_NAME (type_decl), - typename_type, tf_error); - if (type_decl != error_mark_node) - type_decl = TYPE_NAME (type_decl); - } - } if (TREE_CODE (type_decl) != TYPE_DECL && (objc_is_id (identifier) || objc_is_class_name (identifier))) @@ -14742,7 +14720,8 @@ cp_parser_enum_specifier (cp_parser* parser) { underlying_type = grokdeclarator (NULL, &type_specifiers, TYPENAME, /*initialized=*/0, NULL); - if (underlying_type == error_mark_node) + if (underlying_type == error_mark_node + || check_for_bare_parameter_packs (underlying_type)) underlying_type = NULL_TREE; } } @@ -22209,6 +22188,9 @@ cp_parser_functional_cast (cp_parser* parser, tree type) tree cast; bool nonconst_p; + if (!type) + type = error_mark_node; + if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)) { maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS); @@ -22576,6 +22558,9 @@ cp_parser_late_parse_one_default_arg (cp_parser *parser, tree decl, && CONSTRUCTOR_IS_DIRECT_INIT (parsed_arg)) flags = LOOKUP_NORMAL; parsed_arg = digest_init_flags (TREE_TYPE (decl), parsed_arg, flags); + if (TREE_CODE (parsed_arg) == TARGET_EXPR) + /* This represents the whole initialization. */ + TARGET_EXPR_DIRECT_INIT_P (parsed_arg) = true; } } diff --git a/gcc-4.8/gcc/cp/pt.c b/gcc-4.8/gcc/cp/pt.c index 5885021a4..c44e3d0b2 100644 --- a/gcc-4.8/gcc/cp/pt.c +++ b/gcc-4.8/gcc/cp/pt.c @@ -1419,6 +1419,8 @@ register_specialization (tree spec, tree tmpl, tree args, bool is_friend, = DECL_DECLARED_INLINE_P (fn); DECL_SOURCE_LOCATION (clone) = DECL_SOURCE_LOCATION (fn); + DECL_DELETED_FN (clone) + = DECL_DELETED_FN (fn); } check_specialization_namespace (tmpl); @@ -3436,7 +3438,7 @@ expand_template_argument_pack (tree args) for (i = 0; i < num_packed; ++i, ++out_arg) TREE_VEC_ELT (result_args, out_arg) = TREE_VEC_ELT(packed, i); if (non_default_args_count > 0) - non_default_args_count += num_packed; + non_default_args_count += num_packed - 1; } else { @@ -3491,6 +3493,11 @@ check_template_shadow (tree decl) || TEMPLATE_PARMS_FOR_INLINE (current_template_parms)) return true; + /* Don't complain about the injected class name, as we've already + complained about the class itself. */ + if (DECL_SELF_REFERENCE_P (decl)) + return false; + error ("declaration of %q+#D", decl); error (" shadows template parm %q+#D", olddecl); return false; @@ -6672,6 +6679,8 @@ coerce_template_parms (tree parms, /* Store this argument. */ if (arg == error_mark_node) lost++; + if (lost) + break; TREE_VEC_ELT (new_inner_args, parm_idx) = arg; /* We are done with all of the arguments. */ @@ -12694,27 +12703,43 @@ tsubst_omp_for_iterator (tree t, int i, tree declv, tree initv, tsubst_expr ((NODE), args, complain, in_decl, \ integral_constant_expression_p) tree decl, init, cond, incr; - bool init_decl; init = TREE_VEC_ELT (OMP_FOR_INIT (t), i); gcc_assert (TREE_CODE (init) == MODIFY_EXPR); decl = TREE_OPERAND (init, 0); init = TREE_OPERAND (init, 1); - /* Do this before substituting into decl to handle 'auto'. */ - init_decl = (init && TREE_CODE (init) == DECL_EXPR); - init = RECUR (init); - decl = RECUR (decl); - if (init_decl) + tree decl_expr = NULL_TREE; + if (init && TREE_CODE (init) == DECL_EXPR) { - gcc_assert (!processing_template_decl); - init = DECL_INITIAL (decl); - DECL_INITIAL (decl) = NULL_TREE; + /* We need to jump through some hoops to handle declarations in the + for-init-statement, since we might need to handle auto deduction, + but we need to keep control of initialization. */ + decl_expr = init; + init = DECL_INITIAL (DECL_EXPR_DECL (init)); + decl = tsubst_decl (decl, args, complain); } + else + decl = RECUR (decl); + init = RECUR (init); + + tree auto_node = type_uses_auto (TREE_TYPE (decl)); + if (auto_node && init) + TREE_TYPE (decl) + = do_auto_deduction (TREE_TYPE (decl), init, auto_node); gcc_assert (!type_dependent_expression_p (decl)); if (!CLASS_TYPE_P (TREE_TYPE (decl))) { + if (decl_expr) + { + /* Declare the variable, but don't let that initialize it. */ + tree init_sav = DECL_INITIAL (DECL_EXPR_DECL (decl_expr)); + DECL_INITIAL (DECL_EXPR_DECL (decl_expr)) = NULL_TREE; + RECUR (decl_expr); + DECL_INITIAL (DECL_EXPR_DECL (decl_expr)) = init_sav; + } + cond = RECUR (TREE_VEC_ELT (OMP_FOR_COND (t), i)); incr = TREE_VEC_ELT (OMP_FOR_INCR (t), i); if (TREE_CODE (incr) == MODIFY_EXPR) @@ -12731,7 +12756,13 @@ tsubst_omp_for_iterator (tree t, int i, tree declv, tree initv, return; } - if (init && !init_decl) + if (decl_expr) + { + /* Declare and initialize the variable. */ + RECUR (decl_expr); + init = NULL_TREE; + } + else if (init) { tree c; for (c = *clauses; c ; c = OMP_CLAUSE_CHAIN (c)) @@ -13710,6 +13741,10 @@ tsubst_copy_and_build (tree t, RETURN (r); } + case POINTER_PLUS_EXPR: + return fold_build_pointer_plus (RECUR (TREE_OPERAND (t, 0)), + RECUR (TREE_OPERAND (t, 1))); + case SCOPE_REF: RETURN (tsubst_qualified_id (t, args, complain, in_decl, /*done=*/true, /*address_p=*/false)); @@ -14471,12 +14506,12 @@ tsubst_copy_and_build (tree t, case TRAIT_EXPR: { - tree type1 = tsubst_copy (TRAIT_EXPR_TYPE1 (t), args, + tree type1 = tsubst (TRAIT_EXPR_TYPE1 (t), args, complain, in_decl); tree type2 = TRAIT_EXPR_TYPE2 (t); if (type2) - type2 = tsubst_copy (type2, args, complain, in_decl); + type2 = tsubst (type2, args, complain, in_decl); RETURN (finish_trait_expr (TRAIT_EXPR_KIND (t), type1, type2)); } @@ -14778,6 +14813,8 @@ instantiate_template_1 (tree tmpl, tree orig_args, tsubst_flags_t complain) /* Instantiation of the function happens in the context of the function template, not the context of the overload resolution we're doing. */ push_to_top_level (); + struct pointer_map_t *saved_local_specializations = local_specializations; + local_specializations = NULL; /* If there are dependent arguments, e.g. because we're doing partial ordering, make sure processing_template_decl stays set. */ if (uses_template_parms (targ_ptr)) @@ -14793,6 +14830,7 @@ instantiate_template_1 (tree tmpl, tree orig_args, tsubst_flags_t complain) targ_ptr, complain, gen_tmpl); if (DECL_CLASS_SCOPE_P (gen_tmpl)) pop_nested_class (); + local_specializations = saved_local_specializations; pop_from_top_level (); if (fndecl == error_mark_node) @@ -15192,8 +15230,11 @@ fn_type_unification (tree fn, /* If we're looking for an exact match, check that what we got is indeed an exact match. It might not be if some template - parameters are used in non-deduced contexts. */ - if (strict == DEDUCE_EXACT) + parameters are used in non-deduced contexts. But don't check + for an exact match if we have dependent template arguments; + in that case we're doing partial ordering, and we already know + that we have two candidates that will provide the actual type. */ + if (strict == DEDUCE_EXACT && !any_dependent_template_arguments_p (targs)) { tree substed = TREE_TYPE (decl); unsigned int i; @@ -15749,7 +15790,7 @@ resolve_overloaded_unification (tree tparms, if (subargs != error_mark_node && !any_dependent_template_arguments_p (subargs)) { - elem = tsubst (TREE_TYPE (fn), subargs, tf_none, NULL_TREE); + elem = TREE_TYPE (instantiate_template (fn, subargs, tf_none)); if (try_one_overload (tparms, targs, tempargs, parm, elem, strict, sub_strict, addr_p, explain_p) && (!goodfn || !same_type_p (goodfn, elem))) @@ -16207,6 +16248,9 @@ unify_pack_expansion (tree tparms, tree targs, tree packed_parms, tree pattern = PACK_EXPANSION_PATTERN (parm); tree pack, packs = NULL_TREE; int i, start = TREE_VEC_LENGTH (packed_parms) - 1; + + packed_args = expand_template_argument_pack (packed_args); + int len = TREE_VEC_LENGTH (packed_args); /* Determine the parameter packs we will be deducing from the @@ -16574,9 +16618,11 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, if (TREE_CODE (arg) != BOUND_TEMPLATE_TEMPLATE_PARM && !CLASSTYPE_SPECIALIZATION_OF_PRIMARY_TEMPLATE_P (arg)) return unify_template_deduction_failure (explain_p, parm, arg); - { tree parmvec = TYPE_TI_ARGS (parm); + /* An alias template name is never deduced. */ + if (TYPE_ALIAS_P (arg)) + arg = strip_typedefs (arg); tree argvec = INNERMOST_TEMPLATE_ARGS (TYPE_TI_ARGS (arg)); tree full_argvec = add_to_template_args (targs, argvec); tree parm_parms @@ -18552,6 +18598,10 @@ maybe_instantiate_noexcept (tree fn) { tree fntype, spec, noex, clone; + /* Don't instantiate a noexcept-specification from template context. */ + if (processing_template_decl) + return; + if (DECL_CLONED_FUNCTION_P (fn)) fn = DECL_CLONED_FUNCTION (fn); fntype = TREE_TYPE (fn); @@ -19954,6 +20004,10 @@ type_dependent_expression_p (tree expression) if (TREE_CODE (expression) == SCOPE_REF) return false; + /* Always dependent, on the number of arguments if nothing else. */ + if (TREE_CODE (expression) == EXPR_PACK_EXPANSION) + return true; + if (BASELINK_P (expression)) expression = BASELINK_FUNCTIONS (expression); diff --git a/gcc-4.8/gcc/cp/semantics.c b/gcc-4.8/gcc/cp/semantics.c index 580c609ac..0debc78e8 100644 --- a/gcc-4.8/gcc/cp/semantics.c +++ b/gcc-4.8/gcc/cp/semantics.c @@ -2501,7 +2501,8 @@ finish_fname (tree id) tree decl; decl = fname_decl (input_location, C_RID_CODE (id), id); - if (processing_template_decl && current_function_decl) + if (processing_template_decl && current_function_decl + && decl != error_mark_node) decl = DECL_NAME (decl); return decl; } @@ -3853,7 +3854,7 @@ expand_or_defer_fn_1 (tree fn) linkage of all functions, and as that causes writes to the data mapped in from the PCH file, it's advantageous to mark the functions at this point. */ - if (!DECL_IMPLICIT_INSTANTIATION (fn)) + if (!DECL_IMPLICIT_INSTANTIATION (fn) || DECL_DEFAULTED_FN (fn)) { /* This function must have external linkage, as otherwise DECL_INTERFACE_KNOWN would have been @@ -4291,7 +4292,8 @@ finish_omp_clauses (tree clauses) error ("%qE has invalid type for %<reduction%>", t); remove = true; } - else if (FLOAT_TYPE_P (TREE_TYPE (t))) + else if (FLOAT_TYPE_P (TREE_TYPE (t)) + || TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE) { enum tree_code r_code = OMP_CLAUSE_REDUCTION_CODE (c); switch (r_code) @@ -4299,10 +4301,26 @@ finish_omp_clauses (tree clauses) case PLUS_EXPR: case MULT_EXPR: case MINUS_EXPR: + break; case MIN_EXPR: case MAX_EXPR: + if (TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE) + r_code = ERROR_MARK; break; + case BIT_AND_EXPR: + case BIT_XOR_EXPR: + case BIT_IOR_EXPR: default: + r_code = ERROR_MARK; + break; + case TRUTH_ANDIF_EXPR: + case TRUTH_ORIF_EXPR: + if (FLOAT_TYPE_P (TREE_TYPE (t))) + r_code = ERROR_MARK; + break; + } + if (r_code == ERROR_MARK) + { error ("%qE has invalid type for %<reduction(%s)%>", t, operator_name_info[r_code].name); remove = true; @@ -5059,7 +5077,7 @@ finish_omp_atomic (enum tree_code code, enum tree_code opcode, tree lhs, } stmt = build2 (OMP_ATOMIC, void_type_node, integer_zero_node, stmt); } - add_stmt (stmt); + finish_expr_stmt (stmt); } void @@ -7543,7 +7561,7 @@ cxx_fold_indirect_ref (location_t loc, tree type, tree op0, bool *empty_base) unsigned HOST_WIDE_INT indexi = offset * BITS_PER_UNIT; tree index = bitsize_int (indexi); - if (offset/part_widthi <= TYPE_VECTOR_SUBPARTS (op00type)) + if (offset / part_widthi < TYPE_VECTOR_SUBPARTS (op00type)) return fold_build3_loc (loc, BIT_FIELD_REF, type, op00, part_width, index); @@ -9481,7 +9499,14 @@ lambda_expr_this_capture (tree lambda) /* In unevaluated context this isn't an odr-use, so just return the nearest 'this'. */ if (cp_unevaluated_operand) + { + /* In an NSDMI the fake 'this' pointer that we're using for + parsing is in scope_chain. */ + if (LAMBDA_EXPR_EXTRA_SCOPE (lambda) + && TREE_CODE (LAMBDA_EXPR_EXTRA_SCOPE (lambda)) == FIELD_DECL) + return scope_chain->x_current_class_ptr; return lookup_name (this_identifier); + } /* Try to default capture 'this' if we can. */ if (!this_capture diff --git a/gcc-4.8/gcc/cp/typeck.c b/gcc-4.8/gcc/cp/typeck.c index 1a64b6890..2fa47025b 100644 --- a/gcc-4.8/gcc/cp/typeck.c +++ b/gcc-4.8/gcc/cp/typeck.c @@ -4103,6 +4103,11 @@ cp_build_binary_op (location_t location, case TRUTH_ORIF_EXPR: case TRUTH_AND_EXPR: case TRUTH_OR_EXPR: + if (TREE_CODE (type0) == VECTOR_TYPE || TREE_CODE (type1) == VECTOR_TYPE) + { + sorry ("logical operation on vector type"); + return error_mark_node; + } result_type = boolean_type_node; break; @@ -5010,7 +5015,10 @@ tree cp_truthvalue_conversion (tree expr) { tree type = TREE_TYPE (expr); - if (TYPE_PTRDATAMEM_P (type)) + if (TYPE_PTRDATAMEM_P (type) + /* Avoid ICE on invalid use of non-static member function. */ + || (TREE_CODE (expr) == FUNCTION_DECL + && DECL_NONSTATIC_MEMBER_FUNCTION_P (expr))) return build_binary_op (EXPR_LOCATION (expr), NE_EXPR, expr, nullptr_node, 1); else if (TYPE_PTR_P (type) || TYPE_PTRMEMFUNC_P (type)) @@ -5588,7 +5596,9 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert, inc = cxx_sizeof_nowarn (TREE_TYPE (argtype)); } else - inc = integer_one_node; + inc = (TREE_CODE (argtype) == VECTOR_TYPE + ? build_one_cst (argtype) + : integer_one_node); inc = cp_convert (argtype, inc, complain); @@ -6639,7 +6649,7 @@ build_reinterpret_cast_1 (tree type, tree expr, bool c_cast_p, where possible, and it is necessary in some cases. DR 195 addresses this issue, but as of 2004/10/26 is still in drafting. */ - warning (0, "ISO C++ forbids casting between pointer-to-function and pointer-to-object"); + warning (OPT_Wpedantic, "ISO C++ forbids casting between pointer-to-function and pointer-to-object"); return fold_if_not_in_template (build_nop (type, expr)); } else if (TREE_CODE (type) == VECTOR_TYPE) @@ -7194,8 +7204,7 @@ cp_build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs, side effect associated with any single compound assignment operator. -- end note ] */ lhs = stabilize_reference (lhs); - if (TREE_SIDE_EFFECTS (rhs)) - rhs = mark_rvalue_use (rhs); + rhs = rvalue (rhs); rhs = stabilize_expr (rhs, &init); newrhs = cp_build_binary_op (input_location, modifycode, lhs, rhs, @@ -7611,7 +7620,7 @@ build_ptrmemfunc (tree type, tree pfn, int force, bool c_cast_p, /* Handle null pointer to member function conversions. */ if (null_ptr_cst_p (pfn)) { - pfn = build_c_cast (input_location, type, pfn); + pfn = cp_build_c_cast (type, pfn, complain); return build_ptrmemfunc1 (to_type, integer_zero_node, pfn); diff --git a/gcc-4.8/gcc/cp/typeck2.c b/gcc-4.8/gcc/cp/typeck2.c index 9c9f0751f..e7e1246e1 100644 --- a/gcc-4.8/gcc/cp/typeck2.c +++ b/gcc-4.8/gcc/cp/typeck2.c @@ -1015,6 +1015,7 @@ digest_init_flags (tree type, tree init, int flags) #define PICFLAG_ERRONEOUS 1 #define PICFLAG_NOT_ALL_CONSTANT 2 #define PICFLAG_NOT_ALL_SIMPLE 4 +#define PICFLAG_SIDE_EFFECTS 8 /* Given an initializer INIT, return the flag (PICFLAG_*) which better describe it. */ @@ -1025,7 +1026,12 @@ picflag_from_initializer (tree init) if (init == error_mark_node) return PICFLAG_ERRONEOUS; else if (!TREE_CONSTANT (init)) + { + if (TREE_SIDE_EFFECTS (init)) + return PICFLAG_SIDE_EFFECTS; + else return PICFLAG_NOT_ALL_CONSTANT; + } else if (!initializer_constant_valid_p (init, TREE_TYPE (init))) return PICFLAG_NOT_ALL_SIMPLE; return 0; @@ -1392,7 +1398,12 @@ process_init_constructor (tree type, tree init, tsubst_flags_t complain) TREE_TYPE (init) = type; if (TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type) == NULL_TREE) cp_complete_array_type (&TREE_TYPE (init), init, /*do_default=*/0); - if (flags & PICFLAG_NOT_ALL_CONSTANT) + if (flags & PICFLAG_SIDE_EFFECTS) + { + TREE_CONSTANT (init) = false; + TREE_SIDE_EFFECTS (init) = true; + } + else if (flags & PICFLAG_NOT_ALL_CONSTANT) /* Make sure TREE_CONSTANT isn't set from build_constructor. */ TREE_CONSTANT (init) = false; else |