diff options
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/cp/call.c | 6 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 3 | ||||
-rw-r--r-- | gcc/cp/decl.c | 3 | ||||
-rw-r--r-- | gcc/cp/parser.c | 18 | ||||
-rw-r--r-- | gcc/cp/pt.c | 2 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 3 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 13 |
8 files changed, 40 insertions, 20 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bde12e50..6cda4e7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,15 @@ +2019-12-05 Paolo Carlini <paolo.carlini@oracle.com> + + * typeck2.c (build_functional_cast): Add location_t parameter + and use it. + * cp-tree.h: Update declaration. + * parser.c (cp_parser_functional_cast): Adjust call. + * call.c (build_op_delete_call): Likewise. + (build_new_method_call_1): Likewise. + * decl.c (check_initializer): Likewise. + * pt.c (tsubst_copy_and_build): Likewise. + * semantics.c (finish_compound_literal): Likewise. + 2019-12-04 David Edelsohn <dje.gcc@gmail.com> * cp-gimplify.c: Include tm_p.h. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 5e9523e..92d3d68 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -6933,7 +6933,8 @@ build_op_delete_call (enum tree_code code, tree addr, tree size, rtype = cv_unqualified (rtype); rtype = TYPE_POINTER_TO (rtype); addr = cp_convert (rtype, oaddr, complain); - destroying = build_functional_cast (destroying, NULL_TREE, + destroying = build_functional_cast (input_location, + destroying, NULL_TREE, complain); } @@ -9997,7 +9998,8 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args, basetype, name)) inform (input_location, "for a function-style cast, remove the " "redundant %<::%D%>", name); - call = build_functional_cast (basetype, build_tree_list_vec (user_args), + call = build_functional_cast (input_location, basetype, + build_tree_list_vec (user_args), complain); return call; } diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 89828d9..a392be6 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -7681,7 +7681,8 @@ extern tree build_scoped_ref (tree, tree, tree *); extern tree build_x_arrow (location_t, tree, tsubst_flags_t); extern tree build_m_component_ref (tree, tree, tsubst_flags_t); -extern tree build_functional_cast (tree, tree, tsubst_flags_t); +extern tree build_functional_cast (location_t, tree, tree, + tsubst_flags_t); extern tree add_exception_specifier (tree, tree, tsubst_flags_t); extern tree merge_exception_specifiers (tree, tree); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 481c798..7897327 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -6764,7 +6764,8 @@ check_initializer (tree decl, tree init, int flags, vec<tree, va_gc> **cleanups) if (CLASS_TYPE_P (type) && (!init || TREE_CODE (init) == TREE_LIST)) { - init = build_functional_cast (type, init, tf_none); + init = build_functional_cast (input_location, type, + init, tf_none); if (TREE_CODE (init) == TARGET_EXPR) TARGET_EXPR_DIRECT_INIT_P (init) = true; } diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 10ff016..05be440 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -29268,8 +29268,17 @@ cp_parser_functional_cast (cp_parser* parser, tree type) release_tree_vector (vec); } - cast = build_functional_cast (type, expression_list, + /* Create a location of the form: + float(i) + ^~~~~~~~ + with caret == start at the start of the type name, + finishing at the closing paren. */ + location_t combined_loc = make_location (start_loc, start_loc, + parser->lexer); + cast = build_functional_cast (combined_loc, type, expression_list, tf_warning_or_error); + cast.set_location (combined_loc); + /* [expr.const]/1: In an integral constant expression "only type conversions to integral or enumeration type can be used". */ if (TREE_CODE (type) == TYPE_DECL) @@ -29280,13 +29289,6 @@ cp_parser_functional_cast (cp_parser* parser, tree type) NIC_CONSTRUCTOR)) return error_mark_node; - /* Create a location of the form: - float(i) - ^~~~~~~~ - with caret == start at the start of the type name, - finishing at the closing paren. */ - location_t combined_loc = make_location (start_loc, start_loc, parser->lexer); - cast.set_location (combined_loc); return cast; } diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 5088dc1..0990297 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -19017,7 +19017,7 @@ tsubst_copy_and_build (tree t, switch (TREE_CODE (t)) { case CAST_EXPR: - r = build_functional_cast (type, op, complain); + r = build_functional_cast (input_location, type, op, complain); break; case REINTERPRET_CAST_EXPR: r = build_reinterpret_cast (type, op, complain); diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 17de39e..83a7891 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2929,7 +2929,8 @@ finish_compound_literal (tree type, tree compound_literal, that it came from T{} rather than T({}). */ CONSTRUCTOR_IS_DIRECT_INIT (compound_literal) = 1; compound_literal = build_tree_list (NULL_TREE, compound_literal); - return build_functional_cast (type, compound_literal, complain); + return build_functional_cast (input_location, type, + compound_literal, complain); } if (TREE_CODE (type) == ARRAY_TYPE diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 7fda626..ca321f3 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -2228,7 +2228,8 @@ build_m_component_ref (tree datum, tree component, tsubst_flags_t complain) /* Return a tree node for the expression TYPENAME '(' PARMS ')'. */ tree -build_functional_cast (tree exp, tree parms, tsubst_flags_t complain) +build_functional_cast (location_t loc, tree exp, tree parms, + tsubst_flags_t complain) { /* This is either a call to a constructor, or a C cast in C++'s `functional' notation. */ @@ -2254,7 +2255,7 @@ build_functional_cast (tree exp, tree parms, tsubst_flags_t complain) if (TREE_CODE (type) == ARRAY_TYPE) { if (complain & tf_error) - error ("functional cast to array type %qT", type); + error_at (loc, "functional cast to array type %qT", type); return error_mark_node; } @@ -2263,7 +2264,7 @@ build_functional_cast (tree exp, tree parms, tsubst_flags_t complain) if (!CLASS_PLACEHOLDER_TEMPLATE (anode)) { if (complain & tf_error) - error ("invalid use of %qT", anode); + error_at (loc, "invalid use of %qT", anode); return error_mark_node; } else if (!parms) @@ -2276,8 +2277,8 @@ build_functional_cast (tree exp, tree parms, tsubst_flags_t complain) if (type == error_mark_node) { if (complain & tf_error) - error ("cannot deduce template arguments for %qT from %<()%>", - anode); + error_at (loc, "cannot deduce template arguments " + "for %qT from %<()%>", anode); return error_mark_node; } } @@ -2296,7 +2297,7 @@ build_functional_cast (tree exp, tree parms, tsubst_flags_t complain) if (TYPE_REF_P (type) && !parms) { if (complain & tf_error) - error ("invalid value-initialization of reference type"); + error_at (loc, "invalid value-initialization of reference type"); return error_mark_node; } |