diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-11-26 14:57:54 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-11-26 14:57:54 +0000 |
commit | 7bd935cdb41444ec4a53152aa230fc0262b63300 (patch) | |
tree | d7287d5062e65d84edb3ab01ede335336b8b4c3b /gcc/cp | |
parent | 41e69d7b0792fd347b35d4dce100655d1f1b0fbe (diff) | |
download | gcc-7bd935cdb41444ec4a53152aa230fc0262b63300.tar.gz |
[./]
2013-11-26 Basile Starynkevitch <basile@starynkevitch.net>
{{merge using svnmerge.py with trunk GCC 4.9 svn rev 205391 now in
stage 3; very unstable}}
[gcc/]
2013-11-26 Basile Starynkevitch <basile@starynkevitch.net>
{{unstable, xtramelt-ana-base.melt is not translatable. Merge with
trunk svn rev 205391}}
* melt-run.proto.h: Move MELT_GCC_VERSION #definition above.
Include basic-block.h, tree-ssa-alias.h, internal-fn.h,
gimple-expr.h, is-a.h for GCC 4.9...
* melt-runtime.cc: Include basic-block.h, tree-ssa-alias.h, internal-fn.h,
gimple-expr.h, is-a.h, pointer-set.h for GCC 4.9...
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@205393 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 156 | ||||
-rw-r--r-- | gcc/cp/call.c | 21 | ||||
-rw-r--r-- | gcc/cp/class.c | 6 | ||||
-rw-r--r-- | gcc/cp/cp-gimplify.c | 65 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 3 | ||||
-rw-r--r-- | gcc/cp/cvt.c | 11 | ||||
-rw-r--r-- | gcc/cp/decl.c | 91 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 29 | ||||
-rw-r--r-- | gcc/cp/error.c | 6 | ||||
-rw-r--r-- | gcc/cp/init.c | 15 | ||||
-rw-r--r-- | gcc/cp/lex.c | 13 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 8 | ||||
-rw-r--r-- | gcc/cp/optimize.c | 2 | ||||
-rw-r--r-- | gcc/cp/parser.c | 18 | ||||
-rw-r--r-- | gcc/cp/pt.c | 29 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 25 | ||||
-rw-r--r-- | gcc/cp/tree.c | 4 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 18 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 4 | ||||
-rw-r--r-- | gcc/cp/vtable-class-hierarchy.c | 1 |
20 files changed, 399 insertions, 126 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5e769c30eec..604f26dc14b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,159 @@ +2013-11-26 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/58700 + * decl.c (grokdeclarator): Don't try to pass declarator->id_loc + to build_lang_decl_loc when declarator is null. + +2013-11-26 Paolo Carlini <paolo.carlini@oracle.com> + + * cvt.c (cp_convert_and_check): Avoid calling cp_convert + unnecessarily. + +2013-11-25 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/54485 + * decl.c (duplicate_decls): Enforce 8.3.6/6 about default arguments + for member functions of class templates. + +2013-11-25 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/58607 + * semantics.c (check_constexpr_ctor_body): Check for BIND_EXPR_VARS. + +2013-11-25 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/58810 + * decl.c (grokdeclarator): Don't handle qualified free functions here, + leave the diagnostic to grokfndecl. + +2013-11-25 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/59080 + * pt.c (unify): Don't call unify_array_domain with a NULL_TREE + third argument. + + PR c++/59096 + * pt.c (apply_late_template_attributes): Check that TREE_VALUE + isn't NULL_TREE in the attribute_takes_identifier_p case. + +2013-11-25 Adam Butcher <adam@jessamine.co.uk> + + PR c++/59112 + PR c++/59113 + * parser.c (cp_parser_parameter_declaration_clause): Disallow implicit + function templates in local functions unless defining a lambda. + +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-11-23 Jason Merrill <jason@redhat.com> + + PR c++/58868 + * init.c (build_aggr_init): Don't clobber the type of init + if we got an INIT_EXPR back from build_vec_init. + (build_vec_init): Do digest_init on trivial initialization. + +2013-11-23 Alexander Ivchenko <alexander.ivchenko@intel.com> + + PR c++/58525 + * call.c (build_operator_new_call): Add flag_exceptions check. + * decl.c (compute_array_index_type): Ditto. + * init.c (build_new_1): Ditto. + (build_vec_init): Ditto. + +2013-11-22 Jakub Jelinek <jakub@redhat.com> + + * cp-gimplify.c: Include target.h and c-family/c-ubsan.h. + (cp_ubsan_maybe_instrument_return): New function. + (cp_genericize): Call it if -fsanitize=return. + + * decl2.c: Include asan.h. + (one_static_initialization_or_destruction): If -fsanitize=address, + init is non-NULL and guard is NULL, set + vnode->dynamically_initialized. + (do_static_initialization_or_destruction): Call + __asan_{before,after}_dynamic_init around the static initialization. + +2013-11-22 Andrew MacLeod <amacleod@redhat.com> + + * class.c: Add required include files from gimple.h. + * cp-gimplify.c: Likewise + * decl2.c: Likewise + * init.c: Likewise + * optimize.c: Likewise + * pt.c: Likewise + * semantics.c: Likewise + * tree.c: Likewise + * typeck.c: Likewise + * vtable-class-hierarchy.c: Likewise + +2013-11-22 David Malcolm <dmalcolm@redhat.com> + + * call.c (build_integral_nontype_arg_conv): Remove use of + EXPR_LOC_OR_HERE macro. + (convert_like_real): Likewise. + (convert_arg_to_ellipsis): Likewise. + (build_cxx_call): Likewise. + (perform_implicit_conversion_flags): Likewise. + (initialize_reference): Likewise. + * cvt.c (cp_convert_to_pointer): Likewise. + (convert_to_reference): Likewise. + (ocp_convert): Likewise. + (convert_to_void): Likewise. + * decl.c (pop_label): Update comment. + (pop_switch): Remove use of EXPR_LOC_OR_HERE macro. + (check_tag_decl): Remove use of in_system_header macro. + (make_rtl_for_nonlocal_decl): Remove use of input_filename + macro. + (compute_array_index_type): Remove use of in_system_header + macro. + (grokdeclarator): Likewise. + * error.c (dump_global_iord): Remove use of input_filename + macro. + (location_of): Remove use of EXPR_LOC_OR_HERE macro. + (maybe_warn_cpp0x): Remove use of in_system_header macro. + * init.c (build_new_1): Remove use of EXPR_LOC_OR_HERE macro. + * lex.c (handle_pragma_interface): Remove use of input_filename + macro. + (handle_pragma_implementation): Likewise. + (cxx_make_type): Likewise. + (in_main_input_context): Likewise. + * name-lookup.c (push_binding_level): Remove use of + input_line macro. + (leave_scope): Likewise. + (resume_scope): Likewise. + * parser.c (cp_parser_unqualified_id): Remove use of + in_system_header macro. + (cp_parser_cast_expression): Likewise. + (cp_parser_declaration_seq_opt): Likewise. + (cp_parser_enumerator_list): Likewise. + (cp_parser_parameter_declaration_clause): Likewise. + (cp_parser_exception_specification_opt): Likewise. + * pt.c (unify_arg_conversion): Remove use of EXPR_LOC_OR_HERE + macro. + (convert_nontype_argument): Likewise. + (push_tinst_level): Remove use of in_system_header macro. + (tsubst_copy_and_build): Remove use of EXPR_LOC_OR_HERE + macros. + (do_decl_instantiation): Remove use of in_system_header macro. + (do_type_instantiation): Likewise. + * semantics.c (finish_call_expr): Remove use of EXPR_LOC_OR_HERE + macro. + (begin_class_definition): Remove use of input_filename macro. + (cxx_eval_call_expression): Remove use of EXPR_LOC_OR_HERE + macro. + (cxx_eval_constant_expression): Likewise. + (potential_constant_expression_1): Likewise. + * typeck.c (decay_conversion): Likewise. + (rationalize_conditional_expr): Likewise. + (build_x_compound_expr_from_list): Likewise. + (convert_for_assignment): Likewise. + * typeck2.c (check_narrowing): Likewise. + 2013-11-22 Trevor Saunders <tsaunders@mozilla.com> * parser.c, semantics.c: Change some local variables from vec to diff --git a/gcc/cp/call.c b/gcc/cp/call.c index c529c16bc74..4107afa8672 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -3687,7 +3687,7 @@ build_integral_nontype_arg_conv (tree type, tree expr, tsubst_flags_t complain) conversion *conv; void *p; tree t; - location_t loc = EXPR_LOC_OR_HERE (expr); + location_t loc = EXPR_LOC_OR_LOC (expr, input_location); if (error_operand_p (expr)) return error_mark_node; @@ -3956,7 +3956,7 @@ build_operator_new_call (tree fnname, vec<tree, va_gc> **args, if (size_check != NULL_TREE) { tree errval = TYPE_MAX_VALUE (sizetype); - if (cxx_dialect >= cxx11) + if (cxx_dialect >= cxx11 && flag_exceptions) errval = throw_bad_array_new_length (); *size = fold_build3 (COND_EXPR, sizetype, size_check, original_size, errval); @@ -5850,7 +5850,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, tree totype = convs->type; diagnostic_t diag_kind; int flags; - location_t loc = EXPR_LOC_OR_HERE (expr); + location_t loc = EXPR_LOC_OR_LOC (expr, input_location); if (convs->bad_p && !(complain & tf_error)) return error_mark_node; @@ -6263,7 +6263,7 @@ tree convert_arg_to_ellipsis (tree arg, tsubst_flags_t complain) { tree arg_type; - location_t loc = EXPR_LOC_OR_HERE (arg); + location_t loc = EXPR_LOC_OR_LOC (arg, input_location); /* [expr.call] @@ -7168,7 +7168,7 @@ build_cxx_call (tree fn, int nargs, tree *argarray, int optimize_sav; /* Remember roughly where this call is. */ - location_t loc = EXPR_LOC_OR_HERE (fn); + location_t loc = EXPR_LOC_OR_LOC (fn, input_location); fn = build_call_a (fn, nargs, argarray); SET_EXPR_LOCATION (fn, loc); @@ -7514,7 +7514,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 name; @@ -7553,6 +7553,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) @@ -7799,13 +7800,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) @@ -8979,7 +8980,7 @@ perform_implicit_conversion_flags (tree type, tree expr, { conversion *conv; void *p; - location_t loc = EXPR_LOC_OR_HERE (expr); + location_t loc = EXPR_LOC_OR_LOC (expr, input_location); if (error_operand_p (expr)) return error_mark_node; @@ -9295,7 +9296,7 @@ initialize_reference (tree type, tree expr, { conversion *conv; void *p; - location_t loc = EXPR_LOC_OR_HERE (expr); + location_t loc = EXPR_LOC_OR_LOC (expr, input_location); if (type == error_mark_node || error_operand_p (expr)) return error_mark_node; diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 00fec27a3d5..842b11c66c1 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -29,7 +29,8 @@ along with GCC; see the file COPYING3. If not see #include "stringpool.h" #include "stor-layout.h" #include "attribs.h" -#include "gimple.h" +#include "pointer-set.h" +#include "hash-table.h" #include "cp-tree.h" #include "flags.h" #include "toplev.h" @@ -38,9 +39,6 @@ along with GCC; see the file COPYING3. If not see #include "cgraph.h" #include "dumpfile.h" #include "splay-tree.h" -#include "pointer-set.h" -#include "hash-table.h" -#include "gimple.h" #include "gimplify.h" /* The number of nested classes being processed. If we are not in the diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index e2629464dd9..b1270a187f1 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -28,12 +28,19 @@ along with GCC; see the file COPYING3. If not see #include "cp-tree.h" #include "c-family/c-common.h" #include "tree-iterator.h" +#include "pointer-set.h" +#include "basic-block.h" +#include "tree-ssa-alias.h" +#include "internal-fn.h" +#include "gimple-expr.h" +#include "is-a.h" #include "gimple.h" #include "gimplify.h" #include "hashtab.h" -#include "pointer-set.h" #include "flags.h" #include "splay-tree.h" +#include "target.h" +#include "c-family/c-ubsan.h" /* Forward declarations. */ @@ -1173,6 +1180,59 @@ cp_genericize_tree (tree* t_p) wtd.bind_expr_stack.release (); } +/* If a function that should end with a return in non-void + function doesn't obviously end with return, add ubsan + instrmentation code to verify it at runtime. */ + +static void +cp_ubsan_maybe_instrument_return (tree fndecl) +{ + if (VOID_TYPE_P (TREE_TYPE (TREE_TYPE (fndecl))) + || DECL_CONSTRUCTOR_P (fndecl) + || DECL_DESTRUCTOR_P (fndecl) + || !targetm.warn_func_return (fndecl)) + return; + + tree t = DECL_SAVED_TREE (fndecl); + while (t) + { + switch (TREE_CODE (t)) + { + case BIND_EXPR: + t = BIND_EXPR_BODY (t); + continue; + case TRY_FINALLY_EXPR: + t = TREE_OPERAND (t, 0); + continue; + case STATEMENT_LIST: + { + tree_stmt_iterator i = tsi_last (t); + if (!tsi_end_p (i)) + { + t = tsi_stmt (i); + continue; + } + } + break; + case RETURN_EXPR: + return; + default: + break; + } + break; + } + if (t == NULL_TREE) + return; + t = DECL_SAVED_TREE (fndecl); + if (TREE_CODE (t) == BIND_EXPR + && TREE_CODE (BIND_EXPR_BODY (t)) == STATEMENT_LIST) + { + tree_stmt_iterator i = tsi_last (BIND_EXPR_BODY (t)); + t = ubsan_instrument_return (DECL_SOURCE_LOCATION (fndecl)); + tsi_link_after (&i, t, TSI_NEW_STMT); + } +} + void cp_genericize (tree fndecl) { @@ -1235,6 +1295,9 @@ cp_genericize (tree fndecl) walk_tree's hash functionality. */ cp_genericize_tree (&DECL_SAVED_TREE (fndecl)); + if (flag_sanitize & SANITIZE_RETURN) + cp_ubsan_maybe_instrument_return (fndecl); + /* Do everything else. */ c_genericize (fndecl); diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 4e26bd501b4..1fc4b59d846 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -359,7 +359,8 @@ struct GTY(()) tree_overload { /* Returns true iff NODE is a BASELINK. */ #define BASELINK_P(NODE) \ (TREE_CODE (NODE) == BASELINK) -/* The BINFO indicating the base from which the BASELINK_FUNCTIONS came. */ +/* The BINFO indicating the base in which lookup found the + BASELINK_FUNCTIONS. */ #define BASELINK_BINFO(NODE) \ (((struct tree_baselink*) BASELINK_CHECK (NODE))->binfo) /* The functions referred to by the BASELINK; either a FUNCTION_DECL, diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 5264c5df2a8..ecec24a5118 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -78,7 +78,7 @@ cp_convert_to_pointer (tree type, tree expr, tsubst_flags_t complain) tree intype = TREE_TYPE (expr); enum tree_code form; tree rval; - location_t loc = EXPR_LOC_OR_HERE (expr); + location_t loc = EXPR_LOC_OR_LOC (expr, input_location); if (intype == error_mark_node) return error_mark_node; @@ -413,7 +413,7 @@ convert_to_reference (tree reftype, tree expr, int convtype, tree rval = NULL_TREE; tree rval_as_conversion = NULL_TREE; bool can_convert_intype_to_type; - location_t loc = EXPR_LOC_OR_HERE (expr); + location_t loc = EXPR_LOC_OR_LOC (expr, input_location); if (TREE_CODE (type) == FUNCTION_TYPE && TREE_TYPE (expr) == unknown_type_node) @@ -630,7 +630,8 @@ cp_convert_and_check (tree type, tree expr, tsubst_flags_t complain) { tree folded = maybe_constant_value (expr); tree stripped = folded; - tree folded_result = cp_convert (type, folded, complain); + tree folded_result + = folded != expr ? cp_convert (type, folded, complain) : result; /* maybe_constant_value wraps an INTEGER_CST with TREE_OVERFLOW in a NOP_EXPR so that it isn't TREE_CONSTANT anymore. */ @@ -656,7 +657,7 @@ ocp_convert (tree type, tree expr, int convtype, int flags, enum tree_code code = TREE_CODE (type); const char *invalid_conv_diag; tree e1; - location_t loc = EXPR_LOC_OR_HERE (expr); + location_t loc = EXPR_LOC_OR_LOC (expr, input_location); if (error_operand_p (e) || type == error_mark_node) return error_mark_node; @@ -912,7 +913,7 @@ ocp_convert (tree type, tree expr, int convtype, int flags, tree convert_to_void (tree expr, impl_conv_void implicit, tsubst_flags_t complain) { - location_t loc = EXPR_LOC_OR_HERE (expr); + location_t loc = EXPR_LOC_OR_LOC (expr, input_location); if (expr == error_mark_node || TREE_TYPE (expr) == error_mark_node) diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 500c81f79fc..9508131388f 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -376,7 +376,8 @@ pop_label (tree label, tree old_value) location_t location; error ("label %q+D used but not defined", label); - location = input_location; /* FIXME want (input_filename, (line)0) */ + location = input_location; + /* FIXME want (LOCATION_FILE (input_location), (line)0) */ /* Avoid crashing later. */ define_label (location, DECL_NAME (label)); } @@ -1703,25 +1704,47 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) if (TREE_CODE (TREE_TYPE (newdecl)) == METHOD_TYPE) t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2); - for (; t1 && t1 != void_list_node; - t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2), i++) - if (TREE_PURPOSE (t1) && TREE_PURPOSE (t2)) - { - if (1 == simple_cst_equal (TREE_PURPOSE (t1), - TREE_PURPOSE (t2))) + if (TREE_CODE (TREE_TYPE (newdecl)) == METHOD_TYPE + && CLASSTYPE_TEMPLATE_INFO (CP_DECL_CONTEXT (newdecl))) + { + /* C++11 8.3.6/6. + Default arguments for a member function of a class template + shall be specified on the initial declaration of the member + function within the class template. */ + for (; t2 && t2 != void_list_node; t2 = TREE_CHAIN (t2)) + if (TREE_PURPOSE (t2)) { - permerror (input_location, "default argument given for parameter %d of %q#D", - i, newdecl); - permerror (input_location, "after previous specification in %q+#D", olddecl); + permerror (input_location, + "redeclaration of %q#D may not have default " + "arguments", newdecl); + break; } - else + } + else + { + for (; t1 && t1 != void_list_node; + t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2), i++) + if (TREE_PURPOSE (t1) && TREE_PURPOSE (t2)) { - error ("default argument given for parameter %d of %q#D", - i, newdecl); - error ("after previous specification in %q+#D", - olddecl); + if (1 == simple_cst_equal (TREE_PURPOSE (t1), + TREE_PURPOSE (t2))) + { + permerror (input_location, + "default argument given for parameter %d " + "of %q#D", i, newdecl); + permerror (input_location, + "after previous specification in %q+#D", + olddecl); + } + else + { + error ("default argument given for parameter %d " + "of %q#D", i, newdecl); + error ("after previous specification in %q+#D", + olddecl); + } } - } + } } } @@ -3092,7 +3115,7 @@ pop_switch (void) location_t switch_location; /* Emit warnings as needed. */ - switch_location = EXPR_LOC_OR_HERE (cs->switch_stmt); + switch_location = EXPR_LOC_OR_LOC (cs->switch_stmt, input_location); if (!processing_template_decl) c_do_switch_warnings (cs->cases, switch_location, SWITCH_STMT_TYPE (cs->switch_stmt), @@ -4241,7 +4264,7 @@ check_tag_decl (cp_decl_specifier_seq *declspecs, error ("multiple types in one declaration"); else if (declspecs->redefined_builtin_type) { - if (!in_system_header) + if (!in_system_header_at (input_location)) permerror (declspecs->locations[ds_redefined_builtin_type_spec], "redeclaration of C++ built-in type %qT", declspecs->redefined_builtin_type); @@ -4292,7 +4315,8 @@ check_tag_decl (cp_decl_specifier_seq *declspecs, /* Anonymous unions are objects, so they can have specifiers. */; SET_ANON_AGGR_TYPE_P (declared_type); - if (TREE_CODE (declared_type) != UNION_TYPE && !in_system_header) + if (TREE_CODE (declared_type) != UNION_TYPE + && !in_system_header_at (input_location)) pedwarn (input_location, OPT_Wpedantic, "ISO C++ prohibits anonymous structs"); } @@ -5846,7 +5870,7 @@ make_rtl_for_nonlocal_decl (tree decl, tree init, const char* asmspec) /* We try to defer namespace-scope static constants so that they are not emitted into the object file unnecessarily. */ - filename = input_filename; + filename = LOCATION_FILE (input_location); if (!DECL_VIRTUAL_P (decl) && TREE_READONLY (decl) && DECL_INITIAL (decl) != NULL_TREE @@ -8309,7 +8333,7 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain) indicated by the state of complain), so that another substitution can be found. */ return error_mark_node; - else if (in_system_header) + else if (in_system_header_at (input_location)) /* Allow them in system headers because glibc uses them. */; else if (name) pedwarn (input_location, OPT_Wpedantic, "ISO C++ forbids zero-size array %qD", name); @@ -8391,7 +8415,7 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain) stabilize_vla_size (itype); - if (cxx_dialect >= cxx1y) + if (cxx_dialect >= cxx1y && flag_exceptions) { /* If the VLA bound is larger than half the address space, or less than zero, throw std::bad_array_length. */ @@ -9096,7 +9120,7 @@ grokdeclarator (const cp_declarator *declarator, if (type_was_error_mark_node) /* We've already issued an error, don't complain more. */; - else if (in_system_header || flag_ms_extensions) + else if (in_system_header_at (input_location) || flag_ms_extensions) /* Allow it, sigh. */; else if (! is_main) permerror (input_location, "ISO C++ forbids declaration of %qs with no type", name); @@ -9119,7 +9143,7 @@ grokdeclarator (const cp_declarator *declarator, error ("%<__int128%> is not supported by this target"); explicit_int128 = false; } - else if (pedantic && ! in_system_header) + else if (pedantic && ! in_system_header_at (input_location)) pedwarn (input_location, OPT_Wpedantic, "ISO C++ does not support %<__int128%> for %qs", name); } @@ -10254,21 +10278,6 @@ grokdeclarator (const cp_declarator *declarator, if (decl_context != TYPENAME) { - /* A cv-qualifier-seq shall only be part of the function type - for a non-static member function. A ref-qualifier shall only - .... /same as above/ [dcl.fct] */ - if ((type_memfn_quals (type) != TYPE_UNQUALIFIED - || type_memfn_rqual (type) != REF_QUAL_NONE) - && (current_class_type == NULL_TREE || staticp) ) - { - error (staticp - ? G_("qualified function types cannot be used to " - "declare static member functions") - : G_("qualified function types cannot be used to " - "declare free functions")); - type = TYPE_MAIN_VARIANT (type); - } - /* The qualifiers on the function type become the qualifiers on the non-static member function. */ memfn_quals |= type_memfn_quals (type); @@ -10628,7 +10637,9 @@ grokdeclarator (const cp_declarator *declarator, { /* C++ allows static class members. All other work for this is done by grokfield. */ - decl = build_lang_decl_loc (declarator->id_loc, + decl = build_lang_decl_loc (declarator + ? declarator->id_loc + : input_location, VAR_DECL, unqualified_id, type); set_linkage_for_static_data_member (decl); /* Even if there is an in-class initialization, DECL diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 93c75cbf4d6..0e37a5d246c 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -36,7 +36,7 @@ along with GCC; see the file COPYING3. If not see #include "attribs.h" #include "stor-layout.h" #include "calls.h" -#include "gimple.h" +#include "pointer-set.h" #include "flags.h" #include "cp-tree.h" #include "decl.h" @@ -51,10 +51,10 @@ along with GCC; see the file COPYING3. If not see #include "c-family/c-pragma.h" #include "dumpfile.h" #include "intl.h" -#include "pointer-set.h" #include "splay-tree.h" #include "langhooks.h" #include "c-family/c-ada-spec.h" +#include "asan.h" extern cpp_reader *parse_in; @@ -3462,7 +3462,15 @@ one_static_initialization_or_destruction (tree decl, tree init, bool initp) if (initp) { if (init) - finish_expr_stmt (init); + { + finish_expr_stmt (init); + if (flag_sanitize & SANITIZE_ADDRESS) + { + struct varpool_node *vnode = varpool_get_node (decl); + if (vnode) + vnode->dynamically_initialized = 1; + } + } /* If we're using __cxa_atexit, register a function that calls the destructor for the object. */ @@ -3504,6 +3512,16 @@ do_static_initialization_or_destruction (tree vars, bool initp) tf_warning_or_error); finish_if_stmt_cond (cond, init_if_stmt); + /* To make sure dynamic construction doesn't access globals from other + compilation units where they might not be yet constructed, for + -fsanitize=address insert __asan_before_dynamic_init call that + prevents access to either all global variables that need construction + in other compilation units, or at least those that haven't been + initialized yet. Variables that need dynamic construction in + the current compilation unit are kept accessible. */ + if (flag_sanitize & SANITIZE_ADDRESS) + finish_expr_stmt (asan_dynamic_init_call (/*after_p=*/false)); + node = vars; do { tree decl = TREE_VALUE (node); @@ -3552,6 +3570,11 @@ do_static_initialization_or_destruction (tree vars, bool initp) } while (node); + /* Revert what __asan_before_dynamic_init did by calling + __asan_after_dynamic_init. */ + if (flag_sanitize & SANITIZE_ADDRESS) + finish_expr_stmt (asan_dynamic_init_call (/*after_p=*/true)); + /* Finish up the init/destruct if-stmt body. */ finish_then_clause (init_if_stmt); finish_if_stmt (init_if_stmt); diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 5481523868d..72aa936c129 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -924,7 +924,7 @@ dump_global_iord (cxx_pretty_printer *pp, tree t) else gcc_unreachable (); - pp_printf (pp, p, input_filename); + pp_printf (pp, p, LOCATION_FILE (input_location)); } static void @@ -2804,7 +2804,7 @@ location_of (tree t) if (DECL_P (t)) return DECL_SOURCE_LOCATION (t); - return EXPR_LOC_OR_HERE (t); + return EXPR_LOC_OR_LOC (t, input_location); } /* Now the interfaces from error et al to dump_type et al. Each takes an @@ -3463,7 +3463,7 @@ cp_printer (pretty_printer *pp, text_info *text, const char *spec, void maybe_warn_cpp0x (cpp0x_warn_str str) { - if ((cxx_dialect == cxx98) && !in_system_header) + if ((cxx_dialect == cxx98) && !in_system_header_at (input_location)) /* We really want to suppress this warning in system headers, because libstdc++ uses variadic templates even when we aren't in C++0x mode. */ diff --git a/gcc/cp/init.c b/gcc/cp/init.c index fd43a4fc87c..1e6e6915bdc 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -30,7 +30,6 @@ along with GCC; see the file COPYING3. If not see #include "cp-tree.h" #include "flags.h" #include "target.h" -#include "gimple.h" #include "gimplify.h" static bool begin_init_stmts (tree *, tree *); @@ -1508,7 +1507,8 @@ build_aggr_init (tree exp, tree init, int flags, tsubst_flags_t complain) TREE_READONLY (exp) = was_const; TREE_THIS_VOLATILE (exp) = was_volatile; TREE_TYPE (exp) = type; - if (init) + /* Restore the type of init unless it was used directly. */ + if (init && TREE_CODE (stmt_expr) != INIT_EXPR) TREE_TYPE (init) = itype; return stmt_expr; } @@ -2319,7 +2319,7 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts, { if (complain & tf_error) { - error_at (EXPR_LOC_OR_HERE (inner_nelts), + error_at (EXPR_LOC_OR_LOC (inner_nelts, input_location), "array size in operator new must be constant"); cxx_constant_value(inner_nelts); } @@ -2347,7 +2347,7 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts, && !TREE_CONSTANT (maybe_constant_value (outer_nelts))) { if (complain & tf_warning_or_error) - pedwarn(EXPR_LOC_OR_HERE (outer_nelts), OPT_Wvla, + pedwarn(EXPR_LOC_OR_LOC (outer_nelts, input_location), OPT_Wvla, "ISO C++ does not support variable-length array types"); else return error_mark_node; @@ -2529,7 +2529,7 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts, } /* Perform the overflow check. */ tree errval = TYPE_MAX_VALUE (sizetype); - if (cxx_dialect >= cxx11) + if (cxx_dialect >= cxx11 && flag_exceptions) errval = throw_bad_array_new_length (); if (outer_nelts_check != NULL_TREE) size = fold_build3 (COND_EXPR, sizetype, outer_nelts_check, @@ -3399,7 +3399,8 @@ build_vec_init (tree base, tree maxindex, tree init, is big enough for all the initializers. */ if (init && TREE_CODE (init) == CONSTRUCTOR && CONSTRUCTOR_NELTS (init) > 0 - && !TREE_CONSTANT (maxindex)) + && !TREE_CONSTANT (maxindex) + && flag_exceptions) length_check = fold_build2 (LT_EXPR, boolean_type_node, maxindex, size_int (CONSTRUCTOR_NELTS (init) - 1)); @@ -3421,6 +3422,8 @@ build_vec_init (tree base, tree maxindex, tree init, brace-enclosed initializers. In this case, digest_init and store_constructor will handle the semantics for us. */ + if (BRACE_ENCLOSED_INITIALIZER_P (init)) + init = digest_init (atype, init, complain); stmt_expr = build2 (INIT_EXPR, atype, base, init); if (length_check) stmt_expr = build3 (COND_EXPR, atype, length_check, diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index 5d8a313f38b..2d517a4c7fe 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -352,18 +352,18 @@ handle_pragma_interface (cpp_reader* /*dfile*/) if (fname == error_mark_node) return; else if (fname == 0) - filename = lbasename (input_filename); + filename = lbasename (LOCATION_FILE (input_location)); else filename = TREE_STRING_POINTER (fname); - finfo = get_fileinfo (input_filename); + finfo = get_fileinfo (LOCATION_FILE (input_location)); if (impl_file_chain == 0) { /* If this is zero at this point, then we are auto-implementing. */ if (main_input_filename == 0) - main_input_filename = input_filename; + main_input_filename = LOCATION_FILE (input_location); } finfo->interface_only = interface_strcmp (filename); @@ -397,7 +397,7 @@ handle_pragma_implementation (cpp_reader* /*dfile*/) if (main_input_filename) filename = main_input_filename; else - filename = input_filename; + filename = LOCATION_FILE (input_location); filename = lbasename (filename); } else @@ -683,7 +683,8 @@ cxx_make_type (enum tree_code code) /* Set up some flags that give proper default behavior. */ if (RECORD_OR_UNION_CODE_P (code)) { - struct c_fileinfo *finfo = get_fileinfo (input_filename); + struct c_fileinfo *finfo = \ + get_fileinfo (LOCATION_FILE (input_location)); SET_CLASSTYPE_INTERFACE_UNKNOWN_X (t, finfo->interface_unknown); CLASSTYPE_INTERFACE_ONLY (t) = finfo->interface_only; } @@ -711,5 +712,5 @@ in_main_input_context (void) return filename_cmp (main_input_filename, LOCATION_FILE (tl->locus)) == 0; else - return filename_cmp (main_input_filename, input_filename) == 0; + return filename_cmp (main_input_filename, LOCATION_FILE (input_location)) == 0; } diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index d0c024a120f..f527638e713 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -1504,7 +1504,8 @@ push_binding_level (cp_binding_level *scope) { scope->binding_depth = binding_depth; indent (binding_depth); - cp_binding_level_debug (scope, input_line, "push"); + cp_binding_level_debug (scope, LOCATION_LINE (input_location), + "push"); binding_depth++; } } @@ -1590,7 +1591,8 @@ leave_scope (void) if (ENABLE_SCOPE_CHECKING) { indent (--binding_depth); - cp_binding_level_debug (scope, input_line, "leave"); + cp_binding_level_debug (scope, LOCATION_LINE (input_location), + "leave"); } /* Move one nesting level up. */ @@ -1639,7 +1641,7 @@ resume_scope (cp_binding_level* b) { b->binding_depth = binding_depth; indent (binding_depth); - cp_binding_level_debug (b, input_line, "resume"); + cp_binding_level_debug (b, LOCATION_LINE (input_location), "resume"); binding_depth++; } } diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index b8df1347c33..f1b09bfd55e 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -35,7 +35,7 @@ along with GCC; see the file COPYING3. If not see #include "langhooks.h" #include "diagnostic-core.h" #include "dumpfile.h" -#include "gimple.h" +#include "pointer-set.h" #include "tree-iterator.h" #include "cgraph.h" diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index bc86697793c..d7092cc6759 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -5088,7 +5088,8 @@ cp_parser_unqualified_id (cp_parser* parser, { /* 17.6.3.3.5 */ const char *name = UDLIT_OP_SUFFIX (id); - if (name[0] != '_' && !in_system_header && declarator_p) + if (name[0] != '_' && !in_system_header_at (input_location) + && declarator_p) warning (0, "literal operator suffixes not preceded by %<_%>" " are reserved for future standardization"); } @@ -7686,7 +7687,7 @@ cp_parser_cast_expression (cp_parser *parser, bool address_p, bool cast_p, /* Warn about old-style casts, if so requested. */ if (warn_old_style_cast - && !in_system_header + && !in_system_header_at (input_location) && !VOID_TYPE_P (type) && current_lang_name != lang_name_c) warning (OPT_Wold_style_cast, "use of old-style cast"); @@ -10765,7 +10766,7 @@ cp_parser_declaration_seq_opt (cp_parser* parser) /* A declaration consisting of a single semicolon is invalid. Allow it unless we're being pedantic. */ cp_lexer_consume_token (parser->lexer); - if (!in_system_header) + if (!in_system_header_at (input_location)) pedwarn (input_location, OPT_Wpedantic, "extra %<;%>"); continue; } @@ -15527,7 +15528,7 @@ cp_parser_enumerator_list (cp_parser* parser, tree type) /* If the next token is a `}', there is a trailing comma. */ if (cp_lexer_next_token_is (parser->lexer, CPP_CLOSE_BRACE)) { - if (cxx_dialect < cxx11 && !in_system_header) + if (cxx_dialect < cxx11 && !in_system_header_at (input_location)) pedwarn (input_location, OPT_Wpedantic, "comma at end of enumerator list"); break; @@ -18041,7 +18042,9 @@ cp_parser_parameter_declaration_clause (cp_parser* parser) (void) cleanup; if (!processing_specialization) - parser->auto_is_implicit_function_template_parm_p = true; + if (!current_function_decl + || (current_class_type && LAMBDA_TYPE_P (current_class_type))) + parser->auto_is_implicit_function_template_parm_p = true; /* Peek at the next token. */ token = cp_lexer_peek_token (parser->lexer); @@ -18056,7 +18059,8 @@ cp_parser_parameter_declaration_clause (cp_parser* parser) /* There are no parameters. */ { #ifndef NO_IMPLICIT_EXTERN_C - if (in_system_header && current_class_type == NULL + if (in_system_header_at (input_location) + && current_class_type == NULL && current_lang_name == lang_name_c) return NULL_TREE; else @@ -20793,7 +20797,7 @@ cp_parser_exception_specification_opt (cp_parser* parser) #if 0 /* Enable this once a lot of code has transitioned to noexcept? */ - if (cxx_dialect >= cxx11 && !in_system_header) + if (cxx_dialect >= cxx11 && !in_system_header_at (input_location)) warning (OPT_Wdeprecated, "dynamic exception specifications are " "deprecated in C++0x; use %<noexcept%> instead"); #endif diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index bbf8f550f3e..b58c7556e2e 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -46,7 +46,6 @@ along with GCC; see the file COPYING3. If not see #include "timevar.h" #include "tree-iterator.h" #include "type-utils.h" -#include "gimple.h" #include "gimplify.h" /* The type of functions taking a tree, and some additional data, and @@ -5437,7 +5436,7 @@ unify_arg_conversion (bool explain_p, tree to_type, tree from_type, tree arg) { if (explain_p) - inform (EXPR_LOC_OR_HERE (arg), + inform (EXPR_LOC_OR_LOC (arg, input_location), " cannot convert %qE (type %qT) to type %qT", arg, from_type, to_type); return 1; @@ -5677,7 +5676,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) return NULL_TREE; expr = cxx_constant_value (expr); if (errorcount > errs || warningcount + werrorcount > warns) - inform (EXPR_LOC_OR_HERE (expr), + inform (EXPR_LOC_OR_LOC (expr, input_location), "in template argument for type %qT ", type); if (expr == error_mark_node) return NULL_TREE; @@ -8093,7 +8092,7 @@ push_tinst_level (tree d) new_level->decl = d; new_level->locus = input_location; new_level->errors = errorcount+sorrycount; - new_level->in_system_header_p = in_system_header; + new_level->in_system_header_p = in_system_header_at (input_location); new_level->next = current_tinst_level; current_tinst_level = new_level; @@ -8625,7 +8624,8 @@ apply_late_template_attributes (tree *decl_p, tree attributes, int attr_flags, pass it through tsubst. Attributes like mode, format, cleanup and several target specific attributes expect it unmodified. */ - else if (attribute_takes_identifier_p (get_attribute_name (t))) + else if (attribute_takes_identifier_p (get_attribute_name (t)) + && TREE_VALUE (t)) { tree chain = tsubst_expr (TREE_CHAIN (TREE_VALUE (t)), args, complain, @@ -14505,7 +14505,7 @@ tsubst_copy_and_build (tree t, fn = TREE_OPERAND (fn, 1); if (is_overloaded_fn (fn)) fn = get_first_fn (fn); - if (permerror (EXPR_LOC_OR_HERE (t), + if (permerror (EXPR_LOC_OR_LOC (t, input_location), "%qD was not declared in this scope, " "and no declarations were found by " "argument-dependent lookup at the point " @@ -14515,15 +14515,17 @@ tsubst_copy_and_build (tree t, /* Can't say anything more. */; else if (DECL_CLASS_SCOPE_P (fn)) { - inform (EXPR_LOC_OR_HERE (t), + location_t loc = EXPR_LOC_OR_LOC (t, + input_location); + inform (loc, "declarations in dependent base %qT are " "not found by unqualified lookup", DECL_CLASS_CONTEXT (fn)); if (current_class_ptr) - inform (EXPR_LOC_OR_HERE (t), + inform (loc, "use %<this->%D%> instead", function); else - inform (EXPR_LOC_OR_HERE (t), + inform (loc, "use %<%T::%D%> instead", current_class_name, function); } @@ -17209,8 +17211,9 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, /* Also deduce from the length of the initializer list. */ tree max = size_int (CONSTRUCTOR_NELTS (arg)); tree idx = compute_array_index_type (NULL_TREE, max, tf_none); - return unify_array_domain (tparms, targs, TYPE_DOMAIN (parm), - idx, explain_p); + if (TYPE_DOMAIN (parm) != NULL_TREE) + return unify_array_domain (tparms, targs, TYPE_DOMAIN (parm), + idx, explain_p); } /* If the std::initializer_list<T> deduction worked, replace the @@ -18807,7 +18810,7 @@ do_decl_instantiation (tree decl, tree storage) ; else if (storage == ridpointers[(int) RID_EXTERN]) { - if (!in_system_header && (cxx_dialect == cxx98)) + if (!in_system_header_at (input_location) && (cxx_dialect == cxx98)) pedwarn (input_location, OPT_Wpedantic, "ISO C++ 1998 forbids the use of %<extern%> on explicit " "instantiations"); @@ -18900,7 +18903,7 @@ do_type_instantiation (tree t, tree storage, tsubst_flags_t complain) if (storage != NULL_TREE) { - if (!in_system_header) + if (!in_system_header_at (input_location)) { if (storage == ridpointers[(int) RID_EXTERN]) { diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index cd5a91d2c60..d871c4dcea2 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -43,12 +43,11 @@ along with GCC; see the file COPYING3. If not see #include "diagnostic.h" #include "cgraph.h" #include "tree-iterator.h" -#include "vec.h" #include "target.h" -#include "gimple.h" +#include "pointer-set.h" +#include "hash-table.h" #include "gimplify.h" #include "bitmap.h" -#include "hash-table.h" #include "omp-low.h" static bool verify_constant (tree, bool, bool *, bool *); @@ -2146,7 +2145,7 @@ finish_call_expr (tree fn, vec<tree, va_gc> **args, bool disallow_virtual, && type_dependent_expression_p (current_class_ref))) { result = build_nt_call_vec (fn, *args); - SET_EXPR_LOCATION (result, EXPR_LOC_OR_HERE (fn)); + SET_EXPR_LOCATION (result, EXPR_LOC_OR_LOC (fn, input_location)); KOENIG_LOOKUP_P (result) = koenig_p; if (cfun) { @@ -2721,7 +2720,8 @@ begin_class_definition (tree t) before. */ if (! TYPE_ANONYMOUS_P (t)) { - struct c_fileinfo *finfo = get_fileinfo (input_filename); + struct c_fileinfo *finfo = \ + get_fileinfo (LOCATION_FILE (input_location)); CLASSTYPE_INTERFACE_ONLY (t) = finfo->interface_only; SET_CLASSTYPE_INTERFACE_UNKNOWN_X (t, finfo->interface_unknown); @@ -7596,6 +7596,11 @@ check_constexpr_ctor_body (tree last, tree list) break; if (TREE_CODE (t) == BIND_EXPR) { + if (BIND_EXPR_VARS (t)) + { + ok = false; + break; + } if (!check_constexpr_ctor_body (last, BIND_EXPR_BODY (t))) return false; else @@ -8266,7 +8271,7 @@ cxx_eval_call_expression (const constexpr_call *old_call, tree t, bool allow_non_constant, bool addr, bool *non_constant_p, bool *overflow_p) { - location_t loc = EXPR_LOC_OR_HERE (t); + location_t loc = EXPR_LOC_OR_LOC (t, input_location); tree fun = get_function_named_in_call (t); tree result; constexpr_call new_call = { NULL, NULL, NULL, 0 }; @@ -9647,7 +9652,7 @@ cxx_eval_constant_expression (const constexpr_call *call, tree t, && !integer_zerop (op)) { if (!allow_non_constant) - error_at (EXPR_LOC_OR_HERE (t), + error_at (EXPR_LOC_OR_LOC (t, input_location), "reinterpret_cast from integer to pointer"); *non_constant_p = true; return t; @@ -9693,7 +9698,7 @@ cxx_eval_constant_expression (const constexpr_call *call, tree t, case EXPR_STMT: case OFFSET_REF: if (!allow_non_constant) - error_at (EXPR_LOC_OR_HERE (t), + error_at (EXPR_LOC_OR_LOC (t, input_location), "expression %qE is not a constant-expression", t); *non_constant_p = true; break; @@ -9966,7 +9971,7 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags) { if (flags & tf_error) { - error_at (EXPR_LOC_OR_HERE (t), + error_at (EXPR_LOC_OR_LOC (t, input_location), "call to non-constexpr function %qD", fun); explain_invalid_constexpr_fn (fun); } @@ -10058,7 +10063,7 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags) && !integer_zerop (from)) { if (flags & tf_error) - error_at (EXPR_LOC_OR_HERE (t), + error_at (EXPR_LOC_OR_LOC (t, input_location), "reinterpret_cast from integer to pointer"); return false; } diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index a990a79bbb3..cb05633b24d 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -33,9 +33,9 @@ along with GCC; see the file COPYING3. If not see #include "convert.h" #include "cgraph.h" #include "splay-tree.h" -#include "gimple.h" -#include "gimplify.h" #include "hash-table.h" +#include "gimple-expr.h" +#include "gimplify.h" static tree bot_manip (tree *, int *, void *); static tree bot_replace (tree *, int *, void *); diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index c9ddbe9ba24..a4da037db33 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -31,7 +31,6 @@ along with GCC; see the file COPYING3. If not see #include "tree.h" #include "stor-layout.h" #include "varasm.h" -#include "gimple.h" #include "cp-tree.h" #include "flags.h" #include "diagnostic.h" @@ -1883,7 +1882,7 @@ decay_conversion (tree exp, tsubst_flags_t complain) { tree type; enum tree_code code; - location_t loc = EXPR_LOC_OR_HERE (exp); + location_t loc = EXPR_LOC_OR_LOC (exp, input_location); type = TREE_TYPE (exp); if (type == error_mark_node) @@ -2133,6 +2132,8 @@ static tree rationalize_conditional_expr (enum tree_code code, tree t, tsubst_flags_t complain) { + location_t loc = EXPR_LOC_OR_LOC (t, input_location); + /* For MIN_EXPR or MAX_EXPR, fold-const.c has arranged things so that the first operand is always the one to be used if both operands are equal, so we know what conditional expression this used to be. */ @@ -2145,8 +2146,8 @@ rationalize_conditional_expr (enum tree_code code, tree t, gcc_assert (!TREE_SIDE_EFFECTS (op0) && !TREE_SIDE_EFFECTS (op1)); return - build_conditional_expr (EXPR_LOC_OR_HERE (t), - build_x_binary_op (EXPR_LOC_OR_HERE (t), + build_conditional_expr (loc, + build_x_binary_op (loc, (TREE_CODE (t) == MIN_EXPR ? LE_EXPR : GE_EXPR), op0, TREE_CODE (op0), @@ -2159,7 +2160,7 @@ rationalize_conditional_expr (enum tree_code code, tree t, } return - build_conditional_expr (EXPR_LOC_OR_HERE (t), TREE_OPERAND (t, 0), + build_conditional_expr (loc, TREE_OPERAND (t, 0), cp_build_unary_op (code, TREE_OPERAND (t, 1), 0, complain), cp_build_unary_op (code, TREE_OPERAND (t, 2), 0, @@ -6042,8 +6043,9 @@ build_x_compound_expr_from_list (tree list, expr_list_kind exp, && !CONSTRUCTOR_IS_DIRECT_INIT (expr)) { if (complain & tf_error) - pedwarn (EXPR_LOC_OR_HERE (expr), 0, "list-initializer for " - "non-class type must not be parenthesized"); + pedwarn (EXPR_LOC_OR_LOC (expr, input_location), 0, + "list-initializer for non-class type must not " + "be parenthesized"); else return error_mark_node; } @@ -8101,7 +8103,7 @@ convert_for_assignment (tree type, tree rhs, && TREE_CODE (TREE_TYPE (rhs)) != BOOLEAN_TYPE && (complain & tf_warning)) { - location_t loc = EXPR_LOC_OR_HERE (rhs); + location_t loc = EXPR_LOC_OR_LOC (rhs, input_location); warning_at (loc, OPT_Wparentheses, "suggest parentheses around assignment used as truth value"); diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 0f3b01d9bc2..9fa201dca2c 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -896,11 +896,11 @@ check_narrowing (tree type, tree init) if (!ok) { if (cxx_dialect >= cxx11) - pedwarn (EXPR_LOC_OR_HERE (init), OPT_Wnarrowing, + pedwarn (EXPR_LOC_OR_LOC (init, input_location), OPT_Wnarrowing, "narrowing conversion of %qE from %qT to %qT inside { }", init, ftype, type); else - warning_at (EXPR_LOC_OR_HERE (init), OPT_Wnarrowing, + warning_at (EXPR_LOC_OR_LOC (init, input_location), OPT_Wnarrowing, "narrowing conversion of %qE from %qT to %qT inside { } " "is ill-formed in C++11", init, ftype, type); } diff --git a/gcc/cp/vtable-class-hierarchy.c b/gcc/cp/vtable-class-hierarchy.c index 32f9541e43d..b6637248951 100644 --- a/gcc/cp/vtable-class-hierarchy.c +++ b/gcc/cp/vtable-class-hierarchy.c @@ -118,7 +118,6 @@ along with GCC; see the file COPYING3. If not see #include "cgraph.h" #include "tree-iterator.h" #include "vtable-verify.h" -#include "gimple.h" #include "gimplify.h" #include "stringpool.h" #include "stor-layout.h" |