+2009-06-12 Aldy Hernandez <aldyh@redhat.com>
+
+ * tree-pretty-print.c (dump_generic_node): Dump column numbers.
+ * gimple-pretty-print.c (dump_gimple_stmt): Same.
+ * gimplify.c (gimplify_modify_expr): Set location for GIMPLE_ASSIGNs
+ created.
+ * c-parser.c (c_parser_binary_expression): Use current column while
+ building binary operations.
+ * common.opt (fshow-column): Enable by default.
+ * tree-vrp.c (check_array_ref): Use warning_at.
+ (check_array_bounds): Use location from call back if expr has no
+ location.
+ * tree.h: Add location argument to maybe_fold_*.
+ * tree-ssa-ccp.c (ccp_fold): Pass location to maybe_fold_*.
+ (maybe_fold_offset_to_array_ref): Add location argument and use it.
+ (maybe_fold_offset_to_component_ref): Same.
+ (maybe_fold_offset_to_reference): Same.
+ (maybe_fold_offset_to_address): Same.
+ (maybe_fold_stmt_indirect): Same.
+ (maybe_fold_stmt_addition): Same.
+ (fold_stmt_r): Pass location to maybe_fold_*.
+ (fold_gimple_assign): Same.
+ * c-tree.h: Add location argument to finish_decl,
+ default_function_array_conversion, store_init_value.
+ * c-decl.c (define_label): Use error_at.
+ (c_make_fname_decl): Pass location to finish_decl.
+ (finish_decl): New location argument.
+ (build_compound_literal): Pass location to store_init_value.
+ (grokdeclarator): Pass location to finish_decl.
+ (grokfield): Same.
+ * c-typeck.c (array_to_pointer_conversion): New location argument.
+ (function_to_pointer_conversion): Same.
+ (default_function_array_conversion): Same.
+ (parser_build_unary_op): Pass location to overflow_warning.
+ (parser_build_binary_op): Same. Use warning_at.
+ (build_unary_op): Pass location to array_to_pointer_conversion.
+ (build_c_cast): Pass location to digest_init.
+ (build_modify_expr): New location argument.
+ (convert_for_assignment): Same.
+ (store_init_value): Same.
+ (digest_init): Same.
+ (output_init_element): Pass location to digest_init and
+ array_to_pointer_conversion.
+ (c_finish_return): Pass location to convert_for_assignment.
+ * gimplify.c (gimplify_conversion): Pass location to
+ maybe_fold_offset_to_address.
+ * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Pass location
+ to maybe_fold_stmt_addition.
+ * c-omp.c (c_finish_omp_atomic): Pass new location to
+ build_modify_expr.
+ (c_finish_omp_for): Same.
+ * c-common.c (overflow_warning): New argument.
+ * c-common.h: New argument to build_modify_expr, overflow_warning.
+ * c-parser.c (c_parser_declaration_or_fndef): Pass location to
+ finish_decl.
+ (c_parser_initializer): Pass location to
+ default_function_array_conversion.
+ (c_parser_initelt): Same.
+ (c_parser_initval): Same.
+ (c_parser_asm_operands): Same.
+ (c_parser_expr_no_commas): Same. Pass location to build_modify_expr.
+ (c_parser_conditional_expression): Same.
+ (c_parser_binary_expression): Add location info to stack. Use it.
+ (c_parser_unary_expression): Pass location to
+ default_function_array_conversion, parser_build_unary_op,
+ build_indirect_ref, c_parser_postfix_expression_after_primary.
+ (c_parser_postfix_expression_after_primary): New location argument.
+ Use it.
+ (c_parser_expression_conv): Pass location to
+ default_function_array_conversion.
+ (c_parser_expr_list): Same.
+ (c_parser_omp_atomic): Same.
+ (c_parser_omp_for_loop): Same.
+ * c-tree.h: (struct c_declarator): Add comment to id_loc.
+ (build_array_declarator): New argument.
+ * c-decl.c (build_array_declarator): Add location argument.
+ (grokdeclarator): Set id_loc for cdk_array.
+ * c-parser.c (c_parser_direct_declarator_inner): Pass location to
+ build_array_declarator.
+ * tree.c (build_omp_clause): Add location argument.
+ * tree.h (OMP_CLAUSE_HAS_LOCATION): New macro.
+ (OMP_CLAUSE_LOCATION): New macro.
+ (struct tree_omp_clause): Add location field.
+ (build_omp_clause): Add argument.
+ * testsuite/gcc.dg/gomp/for-1.c: Fix column.
+ * cp/pt.c (tsubst_omp_for_iterator): Pass location to
+ build_omp_clause.
+ * cp/parser.c (cp_parser_omp_var_list_no_open): Same.
+ (cp_parser_omp_clause_collapse): Same.
+ (cp_parser_omp_clause_default): Same.
+ (cp_parser_omp_clause_if): Same.
+ (cp_parser_omp_clause_nowait): Same.
+ (cp_parser_omp_clause_num_threads): Same.
+ (cp_parser_omp_clause_ordered): Same.
+ (cp_parser_omp_clause_schedule): Same.
+ (cp_parser_omp_clause_untied): Same.
+ (cp_parser_omp_for_loop): Same.
+ (cp_parser_omp_parallel): Pass location to c_split_parallel_clauses.
+ * c-tree.h (c_start_case): Add location argument.
+ (c_process_expr_stmt): Same.
+ (c_finish_goto_*): Same.
+ * tree-parloops.c (initialize_reductions): Pass location to
+ build_omp_clause.
+ (create_parallel_loop): Same.
+ * fortran/trans-openmp.c (gfc_trans_omp_variable_list): Same.
+ (gfc_trans_omp_reduction_list): Same.
+ (gfc_trans_omp_clauses): Same.
+ (gfc_trans_omp_do): Same.
+ * c-typeck.c (c_finish_goto_label): Same.
+ (c_finish_goto_ptr): New location argument.
+ (c_start_case): Same.
+ (emit_side_effect_warnings): Same.
+ (c_process_expr_stmt): Same.
+ (c_finish_stmt_expr): Same.
+ (c_finish_omp_clauses): Use error_at instead of error.
+ * gimplify.c (gimplify_adjust_omp_clauses_1): Pass location to
+ build_omp_clause.
+ * c-omp.c (c_split_parallel_clauses): New location argument.
+ * tree-nested.c (convert_nonlocal_reference_stmt): Pass location
+ to build_omp_clause.
+ (convert_local_reference_stmt): Same.
+ (convert_gimple_call): Same.
+ * c-common.h (c_split_parallel_clauses): New argument.
+ * c-parser.c (c_parser_statement_after_labels): Pass location to
+ c_finish_goto_label.
+ (c_parser_switch_statement): Pass location to c_start_case.
+ (c_parser_for_statement): Pass location to c_finish_expr_stmt,
+ and c_process_expr_stmt.
+ (c_parser_omp_variable_list): Add location argument.
+ (c_parser_omp_clause_collapse): Pass location to
+ build_omp_clause.
+ (c_parser_omp_clause_default): Same.
+ (c_parser_omp_clause_if): Same.
+ (c_parser_omp_clause_num_threads): Same.
+ (-c_parser_omp_clause_ordered): Same.
+ (c_parser_omp_clause_reduction): Pass location to
+ c_parser_omp_variable_list.
+ (c_parser_omp_clause_schedule): Pass location to build_omp_clause.
+ (c_parser_omp_clause_untied): Same.
+ (c_parser_omp_for_loop): Pass location to c_process_expr_stmt.
+ (c_parser_omp_parallel): Pass location to
+ c_split_parallel_clauses.
+
+ * c-tree.h (check_for_loop_decls, undeclared_variable,
+ build_component_ref, build_array_ref, build_external_ref,
+ c_expr_sizeof_expr, c_expr_sizeof_type, parser_build_unary_op,
+ build_conditional_expr, build_compound_expr, c_cast_expr,
+ build_c_cast, build_asm_expr, c_end_compound_stmt, c_finish_stmt_expr,
+ c_finish_return, c_finish_omp_parallel, c_finish_omp_task): New
+ argument.
+ * c-semantics.c (build_stmt): Same.
+ (build_case_label): Same.
+ * c-decl.c (c_finish_incomplete_decl): Pass location on down.
+ (undeclared_variable): New argument.
+ (make_label): Same.
+ (lookup_label): Pass location on down.
+ (define_label): Same.
+ (finish_decl): Same.
+ (build_compound_literal): Same.
+ (finish_struct): Same.
+ (finish_function): Do not set location here.
+ (check_for_loop_decls): New argument.
+ * tree.c (save_expr): Set location.
+ (build_empty_stmt): New argument.
+ * tree.h (build_empty_stmt): New argument to build_empty_stmt.
+ (CAN_HAVE_LOCATION_P): Make sure we have a non empty node.
+ * builtins.c (gimplify_va_arg_expr): Use locations.
+ (expand_builtin_sync_operation): Same.
+ * c-typeck.c (build_component_ref): New argument.
+ (build_array_ref): Same.
+ (build_external_ref): Same.
+ (c_expr_sizeof_expr): Same.
+ (c_expr_sizeof_type): Same.
+ (parser_build_unary_op): Same.
+ (build_conditional_expr): Same.
+ (build_compound_expr): Pass location on down.
+ (build_compound_expr): New argument.
+ (build_c_cast): Same.
+ (c_cast_expr): Same.
+ (build_asm_expr): Same.
+ (c_finish_return): Same.
+ (c_process_expr_stmt): Pass location on down.
+ (c_finish_stmt_expr): New argument.
+ (push_clenaup): Same.
+ (c_finish_omp_parallel): Same.
+ (c_finish_omp_task): Same.
+ * gimplify.c (gimplify_call_expr): Pass location on down.
+ * c-omp.c (c_finish_omp_master): New argument.
+ (c_finish_omp_critical): Same.
+ (c_finish_omp_ordered): Same.
+ (c_finish_omp_barrier): Same.
+ (-c_finish_omp_taskwait): Same.
+ (c_finish_omp_atomic): Same.
+ (c_finish_omp_flush): Same.
+ * tree-inline.c (copy_tree_body_r): Pass location on down.
+ (inline_forbidden_p): Remove use of input_location.
+ * c-gimplify.c (c_build_bind_expr): New argument.
+ * c-common.c (c_common_truthvalue_conversion): Pass location on down.
+ (c_sizeof_or_alignof_type): New argument.
+ (c_alignof_expr): Same.
+ (build_va_arg): Same.
+ (c_add_case_label): Same.
+ * c-common.h (c_sizeof_or_alignof_type, c_alignof_expr,
+ c_sizeof, c_alignof, build_va_arg, build_stmt, build_case_label,
+ c_build_bind_expr, objc_build_selector_expr, objc_build_throw_stmt,
+ c_finish_omp_master, c_finish_omp_critical, c_finish_omp_ordered,
+ c_finish_omp_barrier, c_finish_omp_atomic, c_finish_omp_flush,
+ c_finish_omp_taskwait, c_finish_omp_for, c_split_parallel_clauses):
+ New argument.
+ * stub-objc.c (objc_build_selector_expr): Same.
+ (objc_build_throw_stmt): Same.
+ * c-parser.c (c_parser_declaration_or_fndef): Pass location on down.
+ (c_parser_initelt): Same.
+ (c_parser_compound_statement): Same.
+ (c_parser_compound_statement_nostart): Same.
+ (c_parser_label): Same.
+ (c_parser_statement_after_labels): Same.
+ (c_parser_if_body): Same.
+ (c_parser_else_body): Same.
+ (c_parser_if_statement): Same.
+ (c_parser_switch_statement): Same.
+ (c_parser_while_statement): Same.
+ (c_parser_do_statement): Same.
+ (c_parser_for_statement): Same.
+ (c_parser_asm_statement): Same.
+ (c_parser_conditional_expression): Same.
+ (c_parser_binary_expression): Same.
+ (c_parser_cast_expression): Same.
+ (c_parser_unary_expression): Same.
+ (c_parser_sizeof_expression): Same.
+ (c_parser_alignof_expression): Same.
+ (c_parser_postfix_expression): Same.
+ (c_parser_expression): Same.
+ (c_parser_objc_receiver): Same.
+ (c_parser_omp_variable_list): Same.
+ (c_parser_omp_structured_block): Same.
+ (c_parser_omp_atomic): New argument.
+ (c_parser_omp_barrier): Same.
+ (c_parser_omp_critical): Same.
+ (c_parser_omp_flush): Pass location on down.
+ (c_parser_omp_for_loop): New argument.
+ (c_parser_omp_for): Same.
+ (c_parser_omp_master): Same.
+ (c_parser_omp_ordered): Same.
+ (c_parser_omp_sections_scope): Same.
+ (c_parser_omp_sections): Same.
+ (c_parser_omp_parallel): Same.
+ (c_parser_omp_single): Same.
+ (c_parser_omp_task): Same.
+ (c_parser_omp_taskwait): Pass location on down.
+ (c_parser_omp_construct): Same.
+ (c_parser_omp_threadprivate): Same.
+ * dwarf2asm.c, targhooks.c, optabs.c, tree.c, tree.h, target.h,
+ builtins.c, omp-low.c, cgraphunit.c, tree-call-cdce.c,
+ tree-ssa-alias.c, gimple-low.c, c-tree.h, expr.c, tree-parloops.c,
+ c-decl.c, tree-eh.c, langhooks.c, function.c, stor-layout.c,
+ c-typeck.c, gimplify.c, c-pragma.c, expmed.c, except.c, coverage.c,
+ emit-rtl.c, cfgexpand.c, tree-mudflap.c, varasm.c, tree-nested.c,
+ rtl.h, tree-inline.c, tree-profile.c, c-common.c, c-common.h,
+ tree-switch-conversion.c, tree-cfg.c, ipa-struct-reorg.c, c-parser.c,
+ config/i386/i386.c, stmt.c:
+ Add location argument to the following function definitions and/or
+ function calls: build_decl, objcp_start_struct, objcp_finish_struct,
+ start_struct, finish_struct, PUSH_FIELD, create_artificial_label,
+ cp_make_fname_decl, pushtag, implicitly_declare, c_make_fname_decl,
+ build_compound_literal, parser_xref_tag, resolve_overloaded_builtin,
+ do_case, c_finish_bc_stmt, build_compound_literal,
+ build_function_call.
+ * c-decl.c (build_compound_literal): Add location argument.
+ Make all diagnostic calls use location.
+ (start_struct): Same.
+ (finish_struct): Same.
+ (start_enum): Same.
+ (build_enumerator): Same.
+ (start_function): Same.
+ (grokdeclarator): Make all diagnostic calls use location.
+ (store_parm_decls_oldstyle): Same.
+ * c-typeck.c (build_function_call): Add location argument.
+ Make all diagnostic calls use location.
+ (do_case): Same.
+ (c_finish_bc_stmt): Same.
+ * tree-nested.c (get_trampoline_type): Add argument.
+ Pass location to build_decl.
+ (lookup_tramp_for_decl): Pass location to get_trampoline_type.
+ * rtl.h (RTL_LOCATION): New.
+ * c-common.c (c_add_case_label): Add location argument.
+ Make all diagnostic calls use location.
+ * c-common.h: Add location argument to make_fname_decl, do_case,
+ c_add_case_label, build_function_call, resolve_overloaded_builtin.
+ * c-parser.c (c_parser_enum_specifier): Rename ident_loc to enum_loc.
+ Set it appropriately for every case. Pass enum_loc to start_enum
+ call. Pass value_loc first to build_enumerator. Pass enum_loc to
+ parser_xref_tag.
+ (c_parser_struct_or_union_specifier): Save location. Use it for
+ start_struct, finish_struct, and parser_xref_tag.
+
2009-06-12 Ian Lance Taylor <iant@google.com>
* fold-const.c (fold_unary): Rename local variable and to
tree valist = TREE_OPERAND (*expr_p, 0);
tree type = TREE_TYPE (*expr_p);
tree t;
+ location_t loc = EXPR_HAS_LOCATION (*expr_p) ? EXPR_LOCATION (*expr_p) :
+ UNKNOWN_LOCATION;
/* Verify that valist is of the proper type. */
have_va_type = TREE_TYPE (valist);
if (have_va_type == NULL_TREE)
{
- error ("first argument to %<va_arg%> not of type %<va_list%>");
+ error_at (loc, "first argument to %<va_arg%> not of type %<va_list%>");
return GS_ERROR;
}
/* Unfortunately, this is merely undefined, rather than a constraint
violation, so we cannot make this an error. If this call is never
executed, the program is still strictly conforming. */
- warned = warning (0, "%qT is promoted to %qT when passed through %<...%>",
- type, promoted_type);
+ warned = warning_at (loc, 0,
+ "%qT is promoted to %qT when passed through %<...%>",
+ type, promoted_type);
if (!gave_help && warned)
{
gave_help = true;
- inform (input_location, "(so you should pass %qT not %qT to %<va_arg%>)",
- promoted_type, type);
+ inform (loc, "(so you should pass %qT not %qT to %<va_arg%>)",
+ promoted_type, type);
}
/* We can, however, treat "undefined" any way we please.
Call abort to encourage the user to fix the program. */
if (warned)
- inform (input_location, "if this code is reached, the program will abort");
+ inform (loc, "if this code is reached, the program will abort");
/* Before the abort, allow the evaluation of the va_list
expression to exit or longjmp. */
gimplify_and_add (valist, pre_p);
gcc_unreachable ();
}
- decl = build_decl (FUNCTION_DECL, id, TREE_TYPE (fn));
+ decl = build_decl (DECL_SOURCE_LOCATION (fn),
+ FUNCTION_DECL, id, TREE_TYPE (fn));
DECL_EXTERNAL (decl) = 1;
TREE_PUBLIC (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
{
rtx val, mem;
enum machine_mode old_mode;
+ location_t loc = EXPR_LOCATION (exp);
if (code == NOT && warn_sync_nand)
{
break;
fndecl = implicit_built_in_decls[BUILT_IN_FETCH_AND_NAND_N];
- inform (input_location,
- "%qD changed semantics in GCC 4.4", fndecl);
+ inform (loc, "%qD changed semantics in GCC 4.4", fndecl);
warned_f_a_n = true;
break;
break;
fndecl = implicit_built_in_decls[BUILT_IN_NAND_AND_FETCH_N];
- inform (input_location,
- "%qD changed semantics in GCC 4.4", fndecl);
+ inform (loc, "%qD changed semantics in GCC 4.4", fndecl);
warned_n_a_f = true;
break;
type names and storage classes. It is indexed by a RID_... value. */
tree *ridpointers;
-tree (*make_fname_decl) (tree, int);
+tree (*make_fname_decl) (location_t, tree, int);
/* Nonzero means the expression being parsed will never be evaluated.
This is a count, since unevaluated expressions can nest. */
input_location = UNKNOWN_LOCATION;
stmts = push_stmt_list ();
- decl = (*make_fname_decl) (id, fname_vars[ix].pretty);
+ decl = (*make_fname_decl) (loc, id, fname_vars[ix].pretty);
stmts = pop_stmt_list (stmts);
if (!IS_EMPTY_STMT (stmts))
saved_function_name_decls
already overflowed. */
void
-overflow_warning (tree value)
+overflow_warning (location_t loc, tree value)
{
if (skip_evaluation) return;
switch (TREE_CODE (value))
{
case INTEGER_CST:
- warning (OPT_Woverflow, "integer overflow in expression");
+ warning_at (loc, OPT_Woverflow, "integer overflow in expression");
break;
case REAL_CST:
- warning (OPT_Woverflow, "floating point overflow in expression");
+ warning_at (loc, OPT_Woverflow,
+ "floating point overflow in expression");
break;
case FIXED_CST:
- warning (OPT_Woverflow, "fixed-point overflow in expression");
+ warning_at (loc, OPT_Woverflow, "fixed-point overflow in expression");
break;
case VECTOR_CST:
- warning (OPT_Woverflow, "vector overflow in expression");
+ warning_at (loc, OPT_Woverflow, "vector overflow in expression");
break;
case COMPLEX_CST:
if (TREE_CODE (TREE_REALPART (value)) == INTEGER_CST)
- warning (OPT_Woverflow, "complex integer overflow in expression");
+ warning_at (loc, OPT_Woverflow,
+ "complex integer overflow in expression");
else if (TREE_CODE (TREE_REALPART (value)) == REAL_CST)
- warning (OPT_Woverflow, "complex floating point overflow in expression");
+ warning_at (loc, OPT_Woverflow,
+ "complex floating point overflow in expression");
break;
default:
{
tree decl;
- decl = build_decl (TYPE_DECL, get_identifier (name), type);
+ decl = build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, get_identifier (name), type);
DECL_ARTIFICIAL (decl) = 1;
if (!TYPE_NAME (type))
TYPE_NAME (type) = decl;
case ORDERED_EXPR: case UNORDERED_EXPR:
if (TREE_TYPE (expr) == truthvalue_type_node)
return expr;
- return build2 (TREE_CODE (expr), truthvalue_type_node,
+ expr = build2 (TREE_CODE (expr), truthvalue_type_node,
TREE_OPERAND (expr, 0), TREE_OPERAND (expr, 1));
+ goto ret;
case TRUTH_ANDIF_EXPR:
case TRUTH_ORIF_EXPR:
case TRUTH_XOR_EXPR:
if (TREE_TYPE (expr) == truthvalue_type_node)
return expr;
- return build2 (TREE_CODE (expr), truthvalue_type_node,
- c_common_truthvalue_conversion (location,
- TREE_OPERAND (expr, 0)),
- c_common_truthvalue_conversion (location,
- TREE_OPERAND (expr, 1)));
+ expr = build2 (TREE_CODE (expr), truthvalue_type_node,
+ c_common_truthvalue_conversion (location,
+ TREE_OPERAND (expr, 0)),
+ c_common_truthvalue_conversion (location,
+ TREE_OPERAND (expr, 1)));
+ goto ret;
case TRUTH_NOT_EXPR:
if (TREE_TYPE (expr) == truthvalue_type_node)
return expr;
- return build1 (TREE_CODE (expr), truthvalue_type_node,
- c_common_truthvalue_conversion (location,
- TREE_OPERAND (expr, 0)));
+ expr = build1 (TREE_CODE (expr), truthvalue_type_node,
+ c_common_truthvalue_conversion (location,
+ TREE_OPERAND (expr, 0)));
+ goto ret;
case ERROR_MARK:
return expr;
}
if (TREE_SIDE_EFFECTS (inner))
- return build2 (COMPOUND_EXPR, truthvalue_type_node,
- inner, truthvalue_true_node);
+ {
+ expr = build2 (COMPOUND_EXPR, truthvalue_type_node,
+ inner, truthvalue_true_node);
+ goto ret;
+ }
else
return truthvalue_true_node;
}
case COMPLEX_EXPR:
- return build_binary_op (EXPR_LOCATION (expr),
+ expr = build_binary_op (EXPR_LOCATION (expr),
(TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1))
? TRUTH_OR_EXPR : TRUTH_ORIF_EXPR),
c_common_truthvalue_conversion (location,
c_common_truthvalue_conversion (location,
TREE_OPERAND (expr, 1)),
0);
+ goto ret;
case NEGATE_EXPR:
case ABS_EXPR:
/* These don't change whether an object is zero or nonzero, but
we can't ignore them if their second arg has side-effects. */
if (TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1)))
- return build2 (COMPOUND_EXPR, truthvalue_type_node,
- TREE_OPERAND (expr, 1),
- c_common_truthvalue_conversion
- (location, TREE_OPERAND (expr, 0)));
+ {
+ expr = build2 (COMPOUND_EXPR, truthvalue_type_node,
+ TREE_OPERAND (expr, 1),
+ c_common_truthvalue_conversion
+ (location, TREE_OPERAND (expr, 0)));
+ goto ret;
+ }
else
return c_common_truthvalue_conversion (location,
TREE_OPERAND (expr, 0));
case COND_EXPR:
/* Distribute the conversion into the arms of a COND_EXPR. */
if (c_dialect_cxx ())
- return fold_build3 (COND_EXPR, truthvalue_type_node,
- TREE_OPERAND (expr, 0),
- c_common_truthvalue_conversion (location,
- TREE_OPERAND (expr,
- 1)),
- c_common_truthvalue_conversion (location,
- TREE_OPERAND (expr,
- 2)));
+ {
+ expr = fold_build3 (COND_EXPR, truthvalue_type_node,
+ TREE_OPERAND (expr, 0),
+ c_common_truthvalue_conversion (location,
+ TREE_OPERAND (expr,
+ 1)),
+ c_common_truthvalue_conversion (location,
+ TREE_OPERAND (expr,
+ 2)));
+ goto ret;
+ }
else
- /* Folding will happen later for C. */
- return build3 (COND_EXPR, truthvalue_type_node,
- TREE_OPERAND (expr, 0),
- c_common_truthvalue_conversion (location,
- TREE_OPERAND (expr, 1)),
- c_common_truthvalue_conversion (location,
- TREE_OPERAND (expr, 2)));
+ {
+ /* Folding will happen later for C. */
+ expr = build3 (COND_EXPR, truthvalue_type_node,
+ TREE_OPERAND (expr, 0),
+ c_common_truthvalue_conversion (location,
+ TREE_OPERAND (expr, 1)),
+ c_common_truthvalue_conversion (location,
+ TREE_OPERAND (expr, 2)));
+ goto ret;
+ }
CASE_CONVERT:
/* Don't cancel the effect of a CONVERT_EXPR from a REFERENCE_TYPE,
if (TREE_CODE (TREE_TYPE (expr)) == COMPLEX_TYPE)
{
tree t = c_save_expr (expr);
- return (build_binary_op
+ expr = (build_binary_op
(EXPR_LOCATION (expr),
(TREE_SIDE_EFFECTS (expr)
? TRUTH_OR_EXPR : TRUTH_ORIF_EXPR),
(location,
build_unary_op (location, IMAGPART_EXPR, t, 0)),
0));
+ goto ret;
}
if (TREE_CODE (TREE_TYPE (expr)) == FIXED_POINT_TYPE)
(TREE_TYPE (expr))));
return build_binary_op (location, NE_EXPR, expr, fixed_zero_node, 1);
}
+ else
+ return build_binary_op (location, NE_EXPR, expr, integer_zero_node, 1);
- return build_binary_op (location, NE_EXPR, expr, integer_zero_node, 1);
+ ret:
+ protected_set_expr_location (expr, location);
+ return expr;
}
\f
static void def_builtin_1 (enum built_in_function fncode,
return -1;
}
\f
-/* Compute the value of 'sizeof (TYPE)' or '__alignof__ (TYPE)', where the
- second parameter indicates which OPERATOR is being applied. The COMPLAIN
- flag controls whether we should diagnose possibly ill-formed
- constructs or not. */
+/* Compute the value of 'sizeof (TYPE)' or '__alignof__ (TYPE)', where
+ the second parameter indicates which OPERATOR is being applied.
+ The COMPLAIN flag controls whether we should diagnose possibly
+ ill-formed constructs or not. LOC is the location of the SIZEOF or
+ TYPEOF operator. */
tree
-c_sizeof_or_alignof_type (tree type, bool is_sizeof, int complain)
+c_sizeof_or_alignof_type (location_t loc,
+ tree type, bool is_sizeof, int complain)
{
const char *op_name;
tree value = NULL;
if (is_sizeof)
{
if (complain && (pedantic || warn_pointer_arith))
- pedwarn (input_location, pedantic ? OPT_pedantic : OPT_Wpointer_arith,
+ pedwarn (loc, pedantic ? OPT_pedantic : OPT_Wpointer_arith,
"invalid application of %<sizeof%> to a function type");
else if (!complain)
return error_mark_node;
{
if (type_code == VOID_TYPE
&& complain && (pedantic || warn_pointer_arith))
- pedwarn (input_location, pedantic ? OPT_pedantic : OPT_Wpointer_arith,
+ pedwarn (loc, pedantic ? OPT_pedantic : OPT_Wpointer_arith,
"invalid application of %qs to a void type", op_name);
else if (!complain)
return error_mark_node;
else if (!COMPLETE_TYPE_P (type))
{
if (complain)
- error ("invalid application of %qs to incomplete type %qT ",
- op_name, type);
+ error_at (loc, "invalid application of %qs to incomplete type %qT ",
+ op_name, type);
value = size_zero_node;
}
else
/* Implement the __alignof keyword: Return the minimum required
alignment of EXPR, measured in bytes. For VAR_DECLs,
FUNCTION_DECLs and FIELD_DECLs return DECL_ALIGN (which can be set
- from an "aligned" __attribute__ specification). */
+ from an "aligned" __attribute__ specification). LOC is the
+ location of the ALIGNOF operator. */
tree
-c_alignof_expr (tree expr)
+c_alignof_expr (location_t loc, tree expr)
{
tree t;
else if (TREE_CODE (expr) == COMPONENT_REF
&& DECL_C_BIT_FIELD (TREE_OPERAND (expr, 1)))
{
- error ("%<__alignof%> applied to a bit-field");
+ error_at (loc, "%<__alignof%> applied to a bit-field");
t = size_one_node;
}
else if (TREE_CODE (expr) == COMPONENT_REF
if (thisalign > bestalign)
best = t, bestalign = thisalign;
}
- return c_alignof (TREE_TYPE (TREE_TYPE (best)));
+ return c_alignof (loc, TREE_TYPE (TREE_TYPE (best)));
}
else
- return c_alignof (TREE_TYPE (expr));
+ return c_alignof (loc, TREE_TYPE (expr));
return fold_convert (size_type_node, t);
}
/* These are types that c_common_type_for_size and
c_common_type_for_mode use. */
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, NULL_TREE,
intQI_type_node));
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, NULL_TREE,
intHI_type_node));
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, NULL_TREE,
intSI_type_node));
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, NULL_TREE,
intDI_type_node));
#if HOST_BITS_PER_WIDE_INT >= 64
if (targetm.scalar_mode_supported_p (TImode))
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL,
get_identifier ("__int128_t"),
intTI_type_node));
#endif
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, NULL_TREE,
unsigned_intQI_type_node));
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, NULL_TREE,
unsigned_intHI_type_node));
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, NULL_TREE,
unsigned_intSI_type_node));
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, NULL_TREE,
unsigned_intDI_type_node));
#if HOST_BITS_PER_WIDE_INT >= 64
if (targetm.scalar_mode_supported_p (TImode))
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL,
get_identifier ("__uint128_t"),
unsigned_intTI_type_node));
#endif
/* Create the widest literal types. */
widest_integer_literal_type_node
= make_signed_type (HOST_BITS_PER_WIDE_INT * 2);
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, NULL_TREE,
widest_integer_literal_type_node));
widest_unsigned_literal_type_node
= make_unsigned_type (HOST_BITS_PER_WIDE_INT * 2);
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, NULL_TREE,
widest_unsigned_literal_type_node));
/* `unsigned long' is the standard type for sizeof.
}
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL,
get_identifier ("complex int"),
complex_integer_type_node));
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL,
get_identifier ("complex float"),
complex_float_type_node));
- lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
+ lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL,
get_identifier ("complex double"),
complex_double_type_node));
lang_hooks.decls.pushdecl
- (build_decl (TYPE_DECL, get_identifier ("complex long double"),
+ (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, get_identifier ("complex long double"),
complex_long_double_type_node));
if (c_dialect_cxx ())
unsigned_ptrdiff_type_node = c_common_unsigned_type (ptrdiff_type_node);
lang_hooks.decls.pushdecl
- (build_decl (TYPE_DECL, get_identifier ("__builtin_va_list"),
+ (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, get_identifier ("__builtin_va_list"),
va_list_type_node));
#ifdef TARGET_ENUM_VA_LIST
{
for (l = 0; TARGET_ENUM_VA_LIST (l, &pname, &ptype); ++l)
{
lang_hooks.decls.pushdecl
- (build_decl (TYPE_DECL, get_identifier (pname),
+ (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, get_identifier (pname),
ptype));
}
}
tree
-build_va_arg (tree expr, tree type)
+build_va_arg (location_t loc, tree expr, tree type)
{
- return build1 (VA_ARG_EXPR, type, expr);
+ expr = build1 (VA_ARG_EXPR, type, expr);
+ SET_EXPR_LOCATION (expr, loc);
+ return expr;
}
return tree_int_cst_compare ((tree) k1, (tree) k2);
}
-/* Process a case label for the range LOW_VALUE ... HIGH_VALUE. If
- LOW_VALUE and HIGH_VALUE are both NULL_TREE then this case label is
- actually a `default' label. If only HIGH_VALUE is NULL_TREE, then
- case label was declared using the usual C/C++ syntax, rather than
- the GNU case range extension. CASES is a tree containing all the
- case ranges processed so far; COND is the condition for the
- switch-statement itself. Returns the CASE_LABEL_EXPR created, or
- ERROR_MARK_NODE if no CASE_LABEL_EXPR is created. */
+/* Process a case label, located at LOC, for the range LOW_VALUE
+ ... HIGH_VALUE. If LOW_VALUE and HIGH_VALUE are both NULL_TREE
+ then this case label is actually a `default' label. If only
+ HIGH_VALUE is NULL_TREE, then case label was declared using the
+ usual C/C++ syntax, rather than the GNU case range extension.
+ CASES is a tree containing all the case ranges processed so far;
+ COND is the condition for the switch-statement itself. Returns the
+ CASE_LABEL_EXPR created, or ERROR_MARK_NODE if no CASE_LABEL_EXPR
+ is created. */
tree
-c_add_case_label (splay_tree cases, tree cond, tree orig_type,
+c_add_case_label (location_t loc, splay_tree cases, tree cond, tree orig_type,
tree low_value, tree high_value)
{
tree type;
splay_tree_node node;
/* Create the LABEL_DECL itself. */
- label = create_artificial_label ();
+ label = create_artificial_label (loc);
/* If there was an error processing the switch condition, bail now
before we get more confused. */
|| (high_value && TREE_TYPE (high_value)
&& POINTER_TYPE_P (TREE_TYPE (high_value))))
{
- error ("pointers are not permitted as case values");
+ error_at (loc, "pointers are not permitted as case values");
goto error_out;
}
/* Case ranges are a GNU extension. */
if (high_value)
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"range expressions in switch statements are non-standard");
type = TREE_TYPE (cond);
if (tree_int_cst_equal (low_value, high_value))
high_value = NULL_TREE;
else if (!tree_int_cst_lt (low_value, high_value))
- warning (0, "empty range specified");
+ warning_at (loc, 0, "empty range specified");
}
/* See if the case is in range of the type of the original testing
if (high_value)
{
- error ("duplicate (or overlapping) case value");
- error ("%Jthis is the first entry overlapping that value", duplicate);
+ error_at (loc, "duplicate (or overlapping) case value");
+ error_at (DECL_SOURCE_LOCATION (duplicate),
+ "this is the first entry overlapping that value");
}
else if (low_value)
{
- error ("duplicate case value") ;
- error ("%Jpreviously used here", duplicate);
+ error_at (loc, "duplicate case value") ;
+ error_at (DECL_SOURCE_LOCATION (duplicate), "previously used here");
}
else
{
- error ("multiple default labels in one switch");
- error ("%Jthis is the first default label", duplicate);
+ error_at (loc, "multiple default labels in one switch");
+ error_at (DECL_SOURCE_LOCATION (duplicate),
+ "this is the first default label");
}
goto error_out;
}
/* Add a CASE_LABEL to the statement-tree. */
- case_label = add_stmt (build_case_label (low_value, high_value, label));
+ case_label = add_stmt (build_case_label (loc, low_value, high_value, label));
/* Register this case label in the splay tree. */
splay_tree_insert (cases,
(splay_tree_key) low_value,
that just leads to duplicates and thence to failure later on. */
if (!cases->root)
{
- tree t = create_artificial_label ();
- add_stmt (build_stmt (LABEL_EXPR, t));
+ tree t = create_artificial_label (loc);
+ add_stmt (build_stmt (loc, LABEL_EXPR, t));
}
return error_mark_node;
}
function should be called immediately after parsing the call expression
before surrounding code has committed to the type of the expression.
+ LOC is the location of the builtin call.
+
FUNCTION is the DECL that has been invoked; it is known to be a builtin.
PARAMS is the argument list for the call. The return value is non-null
when expansion is complete, and null if normal processing should
continue. */
tree
-resolve_overloaded_builtin (tree function, VEC(tree,gc) *params)
+resolve_overloaded_builtin (location_t loc, tree function, VEC(tree,gc) *params)
{
enum built_in_function orig_code = DECL_FUNCTION_CODE (function);
switch (DECL_BUILT_IN_CLASS (function))
break;
case BUILT_IN_MD:
if (targetm.resolve_overloaded_builtin)
- return targetm.resolve_overloaded_builtin (function, params);
+ return targetm.resolve_overloaded_builtin (loc, function, params);
else
return NULL_TREE;
default:
return error_mark_node;
first_param = VEC_index (tree, params, 0);
- result = build_function_call_vec (new_function, params, NULL);
+ result = build_function_call_vec (loc, new_function, params, NULL);
if (orig_code != BUILT_IN_BOOL_COMPARE_AND_SWAP_N
&& orig_code != BUILT_IN_LOCK_RELEASE_N)
result = sync_resolve_return (first_param, result);
extern tree pushdecl_top_level (tree);
extern tree pushdecl (tree);
extern tree build_modify_expr (location_t, tree, tree, enum tree_code,
- tree, tree);
+ location_t, tree, tree);
extern tree build_indirect_ref (location_t, tree, const char *);
extern int c_expand_decl (tree);
TYPE_DEP indicates whether it depends on type of the function or not
(i.e. __PRETTY_FUNCTION__). */
-extern tree (*make_fname_decl) (tree, int);
+extern tree (*make_fname_decl) (location_t, tree, int);
extern tree identifier_global_value (tree);
extern void record_builtin_type (enum rid, const char *, tree);
extern tree c_save_expr (tree);
extern tree c_common_truthvalue_conversion (location_t, tree);
extern void c_apply_type_quals_to_decl (int, tree);
-extern tree c_sizeof_or_alignof_type (tree, bool, int);
-extern tree c_alignof_expr (tree);
+extern tree c_sizeof_or_alignof_type (location_t, tree, bool, int);
+extern tree c_alignof_expr (location_t, tree);
/* Print an error message for invalid operands to arith operation CODE.
NOP_EXPR is used as a special case (see truthvalue_conversion). */
extern void binary_op_error (location_t, enum tree_code, tree, tree);
extern bool strict_aliasing_warning (tree, tree, tree);
extern void warnings_for_convert_and_check (tree, tree, tree);
extern tree convert_and_check (tree, tree);
-extern void overflow_warning (tree);
+extern void overflow_warning (location_t, tree);
extern void warn_logical_operator (location_t, enum tree_code, tree,
enum tree_code, tree, enum tree_code, tree);
extern void check_main_parameter_types (tree decl);
extern void clear_float_const_decimal64 (void);
extern bool float_const_decimal64_p (void);
-#define c_sizeof(T) c_sizeof_or_alignof_type (T, true, 1)
-#define c_alignof(T) c_sizeof_or_alignof_type (T, false, 1)
+#define c_sizeof(LOC, T) c_sizeof_or_alignof_type (LOC, T, true, 1)
+#define c_alignof(LOC, T) c_sizeof_or_alignof_type (LOC, T, false, 1)
/* Subroutine of build_binary_op, used for certain operations. */
extern tree shorten_binary_op (tree result_type, tree op0, tree op1, bool bitwise);
extern void set_compound_literal_name (tree decl);
-extern tree build_va_arg (tree, tree);
+extern tree build_va_arg (location_t, tree, tree);
extern unsigned int c_common_init_options (unsigned int, const char **);
extern bool c_common_post_options (const char **);
#define CLEAR_DECL_C_BIT_FIELD(NODE) \
(DECL_LANG_FLAG_4 (FIELD_DECL_CHECK (NODE)) = 0)
-extern tree do_case (tree, tree);
-extern tree build_stmt (enum tree_code, ...);
-extern tree build_case_label (tree, tree, tree);
+extern tree do_case (location_t, tree, tree);
+extern tree build_stmt (location_t, enum tree_code, ...);
+extern tree build_case_label (location_t, tree, tree, tree);
/* These functions must be defined by each front-end which implements
a variant of the C language. They are used in c-common.c. */
extern int case_compare (splay_tree_key, splay_tree_key);
-extern tree c_add_case_label (splay_tree, tree, tree, tree, tree);
+extern tree c_add_case_label (location_t, splay_tree, tree, tree, tree, tree);
extern void c_do_switch_warnings (splay_tree, location_t, tree, tree);
-extern tree build_function_call (tree, tree);
+extern tree build_function_call (location_t, tree, tree);
-extern tree build_function_call_vec (tree, VEC(tree,gc) *, VEC(tree,gc) *);
+extern tree build_function_call_vec (location_t, tree,
+ VEC(tree,gc) *, VEC(tree,gc) *);
-extern tree resolve_overloaded_builtin (tree, VEC(tree,gc) *);
+extern tree resolve_overloaded_builtin (location_t, tree, VEC(tree,gc) *);
extern tree finish_label_address_expr (tree, location_t);
/* In c-gimplify.c */
extern void c_genericize (tree);
extern int c_gimplify_expr (tree *, gimple_seq *, gimple_seq *);
-extern tree c_build_bind_expr (tree, tree);
+extern tree c_build_bind_expr (location_t, tree, tree);
/* In c-pch.c */
extern void pch_init (void);
extern void objc_declare_protocols (tree);
extern tree objc_build_message_expr (tree);
extern tree objc_finish_message_expr (tree, tree, tree);
-extern tree objc_build_selector_expr (tree);
+extern tree objc_build_selector_expr (location_t, tree);
extern tree objc_build_protocol_expr (tree);
extern tree objc_build_encode_expr (tree);
extern tree objc_build_string_object (tree);
extern void objc_finish_method_definition (tree);
extern void objc_add_instance_variable (tree);
extern tree objc_build_keyword_decl (tree, tree, tree);
-extern tree objc_build_throw_stmt (tree);
+extern tree objc_build_throw_stmt (location_t, tree);
extern void objc_begin_try_stmt (location_t, tree);
extern tree objc_finish_try_stmt (void);
extern void objc_begin_catch_clause (tree);
extern bool check_missing_format_attribute (tree, tree);
/* In c-omp.c */
-extern tree c_finish_omp_master (tree);
-extern tree c_finish_omp_critical (tree, tree);
-extern tree c_finish_omp_ordered (tree);
-extern void c_finish_omp_barrier (void);
-extern tree c_finish_omp_atomic (enum tree_code, tree, tree);
-extern void c_finish_omp_flush (void);
-extern void c_finish_omp_taskwait (void);
+extern tree c_finish_omp_master (location_t, tree);
+extern tree c_finish_omp_critical (location_t, tree, tree);
+extern tree c_finish_omp_ordered (location_t, tree);
+extern void c_finish_omp_barrier (location_t);
+extern tree c_finish_omp_atomic (location_t, enum tree_code, tree, tree);
+extern void c_finish_omp_flush (location_t);
+extern void c_finish_omp_taskwait (location_t);
extern tree c_finish_omp_for (location_t, tree, tree, tree, tree, tree, tree);
-extern void c_split_parallel_clauses (tree, tree *, tree *);
+extern void c_split_parallel_clauses (location_t, tree, tree *, tree *);
extern enum omp_clause_default_kind c_omp_predetermined_sharing (tree);
/* Not in c-omp.c; provided by the front end. */
/* Forward declarations. */
static tree lookup_name_in_scope (tree, struct c_scope *);
-static tree c_make_fname_decl (tree, int);
+static tree c_make_fname_decl (location_t, tree, int);
static tree grokdeclarator (const struct c_declarator *,
struct c_declspecs *,
enum decl_context, bool, tree *, tree *, tree *,
&& !DECL_EXTERNAL (decl)
&& TYPE_DOMAIN (type) == 0)
{
- warning (0, "array %q+D assumed to have one element", decl);
+ warning_at (DECL_SOURCE_LOCATION (decl),
+ 0, "array %q+D assumed to have one element", decl);
complete_array_type (&TREE_TYPE (decl), NULL_TREE, true);
context = current_function_decl;
else if (scope == file_scope)
{
- tree file_decl = build_decl (TRANSLATION_UNIT_DECL, 0, 0);
+ tree file_decl = build_decl (UNKNOWN_LOCATION,
+ TRANSLATION_UNIT_DECL, 0, 0);
TREE_CHAIN (file_decl) = all_translation_units;
all_translation_units = file_decl;
context = file_decl;
\f
/* Push a definition or a declaration of struct, union or enum tag "name".
"type" should be the type node.
- We assume that the tag "name" is not already defined.
+ We assume that the tag "name" is not already defined, and has a location
+ of LOC.
Note that the definition may really be just a forward reference.
In that case, the TYPE_SIZE will be zero. */
static void
-pushtag (tree name, tree type, location_t loc)
+pushtag (location_t loc, tree name, tree type)
{
/* Record the identifier as the type's name if it has none. */
if (name && !TYPE_NAME (type))
us a convenient place to record the "scope start" address for the
tagged type. */
- TYPE_STUB_DECL (type) = pushdecl (build_decl (TYPE_DECL, NULL_TREE, type));
+ TYPE_STUB_DECL (type) = pushdecl (build_decl (loc,
+ TYPE_DECL, NULL_TREE, type));
/* An approximation for now, so we can tell this is a function-scope tag.
This will be updated in pop_scope. */
}
}
-/* Generate an implicit declaration for identifier FUNCTIONID as a
+/* Generate an implicit declaration for identifier FUNCTIONID at LOC as a
function of type int (). */
tree
-implicitly_declare (tree functionid)
+implicitly_declare (location_t loc, tree functionid)
{
struct c_binding *b;
tree decl = 0;
(TREE_TYPE (decl)));
if (!comptypes (newtype, TREE_TYPE (decl)))
{
- warning (0, "incompatible implicit declaration of built-in"
- " function %qD", decl);
+ warning_at (loc, 0, "incompatible implicit declaration of "
+ "built-in function %qD", decl);
newtype = TREE_TYPE (decl);
}
}
{
if (!comptypes (newtype, TREE_TYPE (decl)))
{
- error ("incompatible implicit declaration of function %qD",
- decl);
+ error_at (loc, "incompatible implicit declaration of function %qD", decl);
locate_old_decl (decl);
}
}
}
/* Not seen before. */
- decl = build_decl (FUNCTION_DECL, functionid, default_function_type);
+ decl = build_decl (loc, FUNCTION_DECL, functionid, default_function_type);
DECL_EXTERNAL (decl) = 1;
TREE_PUBLIC (decl) = 1;
C_DECL_IMPLICIT (decl) = 1;
in an appropriate scope, which will suppress further errors for the
same identifier. The error message should be given location LOC. */
void
-undeclared_variable (tree id, location_t loc)
+undeclared_variable (location_t loc, tree id)
{
static bool already = false;
struct c_scope *scope;
LABEL_DECL with all the proper frills. */
static tree
-make_label (tree name, location_t location)
+make_label (location_t location, tree name)
{
- tree label = build_decl (LABEL_DECL, name, void_type_node);
+ tree label = build_decl (location, LABEL_DECL, name, void_type_node);
DECL_CONTEXT (label) = current_function_decl;
DECL_MODE (label) = VOIDmode;
- DECL_SOURCE_LOCATION (label) = location;
return label;
}
}
/* No label binding for that identifier; make one. */
- label = make_label (name, input_location);
+ label = make_label (input_location, name);
/* Ordinary labels go in the current function scope. */
bind (name, label, current_function_scope,
return b->decl;
}
- label = make_label (name, input_location);
+ label = make_label (input_location, name);
C_DECLARED_LABEL_FLAG (label) = 1;
/* Declared labels go in the current scope. */
|| (DECL_CONTEXT (label) != current_function_decl
&& C_DECLARED_LABEL_FLAG (label))))
{
- error ("%Hduplicate label %qD", &location, label);
+ error_at (location, "duplicate label %qD", label);
locate_old_decl (label);
return 0;
}
but not defined. Update its location to point to this
definition. */
if (C_DECL_UNDEFINABLE_STMT_EXPR (label))
- error ("%Jjump into statement expression", label);
+ error_at (location, "jump into statement expression");
if (C_DECL_UNDEFINABLE_VM (label))
- error ("%Jjump into scope of identifier with variably modified type",
- label);
+ error_at (location,
+ "jump into scope of identifier with variably modified type");
DECL_SOURCE_LOCATION (label) = location;
}
else
{
/* No label binding for that identifier; make one. */
- label = make_label (name, location);
+ label = make_label (location, name);
/* Ordinary labels go in the current function scope. */
bind (name, label, current_function_scope,
}
if (!in_system_header && lookup_name (name))
- warning (OPT_Wtraditional, "%Htraditional C lacks a separate namespace "
- "for labels, identifier %qE conflicts", &location, name);
+ warning_at (location, OPT_Wtraditional,
+ "traditional C lacks a separate namespace "
+ "for labels, identifier %qE conflicts", name);
nlist_se = XOBNEW (&parser_obstack, struct c_label_list);
nlist_se->next = label_context_stack_se->labels_def;
truthvalue_false_node = integer_zero_node;
/* Even in C99, which has a real boolean type. */
- pushdecl (build_decl (TYPE_DECL, get_identifier ("_Bool"),
+ pushdecl (build_decl (UNKNOWN_LOCATION, TYPE_DECL, get_identifier ("_Bool"),
boolean_type_node));
input_location = save_loc;
start_fname_decls ();
}
-/* Create the VAR_DECL for __FUNCTION__ etc. ID is the name to give the
- decl, NAME is the initialization string and TYPE_DEP indicates whether
- NAME depended on the type of the function. As we don't yet implement
- delayed emission of static data, we mark the decl as emitted
- so it is not placed in the output. Anything using it must therefore pull
- out the STRING_CST initializer directly. FIXME. */
+/* Create the VAR_DECL at LOC for __FUNCTION__ etc. ID is the name to
+ give the decl, NAME is the initialization string and TYPE_DEP
+ indicates whether NAME depended on the type of the function. As we
+ don't yet implement delayed emission of static data, we mark the
+ decl as emitted so it is not placed in the output. Anything using
+ it must therefore pull out the STRING_CST initializer directly.
+ FIXME. */
static tree
-c_make_fname_decl (tree id, int type_dep)
+c_make_fname_decl (location_t loc, tree id, int type_dep)
{
const char *name = fname_as_string (type_dep);
tree decl, type, init;
build_index_type (size_int (length)));
type = c_build_qualified_type (type, TYPE_QUAL_CONST);
- decl = build_decl (VAR_DECL, id, type);
+ decl = build_decl (loc, VAR_DECL, id, type);
TREE_STATIC (decl) = 1;
TREE_READONLY (decl) = 1;
/*invisible=*/false, /*nested=*/false, UNKNOWN_LOCATION);
}
- finish_decl (decl, init, NULL_TREE, NULL_TREE);
+ finish_decl (decl, loc, init, NULL_TREE, NULL_TREE);
return decl;
}
if (t == 0)
{
t = make_node (code);
- pushtag (name, t, input_location);
+ pushtag (input_location, name, t);
}
}
}
return quals;
}
-/* Construct an array declarator. EXPR is the expression inside [],
- or NULL_TREE. QUALS are the type qualifiers inside the [] (to be
- applied to the pointer to which a parameter array is converted).
- STATIC_P is true if "static" is inside the [], false otherwise.
- VLA_UNSPEC_P is true if the array is [*], a VLA of unspecified
- length which is nevertheless a complete type, false otherwise. The
- field for the contained declarator is left to be filled in by
- set_array_declarator_inner. */
+/* Construct an array declarator. LOC is the location of the
+ beginning of the array (usually the opening brace). EXPR is the
+ expression inside [], or NULL_TREE. QUALS are the type qualifiers
+ inside the [] (to be applied to the pointer to which a parameter
+ array is converted). STATIC_P is true if "static" is inside the
+ [], false otherwise. VLA_UNSPEC_P is true if the array is [*], a
+ VLA of unspecified length which is nevertheless a complete type,
+ false otherwise. The field for the contained declarator is left to
+ be filled in by set_array_declarator_inner. */
struct c_declarator *
-build_array_declarator (tree expr, struct c_declspecs *quals, bool static_p,
+build_array_declarator (location_t loc,
+ tree expr, struct c_declspecs *quals, bool static_p,
bool vla_unspec_p)
{
struct c_declarator *declarator = XOBNEW (&parser_obstack,
struct c_declarator);
+ declarator->id_loc = loc;
declarator->kind = cdk_array;
declarator->declarator = 0;
declarator->u.array.dimen = expr;
if (!flag_isoc99)
{
if (static_p || quals != NULL)
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C90 does not support %<static%> or type "
"qualifiers in parameter array declarators");
if (vla_unspec_p)
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C90 does not support %<[*]%> array declarators");
}
if (vla_unspec_p)
if (!current_scope->parm_flag)
{
/* C99 6.7.5.2p4 */
- error ("%<[*]%> not allowed in other than function prototype scope");
+ error_at (loc, "%<[*]%> not allowed in other than "
+ "function prototype scope");
declarator->u.array.vla_unspec_p = false;
return NULL;
}
install its initial value.
If ORIGTYPE is not NULL_TREE, it is the original type of INIT.
If the length of an array type is not known before,
- it must be determined now, from the initial value, or it is an error. */
+ it must be determined now, from the initial value, or it is an error.
+
+ INIT_LOC is the location of the initial value. */
void
-finish_decl (tree decl, tree init, tree origtype, tree asmspec_tree)
+finish_decl (tree decl, location_t init_loc, tree init,
+ tree origtype, tree asmspec_tree)
{
tree type;
bool was_incomplete = (DECL_SIZE (decl) == 0);
init = 0;
if (init)
- store_init_value (decl, init, origtype);
+ store_init_value (init_loc, decl, init, origtype);
if (c_dialect_objc () && (TREE_CODE (decl) == VAR_DECL
|| TREE_CODE (decl) == FUNCTION_DECL
add_stmt (bind);
BIND_EXPR_BODY (bind) = push_stmt_list ();
}
- add_stmt (build_stmt (DECL_EXPR, decl));
+ add_stmt (build_stmt (DECL_SOURCE_LOCATION (decl),
+ DECL_EXPR, decl));
}
}
{
if (!DECL_FILE_SCOPE_P (decl)
&& variably_modified_type_p (TREE_TYPE (decl), NULL_TREE))
- add_stmt (build_stmt (DECL_EXPR, decl));
+ add_stmt (build_stmt (DECL_SOURCE_LOCATION (decl), DECL_EXPR, decl));
rest_of_decl_compilation (decl, DECL_FILE_SCOPE_P (decl), 0);
}
cleanup = build_unary_op (input_location, ADDR_EXPR, decl, 0);
vec = VEC_alloc (tree, gc, 1);
VEC_quick_push (tree, vec, cleanup);
- cleanup = build_function_call_vec (cleanup_decl, vec, NULL);
+ cleanup = build_function_call_vec (DECL_SOURCE_LOCATION (decl),
+ cleanup_decl, vec, NULL);
VEC_free (tree, gc, vec);
/* Don't warn about decl unused; the cleanup uses it. */
decl = pushdecl (decl);
- finish_decl (decl, NULL_TREE, NULL_TREE, NULL_TREE);
+ finish_decl (decl, input_location, NULL_TREE, NULL_TREE, NULL_TREE);
}
/* Mark all the parameter declarations to date as forward decls.
\f
/* Build a COMPOUND_LITERAL_EXPR. TYPE is the type given in the compound
literal, which may be an incomplete array type completed by the
- initializer; INIT is a CONSTRUCTOR that initializes the compound
+ initializer; INIT is a CONSTRUCTOR at LOC that initializes the compound
literal. NON_CONST is true if the initializers contain something
that cannot occur in a constant expression. */
tree
-build_compound_literal (tree type, tree init, bool non_const)
+build_compound_literal (location_t loc, tree type, tree init, bool non_const)
{
/* We do not use start_decl here because we have a type, not a declarator;
and do not use finish_decl because the decl should be stored inside
if (type == error_mark_node)
return error_mark_node;
- decl = build_decl (VAR_DECL, NULL_TREE, type);
+ decl = build_decl (loc, VAR_DECL, NULL_TREE, type);
DECL_EXTERNAL (decl) = 0;
TREE_PUBLIC (decl) = 0;
TREE_STATIC (decl) = (current_scope == file_scope);
TREE_USED (decl) = 1;
TREE_TYPE (decl) = type;
TREE_READONLY (decl) = TYPE_READONLY (type);
- store_init_value (decl, init, NULL_TREE);
+ store_init_value (loc, decl, init, NULL_TREE);
if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type))
{
if (type == error_mark_node || !COMPLETE_TYPE_P (type))
return error_mark_node;
- stmt = build_stmt (DECL_EXPR, decl);
+ stmt = build_stmt (DECL_SOURCE_LOCATION (decl), DECL_EXPR, decl);
complit = build1 (COMPOUND_LITERAL_EXPR, type, stmt);
TREE_SIDE_EFFECTS (complit) = 1;
is valid for C++. */
void
-check_compound_literal_type (struct c_type_name *type_name, location_t loc)
+check_compound_literal_type (location_t loc, struct c_type_name *type_name)
{
if (warn_cxx_compat && type_name->specs->tag_defined_p)
warning_at (loc, OPT_Wc___compat,
bool bitfield = width != NULL;
tree element_type;
struct c_arg_info *arg_info = 0;
+ location_t loc = UNKNOWN_LOCATION;
const char *errmsg;
tree expr_dummy;
bool expr_const_operands_dummy;
while (decl)
switch (decl->kind)
{
- case cdk_function:
case cdk_array:
+ loc = decl->id_loc;
+ /* FALL THRU. */
+
+ case cdk_function:
case cdk_pointer:
funcdef_syntax = (decl->kind == cdk_function);
decl = decl->declarator;
break;
case cdk_id:
+ loc = decl->id_loc;
if (decl->u.id)
name = decl->u.id;
decl = 0;
&& variably_modified_type_p (type, NULL_TREE))
{
if (name)
- error ("variably modified %qE at file scope", name);
+ error_at (loc, "variably modified %qE at file scope", name);
else
- error ("variably modified field at file scope");
+ error_at (loc, "variably modified field at file scope");
type = integer_type_node;
}
else
{
if (name)
- pedwarn_c99 (input_location, flag_isoc99 ? 0 : OPT_Wimplicit_int,
+ pedwarn_c99 (loc, flag_isoc99 ? 0 : OPT_Wimplicit_int,
"type defaults to %<int%> in declaration of %qE",
name);
else
if (pedantic && !flag_isoc99)
{
if (constp > 1)
- pedwarn (input_location, OPT_pedantic, "duplicate %<const%>");
+ pedwarn (loc, OPT_pedantic, "duplicate %<const%>");
if (restrictp > 1)
- pedwarn (input_location, OPT_pedantic, "duplicate %<restrict%>");
+ pedwarn (loc, OPT_pedantic, "duplicate %<restrict%>");
if (volatilep > 1)
- pedwarn (input_location, OPT_pedantic, "duplicate %<volatile%>");
+ pedwarn (loc, OPT_pedantic, "duplicate %<volatile%>");
}
if (!flag_gen_aux_info && (TYPE_QUALS (element_type)))
type = TYPE_MAIN_VARIANT (type);
|| storage_class == csc_typedef))
{
if (storage_class == csc_auto)
- pedwarn (input_location,
+ pedwarn (loc,
(current_scope == file_scope) ? 0 : OPT_pedantic,
"function definition declared %<auto%>");
if (storage_class == csc_register)
- error ("function definition declared %<register%>");
+ error_at (loc, "function definition declared %<register%>");
if (storage_class == csc_typedef)
- error ("function definition declared %<typedef%>");
+ error_at (loc, "function definition declared %<typedef%>");
if (threadp)
- error ("function definition declared %<__thread%>");
+ error_at (loc, "function definition declared %<__thread%>");
threadp = false;
if (storage_class == csc_auto
|| storage_class == csc_register
{
case FIELD:
if (name)
- error ("storage class specified for structure field %qE",
- name);
+ error_at (loc, "storage class specified for structure "
+ "field %qE", name);
else
- error ("storage class specified for structure field");
+ error_at (loc, "storage class specified for structure field");
break;
case PARM:
if (name)
- error ("storage class specified for parameter %qE", name);
+ error_at (loc, "storage class specified for parameter %qE",
+ name);
else
- error ("storage class specified for unnamed parameter");
+ error_at (loc, "storage class specified for unnamed parameter");
break;
default:
- error ("storage class specified for typename");
+ error_at (loc, "storage class specified for typename");
break;
}
storage_class = csc_none;
/* It is fine to have 'extern const' when compiling at C
and C++ intersection. */
if (!(warn_cxx_compat && constp))
- warning (0, "%qE initialized and declared %<extern%>", name);
+ warning_at (loc, 0, "%qE initialized and declared %<extern%>",
+ name);
}
else
- error ("%qE has both %<extern%> and initializer", name);
+ error_at (loc, "%qE has both %<extern%> and initializer", name);
}
else if (current_scope == file_scope)
{
if (storage_class == csc_auto)
- error ("file-scope declaration of %qE specifies %<auto%>", name);
+ error_at (loc, "file-scope declaration of %qE specifies %<auto%>",
+ name);
if (pedantic && storage_class == csc_register)
pedwarn (input_location, OPT_pedantic,
"file-scope declaration of %qE specifies %<register%>", name);
else
{
if (storage_class == csc_extern && funcdef_flag)
- error ("nested function %qE declared %<extern%>", name);
+ error_at (loc, "nested function %qE declared %<extern%>", name);
else if (threadp && storage_class == csc_none)
{
- error ("function-scope %qE implicitly auto and declared "
- "%<__thread%>",
- name);
+ error_at (loc, "function-scope %qE implicitly auto and declared "
+ "%<__thread%>",
+ name);
threadp = false;
}
}
/* Only the innermost declarator (making a parameter be of
array type which is converted to pointer type)
may have static or type qualifiers. */
- error ("static or type qualifiers in non-parameter array declarator");
+ error_at (loc, "static or type qualifiers in non-parameter array declarator");
array_ptr_quals = TYPE_UNQUALIFIED;
array_ptr_attrs = NULL_TREE;
array_parm_static = 0;
if (VOID_TYPE_P (type))
{
if (name)
- error ("declaration of %qE as array of voids", name);
+ error_at (loc, "declaration of %qE as array of voids", name);
else
- error ("declaration of type name as array of voids");
+ error_at (loc, "declaration of type name as array of voids");
type = error_mark_node;
}
if (TREE_CODE (type) == FUNCTION_TYPE)
{
if (name)
- error ("declaration of %qE as array of functions", name);
+ error_at (loc, "declaration of %qE as array of functions",
+ name);
else
- error ("declaration of type name as array of functions");
+ error_at (loc, "declaration of type name as array of "
+ "functions");
type = error_mark_node;
}
if (pedantic && !in_system_header && flexible_array_type_p (type))
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"invalid use of structure with flexible array member");
if (size == error_mark_node)
if (!INTEGRAL_TYPE_P (TREE_TYPE (size)))
{
if (name)
- error ("size of array %qE has non-integer type", name);
+ error_at (loc, "size of array %qE has non-integer type",
+ name);
else
- error ("size of unnamed array has non-integer type");
+ error_at (loc,
+ "size of unnamed array has non-integer type");
size = integer_one_node;
}
if (pedantic && size_maybe_const && integer_zerop (size))
{
if (name)
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C forbids zero-size array %qE", name);
else
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C forbids zero-size array");
}
if (tree_int_cst_sgn (size) < 0)
{
if (name)
- error ("size of array %qE is negative", name);
+ error_at (loc, "size of array %qE is negative", name);
else
- error ("size of unnamed array is negative");
+ error_at (loc, "size of unnamed array is negative");
size = integer_one_node;
}
/* Handle a size folded to an integer constant but
else if ((decl_context == NORMAL || decl_context == FIELD)
&& current_scope == file_scope)
{
- error ("variably modified %qE at file scope", name);
+ error_at (loc, "variably modified %qE at file scope", name);
size = integer_one_node;
}
else
&& TREE_OVERFLOW (itype))
{
if (name)
- error ("size of array %qE is too large", name);
+ error_at (loc, "size of array %qE is too large",
+ name);
else
- error ("size of unnamed array is too large");
+ error_at (loc, "size of unnamed array is too large");
type = error_mark_node;
continue;
}
}
if (flexible_array_member
&& pedantic && !flag_isoc99 && !in_system_header)
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C90 does not support flexible array members");
/* ISO C99 Flexible array members are effectively
/* Complain about arrays of incomplete types. */
if (!COMPLETE_TYPE_P (type))
{
- error ("array type has incomplete element type");
+ error_at (loc, "array type has incomplete element type");
type = error_mark_node;
}
else
|| array_ptr_attrs != NULL_TREE
|| array_parm_static))
{
- error ("static or type qualifiers in non-parameter array declarator");
+ error_at (loc, "static or type qualifiers in non-parameter array declarator");
array_ptr_quals = TYPE_UNQUALIFIED;
array_ptr_attrs = NULL_TREE;
array_parm_static = 0;
if (TREE_CODE (type) == FUNCTION_TYPE)
{
if (name)
- error ("%qE declared as function returning a function",
- name);
+ error_at (loc, "%qE declared as function returning a "
+ "function", name);
else
- error ("type name declared as function "
- "returning a function");
+ error_at (loc, "type name declared as function "
+ "returning a function");
type = integer_type_node;
}
if (TREE_CODE (type) == ARRAY_TYPE)
{
if (name)
- error ("%qE declared as function returning an array", name);
+ error_at (loc, "%qE declared as function returning an array",
+ name);
else
- error ("type name declared as function returning an array");
+ error_at (loc, "type name declared as function returning "
+ "an array");
type = integer_type_node;
}
errmsg = targetm.invalid_return_type (type);
function definitions in ISO C; GCC used to used
them for noreturn functions. */
if (VOID_TYPE_P (type) && really_funcdef)
- pedwarn (input_location, 0,
+ pedwarn (loc, 0,
"function definition has qualified void return type");
else
- warning (OPT_Wignored_qualifiers,
+ warning_at (loc, OPT_Wignored_qualifiers,
"type qualifiers ignored on function return type");
type = c_build_qualified_type (type, type_quals);
if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
&& type_quals)
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C forbids qualified function types");
if (type_quals)
type = c_build_qualified_type (type, type_quals);
&& (decl_context == NORMAL || decl_context == FIELD)
&& variably_modified_type_p (type, NULL_TREE))
{
- tree decl = build_decl (TYPE_DECL, NULL_TREE, type);
+ tree decl = build_decl (loc, TYPE_DECL, NULL_TREE, type);
DECL_ARTIFICIAL (decl) = 1;
pushdecl (decl);
- finish_decl (decl, NULL_TREE, NULL_TREE, NULL_TREE);
+ finish_decl (decl, loc, NULL_TREE, NULL_TREE, NULL_TREE);
TYPE_NAME (type) = decl;
}
&& TREE_OVERFLOW (TYPE_SIZE_UNIT (type)))
{
if (name)
- error ("size of array %qE is too large", name);
+ error_at (loc, "size of array %qE is too large", name);
else
- error ("size of unnamed array is too large");
+ error_at (loc, "size of unnamed array is too large");
/* If we proceed with the array type as it is, we'll eventually
crash in tree_low_cst(). */
type = error_mark_node;
tree decl;
if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
&& type_quals)
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C forbids qualified function types");
if (type_quals)
type = c_build_qualified_type (type, type_quals);
- decl = build_decl (TYPE_DECL, declarator->u.id, type);
- DECL_SOURCE_LOCATION (decl) = declarator->id_loc;
+ decl = build_decl (declarator->id_loc,
+ TYPE_DECL, declarator->u.id, type);
if (declspecs->explicit_signed_p)
C_TYPEDEF_EXPLICITLY_SIGNED (decl) = 1;
if (declspecs->inline_p)
- pedwarn (input_location, 0,"typedef %q+D declared %<inline%>", decl);
+ pedwarn (loc, 0,"typedef %q+D declared %<inline%>", decl);
if (warn_cxx_compat && declarator->u.id != NULL_TREE)
{
&& !declspecs->inline_p);
if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
&& type_quals)
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C forbids const or volatile function types");
if (type_quals)
type = c_build_qualified_type (type, type_quals);
&& variably_modified_type_p (type, NULL_TREE))
{
/* C99 6.7.2.1p8 */
- pedwarn (input_location, OPT_pedantic,
- "a member of a structure or union cannot have a variably modified type");
+ pedwarn (loc, OPT_pedantic, "a member of a structure or union cannot "
+ "have a variably modified type");
}
/* Aside from typedefs and type names (handle above),
&& !(storage_class == csc_static
|| storage_class == csc_register)))))
{
- error ("variable or field %qE declared void", name);
+ error_at (loc, "variable or field %qE declared void", name);
type = integer_type_node;
}
/* We don't yet implement attributes in this context. */
if (array_ptr_attrs != NULL_TREE)
- warning (OPT_Wattributes,
- "attributes in parameter array declarator ignored");
+ warning_at (loc, OPT_Wattributes,
+ "attributes in parameter array declarator ignored");
size_varies = 0;
}
else if (TREE_CODE (type) == FUNCTION_TYPE)
{
if (type_quals)
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C forbids qualified function types");
if (type_quals)
type = c_build_qualified_type (type, type_quals);
else if (type_quals)
type = c_build_qualified_type (type, type_quals);
- decl = build_decl (PARM_DECL, declarator->u.id, type);
- DECL_SOURCE_LOCATION (decl) = declarator->id_loc;
+ decl = build_decl (declarator->id_loc,
+ PARM_DECL, declarator->u.id, type);
if (size_varies)
C_DECL_VARIABLE_SIZE (decl) = 1;
DECL_ARG_TYPE (decl) = promoted_type;
if (declspecs->inline_p)
- pedwarn (input_location, 0, "parameter %q+D declared %<inline%>", decl);
+ pedwarn (loc, 0, "parameter %q+D declared %<inline%>", decl);
}
else if (decl_context == FIELD)
{
if (TREE_CODE (type) == FUNCTION_TYPE)
{
- error ("field %qE declared as a function", name);
+ error_at (loc, "field %qE declared as a function", name);
type = build_pointer_type (type);
}
else if (TREE_CODE (type) != ERROR_MARK
&& !COMPLETE_OR_UNBOUND_ARRAY_TYPE_P (type))
{
if (name)
- error ("field %qE has incomplete type", name);
+ error_at (loc, "field %qE has incomplete type", name);
else
- error ("unnamed field has incomplete type");
+ error_at (loc, "unnamed field has incomplete type");
type = error_mark_node;
}
type = c_build_qualified_type (type, type_quals);
- decl = build_decl (FIELD_DECL, declarator->u.id, type);
- DECL_SOURCE_LOCATION (decl) = declarator->id_loc;
+ decl = build_decl (declarator->id_loc,
+ FIELD_DECL, declarator->u.id, type);
DECL_NONADDRESSABLE_P (decl) = bitfield;
if (bitfield && !declarator->u.id)
TREE_NO_WARNING (decl) = 1;
{
if (storage_class == csc_register || threadp)
{
- error ("invalid storage class for function %qE", name);
+ error_at (loc, "invalid storage class for function %qE", name);
}
else if (current_scope != file_scope)
{
GCC allows 'auto', perhaps with 'inline', to support
nested functions. */
if (storage_class == csc_auto)
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"invalid storage class for function %qE", name);
else if (storage_class == csc_static)
{
- error ("invalid storage class for function %qE", name);
+ error_at (loc, "invalid storage class for function %qE", name);
if (funcdef_flag)
storage_class = declspecs->storage_class = csc_none;
else
}
}
- decl = build_decl (FUNCTION_DECL, declarator->u.id, type);
- DECL_SOURCE_LOCATION (decl) = declarator->id_loc;
+ decl = build_decl (declarator->id_loc,
+ FUNCTION_DECL, declarator->u.id, type);
decl = build_decl_attribute_variant (decl, decl_attr);
if (pedantic && type_quals && !DECL_IN_SYSTEM_HEADER (decl))
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C forbids qualified function types");
/* GNU C interprets a volatile-qualified function type to indicate
that the function does not return. */
if ((type_quals & TYPE_QUAL_VOLATILE)
&& !VOID_TYPE_P (TREE_TYPE (TREE_TYPE (decl))))
- warning (0, "%<noreturn%> function returns non-void value");
+ warning_at (loc, 0, "%<noreturn%> function returns non-void value");
/* Every function declaration is an external reference
(DECL_EXTERNAL) except for those which are not at file
if (flag_hosted && MAIN_NAME_P (declarator->u.id))
{
if (declspecs->inline_p)
- pedwarn (input_location, 0, "cannot inline function %<main%>");
+ pedwarn (loc, 0, "cannot inline function %<main%>");
}
else if (declspecs->inline_p)
/* Record that the function is declared `inline'. */
&& global_decl != visible_decl
&& TREE_CODE (global_decl) == VAR_DECL
&& !TREE_PUBLIC (global_decl))
- error ("variable previously declared %<static%> redeclared "
- "%<extern%>");
+ error_at (loc, "variable previously declared %<static%> "
+ "redeclared %<extern%>");
}
- decl = build_decl (VAR_DECL, declarator->u.id, type);
- DECL_SOURCE_LOCATION (decl) = declarator->id_loc;
+ decl = build_decl (declarator->id_loc,
+ VAR_DECL, declarator->u.id, type);
if (size_varies)
C_DECL_VARIABLE_SIZE (decl) = 1;
if (declspecs->inline_p)
- pedwarn (input_location, 0, "variable %q+D declared %<inline%>", decl);
+ pedwarn (loc, 0, "variable %q+D declared %<inline%>", decl);
/* At file scope, an initialized extern declaration may follow
a static declaration. In that case, DECL_EXTERNAL will be
{
/* C99 6.7.5.2p2 */
if (TREE_CODE (type) == FUNCTION_TYPE)
- error ("non-nested function with variably modified type");
+ error_at (loc, "non-nested function with variably modified type");
else
- error ("object with variably modified type must have no linkage");
+ error_at (loc, "object with variably modified type must have "
+ "no linkage");
}
/* Record `register' declaration for warnings on &
}
\f
/* Get the struct, enum or union (CODE says which) with tag NAME.
- Define the tag as a forward-reference if it is not defined.
- Return a c_typespec structure for the type specifier. */
+ Define the tag as a forward-reference with location LOC if it is
+ not defined. Return a c_typespec structure for the type
+ specifier. */
struct c_typespec
-parser_xref_tag (enum tree_code code, tree name, location_t loc)
+parser_xref_tag (location_t loc, enum tree_code code, tree name)
{
struct c_typespec ret;
tree ref;
TYPE_MAX_VALUE (ref) = TYPE_MAX_VALUE (unsigned_type_node);
}
- pushtag (name, ref, loc);
+ pushtag (loc, name, ref);
ret.spec = ref;
return ret;
tree
xref_tag (enum tree_code code, tree name)
{
- return parser_xref_tag (code, name, UNKNOWN_LOCATION).spec;
+ return parser_xref_tag (input_location, code, name).spec;
}
\f
/* Make sure that the tag NAME is defined *in the current scope*
at least as a forward reference.
+ LOC is the location of the struct's definition.
CODE says which kind of tag NAME ought to be.
This stores the current value of the file static IN_STRUCT in
finish_struct. */
tree
-start_struct (enum tree_code code, tree name, bool *enclosing_in_struct,
- VEC(tree,heap) **enclosing_struct_types, location_t loc)
+start_struct (location_t loc, enum tree_code code, tree name,
+ bool *enclosing_in_struct,
+ VEC(tree,heap) **enclosing_struct_types)
{
/* If there is already a tag defined at this scope
(as a forward reference), just return it. */
if (ref == NULL_TREE || TREE_CODE (ref) != code)
{
ref = make_node (code);
- pushtag (name, ref, loc);
+ pushtag (loc, name, ref);
}
C_TYPE_BEING_DEFINED (ref) = 1;
width ? &width : NULL, decl_attrs, NULL, NULL,
DEPRECATED_NORMAL);
- finish_decl (value, NULL_TREE, NULL_TREE, NULL_TREE);
+ finish_decl (value, loc, NULL_TREE, NULL_TREE, NULL_TREE);
DECL_INITIAL (value) = width;
return value;
}
/* Fill in the fields of a RECORD_TYPE or UNION_TYPE node, T.
+ LOC is the location of the RECORD_TYPE or UNION_TYPE's definition.
FIELDLIST is a chain of FIELD_DECL nodes for the fields.
ATTRIBUTES are attributes to be applied to the structure.
for any type defined in the current struct. */
tree
-finish_struct (tree t, tree fieldlist, tree attributes,
+finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
bool enclosing_in_struct,
VEC(tree,heap) *enclosing_struct_types)
{
if (TREE_CODE (t) == UNION_TYPE)
{
if (fieldlist)
- pedwarn (input_location, OPT_pedantic, "union has no named members");
+ pedwarn (loc, OPT_pedantic, "union has no named members");
else
- pedwarn (input_location, OPT_pedantic, "union has no members");
+ pedwarn (loc, OPT_pedantic, "union has no members");
}
else
{
if (fieldlist)
- pedwarn (input_location, OPT_pedantic, "struct has no named members");
+ pedwarn (loc, OPT_pedantic, "struct has no named members");
else
- pedwarn (input_location, OPT_pedantic, "struct has no members");
+ pedwarn (loc, OPT_pedantic, "struct has no members");
}
}
}
{
if (TREE_CODE (t) == UNION_TYPE)
{
- error ("%Jflexible array member in union", x);
+ error_at (DECL_SOURCE_LOCATION (x),
+ "%Jflexible array member in union", x);
TREE_TYPE (x) = error_mark_node;
}
else if (TREE_CHAIN (x) != NULL_TREE)
{
- error ("%Jflexible array member not at end of struct", x);
+ error_at (DECL_SOURCE_LOCATION (x),
+ "%Jflexible array member not at end of struct", x);
TREE_TYPE (x) = error_mark_node;
}
else if (!saw_named_field)
{
- error ("%Jflexible array member in otherwise empty struct", x);
+ error_at (DECL_SOURCE_LOCATION (x),
+ "%Jflexible array member in otherwise empty struct",
+ x);
TREE_TYPE (x) = error_mark_node;
}
}
if (pedantic && !in_system_header && TREE_CODE (t) == RECORD_TYPE
&& flexible_array_type_p (TREE_TYPE (x)))
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"%Jinvalid use of structure with flexible array member", x);
if (DECL_NAME (x))
&& (!TYPE_FIELDS (t) || TYPE_MODE (t) != DECL_MODE (TYPE_FIELDS (t))))
{
TYPE_TRANSPARENT_UNION (t) = 0;
- warning (0, "union cannot be made transparent");
+ warning_at (loc, 0, "union cannot be made transparent");
}
/* If this structure or union completes the type of any previous
parsing parameters, then arrange for the size of a variable sized type
to be bound now. */
if (cur_stmt_list && variably_modified_type_p (t, NULL_TREE))
- add_stmt (build_stmt (DECL_EXPR, build_decl (TYPE_DECL, NULL, t)));
+ add_stmt (build_stmt (loc,
+ DECL_EXPR, build_decl (loc, TYPE_DECL, NULL, t)));
/* Set the C_TYPE_DEFINED_IN_STRUCT flag for each type defined in
the current struct. We do this now at the end of the struct
\f
/* Begin compiling the definition of an enumeration type.
NAME is its name (or null if anonymous).
+ LOC is the enum's location.
Returns the type object, as yet incomplete.
Also records info about it so that build_enumerator
may be used to declare the individual values as they are read. */
tree
-start_enum (struct c_enum_contents *the_enum, tree name, location_t loc)
+start_enum (location_t loc, struct c_enum_contents *the_enum, tree name)
{
tree enumtype = NULL_TREE;
location_t enumloc = UNKNOWN_LOCATION;
if (enumtype == 0 || TREE_CODE (enumtype) != ENUMERAL_TYPE)
{
enumtype = make_node (ENUMERAL_TYPE);
- pushtag (name, enumtype, loc);
+ pushtag (loc, name, enumtype);
}
if (C_TYPE_BEING_DEFINED (enumtype))
/* Build and install a CONST_DECL for one value of the
current enumeration type (one that was begun with start_enum).
+ LOC is the location of the enumerator.
Return a tree-list containing the CONST_DECL and its value.
Assignment of sequential values by default is handled here. */
tree
-build_enumerator (struct c_enum_contents *the_enum, tree name, tree value,
- location_t value_loc)
+build_enumerator (location_t loc,
+ struct c_enum_contents *the_enum, tree name, tree value)
{
tree decl, type;
value = 0;
else if (!INTEGRAL_TYPE_P (TREE_TYPE (value)))
{
- error ("enumerator value for %qE is not an integer constant", name);
+ error_at (loc, "enumerator value for %qE is not an integer constant",
+ name);
value = 0;
}
else
{
value = c_fully_fold (value, false, NULL);
if (TREE_CODE (value) == INTEGER_CST)
- pedwarn (value_loc, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"enumerator value for %qE is not an integer "
"constant expression", name);
}
{
value = the_enum->enum_next_value;
if (the_enum->enum_overflow)
- error ("overflow in enumeration values");
+ error_at (loc, "overflow in enumeration values");
}
/* Even though the underlying type of an enum is unspecified, the
type of enumeration constants is explicitly defined as int
(6.4.4.3/2 in the C99 Standard). GCC allows any integer type as
an extension. */
else if (!int_fits_type_p (value, integer_type_node))
- pedwarn (value_loc, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C restricts enumerator values to range of %<int%>");
/* The ISO C Standard mandates enumerators to have type int, even
>= TYPE_PRECISION (integer_type_node)
&& TYPE_UNSIGNED (type)));
- decl = build_decl (CONST_DECL, name, type);
+ decl = build_decl (loc, CONST_DECL, name, type);
DECL_INITIAL (decl) = convert (type, value);
pushdecl (decl);
tree restype, resdecl;
struct c_label_context_se *nstack_se;
struct c_label_context_vm *nstack_vm;
+ location_t loc;
current_function_returns_value = 0; /* Assume, until we see it does. */
current_function_returns_null = 0;
return 0;
}
+ loc = DECL_SOURCE_LOCATION (decl1);
+
decl_attributes (&decl1, attributes, 0);
if (DECL_DECLARED_INLINE_P (decl1)
&& DECL_UNINLINABLE (decl1)
&& lookup_attribute ("noinline", DECL_ATTRIBUTES (decl1)))
- warning (OPT_Wattributes, "inline function %q+D given attribute noinline",
- decl1);
+ warning_at (loc, OPT_Wattributes,
+ "inline function %qD given attribute noinline",
+ decl1);
/* Handle gnu_inline attribute. */
if (declspecs->inline_p
if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (TREE_TYPE (decl1))))
{
- error ("return type is an incomplete type");
+ error_at (loc, "return type is an incomplete type");
/* Make it return void instead. */
TREE_TYPE (decl1)
= build_function_type (void_type_node,
}
if (warn_about_return_type)
- pedwarn_c99 (input_location, flag_isoc99 ? 0
+ pedwarn_c99 (loc, flag_isoc99 ? 0
: (warn_return_type ? OPT_Wreturn_type : OPT_Wimplicit_int),
"return type defaults to %<int%>");
&& old_decl != error_mark_node
&& TYPE_ARG_TYPES (TREE_TYPE (decl1)) == 0
&& C_DECL_ISNT_PROTOTYPE (old_decl))
- warning (OPT_Wstrict_prototypes,
- "function declaration isn%'t a prototype");
+ warning_at (loc, OPT_Wstrict_prototypes,
+ "function declaration isn%'t a prototype");
/* Optionally warn of any global def with no previous prototype. */
else if (warn_missing_prototypes
&& old_decl != error_mark_node
&& TREE_PUBLIC (decl1)
&& !MAIN_NAME_P (DECL_NAME (decl1))
&& C_DECL_ISNT_PROTOTYPE (old_decl))
- warning (OPT_Wmissing_prototypes, "no previous prototype for %q+D", decl1);
+ warning_at (loc, OPT_Wmissing_prototypes,
+ "no previous prototype for %qD", decl1);
/* Optionally warn of any def with no previous prototype
if the function has already been used. */
else if (warn_missing_prototypes
&& old_decl != error_mark_node
&& TREE_USED (old_decl)
&& TYPE_ARG_TYPES (TREE_TYPE (old_decl)) == 0)
- warning (OPT_Wmissing_prototypes,
- "%q+D was used with no prototype before its definition", decl1);
+ warning_at (loc, OPT_Wmissing_prototypes,
+ "%qD was used with no prototype before its definition", decl1);
/* Optionally warn of any global def with no previous declaration. */
else if (warn_missing_declarations
&& TREE_PUBLIC (decl1)
&& old_decl == 0
&& !MAIN_NAME_P (DECL_NAME (decl1)))
- warning (OPT_Wmissing_declarations, "no previous declaration for %q+D",
- decl1);
+ warning_at (loc, OPT_Wmissing_declarations,
+ "no previous declaration for %qD",
+ decl1);
/* Optionally warn of any def with no previous declaration
if the function has already been used. */
else if (warn_missing_declarations
&& old_decl != error_mark_node
&& TREE_USED (old_decl)
&& C_DECL_IMPLICIT (old_decl))
- warning (OPT_Wmissing_declarations,
- "%q+D was used with no declaration before its definition", decl1);
+ warning_at (loc, OPT_Wmissing_declarations,
+ "%qD was used with no declaration before its definition", decl1);
/* This function exists in static storage.
(This does not mean `static' in the C sense!) */
{
if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (decl1)))
!= integer_type_node)
- pedwarn (input_location, OPT_Wmain, "return type of %q+D is not %<int%>", decl1);
+ pedwarn (loc, OPT_Wmain, "return type of %qD is not %<int%>", decl1);
check_main_parameter_types (decl1);
if (!TREE_PUBLIC (decl1))
- pedwarn (input_location, OPT_Wmain, "%q+D is normally a non-static function", decl1);
+ pedwarn (loc, OPT_Wmain,
+ "%qD is normally a non-static function", decl1);
}
/* Record the decl so that the function name is defined.
declare_parm_level ();
restype = TREE_TYPE (TREE_TYPE (current_function_decl));
- resdecl = build_decl (RESULT_DECL, NULL_TREE, restype);
+ resdecl = build_decl (loc, RESULT_DECL, NULL_TREE, restype);
DECL_ARTIFICIAL (resdecl) = 1;
DECL_IGNORED_P (resdecl) = 1;
DECL_RESULT (current_function_decl) = resdecl;
struct pointer_set_t *seen_args = pointer_set_create ();
if (!in_system_header)
- warning (OPT_Wold_style_definition, "%Jold-style function definition",
- fndecl);
+ warning_at (DECL_SOURCE_LOCATION (fndecl),
+ OPT_Wold_style_definition, "old-style function definition");
/* Match each formal parameter name with its declaration. Save each
decl in the appropriate TREE_PURPOSE slot of the parmids chain. */
{
if (TREE_VALUE (parm) == 0)
{
- error ("%Jparameter name missing from parameter list", fndecl);
+ error_at (DECL_SOURCE_LOCATION (fndecl),
+ "parameter name missing from parameter list");
TREE_PURPOSE (parm) = 0;
continue;
}
decl = b->decl;
/* If we got something other than a PARM_DECL it is an error. */
if (TREE_CODE (decl) != PARM_DECL)
- error ("%q+D declared as a non-parameter", decl);
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "%qD declared as a non-parameter", decl);
/* If the declaration is already marked, we have a duplicate
name. Complain and ignore the duplicate. */
else if (pointer_set_contains (seen_args, decl))
{
- error ("multiple parameters named %q+D", decl);
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "multiple parameters named %qD", decl);
TREE_PURPOSE (parm) = 0;
continue;
}
an int. */
else if (VOID_TYPE_P (TREE_TYPE (decl)))
{
- error ("parameter %q+D declared with void type", decl);
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "parameter %qD declared with void type", decl);
TREE_TYPE (decl) = integer_type_node;
DECL_ARG_TYPE (decl) = integer_type_node;
layout_decl (decl, 0);
/* If no declaration found, default to int. */
else
{
- decl = build_decl (PARM_DECL, TREE_VALUE (parm), integer_type_node);
+ /* FIXME diagnostics: This should be the location of the argument,
+ not the FNDECL. E.g., for an old-style declaration
+
+ int f10(v) { blah; }
+
+ We should use the location of the V, not the F10.
+ Unfortunately, the V is an IDENTIFIER_NODE which has no
+ location. In the future we need locations for c_arg_info
+ entries.
+
+ See gcc.dg/Wshadow-3.c for an example of this problem. */
+ decl = build_decl (DECL_SOURCE_LOCATION (fndecl),
+ PARM_DECL, TREE_VALUE (parm), integer_type_node);
DECL_ARG_TYPE (decl) = TREE_TYPE (decl);
- DECL_SOURCE_LOCATION (decl) = DECL_SOURCE_LOCATION (fndecl);
pushdecl (decl);
warn_if_shadowing (decl);
if (flag_isoc99)
- pedwarn (input_location, 0, "type of %q+D defaults to %<int%>", decl);
+ pedwarn (DECL_SOURCE_LOCATION (decl),
+ 0, "type of %qD defaults to %<int%>", decl);
else
- warning (OPT_Wmissing_parameter_type, "type of %q+D defaults to %<int%>", decl);
+ warning_at (DECL_SOURCE_LOCATION (decl),
+ OPT_Wmissing_parameter_type,
+ "type of %qD defaults to %<int%>", decl);
}
TREE_PURPOSE (parm) = decl;
if (TREE_TYPE (parm) != error_mark_node
&& !COMPLETE_TYPE_P (TREE_TYPE (parm)))
{
- error ("parameter %q+D has incomplete type", parm);
+ error_at (DECL_SOURCE_LOCATION (parm),
+ "parameter %qD has incomplete type", parm);
TREE_TYPE (parm) = error_mark_node;
}
if (!pointer_set_contains (seen_args, parm))
{
- error ("declaration for parameter %q+D but no such parameter", parm);
+ error_at (DECL_SOURCE_LOCATION (parm),
+ "declaration for parameter %qD but no such parameter",
+ parm);
/* Pretend the parameter was not missing.
This gets us to a standard state and minimizes
|| TYPE_MAIN_VARIANT (TREE_VALUE (type)) == void_type_node)
{
if (current_function_prototype_built_in)
- warning (0, "number of arguments doesn%'t match "
- "built-in prototype");
+ warning_at (DECL_SOURCE_LOCATION (fndecl),
+ 0, "number of arguments doesn%'t match "
+ "built-in prototype");
else
{
- error ("number of arguments doesn%'t match prototype");
- error ("%Hprototype declaration",
- ¤t_function_prototype_locus);
+ /* FIXME diagnostics: This should be the location of
+ FNDECL, but there is bug when a prototype is
+ declared inside function context, but defined
+ outside of it (e.g., gcc.dg/pr15698-2.c). In
+ which case FNDECL gets the location of the
+ prototype, not the definition. */
+ error_at (input_location,
+ "number of arguments doesn%'t match prototype");
+
+ error_at (current_function_prototype_locus,
+ "prototype declaration");
}
break;
}
been diagnosed as conflicting with an
old-style definition and discarded? */
if (current_function_prototype_built_in)
- warning (OPT_pedantic, "promoted argument %qD "
- "doesn%'t match built-in prototype", parm);
+ warning_at (DECL_SOURCE_LOCATION (parm),
+ OPT_pedantic, "promoted argument %qD "
+ "doesn%'t match built-in prototype", parm);
else
{
- pedwarn (input_location, OPT_pedantic, "promoted argument %qD "
+ pedwarn (DECL_SOURCE_LOCATION (parm),
+ OPT_pedantic, "promoted argument %qD "
"doesn%'t match prototype", parm);
pedwarn (current_function_prototype_locus, OPT_pedantic,
"prototype declaration");
else
{
if (current_function_prototype_built_in)
- warning (0, "argument %qD doesn%'t match "
- "built-in prototype", parm);
+ warning_at (DECL_SOURCE_LOCATION (parm),
+ 0, "argument %qD doesn%'t match "
+ "built-in prototype", parm);
else
{
- error ("argument %qD doesn%'t match prototype", parm);
- error ("%Hprototype declaration",
- ¤t_function_prototype_locus);
+ error_at (DECL_SOURCE_LOCATION (parm),
+ "argument %qD doesn%'t match prototype", parm);
+ error_at (current_function_prototype_locus,
+ "prototype declaration");
}
}
}
&& TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (fndecl)))
== integer_type_node && flag_isoc99)
{
- tree stmt = c_finish_return (integer_zero_node, NULL_TREE);
/* Hack. We don't want the middle-end to warn that this return
is unreachable, so we mark its location as special. Using
UNKNOWN_LOCATION has the problem that it gets clobbered in
annotate_one_with_locus. A cleaner solution might be to
ensure ! should_carry_locus_p (stmt), but that needs a flag.
*/
- SET_EXPR_LOCATION (stmt, BUILTINS_LOCATION);
+ c_finish_return (BUILTINS_LOCATION, integer_zero_node, NULL_TREE);
}
/* Tie off the statement tree for this function. */
}
\f
/* Check the declarations given in a for-loop for satisfying the C99
- constraints. If exactly one such decl is found, return it. */
+ constraints. If exactly one such decl is found, return it. LOC is
+ the location of the opening parenthesis of the for loop. */
tree
-check_for_loop_decls (void)
+check_for_loop_decls (location_t loc)
{
struct c_binding *b;
tree one_decl = NULL_TREE;
/* If we get here, declarations have been used in a for loop without
the C99 for loop scope. This doesn't make much sense, so don't
allow it. */
- error ("%<for%> loop initial declarations are only allowed in C99 mode");
+ error_at (loc, "%<for%> loop initial declarations "
+ "are only allowed in C99 mode");
if (hint)
{
- inform (input_location,
+ inform (loc,
"use option -std=c99 or -std=gnu99 to compile your code");
hint = false;
}
switch (TREE_CODE (decl))
{
case VAR_DECL:
- if (TREE_STATIC (decl))
- error ("declaration of static variable %q+D in %<for%> loop "
- "initial declaration", decl);
- else if (DECL_EXTERNAL (decl))
- error ("declaration of %<extern%> variable %q+D in %<for%> loop "
- "initial declaration", decl);
+ {
+ location_t decl_loc = DECL_SOURCE_LOCATION (decl);
+ if (TREE_STATIC (decl))
+ error_at (decl_loc,
+ "declaration of static variable %qD in %<for%> loop "
+ "initial declaration", decl);
+ else if (DECL_EXTERNAL (decl))
+ error_at (decl_loc,
+ "declaration of %<extern%> variable %qD in %<for%> loop "
+ "initial declaration", decl);
+ }
break;
case RECORD_TYPE:
- error ("%<struct %E%> declared in %<for%> loop initial declaration",
- id);
+ error_at (loc,
+ "%<struct %E%> declared in %<for%> loop initial "
+ "declaration", id);
break;
case UNION_TYPE:
- error ("%<union %E%> declared in %<for%> loop initial declaration",
- id);
+ error_at (loc,
+ "%<union %E%> declared in %<for%> loop initial declaration",
+ id);
break;
case ENUMERAL_TYPE:
- error ("%<enum %E%> declared in %<for%> loop initial declaration",
- id);
+ error_at (loc, "%<enum %E%> declared in %<for%> loop "
+ "initial declaration", id);
break;
default:
- error ("declaration of non-variable %q+D in %<for%> loop "
- "initial declaration", decl);
+ error_at (loc, "declaration of non-variable "
+ "%qD in %<for%> loop initial declaration", decl);
}
n_decls++;
id = ridpointers[(int) rid_index];
else
id = get_identifier (name);
- decl = build_decl (TYPE_DECL, id, type);
+ decl = build_decl (UNKNOWN_LOCATION, TYPE_DECL, id, type);
pushdecl (decl);
if (debug_hooks->type_decl)
debug_hooks->type_decl (decl, false);
genericized. */
tree
-c_build_bind_expr (tree block, tree body)
+c_build_bind_expr (location_t loc, tree block, tree body)
{
tree decls, bind;
}
if (!body)
- body = build_empty_stmt ();
+ body = build_empty_stmt (loc);
if (decls || block)
{
bind = build3 (BIND_EXPR, void_type_node, decls, body, block);
TREE_SIDE_EFFECTS (bind) = 1;
+ SET_EXPR_LOCATION (bind, loc);
}
else
bind = body;
/* Complete a #pragma omp master construct. STMT is the structured-block
- that follows the pragma. */
+ that follows the pragma. LOC is the l*/
tree
-c_finish_omp_master (tree stmt)
+c_finish_omp_master (location_t loc, tree stmt)
{
- return add_stmt (build1 (OMP_MASTER, void_type_node, stmt));
+ tree t = add_stmt (build1 (OMP_MASTER, void_type_node, stmt));
+ SET_EXPR_LOCATION (t, loc);
+ return t;
}
/* Complete a #pragma omp critical construct. STMT is the structured-block
that follows the pragma, NAME is the identifier in the pragma, or null
- if it was omitted. */
+ if it was omitted. LOC is the location of the #pragma. */
tree
-c_finish_omp_critical (tree body, tree name)
+c_finish_omp_critical (location_t loc, tree body, tree name)
{
tree stmt = make_node (OMP_CRITICAL);
TREE_TYPE (stmt) = void_type_node;
OMP_CRITICAL_BODY (stmt) = body;
OMP_CRITICAL_NAME (stmt) = name;
+ SET_EXPR_LOCATION (stmt, loc);
return add_stmt (stmt);
}
/* Complete a #pragma omp ordered construct. STMT is the structured-block
- that follows the pragma. */
+ that follows the pragma. LOC is the location of the #pragma. */
tree
-c_finish_omp_ordered (tree stmt)
+c_finish_omp_ordered (location_t loc, tree stmt)
{
- return add_stmt (build1 (OMP_ORDERED, void_type_node, stmt));
+ tree t = build1 (OMP_ORDERED, void_type_node, stmt);
+ SET_EXPR_LOCATION (t, loc);
+ return add_stmt (t);
}
-/* Complete a #pragma omp barrier construct. */
+/* Complete a #pragma omp barrier construct. LOC is the location of
+ the #pragma. */
void
-c_finish_omp_barrier (void)
+c_finish_omp_barrier (location_t loc)
{
tree x;
x = built_in_decls[BUILT_IN_GOMP_BARRIER];
x = build_call_expr (x, 0);
+ SET_EXPR_LOCATION (x, loc);
add_stmt (x);
}
-/* Complete a #pragma omp taskwait construct. */
+/* Complete a #pragma omp taskwait construct. LOC is the location of the
+ pragma. */
void
-c_finish_omp_taskwait (void)
+c_finish_omp_taskwait (location_t loc)
{
tree x;
x = built_in_decls[BUILT_IN_GOMP_TASKWAIT];
x = build_call_expr (x, 0);
+ SET_EXPR_LOCATION (x, loc);
add_stmt (x);
}
-/* Complete a #pragma omp atomic construct. The expression to be
- implemented atomically is LHS code= RHS. The value returned is
- either error_mark_node (if the construct was erroneous) or an
- OMP_ATOMIC node which should be added to the current statement tree
- with add_stmt. */
+/* Complete a #pragma omp atomic construct. The expression to be
+ implemented atomically is LHS code= RHS. LOC is the location of
+ the atomic statement. The value returned is either error_mark_node
+ (if the construct was erroneous) or an OMP_ATOMIC node which should
+ be added to the current statement tree with add_stmt.*/
tree
-c_finish_omp_atomic (enum tree_code code, tree lhs, tree rhs)
+c_finish_omp_atomic (location_t loc, enum tree_code code, tree lhs, tree rhs)
{
tree x, type, addr;
&& !POINTER_TYPE_P (type)
&& !SCALAR_FLOAT_TYPE_P (type))
{
- error ("invalid expression type for %<#pragma omp atomic%>");
+ error_at (loc, "invalid expression type for %<#pragma omp atomic%>");
return error_mark_node;
}
/* Take and save the address of the lhs. From then on we'll reference it
via indirection. */
- addr = build_unary_op (input_location, ADDR_EXPR, lhs, 0);
+ addr = build_unary_op (loc, ADDR_EXPR, lhs, 0);
if (addr == error_mark_node)
return error_mark_node;
addr = save_expr (addr);
tree var = create_tmp_var_raw (TREE_TYPE (addr), NULL);
addr = build4 (TARGET_EXPR, TREE_TYPE (addr), var, addr, NULL, NULL);
}
- lhs = build_indirect_ref (input_location, addr, NULL);
+ lhs = build_indirect_ref (loc, addr, NULL);
/* There are lots of warnings, errors, and conversions that need to happen
in the course of interpreting a statement. Use the normal mechanisms
to do this, and then take it apart again. */
- x = build_modify_expr (input_location, lhs, NULL_TREE, code, rhs, NULL_TREE);
+ x = build_modify_expr (input_location, lhs, NULL_TREE, code,
+ input_location, rhs, NULL_TREE);
if (x == error_mark_node)
return error_mark_node;
gcc_assert (TREE_CODE (x) == MODIFY_EXPR);
rhs = TREE_OPERAND (x, 1);
/* Punt the actual generation of atomic operations to common code. */
- return build2 (OMP_ATOMIC, void_type_node, addr, rhs);
+ x = build2 (OMP_ATOMIC, void_type_node, addr, rhs);
+ SET_EXPR_LOCATION (x, loc);
+ return x;
}
-/* Complete a #pragma omp flush construct. We don't do anything with the
- variable list that the syntax allows. */
+/* Complete a #pragma omp flush construct. We don't do anything with
+ the variable list that the syntax allows. LOC is the location of
+ the #pragma. */
void
-c_finish_omp_flush (void)
+c_finish_omp_flush (location_t loc)
{
tree x;
x = built_in_decls[BUILT_IN_SYNCHRONIZE];
x = build_call_expr (x, 0);
+ SET_EXPR_LOCATION (x, loc);
add_stmt (x);
}
fail = true;
}
- init = build_modify_expr (elocus, decl, NULL_TREE, NOP_EXPR, init,
+ init = build_modify_expr (elocus, decl, NULL_TREE, NOP_EXPR,
+ /* FIXME diagnostics: This should
+ be the location of the INIT. */
+ elocus,
+ init,
NULL_TREE);
}
gcc_assert (TREE_CODE (init) == MODIFY_EXPR);
}
-/* Divide CLAUSES into two lists: those that apply to a parallel construct,
- and those that apply to a work-sharing construct. Place the results in
- *PAR_CLAUSES and *WS_CLAUSES respectively. In addition, add a nowait
- clause to the work-sharing list. */
+/* Divide CLAUSES into two lists: those that apply to a parallel
+ construct, and those that apply to a work-sharing construct. Place
+ the results in *PAR_CLAUSES and *WS_CLAUSES respectively. In
+ addition, add a nowait clause to the work-sharing list. LOC is the
+ location of the OMP_PARALLEL*. */
void
-c_split_parallel_clauses (tree clauses, tree *par_clauses, tree *ws_clauses)
+c_split_parallel_clauses (location_t loc, tree clauses,
+ tree *par_clauses, tree *ws_clauses)
{
tree next;
*par_clauses = NULL;
- *ws_clauses = build_omp_clause (OMP_CLAUSE_NOWAIT);
+ *ws_clauses = build_omp_clause (loc, OMP_CLAUSE_NOWAIT);
for (; clauses ; clauses = next)
{
struct c_type_name *,
location_t);
static struct c_expr c_parser_postfix_expression_after_primary (c_parser *,
+ location_t loc,
struct c_expr);
static struct c_expr c_parser_expression (c_parser *);
static struct c_expr c_parser_expression_conv (c_parser *);
{
tree d;
struct c_expr init;
+ location_t init_loc;
c_parser_consume_token (parser);
/* The declaration of the variable is in effect while
its initializer is parsed. */
if (!d)
d = error_mark_node;
start_init (d, asm_name, global_bindings_p ());
+ init_loc = c_parser_peek_token (parser)->location;
init = c_parser_initializer (parser);
finish_init ();
if (d != error_mark_node)
{
maybe_warn_string_init (TREE_TYPE (d), init);
- finish_decl (d, init.value, init.original_type, asm_name);
+ finish_decl (d, init_loc, init.value,
+ init.original_type, asm_name);
}
}
else
chainon (postfix_attrs,
all_prefix_attrs));
if (d)
- finish_decl (d, NULL_TREE, NULL_TREE, asm_name);
+ finish_decl (d, UNKNOWN_LOCATION, NULL_TREE,
+ NULL_TREE, asm_name);
}
if (c_parser_next_token_is (parser, CPP_COMMA))
{
add_stmt (fnbody);
finish_function ();
c_pop_function_context ();
- add_stmt (build_stmt (DECL_EXPR, decl));
+ add_stmt (build_stmt (DECL_SOURCE_LOCATION (decl), DECL_EXPR, decl));
}
else
{
enum_loc = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser);
attrs = c_parser_attributes (parser);
+ enum_loc = c_parser_peek_token (parser)->location;
/* Set the location in case we create a decl now. */
c_parser_set_source_position_from_token (c_parser_peek_token (parser));
if (c_parser_next_token_is (parser, CPP_NAME))
{
/* Parse an enum definition. */
struct c_enum_contents the_enum;
- tree type = start_enum (&the_enum, ident, enum_loc);
+ tree type = start_enum (enum_loc, &the_enum, ident);
tree postfix_attrs;
/* We chain the enumerators in reverse order, then put them in
forward order at the end. */
}
else
enum_value = NULL_TREE;
- enum_decl = build_enumerator (&the_enum, enum_id, enum_value,
- value_loc);
+ enum_decl = build_enumerator (value_loc,
+ &the_enum, enum_id, enum_value);
TREE_CHAIN (enum_decl) = values;
values = enum_decl;
seen_comma = false;
ret.expr_const_operands = true;
return ret;
}
- ret = parser_xref_tag (ENUMERAL_TYPE, ident, ident_loc);
+ ret = parser_xref_tag (ident_loc, ENUMERAL_TYPE, ident);
/* In ISO C, enumerated types can be referred to only if already
defined. */
if (pedantic && !COMPLETE_TYPE_P (ret.spec))
{
gcc_assert (ident);
- pedwarn (ident_loc, OPT_pedantic,
+ pedwarn (enum_loc, OPT_pedantic,
"ISO C forbids forward references to %<enum%> types");
}
return ret;
struct_loc = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser);
attrs = c_parser_attributes (parser);
+
/* Set the location in case we create a decl now. */
c_parser_set_source_position_from_token (c_parser_peek_token (parser));
+
if (c_parser_next_token_is (parser, CPP_NAME))
{
ident = c_parser_peek_token (parser)->value;
tag before parsing components. */
bool in_struct;
VEC(tree,heap) *struct_types;
- tree type = start_struct (code, ident, &in_struct, &struct_types,
- struct_loc);
+ tree type = start_struct (struct_loc, code, ident,
+ &in_struct, &struct_types);
tree postfix_attrs;
/* We chain the components in reverse order, then put them in
forward order at the end. Each struct-declaration may
}
}
postfix_attrs = c_parser_attributes (parser);
- ret.spec = finish_struct (type, nreverse (contents),
+ ret.spec = finish_struct (struct_loc, type, nreverse (contents),
chainon (attrs, postfix_attrs),
in_struct, struct_types);
ret.kind = ctsk_tagdef;
ret.expr_const_operands = true;
return ret;
}
- ret = parser_xref_tag (code, ident, ident_loc);
+ ret = parser_xref_tag (ident_loc, code, ident);
return ret;
}
/* Parse a sequence of array declarators and parameter lists. */
if (c_parser_next_token_is (parser, CPP_OPEN_SQUARE))
{
+ location_t brace_loc = c_parser_peek_token (parser)->location;
struct c_declarator *declarator;
struct c_declspecs *quals_attrs = build_null_declspecs ();
bool static_seen;
"expected %<]%>");
return NULL;
}
- declarator = build_array_declarator (dimen, quals_attrs, static_seen,
- star_seen);
+ declarator = build_array_declarator (brace_loc, dimen, quals_attrs,
+ static_seen, star_seen);
if (declarator == NULL)
return NULL;
inner = set_array_declarator_inner (declarator, inner);
else
{
struct c_expr ret;
+ location_t loc = c_parser_peek_token (parser)->location;
ret = c_parser_expr_no_commas (parser, NULL);
if (TREE_CODE (ret.value) != STRING_CST
&& TREE_CODE (ret.value) != COMPOUND_LITERAL_EXPR)
- ret = default_function_array_conversion (ret);
+ ret = default_function_array_conversion (loc, ret);
return ret;
}
}
while (c_parser_next_token_is (parser, CPP_COMMA))
{
struct c_expr next;
+ location_t comma_loc, exp_loc;
+ comma_loc = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser);
+ exp_loc = c_parser_peek_token (parser)->location;
next = c_parser_expr_no_commas (parser, NULL);
- next = default_function_array_conversion (next);
- rec = build_compound_expr (rec, next.value);
+ next = default_function_array_conversion (exp_loc, next);
+ rec = build_compound_expr (comma_loc, rec, next.value);
}
parse_message_args:
/* Now parse the objc-message-args. */
init = c_parser_braced_init (parser, NULL_TREE, true);
else
{
+ location_t loc = c_parser_peek_token (parser)->location;
init = c_parser_expr_no_commas (parser, after);
if (init.value != NULL_TREE
&& TREE_CODE (init.value) != STRING_CST
&& TREE_CODE (init.value) != COMPOUND_LITERAL_EXPR)
- init = default_function_array_conversion (init);
+ init = default_function_array_conversion (loc, init);
}
process_init_element (init, false);
}
c_parser_compound_statement (c_parser *parser)
{
tree stmt;
+ location_t brace_loc;
+ brace_loc = c_parser_peek_token (parser)->location;
if (!c_parser_require (parser, CPP_OPEN_BRACE, "expected %<{%>"))
{
/* Ensure a scope is entered and left anyway to avoid confusion
if we have just prepared to enter a function body. */
stmt = c_begin_compound_stmt (true);
- c_end_compound_stmt (stmt, true);
+ c_end_compound_stmt (brace_loc, stmt, true);
return error_mark_node;
}
stmt = c_begin_compound_stmt (true);
c_parser_compound_statement_nostart (parser);
- return c_end_compound_stmt (stmt, true);
+ return c_end_compound_stmt (brace_loc, stmt, true);
}
/* Parse a compound statement except for the opening brace. This is
mark_valid_location_for_stdc_pragma (true);
if (c_parser_next_token_is_keyword (parser, RID_LABEL))
{
- location_t err_loc = c_parser_peek_token (parser)->location;
/* Read zero or more forward-declarations for labels that nested
functions can jump to. */
mark_valid_location_for_stdc_pragma (false);
while (c_parser_next_token_is_keyword (parser, RID_LABEL))
{
+ label_loc = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser);
/* Any identifiers, including those declared as type names,
are OK here. */
label
= declare_label (c_parser_peek_token (parser)->value);
C_DECLARED_LABEL_FLAG (label) = 1;
- add_stmt (build_stmt (DECL_EXPR, label));
+ add_stmt (build_stmt (label_loc, DECL_EXPR, label));
c_parser_consume_token (parser);
if (c_parser_next_token_is (parser, CPP_COMMA))
c_parser_consume_token (parser);
}
c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
}
- pedwarn (err_loc, OPT_pedantic, "ISO C forbids label declarations");
+ pedwarn (label_loc, OPT_pedantic, "ISO C forbids label declarations");
}
/* We must now have at least one statement, label or declaration. */
if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
if (c_parser_next_token_is (parser, CPP_COLON))
{
c_parser_consume_token (parser);
- label = do_case (exp1, NULL_TREE);
+ label = do_case (loc1, exp1, NULL_TREE);
}
else if (c_parser_next_token_is (parser, CPP_ELLIPSIS))
{
c_parser_consume_token (parser);
exp2 = c_parser_expr_no_commas (parser, NULL).value;
if (c_parser_require (parser, CPP_COLON, "expected %<:%>"))
- label = do_case (exp1, exp2);
+ label = do_case (loc1, exp1, exp2);
}
else
c_parser_error (parser, "expected %<:%> or %<...%>");
{
c_parser_consume_token (parser);
if (c_parser_require (parser, CPP_COLON, "expected %<:%>"))
- label = do_case (NULL_TREE, NULL_TREE);
+ label = do_case (loc1, NULL_TREE, NULL_TREE);
}
else
{
if (tlab)
{
decl_attributes (&tlab, attrs, 0);
- label = add_stmt (build_stmt (LABEL_EXPR, tlab));
+ label = add_stmt (build_stmt (loc1, LABEL_EXPR, tlab));
}
}
if (label)
{
- SET_EXPR_LOCATION (label, loc1);
if (c_parser_next_token_starts_declspecs (parser)
&& !(c_parser_next_token_is (parser, CPP_NAME)
&& c_parser_peek_2nd_token (parser)->type == CPP_COLON))
c_parser_consume_token (parser);
if (c_parser_next_token_is (parser, CPP_NAME))
{
- stmt = c_finish_goto_label (c_parser_peek_token (parser)->value);
+ stmt = c_finish_goto_label (loc,
+ c_parser_peek_token (parser)->value);
c_parser_consume_token (parser);
}
else if (c_parser_next_token_is (parser, CPP_MULT))
{
c_parser_consume_token (parser);
- stmt = c_finish_goto_ptr (c_parser_expression (parser).value);
+ stmt = c_finish_goto_ptr (loc,
+ c_parser_expression (parser).value);
}
else
c_parser_error (parser, "expected identifier or %<*%>");
goto expect_semicolon;
case RID_CONTINUE:
c_parser_consume_token (parser);
- stmt = c_finish_bc_stmt (&c_cont_label, false);
+ stmt = c_finish_bc_stmt (loc, &c_cont_label, false);
goto expect_semicolon;
case RID_BREAK:
c_parser_consume_token (parser);
- stmt = c_finish_bc_stmt (&c_break_label, true);
+ stmt = c_finish_bc_stmt (loc, &c_break_label, true);
goto expect_semicolon;
case RID_RETURN:
c_parser_consume_token (parser);
if (c_parser_next_token_is (parser, CPP_SEMICOLON))
{
- stmt = c_finish_return (NULL_TREE, NULL_TREE);
+ stmt = c_finish_return (loc, NULL_TREE, NULL_TREE);
c_parser_consume_token (parser);
}
else
{
struct c_expr expr = c_parser_expression_conv (parser);
- stmt = c_finish_return (expr.value, expr.original_type);
+ stmt = c_finish_return (loc, expr.value, expr.original_type);
goto expect_semicolon;
}
break;
c_parser_consume_token (parser);
if (c_parser_next_token_is (parser, CPP_SEMICOLON))
{
- stmt = objc_build_throw_stmt (NULL_TREE);
+ stmt = objc_build_throw_stmt (loc, NULL_TREE);
c_parser_consume_token (parser);
}
else
{
tree expr = c_parser_expression (parser).value;
expr = c_fully_fold (expr, false, NULL);
- stmt = objc_build_throw_stmt (expr);
+ stmt = objc_build_throw_stmt (loc, expr);
goto expect_semicolon;
}
break;
break;
default:
expr_stmt:
- stmt = c_finish_expr_stmt (c_parser_expression_conv (parser).value);
+ stmt = c_finish_expr_stmt (loc, c_parser_expression_conv (parser).value);
expect_semicolon:
c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
break;
(recursively) all of the component statements should already have
line numbers assigned. ??? Can we discard no-op statements
earlier? */
- protected_set_expr_location (stmt, loc);
+ if (CAN_HAVE_LOCATION_P (stmt)
+ && EXPR_LOCATION (stmt) == UNKNOWN_LOCATION)
+ SET_EXPR_LOCATION (stmt, loc);
parser->in_if_block = in_if_block;
}
static tree
c_parser_condition (c_parser *parser)
{
- location_t loc;
+ location_t loc = c_parser_peek_token (parser)->location;
tree cond;
- loc = c_parser_peek_token (parser)->location;
cond = c_parser_expression_conv (parser).value;
cond = c_objc_common_truthvalue_conversion (loc, cond);
cond = c_fully_fold (cond, false, NULL);
c_parser_c99_block_statement (c_parser *parser)
{
tree block = c_begin_compound_stmt (flag_isoc99);
+ location_t loc = c_parser_peek_token (parser)->location;
c_parser_statement (parser);
- return c_end_compound_stmt (block, flag_isoc99);
+ return c_end_compound_stmt (loc, block, flag_isoc99);
}
/* Parse the body of an if statement. This is just parsing a
c_parser_if_body (c_parser *parser, bool *if_p)
{
tree block = c_begin_compound_stmt (flag_isoc99);
+ location_t body_loc = c_parser_peek_token (parser)->location;
while (c_parser_next_token_is_keyword (parser, RID_CASE)
|| c_parser_next_token_is_keyword (parser, RID_DEFAULT)
|| (c_parser_next_token_is (parser, CPP_NAME)
if (c_parser_next_token_is (parser, CPP_SEMICOLON))
{
location_t loc = c_parser_peek_token (parser)->location;
- add_stmt (build_empty_stmt ());
+ add_stmt (build_empty_stmt (loc));
c_parser_consume_token (parser);
if (!c_parser_next_token_is_keyword (parser, RID_ELSE))
warning_at (loc, OPT_Wempty_body,
add_stmt (c_parser_compound_statement (parser));
else
c_parser_statement_after_labels (parser);
- return c_end_compound_stmt (block, flag_isoc99);
+ return c_end_compound_stmt (body_loc, block, flag_isoc99);
}
/* Parse the else body of an if statement. This is just parsing a
static tree
c_parser_else_body (c_parser *parser)
{
+ location_t else_loc = c_parser_peek_token (parser)->location;
tree block = c_begin_compound_stmt (flag_isoc99);
while (c_parser_next_token_is_keyword (parser, RID_CASE)
|| c_parser_next_token_is_keyword (parser, RID_DEFAULT)
c_parser_label (parser);
if (c_parser_next_token_is (parser, CPP_SEMICOLON))
{
- warning_at (c_parser_peek_token (parser)->location,
+ location_t loc = c_parser_peek_token (parser)->location;
+ warning_at (loc,
OPT_Wempty_body,
"suggest braces around empty body in an %<else%> statement");
- add_stmt (build_empty_stmt ());
+ add_stmt (build_empty_stmt (loc));
c_parser_consume_token (parser);
}
else
c_parser_statement_after_labels (parser);
- return c_end_compound_stmt (block, flag_isoc99);
+ return c_end_compound_stmt (else_loc, block, flag_isoc99);
}
/* Parse an if statement (C90 6.6.4, C99 6.8.4).
else
second_body = NULL_TREE;
c_finish_if_stmt (loc, cond, first_body, second_body, first_if);
- add_stmt (c_end_compound_stmt (block, flag_isoc99));
+ add_stmt (c_end_compound_stmt (loc, block, flag_isoc99));
}
/* Parse a switch statement (C90 6.6.4, C99 6.8.4).
c_parser_switch_statement (c_parser *parser)
{
tree block, expr, body, save_break;
+ location_t switch_loc = c_parser_peek_token (parser)->location;
+ location_t switch_cond_loc;
gcc_assert (c_parser_next_token_is_keyword (parser, RID_SWITCH));
c_parser_consume_token (parser);
block = c_begin_compound_stmt (flag_isoc99);
if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
{
+ switch_cond_loc = c_parser_peek_token (parser)->location;
expr = c_parser_expression (parser).value;
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
}
else
- expr = error_mark_node;
- c_start_case (expr);
+ {
+ switch_cond_loc = UNKNOWN_LOCATION;
+ expr = error_mark_node;
+ }
+ c_start_case (switch_loc, switch_cond_loc, expr);
save_break = c_break_label;
c_break_label = NULL_TREE;
body = c_parser_c99_block_statement (parser);
c_finish_case (body);
if (c_break_label)
- add_stmt (build1 (LABEL_EXPR, void_type_node, c_break_label));
+ {
+ location_t here = c_parser_peek_token (parser)->location;
+ tree t = build1 (LABEL_EXPR, void_type_node, c_break_label);
+ SET_EXPR_LOCATION (t, here);
+ add_stmt (t);
+ }
c_break_label = save_break;
- add_stmt (c_end_compound_stmt (block, flag_isoc99));
+ add_stmt (c_end_compound_stmt (switch_loc, block, flag_isoc99));
}
/* Parse a while statement (C90 6.6.5, C99 6.8.5).
c_cont_label = NULL_TREE;
body = c_parser_c99_block_statement (parser);
c_finish_loop (loc, cond, NULL, body, c_break_label, c_cont_label, true);
- add_stmt (c_end_compound_stmt (block, flag_isoc99));
+ add_stmt (c_end_compound_stmt (loc, block, flag_isoc99));
c_break_label = save_break;
c_cont_label = save_cont;
}
if (!c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>"))
c_parser_skip_to_end_of_block_or_statement (parser);
c_finish_loop (loc, cond, NULL, body, new_break, new_cont, false);
- add_stmt (c_end_compound_stmt (block, flag_isoc99));
+ add_stmt (c_end_compound_stmt (loc, block, flag_isoc99));
}
/* Parse a for statement (C90 6.6.5, C99 6.8.5).
c_parser_for_statement (c_parser *parser)
{
tree block, cond, incr, save_break, save_cont, body;
- location_t loc;
+ location_t loc = c_parser_peek_token (parser)->location;
+ location_t for_loc = c_parser_peek_token (parser)->location;
gcc_assert (c_parser_next_token_is_keyword (parser, RID_FOR));
- loc = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser);
block = c_begin_compound_stmt (flag_isoc99);
if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
if (c_parser_next_token_is (parser, CPP_SEMICOLON))
{
c_parser_consume_token (parser);
- c_finish_expr_stmt (NULL_TREE);
+ c_finish_expr_stmt (loc, NULL_TREE);
}
else if (c_parser_next_token_starts_declspecs (parser))
{
c_parser_declaration_or_fndef (parser, true, true, true, true);
- check_for_loop_decls ();
+ check_for_loop_decls (for_loc);
}
else if (c_parser_next_token_is_keyword (parser, RID_EXTENSION))
{
c_parser_consume_token (parser);
c_parser_declaration_or_fndef (parser, true, true, true, true);
restore_extension_diagnostics (ext);
- check_for_loop_decls ();
+ check_for_loop_decls (for_loc);
}
else
goto init_expr;
else
{
init_expr:
- c_finish_expr_stmt (c_parser_expression (parser).value);
+ c_finish_expr_stmt (loc, c_parser_expression (parser).value);
c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
}
/* Parse the loop condition. */
}
/* Parse the increment expression. */
if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
- incr = c_process_expr_stmt (NULL_TREE);
+ incr = c_process_expr_stmt (loc, NULL_TREE);
else
- incr = c_process_expr_stmt (c_parser_expression (parser).value);
+ incr = c_process_expr_stmt (loc, c_parser_expression (parser).value);
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
}
else
c_cont_label = NULL_TREE;
body = c_parser_c99_block_statement (parser);
c_finish_loop (loc, cond, incr, body, c_break_label, c_cont_label, true);
- add_stmt (c_end_compound_stmt (block, flag_isoc99));
+ add_stmt (c_end_compound_stmt (loc, block, flag_isoc99));
c_break_label = save_break;
c_cont_label = save_cont;
}
{
tree quals, str, outputs, inputs, clobbers, ret;
bool simple;
+ location_t asm_loc = c_parser_peek_token (parser)->location;
gcc_assert (c_parser_next_token_is_keyword (parser, RID_ASM));
c_parser_consume_token (parser);
if (c_parser_next_token_is_keyword (parser, RID_VOLATILE))
}
if (!c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>"))
c_parser_skip_to_end_of_block_or_statement (parser);
- ret = build_asm_stmt (quals, build_asm_expr (str, outputs, inputs,
+ ret = build_asm_stmt (quals, build_asm_expr (asm_loc, str, outputs, inputs,
clobbers, simple));
return ret;
}
c_parser_asm_operands (c_parser *parser, bool convert_p)
{
tree list = NULL_TREE;
+ location_t loc;
while (true)
{
tree name, str;
parser->lex_untranslated_string = true;
return NULL_TREE;
}
+ loc = c_parser_peek_token (parser)->location;
expr = c_parser_expression (parser);
if (convert_p)
- expr = default_function_array_conversion (expr);
+ expr = default_function_array_conversion (loc, expr);
expr.value = c_fully_fold (expr.value, false, NULL);
parser->lex_untranslated_string = true;
if (!c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>"))
{
struct c_expr lhs, rhs, ret;
enum tree_code code;
- location_t op_location;
+ location_t op_location, exp_location;
gcc_assert (!after || c_dialect_objc ());
lhs = c_parser_conditional_expression (parser, after);
op_location = c_parser_peek_token (parser)->location;
return lhs;
}
c_parser_consume_token (parser);
+ exp_location = c_parser_peek_token (parser)->location;
rhs = c_parser_expr_no_commas (parser, NULL);
- rhs = default_function_array_conversion (rhs);
+ rhs = default_function_array_conversion (exp_location, rhs);
ret.value = build_modify_expr (op_location, lhs.value, lhs.original_type,
- code, rhs.value, rhs.original_type);
+ code, exp_location, rhs.value,
+ rhs.original_type);
if (code == NOP_EXPR)
ret.original_code = MODIFY_EXPR;
else
gcc_assert (!after || c_dialect_objc ());
- cond_loc = c_parser_peek_token (parser)->location;
cond = c_parser_binary_expression (parser, after);
if (c_parser_next_token_is_not (parser, CPP_QUERY))
return cond;
- cond = default_function_array_conversion (cond);
+ cond_loc = c_parser_peek_token (parser)->location;
+ cond = default_function_array_conversion (cond_loc, cond);
c_parser_consume_token (parser);
if (c_parser_next_token_is (parser, CPP_COLON))
{
ret.original_type = NULL;
return ret;
}
- exp2 = c_parser_conditional_expression (parser, NULL);
- exp2 = default_function_array_conversion (exp2);
+ {
+ location_t exp2_loc = c_parser_peek_token (parser)->location;
+ exp2 = c_parser_conditional_expression (parser, NULL);
+ exp2 = default_function_array_conversion (exp2_loc, exp2);
+ }
skip_evaluation -= cond.value == truthvalue_true_node;
ret.value = build_conditional_expr (colon_loc, cond.value,
cond.original_code == C_MAYBE_CONST_EXPR,
break; \
} \
stack[sp - 1].expr \
- = default_function_array_conversion (stack[sp - 1].expr); \
+ = default_function_array_conversion (stack[sp - 1].loc, \
+ stack[sp - 1].expr); \
stack[sp].expr \
- = default_function_array_conversion (stack[sp].expr); \
+ = default_function_array_conversion (stack[sp].loc, stack[sp].expr); \
stack[sp - 1].expr = parser_build_binary_op (stack[sp].loc, \
stack[sp].op, \
stack[sp - 1].expr, \
{
case TRUTH_ANDIF_EXPR:
stack[sp].expr
- = default_function_array_conversion (stack[sp].expr);
+ = default_function_array_conversion (stack[sp].loc,
+ stack[sp].expr);
stack[sp].expr.value = c_objc_common_truthvalue_conversion
(stack[sp].loc, default_conversion (stack[sp].expr.value));
skip_evaluation += stack[sp].expr.value == truthvalue_false_node;
break;
case TRUTH_ORIF_EXPR:
stack[sp].expr
- = default_function_array_conversion (stack[sp].expr);
+ = default_function_array_conversion (stack[sp].loc,
+ stack[sp].expr);
stack[sp].expr.value = c_objc_common_truthvalue_conversion
(stack[sp].loc, default_conversion (stack[sp].expr.value));
skip_evaluation += stack[sp].expr.value == truthvalue_true_node;
stack[sp].expr = c_parser_cast_expression (parser, NULL);
stack[sp].prec = oprec;
stack[sp].op = ocode;
+ stack[sp].loc = binary_loc;
}
out:
while (sp > 0)
static struct c_expr
c_parser_cast_expression (c_parser *parser, struct c_expr *after)
{
+ location_t cast_loc = c_parser_peek_token (parser)->location;
gcc_assert (!after || c_dialect_objc ());
if (after)
- return c_parser_postfix_expression_after_primary (parser, *after);
+ return c_parser_postfix_expression_after_primary (parser,
+ cast_loc, *after);
/* If the expression begins with a parenthesized type name, it may
be either a cast or a compound literal; we need to see whether
the next character is '{' to tell the difference. If not, it is
if (c_parser_next_token_is (parser, CPP_OPEN_PAREN)
&& c_token_starts_typename (c_parser_peek_2nd_token (parser)))
{
- location_t loc;
struct c_type_name *type_name;
struct c_expr ret;
struct c_expr expr;
c_parser_consume_token (parser);
- loc = c_parser_peek_token (parser)->location;
type_name = c_parser_type_name (parser);
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
if (type_name == NULL)
if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
return c_parser_postfix_expression_after_paren_type (parser, type_name,
- loc);
- expr = c_parser_cast_expression (parser, NULL);
- expr = default_function_array_conversion (expr);
- ret.value = c_cast_expr (type_name, expr.value, loc);
+ cast_loc);
+ {
+ location_t expr_loc = c_parser_peek_token (parser)->location;
+ expr = c_parser_cast_expression (parser, NULL);
+ expr = default_function_array_conversion (expr_loc, expr);
+ }
+ ret.value = c_cast_expr (cast_loc, type_name, expr.value);
ret.original_code = ERROR_MARK;
ret.original_type = NULL;
return ret;
{
int ext;
struct c_expr ret, op;
- location_t loc = c_parser_peek_token (parser)->location;
+ location_t op_loc = c_parser_peek_token (parser)->location;
+ location_t exp_loc;
ret.original_code = ERROR_MARK;
ret.original_type = NULL;
switch (c_parser_peek_token (parser)->type)
{
case CPP_PLUS_PLUS:
c_parser_consume_token (parser);
+ exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (op);
- return parser_build_unary_op (PREINCREMENT_EXPR, op, loc);
+ op = default_function_array_conversion (exp_loc, op);
+ return parser_build_unary_op (op_loc, PREINCREMENT_EXPR, op);
case CPP_MINUS_MINUS:
c_parser_consume_token (parser);
+ exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (op);
- return parser_build_unary_op (PREDECREMENT_EXPR, op, loc);
+ op = default_function_array_conversion (exp_loc, op);
+ return parser_build_unary_op (op_loc, PREDECREMENT_EXPR, op);
case CPP_AND:
c_parser_consume_token (parser);
- return parser_build_unary_op (ADDR_EXPR,
- c_parser_cast_expression (parser, NULL),
- loc);
+ return parser_build_unary_op (op_loc, ADDR_EXPR,
+ c_parser_cast_expression (parser, NULL));
case CPP_MULT:
c_parser_consume_token (parser);
+ exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (op);
- ret.value = build_indirect_ref (loc, op.value, "unary *");
+ op = default_function_array_conversion (exp_loc, op);
+ ret.value = build_indirect_ref (op_loc, op.value, "unary *");
return ret;
case CPP_PLUS:
if (!c_dialect_objc () && !in_system_header)
- warning_at (c_parser_peek_token (parser)->location,
+ warning_at (op_loc,
OPT_Wtraditional,
"traditional C rejects the unary plus operator");
c_parser_consume_token (parser);
+ exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (op);
- return parser_build_unary_op (CONVERT_EXPR, op, loc);
+ op = default_function_array_conversion (exp_loc, op);
+ return parser_build_unary_op (op_loc, CONVERT_EXPR, op);
case CPP_MINUS:
c_parser_consume_token (parser);
+ exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (op);
- return parser_build_unary_op (NEGATE_EXPR, op, loc);
+ op = default_function_array_conversion (exp_loc, op);
+ return parser_build_unary_op (op_loc, NEGATE_EXPR, op);
case CPP_COMPL:
c_parser_consume_token (parser);
+ exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (op);
- return parser_build_unary_op (BIT_NOT_EXPR, op, loc);
+ op = default_function_array_conversion (exp_loc, op);
+ return parser_build_unary_op (op_loc, BIT_NOT_EXPR, op);
case CPP_NOT:
c_parser_consume_token (parser);
+ exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (op);
- return parser_build_unary_op (TRUTH_NOT_EXPR, op, loc);
+ op = default_function_array_conversion (exp_loc, op);
+ return parser_build_unary_op (op_loc, TRUTH_NOT_EXPR, op);
case CPP_AND_AND:
/* Refer to the address of a label as a pointer. */
c_parser_consume_token (parser);
if (c_parser_next_token_is (parser, CPP_NAME))
{
ret.value = finish_label_address_expr
- (c_parser_peek_token (parser)->value, loc);
+ (c_parser_peek_token (parser)->value, op_loc);
c_parser_consume_token (parser);
}
else
return ret;
case RID_REALPART:
c_parser_consume_token (parser);
+ exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (op);
- return parser_build_unary_op (REALPART_EXPR, op, loc);
+ op = default_function_array_conversion (exp_loc, op);
+ return parser_build_unary_op (op_loc, REALPART_EXPR, op);
case RID_IMAGPART:
c_parser_consume_token (parser);
+ exp_loc = c_parser_peek_token (parser)->location;
op = c_parser_cast_expression (parser, NULL);
- op = default_function_array_conversion (op);
- return parser_build_unary_op (IMAGPART_EXPR, op, loc);
+ op = default_function_array_conversion (exp_loc, op);
+ return parser_build_unary_op (op_loc, IMAGPART_EXPR, op);
default:
return c_parser_postfix_expression (parser);
}
/* sizeof ( type-name ). */
skip_evaluation--;
in_sizeof--;
- return c_expr_sizeof_type (type_name);
+ return c_expr_sizeof_type (expr_loc, type_name);
}
else
{
if (TREE_CODE (expr.value) == COMPONENT_REF
&& DECL_C_BIT_FIELD (TREE_OPERAND (expr.value, 1)))
error_at (expr_loc, "%<sizeof%> applied to a bit-field");
- return c_expr_sizeof_expr (expr);
+ return c_expr_sizeof_expr (expr_loc, expr);
}
}
c_parser_alignof_expression (c_parser *parser)
{
struct c_expr expr;
+ location_t loc = c_parser_peek_token (parser)->location;
gcc_assert (c_parser_next_token_is_keyword (parser, RID_ALIGNOF));
c_parser_consume_token (parser);
skip_evaluation++;
/* alignof ( type-name ). */
skip_evaluation--;
in_alignof--;
- ret.value = c_alignof (groktypename (type_name, NULL, NULL));
+ ret.value = c_alignof (loc, groktypename (type_name, NULL, NULL));
ret.original_code = ERROR_MARK;
ret.original_type = NULL;
return ret;
alignof_expr:
skip_evaluation--;
in_alignof--;
- ret.value = c_alignof_expr (expr.value);
+ ret.value = c_alignof_expr (loc, expr.value);
ret.original_code = ERROR_MARK;
ret.original_type = NULL;
return ret;
{
struct c_expr expr, e1, e2, e3;
struct c_type_name *t1, *t2;
- location_t loc;
+ location_t loc = c_parser_peek_token (parser)->location;;
expr.original_code = ERROR_MARK;
expr.original_type = NULL;
switch (c_parser_peek_token (parser)->type)
}
{
tree id = c_parser_peek_token (parser)->value;
- location_t loc = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser);
- expr.value = build_external_ref (id,
+ expr.value = build_external_ref (loc, id,
(c_parser_peek_token (parser)->type
- == CPP_OPEN_PAREN), loc,
+ == CPP_OPEN_PAREN),
&expr.original_type);
}
break;
{
/* A statement expression. */
tree stmt;
- location_t here = c_parser_peek_token (parser)->location;
+ location_t brace_loc;
c_parser_consume_token (parser);
+ brace_loc = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser);
if (cur_stmt_list == NULL)
{
- error_at (here, "braced-group within expression allowed "
+ error_at (loc, "braced-group within expression allowed "
"only inside a function");
parser->error = true;
c_parser_skip_until_found (parser, CPP_CLOSE_BRACE, NULL);
c_parser_compound_statement_nostart (parser);
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
"expected %<)%>");
- pedwarn (here, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C forbids braced-groups within expressions");
- expr.value = c_finish_stmt_expr (stmt);
+ expr.value = c_finish_stmt_expr (brace_loc, stmt);
}
else if (c_token_starts_typename (c_parser_peek_2nd_token (parser)))
{
case RID_FUNCTION_NAME:
case RID_PRETTY_FUNCTION_NAME:
case RID_C99_FUNCTION_NAME:
- expr.value = fname_decl (c_parser_peek_token (parser)->location,
+ expr.value = fname_decl (loc,
c_parser_peek_token (parser)->keyword,
c_parser_peek_token (parser)->value);
c_parser_consume_token (parser);
else
{
tree type_expr = NULL_TREE;
- expr.value = c_build_va_arg (e1.value,
- groktypename (t1, &type_expr, NULL),
- loc);
+ expr.value = c_build_va_arg (loc, e1.value,
+ groktypename (t1, &type_expr, NULL));
if (type_expr)
{
expr.value = build2 (C_MAYBE_CONST_EXPR,
if (type == error_mark_node)
offsetof_ref = error_mark_node;
else
- offsetof_ref = build1 (INDIRECT_REF, type, null_pointer_node);
+ {
+ offsetof_ref = build1 (INDIRECT_REF, type, null_pointer_node);
+ SET_EXPR_LOCATION (offsetof_ref, loc);
+ }
/* Parse the second argument to __builtin_offsetof. We
must have one identifier, and beyond that we want to
accept sub structure and sub array references. */
if (c_parser_next_token_is (parser, CPP_NAME))
{
offsetof_ref = build_component_ref
- (offsetof_ref, c_parser_peek_token (parser)->value);
+ (loc, offsetof_ref, c_parser_peek_token (parser)->value);
c_parser_consume_token (parser);
while (c_parser_next_token_is (parser, CPP_DOT)
|| c_parser_next_token_is (parser,
if (c_parser_next_token_is (parser, CPP_DEREF))
{
loc = c_parser_peek_token (parser)->location;
- offsetof_ref = build_array_ref (offsetof_ref,
- integer_zero_node,
- loc);
+ offsetof_ref = build_array_ref (loc,
+ offsetof_ref,
+ integer_zero_node);
goto do_dot;
}
else if (c_parser_next_token_is (parser, CPP_DOT))
break;
}
offsetof_ref = build_component_ref
- (offsetof_ref,
+ (loc, offsetof_ref,
c_parser_peek_token (parser)->value);
c_parser_consume_token (parser);
}
idx = c_fully_fold (idx, false, NULL);
c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE,
"expected %<]%>");
- offsetof_ref = build_array_ref (offsetof_ref, idx, loc);
+ offsetof_ref = build_array_ref (loc, offsetof_ref, idx);
}
}
}
tree sel = c_parser_objc_selector_arg (parser);
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
"expected %<)%>");
- expr.value = objc_build_selector_expr (sel);
+ expr.value = objc_build_selector_expr (loc, sel);
}
break;
case RID_AT_PROTOCOL:
expr.value = error_mark_node;
break;
}
- return c_parser_postfix_expression_after_primary (parser, expr);
+ return c_parser_postfix_expression_after_primary (parser, loc, expr);
}
/* Parse a postfix expression after a parenthesized type name: the
location_t start_loc;
tree type_expr = NULL_TREE;
bool type_expr_const = true;
- check_compound_literal_type (type_name, type_loc);
+ check_compound_literal_type (type_loc, type_name);
start_init (NULL_TREE, NULL, 0);
type = groktypename (type_name, &type_expr, &type_expr_const);
start_loc = c_parser_peek_token (parser)->location;
? CONSTRUCTOR_NON_CONST (init.value)
: init.original_code == C_MAYBE_CONST_EXPR);
non_const |= !type_expr_const;
- expr.value = build_compound_literal (type, init.value, non_const);
+ expr.value = build_compound_literal (start_loc, type, init.value, non_const);
expr.original_code = ERROR_MARK;
expr.original_type = NULL;
if (type_expr)
type_expr, expr.value);
}
}
- return c_parser_postfix_expression_after_primary (parser, expr);
+ return c_parser_postfix_expression_after_primary (parser, start_loc, expr);
}
/* Parse a postfix expression after the initial primary or compound
- literal; that is, parse a series of postfix operators. */
+ literal; that is, parse a series of postfix operators.
+
+ EXPR_LOC is the location of the primary expression. */
static struct c_expr
c_parser_postfix_expression_after_primary (c_parser *parser,
+ location_t expr_loc,
struct c_expr expr)
{
struct c_expr orig_expr;
tree ident, idx;
VEC(tree,gc) *exprlist;
VEC(tree,gc) *origtypes;
- location_t loc = c_parser_peek_token (parser)->location;
while (true)
{
+ location_t op_loc = c_parser_peek_token (parser)->location;
switch (c_parser_peek_token (parser)->type)
{
case CPP_OPEN_SQUARE:
/* Array reference. */
- loc = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser);
idx = c_parser_expression (parser).value;
c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE,
"expected %<]%>");
- expr.value = build_array_ref (expr.value, idx, loc);
+ expr.value = build_array_ref (op_loc, expr.value, idx);
expr.original_code = ERROR_MARK;
expr.original_type = NULL;
break;
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
"expected %<)%>");
orig_expr = expr;
- expr.value = build_function_call_vec (expr.value, exprlist,
+ /* FIXME diagnostics: Ideally we want the FUNCNAME, not the
+ "(" after the FUNCNAME, which is what we have now. */
+ expr.value = build_function_call_vec (op_loc, expr.value, exprlist,
origtypes);
expr.original_code = ERROR_MARK;
if (TREE_CODE (expr.value) == INTEGER_CST
case CPP_DOT:
/* Structure element reference. */
c_parser_consume_token (parser);
- expr = default_function_array_conversion (expr);
+ expr = default_function_array_conversion (expr_loc, expr);
if (c_parser_next_token_is (parser, CPP_NAME))
ident = c_parser_peek_token (parser)->value;
else
return expr;
}
c_parser_consume_token (parser);
- expr.value = build_component_ref (expr.value, ident);
+ expr.value = build_component_ref (op_loc, expr.value, ident);
expr.original_code = ERROR_MARK;
if (TREE_CODE (expr.value) != COMPONENT_REF)
expr.original_type = NULL;
case CPP_DEREF:
/* Structure element reference. */
c_parser_consume_token (parser);
- expr = default_function_array_conversion (expr);
+ expr = default_function_array_conversion (expr_loc, expr);
if (c_parser_next_token_is (parser, CPP_NAME))
ident = c_parser_peek_token (parser)->value;
else
return expr;
}
c_parser_consume_token (parser);
- expr.value = build_component_ref (build_indirect_ref (loc,
+ expr.value = build_component_ref (op_loc,
+ build_indirect_ref (op_loc,
expr.value,
"->"),
ident);
case CPP_PLUS_PLUS:
/* Postincrement. */
c_parser_consume_token (parser);
- expr = default_function_array_conversion (expr);
- expr.value = build_unary_op (loc,
+ expr = default_function_array_conversion (expr_loc, expr);
+ expr.value = build_unary_op (op_loc,
POSTINCREMENT_EXPR, expr.value, 0);
expr.original_code = ERROR_MARK;
expr.original_type = NULL;
case CPP_MINUS_MINUS:
/* Postdecrement. */
c_parser_consume_token (parser);
- expr = default_function_array_conversion (expr);
- expr.value = build_unary_op (loc,
+ expr = default_function_array_conversion (expr_loc, expr);
+ expr.value = build_unary_op (op_loc,
POSTDECREMENT_EXPR, expr.value, 0);
expr.original_code = ERROR_MARK;
expr.original_type = NULL;
while (c_parser_next_token_is (parser, CPP_COMMA))
{
struct c_expr next;
+ location_t loc = c_parser_peek_token (parser)->location;
+ location_t expr_loc;
c_parser_consume_token (parser);
+ expr_loc = c_parser_peek_token (parser)->location;
next = c_parser_expr_no_commas (parser, NULL);
- next = default_function_array_conversion (next);
- expr.value = build_compound_expr (expr.value, next.value);
+ next = default_function_array_conversion (expr_loc, next);
+ expr.value = build_compound_expr (loc, expr.value, next.value);
expr.original_code = COMPOUND_EXPR;
expr.original_type = next.original_type;
}
c_parser_expression_conv (c_parser *parser)
{
struct c_expr expr;
+ location_t loc = c_parser_peek_token (parser)->location;
expr = c_parser_expression (parser);
- expr = default_function_array_conversion (expr);
+ expr = default_function_array_conversion (loc, expr);
return expr;
}
VEC(tree,gc) *ret;
VEC(tree,gc) *orig_types;
struct c_expr expr;
+ location_t loc = c_parser_peek_token (parser)->location;
ret = make_tree_vector ();
if (p_orig_types == NULL)
expr = c_parser_expr_no_commas (parser, NULL);
if (convert_p)
- expr = default_function_array_conversion (expr);
+ expr = default_function_array_conversion (loc, expr);
if (fold_p)
expr.value = c_fully_fold (expr.value, false, NULL);
VEC_quick_push (tree, ret, expr.value);
while (c_parser_next_token_is (parser, CPP_COMMA))
{
c_parser_consume_token (parser);
+ loc = c_parser_peek_token (parser)->location;
expr = c_parser_expr_no_commas (parser, NULL);
if (convert_p)
- expr = default_function_array_conversion (expr);
+ expr = default_function_array_conversion (loc, expr);
if (fold_p)
expr.value = c_fully_fold (expr.value, false, NULL);
VEC_safe_push (tree, gc, ret, expr.value);
for (c = clauses; c ; c = OMP_CLAUSE_CHAIN (c))
if (OMP_CLAUSE_CODE (c) == code)
{
- error ("too many %qs clauses", name);
+ location_t loc = OMP_CLAUSE_LOCATION (c);
+ error_at (loc, "too many %qs clauses", name);
break;
}
}
identifier
variable-list , identifier
- If KIND is nonzero, create the appropriate node and install the decl
- in OMP_CLAUSE_DECL and add the node to the head of the list.
+ If KIND is nonzero, create the appropriate node and install the
+ decl in OMP_CLAUSE_DECL and add the node to the head of the list.
+ If KIND is nonzero, CLAUSE_LOC is the location of the clause.
If KIND is zero, create a TREE_LIST with the decl in TREE_PURPOSE;
return the list created. */
static tree
-c_parser_omp_variable_list (c_parser *parser, enum omp_clause_code kind,
+c_parser_omp_variable_list (c_parser *parser,
+ location_t clause_loc,
+ enum omp_clause_code kind,
tree list)
{
if (c_parser_next_token_is_not (parser, CPP_NAME)
tree t = lookup_name (c_parser_peek_token (parser)->value);
if (t == NULL_TREE)
- undeclared_variable (c_parser_peek_token (parser)->value,
- c_parser_peek_token (parser)->location);
+ undeclared_variable (c_parser_peek_token (parser)->location,
+ c_parser_peek_token (parser)->value);
else if (t == error_mark_node)
;
else if (kind != 0)
{
- tree u = build_omp_clause (kind);
+ tree u = build_omp_clause (clause_loc, kind);
OMP_CLAUSE_DECL (u) = t;
OMP_CLAUSE_CHAIN (u) = list;
list = u;
c_parser_omp_var_list_parens (c_parser *parser, enum omp_clause_code kind,
tree list)
{
+ /* The clauses location. */
+ location_t loc = c_parser_peek_token (parser)->location;
+
if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
{
- list = c_parser_omp_variable_list (parser, kind, list);
+ list = c_parser_omp_variable_list (parser, loc, kind, list);
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
}
return list;
"collapse argument needs positive constant integer expression");
return list;
}
- c = build_omp_clause (OMP_CLAUSE_COLLAPSE);
+ c = build_omp_clause (loc, OMP_CLAUSE_COLLAPSE);
OMP_CLAUSE_COLLAPSE_EXPR (c) = num;
OMP_CLAUSE_CHAIN (c) = list;
return c;
c_parser_omp_clause_default (c_parser *parser, tree list)
{
enum omp_clause_default_kind kind = OMP_CLAUSE_DEFAULT_UNSPECIFIED;
+ location_t loc = c_parser_peek_token (parser)->location;
tree c;
if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
return list;
check_no_duplicate_clause (list, OMP_CLAUSE_DEFAULT, "default");
- c = build_omp_clause (OMP_CLAUSE_DEFAULT);
+ c = build_omp_clause (loc, OMP_CLAUSE_DEFAULT);
OMP_CLAUSE_CHAIN (c) = list;
OMP_CLAUSE_DEFAULT_KIND (c) = kind;
static tree
c_parser_omp_clause_if (c_parser *parser, tree list)
{
+ location_t loc = c_parser_peek_token (parser)->location;
if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
{
tree t = c_parser_paren_condition (parser);
check_no_duplicate_clause (list, OMP_CLAUSE_IF, "if");
- c = build_omp_clause (OMP_CLAUSE_IF);
+ c = build_omp_clause (loc, OMP_CLAUSE_IF);
OMP_CLAUSE_IF_EXPR (c) = t;
OMP_CLAUSE_CHAIN (c) = list;
list = c;
c_parser_omp_clause_nowait (c_parser *parser ATTRIBUTE_UNUSED, tree list)
{
tree c;
+ location_t loc = c_parser_peek_token (parser)->location;
check_no_duplicate_clause (list, OMP_CLAUSE_NOWAIT, "nowait");
- c = build_omp_clause (OMP_CLAUSE_NOWAIT);
+ c = build_omp_clause (loc, OMP_CLAUSE_NOWAIT);
OMP_CLAUSE_CHAIN (c) = list;
return c;
}
static tree
c_parser_omp_clause_num_threads (c_parser *parser, tree list)
{
+ location_t num_threads_loc = c_parser_peek_token (parser)->location;
if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
{
location_t expr_loc = c_parser_peek_token (parser)->location;
/* Attempt to statically determine when the number isn't positive. */
c = fold_build2 (LE_EXPR, boolean_type_node, t,
build_int_cst (TREE_TYPE (t), 0));
+ if (CAN_HAVE_LOCATION_P (c))
+ SET_EXPR_LOCATION (c, expr_loc);
if (c == boolean_true_node)
{
warning_at (expr_loc, 0,
check_no_duplicate_clause (list, OMP_CLAUSE_NUM_THREADS, "num_threads");
- c = build_omp_clause (OMP_CLAUSE_NUM_THREADS);
+ c = build_omp_clause (num_threads_loc, OMP_CLAUSE_NUM_THREADS);
OMP_CLAUSE_NUM_THREADS_EXPR (c) = t;
OMP_CLAUSE_CHAIN (c) = list;
list = c;
ordered */
static tree
-c_parser_omp_clause_ordered (c_parser *parser ATTRIBUTE_UNUSED, tree list)
+c_parser_omp_clause_ordered (c_parser *parser, tree list)
{
tree c;
check_no_duplicate_clause (list, OMP_CLAUSE_ORDERED, "ordered");
- c = build_omp_clause (OMP_CLAUSE_ORDERED);
+ c = build_omp_clause (c_parser_peek_token (parser)->location,
+ OMP_CLAUSE_ORDERED);
OMP_CLAUSE_CHAIN (c) = list;
+
return c;
}
static tree
c_parser_omp_clause_reduction (c_parser *parser, tree list)
{
+ location_t clause_loc = c_parser_peek_token (parser)->location;
if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
{
enum tree_code code;
{
tree nl, c;
- nl = c_parser_omp_variable_list (parser, OMP_CLAUSE_REDUCTION, list);
+ nl = c_parser_omp_variable_list (parser, clause_loc,
+ OMP_CLAUSE_REDUCTION, list);
for (c = nl; c != list; c = OMP_CLAUSE_CHAIN (c))
OMP_CLAUSE_REDUCTION_CODE (c) = code;
c_parser_omp_clause_schedule (c_parser *parser, tree list)
{
tree c, t;
+ location_t loc = c_parser_peek_token (parser)->location;
if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
return list;
- c = build_omp_clause (OMP_CLAUSE_SCHEDULE);
+ c = build_omp_clause (loc, OMP_CLAUSE_SCHEDULE);
if (c_parser_next_token_is (parser, CPP_NAME))
{
/* FIXME: Should we allow duplicates? */
check_no_duplicate_clause (list, OMP_CLAUSE_UNTIED, "untied");
- c = build_omp_clause (OMP_CLAUSE_UNTIED);
+ c = build_omp_clause (c_parser_peek_token (parser)->location,
+ OMP_CLAUSE_UNTIED);
OMP_CLAUSE_CHAIN (c) = list;
+
return c;
}
binop:
+, *, -, /, &, ^, |, <<, >>
- where x is an lvalue expression with scalar type. */
+ where x is an lvalue expression with scalar type.
+
+ LOC is the location of the #pragma token. */
static void
-c_parser_omp_atomic (c_parser *parser)
+c_parser_omp_atomic (location_t loc, c_parser *parser)
{
tree lhs, rhs;
tree stmt;
}
c_parser_consume_token (parser);
- rhs_expr = c_parser_expression (parser);
- rhs_expr = default_function_array_conversion (rhs_expr);
+ {
+ location_t rhs_loc = c_parser_peek_token (parser)->location;
+ rhs_expr = c_parser_expression (parser);
+ rhs_expr = default_function_array_conversion (rhs_loc, rhs_expr);
+ }
rhs = rhs_expr.value;
rhs = c_fully_fold (rhs, false, NULL);
break;
}
- stmt = c_finish_omp_atomic (code, lhs, rhs);
+ stmt = c_finish_omp_atomic (loc, code, lhs, rhs);
if (stmt != error_mark_node)
add_stmt (stmt);
c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
static void
c_parser_omp_barrier (c_parser *parser)
{
+ location_t loc = c_parser_peek_token (parser)->location;
c_parser_consume_pragma (parser);
c_parser_skip_to_pragma_eol (parser);
- c_finish_omp_barrier ();
+ c_finish_omp_barrier (loc);
}
/* OpenMP 2.5:
# pragma omp critical [(name)] new-line
structured-block
-*/
+
+ LOC is the location of the #pragma itself. */
static tree
-c_parser_omp_critical (c_parser *parser)
+c_parser_omp_critical (location_t loc, c_parser *parser)
{
tree stmt, name = NULL;
c_parser_skip_to_pragma_eol (parser);
stmt = c_parser_omp_structured_block (parser);
- return c_finish_omp_critical (stmt, name);
+ return c_finish_omp_critical (loc, stmt, name);
}
/* OpenMP 2.5:
static void
c_parser_omp_flush (c_parser *parser)
{
+ location_t loc = c_parser_peek_token (parser)->location;
c_parser_consume_pragma (parser);
if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
c_parser_omp_var_list_parens (parser, OMP_CLAUSE_ERROR, NULL);
c_parser_error (parser, "expected %<(%> or end of line");
c_parser_skip_to_pragma_eol (parser);
- c_finish_omp_flush ();
+ c_finish_omp_flush (loc);
}
/* Parse the restricted form of the for statement allowed by OpenMP.
The real trick here is to determine the loop control variable early
- so that we can push a new decl if necessary to make it private. */
+ so that we can push a new decl if necessary to make it private.
+ LOC is the location of the OMP in "#pragma omp". */
static tree
-c_parser_omp_for_loop (c_parser *parser, tree clauses, tree *par_clauses)
+c_parser_omp_for_loop (location_t loc,
+ c_parser *parser, tree clauses, tree *par_clauses)
{
tree decl, cond, incr, save_break, save_cont, body, init, stmt, cl;
tree declv, condv, incrv, initv, for_block = NULL, ret = NULL;
- location_t loc;
bool fail = false, open_brace_parsed = false;
int i, collapse = 1, nbraces = 0;
+ location_t for_loc;
for (cl = clauses; cl; cl = OMP_CLAUSE_CHAIN (cl))
if (OMP_CLAUSE_CODE (cl) == OMP_CLAUSE_COLLAPSE)
c_parser_error (parser, "for statement expected");
return NULL;
}
- loc = c_parser_peek_token (parser)->location;
+ for_loc = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser);
for (i = 0; i < collapse; i++)
for_block
= tree_cons (NULL, c_begin_compound_stmt (true), for_block);
c_parser_declaration_or_fndef (parser, true, true, true, true);
- decl = check_for_loop_decls ();
+ decl = check_for_loop_decls (for_loc);
if (decl == NULL)
goto error_init;
if (DECL_INITIAL (decl) == error_mark_node)
decl = decl_exp.value;
c_parser_require (parser, CPP_EQ, "expected %<=%>");
- init_loc = c_parser_peek_token (parser)->location;
+ init_loc = c_parser_peek_token (parser)->location;
init_exp = c_parser_expr_no_commas (parser, NULL);
- init_exp = default_function_array_conversion (init_exp);
+ init_exp = default_function_array_conversion (init_loc, init_exp);
init = build_modify_expr (init_loc, decl, decl_exp.original_type,
- NOP_EXPR, init_exp.value,
+ NOP_EXPR, init_loc, init_exp.value,
init_exp.original_type);
- init = c_process_expr_stmt (init);
+ init = c_process_expr_stmt (init_loc, init);
c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
}
{
location_t incr_loc = c_parser_peek_token (parser)->location;
- incr = c_process_expr_stmt (c_parser_expression (parser).value);
- protected_set_expr_location (incr, incr_loc);
+ incr = c_process_expr_stmt (incr_loc,
+ c_parser_expression (parser).value);
}
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
if (open_brace_parsed)
{
+ location_t here = c_parser_peek_token (parser)->location;
stmt = c_begin_compound_stmt (true);
c_parser_compound_statement_nostart (parser);
- add_stmt (c_end_compound_stmt (stmt, true));
+ add_stmt (c_end_compound_stmt (here, stmt, true));
}
else
add_stmt (c_parser_c99_block_statement (parser));
if (c_cont_label)
- add_stmt (build1 (LABEL_EXPR, void_type_node, c_cont_label));
+ {
+ tree t = build1 (LABEL_EXPR, void_type_node, c_cont_label);
+ SET_EXPR_LOCATION (t, loc);
+ add_stmt (t);
+ }
body = pop_stmt_list (body);
c_break_label = save_break;
c_parser_error (parser, "collapsed loops not perfectly nested");
while (nbraces)
{
+ location_t here = c_parser_peek_token (parser)->location;
stmt = c_begin_compound_stmt (true);
add_stmt (body);
c_parser_compound_statement_nostart (parser);
- body = c_end_compound_stmt (stmt, true);
+ body = c_end_compound_stmt (here, stmt, true);
nbraces--;
}
goto pop_scopes;
/* Copy lastprivate (decl) clause to OMP_FOR_CLAUSES,
change it to shared (decl) in
OMP_PARALLEL_CLAUSES. */
- tree l = build_omp_clause (OMP_CLAUSE_LASTPRIVATE);
+ tree l = build_omp_clause (OMP_CLAUSE_LOCATION (*c),
+ OMP_CLAUSE_LASTPRIVATE);
OMP_CLAUSE_DECL (l) = OMP_CLAUSE_DECL (*c);
OMP_CLAUSE_CHAIN (l) = clauses;
clauses = l;
pop_scopes:
while (for_block)
{
- stmt = c_end_compound_stmt (TREE_VALUE (for_block), true);
+ /* FIXME diagnostics: LOC below should be the actual location of
+ this particular for block. We need to build a list of
+ locations to go along with FOR_BLOCK. */
+ stmt = c_end_compound_stmt (loc, TREE_VALUE (for_block), true);
add_stmt (stmt);
for_block = TREE_CHAIN (for_block);
}
/* OpenMP 2.5:
#pragma omp for for-clause[optseq] new-line
for-loop
+
+ LOC is the location of the #pragma token.
*/
#define OMP_FOR_CLAUSE_MASK \
| (1u << PRAGMA_OMP_CLAUSE_NOWAIT))
static tree
-c_parser_omp_for (c_parser *parser)
+c_parser_omp_for (location_t loc, c_parser *parser)
{
tree block, clauses, ret;
"#pragma omp for");
block = c_begin_compound_stmt (true);
- ret = c_parser_omp_for_loop (parser, clauses, NULL);
- block = c_end_compound_stmt (block, true);
+ ret = c_parser_omp_for_loop (loc, parser, clauses, NULL);
+ block = c_end_compound_stmt (loc, block, true);
add_stmt (block);
return ret;
/* OpenMP 2.5:
# pragma omp master new-line
structured-block
+
+ LOC is the location of the #pragma token.
*/
static tree
-c_parser_omp_master (c_parser *parser)
+c_parser_omp_master (location_t loc, c_parser *parser)
{
c_parser_skip_to_pragma_eol (parser);
- return c_finish_omp_master (c_parser_omp_structured_block (parser));
+ return c_finish_omp_master (loc, c_parser_omp_structured_block (parser));
}
/* OpenMP 2.5:
# pragma omp ordered new-line
structured-block
+
+ LOC is the location of the #pragma itself.
*/
static tree
-c_parser_omp_ordered (c_parser *parser)
+c_parser_omp_ordered (location_t loc, c_parser *parser)
{
c_parser_skip_to_pragma_eol (parser);
- return c_finish_omp_ordered (c_parser_omp_structured_block (parser));
+ return c_finish_omp_ordered (loc, c_parser_omp_structured_block (parser));
}
/* OpenMP 2.5:
section-sequence:
section-directive[opt] structured-block
- section-sequence section-directive structured-block */
+ section-sequence section-directive structured-block
+
+ SECTIONS_LOC is the location of the #pragma omp sections. */
static tree
-c_parser_omp_sections_scope (c_parser *parser)
+c_parser_omp_sections_scope (location_t sections_loc, c_parser *parser)
{
tree stmt, substmt;
bool error_suppress = false;
location_t loc;
+ loc = c_parser_peek_token (parser)->location;
if (!c_parser_require (parser, CPP_OPEN_BRACE, "expected %<{%>"))
{
/* Avoid skipping until the end of the block. */
stmt = push_stmt_list ();
- loc = c_parser_peek_token (parser)->location;
if (c_parser_peek_token (parser)->pragma_kind != PRAGMA_OMP_SECTION)
{
substmt = push_stmt_list ();
substmt = pop_stmt_list (stmt);
stmt = make_node (OMP_SECTIONS);
+ SET_EXPR_LOCATION (stmt, sections_loc);
TREE_TYPE (stmt) = void_type_node;
OMP_SECTIONS_BODY (stmt) = substmt;
/* OpenMP 2.5:
# pragma omp sections sections-clause[optseq] newline
sections-scope
+
+ LOC is the location of the #pragma token.
*/
#define OMP_SECTIONS_CLAUSE_MASK \
| (1u << PRAGMA_OMP_CLAUSE_NOWAIT))
static tree
-c_parser_omp_sections (c_parser *parser)
+c_parser_omp_sections (location_t loc, c_parser *parser)
{
tree block, clauses, ret;
"#pragma omp sections");
block = c_begin_compound_stmt (true);
- ret = c_parser_omp_sections_scope (parser);
+ ret = c_parser_omp_sections_scope (loc, parser);
if (ret)
OMP_SECTIONS_CLAUSES (ret) = clauses;
- block = c_end_compound_stmt (block, true);
+ block = c_end_compound_stmt (loc, block, true);
add_stmt (block);
return ret;
# pragma parallel parallel-clause new-line
# pragma parallel for parallel-for-clause new-line
# pragma parallel sections parallel-sections-clause new-line
+
+ LOC is the location of the #pragma token.
*/
#define OMP_PARALLEL_CLAUSE_MASK \
| (1u << PRAGMA_OMP_CLAUSE_NUM_THREADS))
static tree
-c_parser_omp_parallel (c_parser *parser)
+c_parser_omp_parallel (location_t loc, c_parser *parser)
{
enum pragma_kind p_kind = PRAGMA_OMP_PARALLEL;
const char *p_name = "#pragma omp parallel";
case PRAGMA_OMP_PARALLEL:
block = c_begin_omp_parallel ();
c_parser_statement (parser);
- stmt = c_finish_omp_parallel (clauses, block);
+ stmt = c_finish_omp_parallel (loc, clauses, block);
break;
case PRAGMA_OMP_PARALLEL_FOR:
block = c_begin_omp_parallel ();
- c_split_parallel_clauses (clauses, &par_clause, &ws_clause);
- c_parser_omp_for_loop (parser, ws_clause, &par_clause);
- stmt = c_finish_omp_parallel (par_clause, block);
+ c_split_parallel_clauses (loc, clauses, &par_clause, &ws_clause);
+ c_parser_omp_for_loop (loc, parser, ws_clause, &par_clause);
+ stmt = c_finish_omp_parallel (loc, par_clause, block);
OMP_PARALLEL_COMBINED (stmt) = 1;
break;
case PRAGMA_OMP_PARALLEL_SECTIONS:
block = c_begin_omp_parallel ();
- c_split_parallel_clauses (clauses, &par_clause, &ws_clause);
- stmt = c_parser_omp_sections_scope (parser);
+ c_split_parallel_clauses (loc, clauses, &par_clause, &ws_clause);
+ stmt = c_parser_omp_sections_scope (loc, parser);
if (stmt)
OMP_SECTIONS_CLAUSES (stmt) = ws_clause;
- stmt = c_finish_omp_parallel (par_clause, block);
+ stmt = c_finish_omp_parallel (loc, par_clause, block);
OMP_PARALLEL_COMBINED (stmt) = 1;
break;
/* OpenMP 2.5:
# pragma omp single single-clause[optseq] new-line
structured-block
+
+ LOC is the location of the #pragma.
*/
#define OMP_SINGLE_CLAUSE_MASK \
| (1u << PRAGMA_OMP_CLAUSE_NOWAIT))
static tree
-c_parser_omp_single (c_parser *parser)
+c_parser_omp_single (location_t loc, c_parser *parser)
{
tree stmt = make_node (OMP_SINGLE);
+ SET_EXPR_LOCATION (stmt, loc);
TREE_TYPE (stmt) = void_type_node;
OMP_SINGLE_CLAUSES (stmt)
/* OpenMP 3.0:
# pragma omp task task-clause[optseq] new-line
+
+ LOC is the location of the #pragma.
*/
#define OMP_TASK_CLAUSE_MASK \
| (1u << PRAGMA_OMP_CLAUSE_SHARED))
static tree
-c_parser_omp_task (c_parser *parser)
+c_parser_omp_task (location_t loc, c_parser *parser)
{
tree clauses, block;
block = c_begin_omp_task ();
c_parser_statement (parser);
- return c_finish_omp_task (clauses, block);
+ return c_finish_omp_task (loc, clauses, block);
}
/* OpenMP 3.0:
static void
c_parser_omp_taskwait (c_parser *parser)
{
+ location_t loc = c_parser_peek_token (parser)->location;
c_parser_consume_pragma (parser);
c_parser_skip_to_pragma_eol (parser);
- c_finish_omp_taskwait ();
+ c_finish_omp_taskwait (loc);
}
/* Main entry point to parsing most OpenMP pragmas. */
switch (p_kind)
{
case PRAGMA_OMP_ATOMIC:
- c_parser_omp_atomic (parser);
+ c_parser_omp_atomic (loc, parser);
return;
case PRAGMA_OMP_CRITICAL:
- stmt = c_parser_omp_critical (parser);
+ stmt = c_parser_omp_critical (loc, parser);
break;
case PRAGMA_OMP_FOR:
- stmt = c_parser_omp_for (parser);
+ stmt = c_parser_omp_for (loc, parser);
break;
case PRAGMA_OMP_MASTER:
- stmt = c_parser_omp_master (parser);
+ stmt = c_parser_omp_master (loc, parser);
break;
case PRAGMA_OMP_ORDERED:
- stmt = c_parser_omp_ordered (parser);
+ stmt = c_parser_omp_ordered (loc, parser);
break;
case PRAGMA_OMP_PARALLEL:
- stmt = c_parser_omp_parallel (parser);
+ stmt = c_parser_omp_parallel (loc, parser);
break;
case PRAGMA_OMP_SECTIONS:
- stmt = c_parser_omp_sections (parser);
+ stmt = c_parser_omp_sections (loc, parser);
break;
case PRAGMA_OMP_SINGLE:
- stmt = c_parser_omp_single (parser);
+ stmt = c_parser_omp_single (loc, parser);
break;
case PRAGMA_OMP_TASK:
- stmt = c_parser_omp_task (parser);
+ stmt = c_parser_omp_task (loc, parser);
break;
default:
gcc_unreachable ();
}
if (stmt)
- SET_EXPR_LOCATION (stmt, loc);
+ gcc_assert (EXPR_LOCATION (stmt) != UNKNOWN_LOCATION);
}
c_parser_omp_threadprivate (c_parser *parser)
{
tree vars, t;
+ location_t loc;
c_parser_consume_pragma (parser);
+ loc = c_parser_peek_token (parser)->location;
vars = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_ERROR, NULL);
/* Mark every variable in VARS to be assigned thread local storage. */
{
tree v = TREE_PURPOSE (t);
+ /* FIXME diagnostics: Ideally we should keep individual
+ locations for all the variables in the var list to make the
+ following errors more precise. Perhaps
+ c_parser_omp_var_list_parens() should construct a list of
+ locations to go along with the var list. */
+
/* If V had already been marked threadprivate, it doesn't matter
whether it had been used prior to this point. */
if (TREE_CODE (v) != VAR_DECL)
- error ("%qD is not a variable", v);
+ error_at (loc, "%qD is not a variable", v);
else if (TREE_USED (v) && !C_DECL_THREADPRIVATE_P (v))
- error ("%qE declared %<threadprivate%> after first use", v);
+ error_at (loc, "%qE declared %<threadprivate%> after first use", v);
else if (! TREE_STATIC (v) && ! DECL_EXTERNAL (v))
- error ("automatic variable %qE cannot be %<threadprivate%>", v);
+ error_at (loc, "automatic variable %qE cannot be %<threadprivate%>", v);
else if (TREE_TYPE (v) == error_mark_node)
;
else if (! COMPLETE_TYPE_P (TREE_TYPE (v)))
- error ("%<threadprivate%> %qE has incomplete type", v);
+ error_at (loc, "%<threadprivate%> %qE has incomplete type", v);
else
{
if (! DECL_THREAD_LOCAL_P (v))
if (TREE_VALUE (t) == NULL)
continue;
- decl = build_decl (FUNCTION_DECL, alias_id, default_function_type);
+ decl = build_decl (UNKNOWN_LOCATION,
+ FUNCTION_DECL, alias_id, default_function_type);
DECL_ARTIFICIAL (decl) = 1;
TREE_PUBLIC (decl) = 1;
/* Build a generic statement based on the given type of node and
arguments. Similar to `build_nt', except that we set
- EXPR_LOCATION to be the current source location. */
+ EXPR_LOCATION to LOC. */
/* ??? This should be obsolete with the lineno_stmt productions
in the grammar. */
tree
-build_stmt (enum tree_code code, ...)
+build_stmt (location_t loc, enum tree_code code, ...)
{
tree ret;
int length, i;
ret = make_node (code);
TREE_TYPE (ret) = void_type_node;
length = TREE_CODE_LENGTH (code);
- SET_EXPR_LOCATION (ret, input_location);
+ SET_EXPR_LOCATION (ret, loc);
/* TREE_SIDE_EFFECTS will already be set for statements with
implicit side effects. Here we make sure it is set for other
/* Create a CASE_LABEL_EXPR tree node and return it. */
tree
-build_case_label (tree low_value, tree high_value, tree label_decl)
+build_case_label (location_t loc,
+ tree low_value, tree high_value, tree label_decl)
{
- return build_stmt (CASE_LABEL_EXPR, low_value, high_value, label_decl);
+ return build_stmt (loc, CASE_LABEL_EXPR, low_value, high_value, label_decl);
}
enum c_declarator_kind kind;
/* Except for cdk_id, the contained declarator. For cdk_id, NULL. */
struct c_declarator *declarator;
- location_t id_loc; /* Currently only set for cdk_id. */
+ location_t id_loc; /* Currently only set for cdk_id, cdk_array. */
union {
/* For identifiers, an IDENTIFIER_NODE or NULL_TREE if an abstract
declarator. */
extern void c_dup_lang_specific_decl (tree);
extern void c_print_identifier (FILE *, tree, int);
extern int quals_from_declspecs (const struct c_declspecs *);
-extern struct c_declarator *build_array_declarator (tree, struct c_declspecs *,
+extern struct c_declarator *build_array_declarator (location_t, tree,
+ struct c_declspecs *,
bool, bool);
-extern tree build_enumerator (struct c_enum_contents *, tree, tree, location_t);
-extern tree check_for_loop_decls (void);
+extern tree build_enumerator (location_t, struct c_enum_contents *, tree, tree);
+extern tree check_for_loop_decls (location_t);
extern void mark_forward_parm_decls (void);
extern void declare_parm_level (void);
-extern void undeclared_variable (tree, location_t);
+extern void undeclared_variable (location_t, tree);
extern tree declare_label (tree);
extern tree define_label (location_t, tree);
extern void c_maybe_initialize_eh (void);
-extern void finish_decl (tree, tree, tree, tree);
+extern void finish_decl (tree, location_t, tree, tree, tree);
extern tree finish_enum (tree, tree, tree);
extern void finish_function (void);
-extern tree finish_struct (tree, tree, tree, bool, VEC(tree,heap) *);
+extern tree finish_struct (location_t, tree, tree, tree, bool, VEC(tree,heap) *);
extern struct c_arg_info *get_parm_info (bool);
extern tree grokfield (location_t, struct c_declarator *,
struct c_declspecs *, tree, tree *);
extern tree groktypename (struct c_type_name *, tree *, bool *);
extern tree grokparm (const struct c_parm *);
-extern tree implicitly_declare (tree);
+extern tree implicitly_declare (location_t, tree);
extern void keep_next_level (void);
extern void pending_xref_error (void);
extern void c_push_function_context (void);
extern tree c_builtin_function_ext_scope (tree);
extern void shadow_tag (const struct c_declspecs *);
extern void shadow_tag_warned (const struct c_declspecs *, int);
-extern tree start_enum (struct c_enum_contents *, tree, location_t);
+extern tree start_enum (location_t, struct c_enum_contents *, tree);
extern int start_function (struct c_declspecs *, struct c_declarator *, tree);
extern tree start_decl (struct c_declarator *, struct c_declspecs *, bool,
tree);
-extern tree start_struct (enum tree_code, tree, bool *, VEC(tree,heap) **,
- location_t);
+extern tree start_struct (location_t, enum tree_code, tree, bool *, VEC(tree,heap) **);
extern void store_parm_decls (void);
extern void store_parm_decls_from (struct c_arg_info *);
extern tree xref_tag (enum tree_code, tree);
-extern struct c_typespec parser_xref_tag (enum tree_code, tree, location_t);
+extern struct c_typespec parser_xref_tag (location_t, enum tree_code, tree);
extern int c_expand_decl (tree);
extern struct c_parm *build_c_parm (struct c_declspecs *, tree,
struct c_declarator *);
extern bool c_mark_addressable (tree);
extern void c_incomplete_type_error (const_tree, const_tree);
extern tree c_type_promotes_to (tree);
-extern struct c_expr default_function_array_conversion (struct c_expr);
+extern struct c_expr default_function_array_conversion (location_t,
+ struct c_expr);
extern tree composite_type (tree, tree);
-extern tree build_component_ref (tree, tree);
-extern tree build_array_ref (tree, tree, location_t);
-extern tree build_external_ref (tree, int, location_t, tree *);
+extern tree build_component_ref (location_t, tree, tree);
+extern tree build_array_ref (location_t, tree, tree);
+extern tree build_external_ref (location_t, tree, int, tree *);
extern void pop_maybe_used (bool);
-extern struct c_expr c_expr_sizeof_expr (struct c_expr);
-extern struct c_expr c_expr_sizeof_type (struct c_type_name *);
-extern struct c_expr parser_build_unary_op (enum tree_code, struct c_expr,
- location_t);
+extern struct c_expr c_expr_sizeof_expr (location_t, struct c_expr);
+extern struct c_expr c_expr_sizeof_type (location_t, struct c_type_name *);
+extern struct c_expr parser_build_unary_op (location_t, enum tree_code,
+ struct c_expr);
extern struct c_expr parser_build_binary_op (location_t,
enum tree_code, struct c_expr,
struct c_expr);
extern tree build_conditional_expr (location_t, tree, bool, tree, tree);
-extern tree build_compound_expr (tree, tree);
-extern tree c_cast_expr (struct c_type_name *, tree, location_t);
-extern tree build_c_cast (tree, tree);
-extern void store_init_value (tree, tree, tree);
+extern tree build_compound_expr (location_t, tree, tree);
+extern tree c_cast_expr (location_t, struct c_type_name *, tree);
+extern tree build_c_cast (location_t, tree, tree);
+extern void store_init_value (location_t, tree, tree, tree);
extern void error_init (const char *);
extern void pedwarn_init (location_t, int opt, const char *);
extern void maybe_warn_string_init (tree, struct c_expr);
extern void set_init_index (tree, tree);
extern void set_init_label (tree);
extern void process_init_element (struct c_expr, bool);
-extern tree build_compound_literal (tree, tree, bool);
-extern void check_compound_literal_type (struct c_type_name *, location_t);
-extern tree c_start_case (tree);
+extern tree build_compound_literal (location_t, tree, tree, bool);
+extern void check_compound_literal_type (location_t, struct c_type_name *);
+extern tree c_start_case (location_t, location_t, tree);
extern void c_finish_case (tree);
-extern tree build_asm_expr (tree, tree, tree, tree, bool);
+extern tree build_asm_expr (location_t, tree, tree, tree, tree, bool);
extern tree build_asm_stmt (tree, tree);
extern int c_types_compatible_p (tree, tree);
extern tree c_begin_compound_stmt (bool);
-extern tree c_end_compound_stmt (tree, bool);
+extern tree c_end_compound_stmt (location_t, tree, bool);
extern void c_finish_if_stmt (location_t, tree, tree, tree, bool);
extern void c_finish_loop (location_t, tree, tree, tree, tree, tree, bool);
extern tree c_begin_stmt_expr (void);
-extern tree c_finish_stmt_expr (tree);
-extern tree c_process_expr_stmt (tree);
-extern tree c_finish_expr_stmt (tree);
-extern tree c_finish_return (tree, tree);
-extern tree c_finish_bc_stmt (tree *, bool);
-extern tree c_finish_goto_label (tree);
-extern tree c_finish_goto_ptr (tree);
+extern tree c_finish_stmt_expr (location_t, tree);
+extern tree c_process_expr_stmt (location_t, tree);
+extern tree c_finish_expr_stmt (location_t, tree);
+extern tree c_finish_return (location_t, tree, tree);
+extern tree c_finish_bc_stmt (location_t, tree *, bool);
+extern tree c_finish_goto_label (location_t, tree);
+extern tree c_finish_goto_ptr (location_t, tree);
extern void c_begin_vm_scope (unsigned int);
extern void c_end_vm_scope (unsigned int);
extern tree c_expr_to_decl (tree, bool *, bool *);
extern tree c_begin_omp_parallel (void);
-extern tree c_finish_omp_parallel (tree, tree);
+extern tree c_finish_omp_parallel (location_t, tree, tree);
extern tree c_begin_omp_task (void);
-extern tree c_finish_omp_task (tree, tree);
+extern tree c_finish_omp_task (location_t, tree, tree);
extern tree c_finish_omp_clauses (tree);
-extern tree c_build_va_arg (tree, tree, location_t);
+extern tree c_build_va_arg (location_t, tree, tree);
/* Set to 0 at beginning of a function definition, set to 1 if
a return statement that specifies a return value is seen. */
static int spelling_length (void);
static char *print_spelling (char *);
static void warning_init (int, const char *);
-static tree digest_init (tree, tree, tree, bool, bool, int);
+static tree digest_init (location_t, tree, tree, tree, bool, bool, int);
static void output_init_element (tree, tree, bool, tree, tree, int, bool);
static void output_pending_init_elements (int);
static int set_designator (int);
/* Convert the array expression EXP to a pointer. */
static tree
-array_to_pointer_conversion (tree exp)
+array_to_pointer_conversion (location_t loc, tree exp)
{
tree orig_exp = exp;
tree type = TREE_TYPE (exp);
if (TREE_CODE (exp) == INDIRECT_REF)
return convert (ptrtype, TREE_OPERAND (exp, 0));
- adr = build_unary_op (EXPR_LOCATION (exp), ADDR_EXPR, exp, 1);
+ adr = build_unary_op (loc, ADDR_EXPR, exp, 1);
return convert (ptrtype, adr);
}
/* Convert the function expression EXP to a pointer. */
static tree
-function_to_pointer_conversion (tree exp)
+function_to_pointer_conversion (location_t loc, tree exp)
{
tree orig_exp = exp;
if (TREE_NO_WARNING (orig_exp))
TREE_NO_WARNING (exp) = 1;
- return build_unary_op (EXPR_LOCATION (exp), ADDR_EXPR, exp, 0);
+ return build_unary_op (loc, ADDR_EXPR, exp, 0);
}
/* Perform the default conversion of arrays and functions to pointers.
Return the result of converting EXP. For any other expression, just
- return EXP. */
+ return EXP.
+
+ LOC is the location of the expression. */
struct c_expr
-default_function_array_conversion (struct c_expr exp)
+default_function_array_conversion (location_t loc, struct c_expr exp)
{
tree orig_exp = exp.value;
tree type = TREE_TYPE (exp.value);
return exp;
}
- exp.value = array_to_pointer_conversion (exp.value);
+ exp.value = array_to_pointer_conversion (loc, exp.value);
}
break;
case FUNCTION_TYPE:
- exp.value = function_to_pointer_conversion (exp.value);
+ exp.value = function_to_pointer_conversion (loc, exp.value);
break;
default:
break;
return tree_cons (NULL_TREE, field, NULL_TREE);
}
-/* Make an expression to refer to the COMPONENT field of
- structure or union value DATUM. COMPONENT is an IDENTIFIER_NODE. */
+/* Make an expression to refer to the COMPONENT field of structure or
+ union value DATUM. COMPONENT is an IDENTIFIER_NODE. LOC is the
+ location of the COMPONENT_REF. */
tree
-build_component_ref (tree datum, tree component)
+build_component_ref (location_t loc, tree datum, tree component)
{
tree type = TREE_TYPE (datum);
enum tree_code code = TREE_CODE (type);
if (!field)
{
- error ("%qT has no member named %qE", type, component);
+ error_at (loc, "%qT has no member named %qE", type, component);
return error_mark_node;
}
ref = build3 (COMPONENT_REF, subtype, datum, subdatum,
NULL_TREE);
+ SET_EXPR_LOCATION (ref, loc);
if (TREE_READONLY (subdatum)
|| (use_datum_quals && TREE_READONLY (datum)))
TREE_READONLY (ref) = 1;
return ref;
}
else if (code != ERROR_MARK)
- error ("request for member %qE in something not a structure or union",
- component);
+ error_at (loc,
+ "request for member %qE in something not a structure or union",
+ component);
return error_mark_node;
}
LOC is the location to use for the returned expression. */
tree
-build_array_ref (tree array, tree index, location_t loc)
+build_array_ref (location_t loc, tree array, tree index)
{
tree ret;
bool swapped = false;
for CONST_DECLs defined as enum constants. If the type of the
identifier is not available, *TYPE is set to NULL. */
tree
-build_external_ref (tree id, int fun, location_t loc, tree *type)
+build_external_ref (location_t loc, tree id, int fun, tree *type)
{
tree ref;
tree decl = lookup_name (id);
}
else if (fun)
/* Implicit function declaration. */
- ref = implicitly_declare (id);
+ ref = implicitly_declare (loc, id);
else if (decl == error_mark_node)
/* Don't complain about something that's already been
complained about. */
return error_mark_node;
else
{
- undeclared_variable (id, loc);
+ undeclared_variable (loc, id);
return error_mark_node;
}
/* Return the result of sizeof applied to EXPR. */
struct c_expr
-c_expr_sizeof_expr (struct c_expr expr)
+c_expr_sizeof_expr (location_t loc, struct c_expr expr)
{
struct c_expr ret;
if (expr.value == error_mark_node)
bool expr_const_operands = true;
tree folded_expr = c_fully_fold (expr.value, require_constant_value,
&expr_const_operands);
- ret.value = c_sizeof (TREE_TYPE (folded_expr));
+ ret.value = c_sizeof (loc, TREE_TYPE (folded_expr));
ret.original_code = ERROR_MARK;
ret.original_type = NULL;
if (c_vla_type_p (TREE_TYPE (folded_expr)))
ret.value = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret.value),
folded_expr, ret.value);
C_MAYBE_CONST_EXPR_NON_CONST (ret.value) = !expr_const_operands;
+ SET_EXPR_LOCATION (ret.value, loc);
}
pop_maybe_used (C_TYPE_VARIABLE_SIZE (TREE_TYPE (folded_expr)));
}
}
/* Return the result of sizeof applied to T, a structure for the type
- name passed to sizeof (rather than the type itself). */
+ name passed to sizeof (rather than the type itself). LOC is the
+ location of the original expression. */
struct c_expr
-c_expr_sizeof_type (struct c_type_name *t)
+c_expr_sizeof_type (location_t loc, struct c_type_name *t)
{
tree type;
struct c_expr ret;
tree type_expr = NULL_TREE;
bool type_expr_const = true;
type = groktypename (t, &type_expr, &type_expr_const);
- ret.value = c_sizeof (type);
+ ret.value = c_sizeof (loc, type);
ret.original_code = ERROR_MARK;
ret.original_type = NULL;
if ((type_expr || TREE_CODE (ret.value) == INTEGER_CST)
}
/* Build a function call to function FUNCTION with parameters PARAMS.
+ The function call is at LOC.
PARAMS is a list--a chain of TREE_LIST nodes--in which the
TREE_VALUE of each node is a parameter-expression.
FUNCTION's data type may be a function type or a pointer-to-function. */
tree
-build_function_call (tree function, tree params)
+build_function_call (location_t loc, tree function, tree params)
{
VEC(tree,gc) *vec;
tree ret;
vec = VEC_alloc (tree, gc, list_length (params));
for (; params; params = TREE_CHAIN (params))
VEC_quick_push (tree, vec, TREE_VALUE (params));
- ret = build_function_call_vec (function, vec, NULL);
+ ret = build_function_call_vec (loc, function, vec, NULL);
VEC_free (tree, gc, vec);
return ret;
}
PARAMS. */
tree
-build_function_call_vec (tree function, VEC(tree,gc) *params,
+build_function_call_vec (location_t loc, tree function, VEC(tree,gc) *params,
VEC(tree,gc) *origtypes)
{
tree fntype, fundecl = 0;
resolve_overloaded_builtin and targetm.resolve_overloaded_builtin
handle all the type checking. The result is a complete expression
that implements this function call. */
- tem = resolve_overloaded_builtin (function, params);
+ tem = resolve_overloaded_builtin (loc, function, params);
if (tem)
return tem;
fundecl = function;
}
if (TREE_CODE (TREE_TYPE (function)) == FUNCTION_TYPE)
- function = function_to_pointer_conversion (function);
+ function = function_to_pointer_conversion (loc, function);
/* For Objective-C, convert any calls via a cast to OBJC_TYPE_REF
expressions, like those used for ObjC messenger dispatches. */
if (!(TREE_CODE (fntype) == POINTER_TYPE
&& TREE_CODE (TREE_TYPE (fntype)) == FUNCTION_TYPE))
{
- error ("called object %qE is not a function", function);
+ error_at (loc, "called object %qE is not a function", function);
return error_mark_node;
}
&& !comptypes (fntype, TREE_TYPE (tem)))
{
tree return_type = TREE_TYPE (fntype);
- tree trap = build_function_call (built_in_decls[BUILT_IN_TRAP],
+ tree trap = build_function_call (loc, built_in_decls[BUILT_IN_TRAP],
NULL_TREE);
int i;
/* This situation leads to run-time undefined behavior. We can't,
therefore, simply error unless we can prove that all possible
executions of the program must execute the code. */
- if (warning (0, "function called through a non-compatible type"))
+ if (warning_at (loc, 0, "function called through a non-compatible type"))
/* We can, however, treat "undefined" any way we please.
Call abort to encourage the user to fix the program. */
- inform (input_location, "if this code is reached, the program will abort");
+ inform (loc, "if this code is reached, the program will abort");
/* Before the abort, allow the function arguments to exit or
call longjmp. */
for (i = 0; i < nargs; i++)
tree rhs;
if (AGGREGATE_TYPE_P (return_type))
- rhs = build_compound_literal (return_type,
+ rhs = build_compound_literal (loc, return_type,
build_constructor (return_type, 0),
false);
else
and the actual arg is that enum type. */
;
else if (formal_prec != TYPE_PRECISION (type1))
- warning (OPT_Wtraditional_conversion, "passing argument %d of %qE "
+ warning (OPT_Wtraditional_conversion,
+ "passing argument %d of %qE "
"with different width due to prototype",
argnum, rname);
else if (TYPE_UNSIGNED (type) == TYPE_UNSIGNED (type1))
&& TYPE_UNSIGNED (valtype))
;
else if (TYPE_UNSIGNED (type))
- warning (OPT_Wtraditional_conversion, "passing argument %d of %qE "
+ warning (OPT_Wtraditional_conversion,
+ "passing argument %d of %qE "
"as unsigned due to prototype",
argnum, rname);
else
- warning (OPT_Wtraditional_conversion, "passing argument %d of %qE "
+ warning (OPT_Wtraditional_conversion,
+ "passing argument %d of %qE "
"as signed due to prototype", argnum, rname);
}
}
*/
struct c_expr
-parser_build_unary_op (enum tree_code code, struct c_expr arg, location_t loc)
+parser_build_unary_op (location_t loc, enum tree_code code, struct c_expr arg)
{
struct c_expr result;
result.original_type = NULL;
if (TREE_OVERFLOW_P (result.value) && !TREE_OVERFLOW_P (arg.value))
- overflow_warning (result.value);
+ overflow_warning (loc, result.value);
return result;
}
{
if ((code1 == STRING_CST && !integer_zerop (arg2.value))
|| (code2 == STRING_CST && !integer_zerop (arg1.value)))
- warning (OPT_Waddress, "comparison with string literal results in unspecified behavior");
+ warning_at (location, OPT_Waddress,
+ "comparison with string literal results in unspecified behavior");
}
else if (TREE_CODE_CLASS (code) == tcc_comparison
&& (code1 == STRING_CST || code2 == STRING_CST))
- warning (OPT_Waddress, "comparison with string literal results in unspecified behavior");
+ warning_at (location, OPT_Waddress,
+ "comparison with string literal results in unspecified behavior");
if (TREE_OVERFLOW_P (result.value)
&& !TREE_OVERFLOW_P (arg1.value)
&& !TREE_OVERFLOW_P (arg2.value))
- overflow_warning (result.value);
+ overflow_warning (location, result.value);
/* Warn about comparisons of different enum types. */
if (warn_enum_compare
return error_mark_node;
return build_binary_op (location, PLUS_EXPR,
(TREE_CODE (TREE_TYPE (op0)) == ARRAY_TYPE
- ? array_to_pointer_conversion (op0)
+ ? array_to_pointer_conversion (location,
+ op0)
: op0),
TREE_OPERAND (arg, 1), 1);
}
IFEXP_BCP then the condition is a call to __builtin_constant_p, and
if folded to an integer constant then the unselected half may
contain arbitrary operations not normally permitted in constant
- expressions. */
+ expressions. Set the location of the expression to LOC. */
tree
build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp,
result_type = void_type_node;
else
{
- error ("type mismatch in conditional expression");
+ error_at (colon_loc, "type mismatch in conditional expression");
return error_mark_node;
}
}
if (ep_result_type)
ret = build1 (EXCESS_PRECISION_EXPR, ep_result_type, ret);
+ protected_set_expr_location (ret, colon_loc);
return ret;
}
\f
/* Return a compound expression that performs two expressions and
- returns the value of the second of them. */
+ returns the value of the second of them.
+
+ LOC is the location of the COMPOUND_EXPR. */
tree
-build_compound_expr (tree expr1, tree expr2)
+build_compound_expr (location_t loc, tree expr1, tree expr2)
{
bool expr1_int_operands, expr2_int_operands;
tree eptype = NULL_TREE;
&& CONVERT_EXPR_P (TREE_OPERAND (expr1, 1)))
; /* (void) a, (void) b, c */
else
- warning (OPT_Wunused_value,
- "left-hand operand of comma expression has no effect");
+ warning_at (loc, OPT_Wunused_value,
+ "left-hand operand of comma expression has no effect");
}
}
`foo() + bar(), baz()' the result of the `+' operator is not used,
so we should issue a warning. */
else if (warn_unused_value)
- warn_if_unused_value (expr1, input_location);
+ warn_if_unused_value (expr1, loc);
if (expr2 == error_mark_node)
return error_mark_node;
if (eptype)
ret = build1 (EXCESS_PRECISION_EXPR, eptype, ret);
+ protected_set_expr_location (ret, loc);
return ret;
}
while (TREE_CODE (in_type) == POINTER_TYPE);
}
-/* Build an expression representing a cast to type TYPE of expression EXPR. */
+/* Build an expression representing a cast to type TYPE of expression EXPR.
+ LOC is the location of the cast-- typically the open paren of the cast. */
tree
-build_c_cast (tree type, tree expr)
+build_c_cast (location_t loc, tree type, tree expr)
{
tree value;
if (TREE_CODE (type) == ARRAY_TYPE)
{
- error ("cast specifies array type");
+ error_at (loc, "cast specifies array type");
return error_mark_node;
}
if (TREE_CODE (type) == FUNCTION_TYPE)
{
- error ("cast specifies function type");
+ error_at (loc, "cast specifies function type");
return error_mark_node;
}
{
if (TREE_CODE (type) == RECORD_TYPE
|| TREE_CODE (type) == UNION_TYPE)
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (loc, OPT_pedantic,
"ISO C forbids casting nonscalar to the same type");
}
else if (TREE_CODE (type) == UNION_TYPE)
{
tree t;
- pedwarn (input_location, OPT_pedantic,
- "ISO C forbids casts to union type");
- t = digest_init (type,
+ pedwarn (loc, OPT_pedantic, "ISO C forbids casts to union type");
+ t = digest_init (loc, type,
build_constructor_single (type, field, value),
NULL_TREE, false, true, 0);
TREE_CONSTANT (t) = TREE_CONSTANT (value);
return t;
}
- error ("cast to union type from type not present in union");
+ error_at (loc, "cast to union type from type not present in union");
return error_mark_node;
}
else
tree otype, ovalue;
if (type == void_type_node)
- return build1 (CONVERT_EXPR, type, value);
+ {
+ tree t = build1 (CONVERT_EXPR, type, value);
+ SET_EXPR_LOCATION (t, loc);
+ return t;
+ }
otype = TREE_TYPE (value);
|| TREE_CODE (TREE_TYPE (otype)) == RECORD_TYPE)
&& TYPE_MODE (TREE_TYPE (otype)) == VOIDmode)
&& TYPE_ALIGN (TREE_TYPE (type)) > TYPE_ALIGN (TREE_TYPE (otype)))
- warning (OPT_Wcast_align,
- "cast increases required alignment of target type");
+ warning_at (loc, OPT_Wcast_align,
+ "cast increases required alignment of target type");
if (TREE_CODE (type) == INTEGER_TYPE
&& TREE_CODE (otype) == POINTER_TYPE
of cases such as SIG_*, warn about converting constant
pointers to integers. In some cases it may cause unwanted
sign extension, and a warning is appropriate. */
- warning (OPT_Wpointer_to_int_cast,
- "cast from pointer to integer of different size");
+ warning_at (loc, OPT_Wpointer_to_int_cast,
+ "cast from pointer to integer of different size");
if (TREE_CODE (value) == CALL_EXPR
&& TREE_CODE (type) != TREE_CODE (otype))
- warning (OPT_Wbad_function_cast, "cast from function call of type %qT "
- "to non-matching type %qT", otype, type);
+ warning_at (loc, OPT_Wbad_function_cast,
+ "cast from function call of type %qT "
+ "to non-matching type %qT", otype, type);
if (TREE_CODE (type) == POINTER_TYPE
&& TREE_CODE (otype) == INTEGER_TYPE
&& TYPE_PRECISION (type) != TYPE_PRECISION (otype)
/* Don't warn about converting any constant. */
&& !TREE_CONSTANT (value))
- warning (OPT_Wint_to_pointer_cast, "cast to pointer from integer "
- "of different size");
+ warning_at (loc,
+ OPT_Wint_to_pointer_cast, "cast to pointer from integer "
+ "of different size");
if (warn_strict_aliasing <= 2)
strict_aliasing_warning (otype, type, expr);
&& TREE_CODE (otype) == POINTER_TYPE
&& TREE_CODE (TREE_TYPE (otype)) == FUNCTION_TYPE
&& TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE)
- pedwarn (input_location, OPT_pedantic, "ISO C forbids "
+ pedwarn (loc, OPT_pedantic, "ISO C forbids "
"conversion of function pointer to object pointer type");
if (pedantic
&& TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE
&& TREE_CODE (TREE_TYPE (otype)) != FUNCTION_TYPE
&& !null_pointer_constant_p (value))
- pedwarn (input_location, OPT_pedantic, "ISO C forbids "
+ pedwarn (loc, OPT_pedantic, "ISO C forbids "
"conversion of object pointer to function pointer type");
ovalue = value;
|| TREE_CODE (expr) == COMPLEX_CST)))
value = build1 (NOP_EXPR, type, value);
+ if (CAN_HAVE_LOCATION_P (value))
+ SET_EXPR_LOCATION (value, loc);
return value;
}
-/* Interpret a cast of expression EXPR to type TYPE. */
+/* Interpret a cast of expression EXPR to type TYPE. LOC is the
+ location of the open paren of the cast, or the position of the cast
+ expr. */
tree
-c_cast_expr (struct c_type_name *type_name, tree expr, location_t loc)
+c_cast_expr (location_t loc, struct c_type_name *type_name, tree expr)
{
tree type;
tree type_expr = NULL_TREE;
type = groktypename (type_name, &type_expr, &type_expr_const);
warn_strict_prototypes = saved_wsp;
- ret = build_c_cast (type, expr);
+ ret = build_c_cast (loc, type, expr);
if (type_expr)
{
ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret), type_expr, ret);
C_MAYBE_CONST_EXPR_NON_CONST (ret) = !type_expr_const;
+ SET_EXPR_LOCATION (ret, loc);
}
if (CAN_HAVE_LOCATION_P (ret) && !EXPR_HAS_LOCATION (ret))
If RHS_ORIGTYPE is not NULL_TREE, it is the original type of RHS,
which may differ from TREE_TYPE (RHS) for an enum value.
- LOCATION is the location of the MODIFYCODE operator. */
+ LOCATION is the location of the MODIFYCODE operator.
+ RHS_LOC is the location of the RHS. */
tree
build_modify_expr (location_t location, tree lhs, tree lhs_origtype,
- enum tree_code modifycode, tree rhs, tree rhs_origtype)
+ enum tree_code modifycode,
+ location_t rhs_loc, tree rhs, tree rhs_origtype)
{
tree result;
tree newrhs;
if (TREE_CODE (lhs) == C_MAYBE_CONST_EXPR)
{
tree inner = build_modify_expr (location, C_MAYBE_CONST_EXPR_EXPR (lhs),
- lhs_origtype, modifycode, rhs,
+ lhs_origtype, modifycode, rhs_loc, rhs,
rhs_origtype);
if (inner == error_mark_node)
return error_mark_node;
ERRTYPE says whether it is argument passing, assignment,
initialization or return.
+ LOCATION is the location of the RHS.
FUNCTION is a tree for the function being called.
PARMNUM is the number of the argument, for printing in error messages. */
/* This macro is used to emit diagnostics to ensure that all format
strings are complete sentences, visible to gettext and checked at
compile time. */
-#define WARN_FOR_ASSIGNMENT(LOCATION, OPT, AR, AS, IN, RE) \
+#define WARN_FOR_ASSIGNMENT(LOCATION, OPT, AR, AS, IN, RE) \
do { \
switch (errtype) \
{ \
case ic_argpass: \
if (pedwarn (LOCATION, OPT, AR, parmnum, rname)) \
- inform ((fundecl && !DECL_IS_BUILTIN (fundecl)) \
- ? DECL_SOURCE_LOCATION (fundecl) : LOCATION, \
+ inform ((fundecl && !DECL_IS_BUILTIN (fundecl)) \
+ ? DECL_SOURCE_LOCATION (fundecl) : LOCATION, \
"expected %qT but argument is of type %qT", \
type, rhstype); \
break; \
pedwarn (LOCATION, OPT, IN); \
break; \
case ic_return: \
- pedwarn (LOCATION, OPT, RE); \
+ pedwarn (LOCATION, OPT, RE); \
break; \
default: \
gcc_unreachable (); \
an unprototyped function, it is compile-time undefined;
making it a constraint in that case was rejected in
DR#252. */
- error ("void value not ignored as it ought to be");
+ error_at (location, "void value not ignored as it ought to be");
return error_mark_node;
}
rhs = require_complete_type (rhs);
{
if (!lvalue_p (rhs))
{
- error ("cannot pass rvalue to reference parameter");
+ error_at (location, "cannot pass rvalue to reference parameter");
return error_mark_node;
}
if (!c_mark_addressable (rhs))
return error_mark_node;
rhs = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (rhs)), rhs);
+ SET_EXPR_LOCATION (rhs, location);
/* We already know that these two types are compatible, but they
may not be exactly identical. In fact, `TREE_TYPE (type)' is
likely to be va_list, a typedef to __builtin_va_list, which
is different enough that it will cause problems later. */
if (TREE_TYPE (TREE_TYPE (rhs)) != TREE_TYPE (type))
- rhs = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (type)), rhs);
+ {
+ rhs = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (type)), rhs);
+ SET_EXPR_LOCATION (rhs, location);
+ }
rhs = build1 (NOP_EXPR, type, rhs);
+ SET_EXPR_LOCATION (rhs, location);
return rhs;
}
/* Some types can interconvert without explicit casts. */
function where an ordinary one is wanted, but not
vice-versa. */
if (TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr))
- WARN_FOR_ASSIGNMENT (input_location, 0,
+ WARN_FOR_ASSIGNMENT (location, 0,
G_("passing argument %d of %qE "
"makes qualified function "
"pointer from unqualified"),
"pointer from unqualified"));
}
else if (TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl))
- WARN_FOR_ASSIGNMENT (input_location, 0,
+ WARN_FOR_ASSIGNMENT (location, 0,
G_("passing argument %d of %qE discards "
"qualifiers from pointer target type"),
G_("assignment discards qualifiers "
}
if (!fundecl || !DECL_IN_SYSTEM_HEADER (fundecl))
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (location, OPT_pedantic,
"ISO C prohibits argument conversion to union type");
rhs = fold_convert (TREE_TYPE (memb), rhs);
where NULL is typically defined in C to be '(void *) 0'. */
if (VOID_TYPE_P (ttr) && rhs != null_pointer_node && !VOID_TYPE_P (ttl))
- warning (OPT_Wc___compat, "request for implicit conversion from "
- "%qT to %qT not permitted in C++", rhstype, type);
+ warning_at (location, OPT_Wc___compat,
+ "request for implicit conversion "
+ "from %qT to %qT not permitted in C++", rhstype, type);
/* Check if the right-hand side has a format attribute but the
left-hand side doesn't. */
switch (errtype)
{
case ic_argpass:
- warning (OPT_Wmissing_format_attribute,
- "argument %d of %qE might be "
- "a candidate for a format attribute",
- parmnum, rname);
+ warning_at (location, OPT_Wmissing_format_attribute,
+ "argument %d of %qE might be "
+ "a candidate for a format attribute",
+ parmnum, rname);
break;
case ic_assign:
- warning (OPT_Wmissing_format_attribute,
- "assignment left-hand side might be "
- "a candidate for a format attribute");
+ warning_at (location, OPT_Wmissing_format_attribute,
+ "assignment left-hand side might be "
+ "a candidate for a format attribute");
break;
case ic_init:
- warning (OPT_Wmissing_format_attribute,
- "initialization left-hand side might be "
- "a candidate for a format attribute");
+ warning_at (location, OPT_Wmissing_format_attribute,
+ "initialization left-hand side might be "
+ "a candidate for a format attribute");
break;
case ic_return:
- warning (OPT_Wmissing_format_attribute,
- "return type might be "
- "a candidate for a format attribute");
+ warning_at (location, OPT_Wmissing_format_attribute,
+ "return type might be "
+ "a candidate for a format attribute");
break;
default:
gcc_unreachable ();
(VOID_TYPE_P (ttr)
&& !null_pointer_constant
&& TREE_CODE (ttl) == FUNCTION_TYPE)))
- WARN_FOR_ASSIGNMENT (input_location, OPT_pedantic,
+ WARN_FOR_ASSIGNMENT (location, OPT_pedantic,
G_("ISO C forbids passing argument %d of "
"%qE between function pointer "
"and %<void *%>"),
qualifier are acceptable if the 'volatile' has been added
in by the Objective-C EH machinery. */
if (!objc_type_quals_match (ttl, ttr))
- WARN_FOR_ASSIGNMENT (input_location, 0,
+ WARN_FOR_ASSIGNMENT (location, 0,
G_("passing argument %d of %qE discards "
"qualifiers from pointer target type"),
G_("assignment discards qualifiers "
;
/* If there is a mismatch, do warn. */
else if (warn_pointer_sign)
- WARN_FOR_ASSIGNMENT (input_location, OPT_Wpointer_sign,
+ WARN_FOR_ASSIGNMENT (location, OPT_Wpointer_sign,
G_("pointer targets in passing argument "
"%d of %qE differ in signedness"),
G_("pointer targets in assignment "
it is okay to use a const or volatile function
where an ordinary one is wanted, but not vice-versa. */
if (TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr))
- WARN_FOR_ASSIGNMENT (input_location, 0,
+ WARN_FOR_ASSIGNMENT (location, 0,
G_("passing argument %d of %qE makes "
"qualified function pointer "
"from unqualified"),
else
/* Avoid warning about the volatile ObjC EH puts on decls. */
if (!objc_ok)
- WARN_FOR_ASSIGNMENT (input_location, 0,
+ WARN_FOR_ASSIGNMENT (location, 0,
G_("passing argument %d of %qE from "
"incompatible pointer type"),
G_("assignment from incompatible pointer type"),
{
/* ??? This should not be an error when inlining calls to
unprototyped functions. */
- error ("invalid use of non-lvalue array");
+ error_at (location, "invalid use of non-lvalue array");
return error_mark_node;
}
else if (codel == POINTER_TYPE && coder == INTEGER_TYPE)
or one that results from arithmetic, even including
a cast to integer type. */
if (!null_pointer_constant)
- WARN_FOR_ASSIGNMENT (input_location, 0,
+ WARN_FOR_ASSIGNMENT (location, 0,
G_("passing argument %d of %qE makes "
"pointer from integer without a cast"),
G_("assignment makes pointer from integer "
}
else if (codel == INTEGER_TYPE && coder == POINTER_TYPE)
{
- WARN_FOR_ASSIGNMENT (input_location, 0,
+ WARN_FOR_ASSIGNMENT (location, 0,
G_("passing argument %d of %qE makes integer "
"from pointer without a cast"),
G_("assignment makes integer from pointer "
switch (errtype)
{
case ic_argpass:
- error ("incompatible type for argument %d of %qE", parmnum, rname);
+ error_at (location, "incompatible type for argument %d of %qE", parmnum, rname);
inform ((fundecl && !DECL_IS_BUILTIN (fundecl))
? DECL_SOURCE_LOCATION (fundecl) : input_location,
"expected %qT but argument is of type %qT", type, rhstype);
break;
case ic_assign:
- error ("incompatible types when assigning to type %qT from type %qT",
- type, rhstype);
+ error_at (location, "incompatible types when assigning to type %qT from "
+ "type %qT", type, rhstype);
break;
case ic_init:
- error ("incompatible types when initializing type %qT using type %qT",
- type, rhstype);
+ error_at (location,
+ "incompatible types when initializing type %qT using type %qT",
+ type, rhstype);
break;
case ic_return:
- error ("incompatible types when returning type %qT but %qT was expected",
- rhstype, type);
+ error_at (location,
+ "incompatible types when returning type %qT but %qT was "
+ "expected", rhstype, type);
break;
default:
gcc_unreachable ();
store it in the declaration DECL,
and print any error messages that are appropriate.
If ORIGTYPE is not NULL_TREE, it is the original type of INIT.
- If the init is invalid, store an ERROR_MARK. */
+ If the init is invalid, store an ERROR_MARK.
+
+ INIT_LOC is the location of the initial value. */
void
-store_init_value (tree decl, tree init, tree origtype)
+store_init_value (location_t init_loc, tree decl, tree init, tree origtype)
{
tree value, type;
bool npc = false;
if (init)
npc = null_pointer_constant_p (init);
- value = digest_init (type, init, origtype, npc, true, TREE_STATIC (decl));
+ value = digest_init (init_loc, type, init, origtype, npc,
+ true, TREE_STATIC (decl));
/* Store the expression if valid; else report error. */
unparenthesized or we should not warn here for it being parenthesized.
For other types of INIT, STRICT_STRING is not used.
+ INIT_LOC is the location of the INIT.
+
REQUIRE_CONSTANT requests an error if non-constant initializers or
elements are seen. */
static tree
-digest_init (tree type, tree init, tree origtype, bool null_pointer_constant,
- bool strict_string, int require_constant)
+digest_init (location_t init_loc, tree type, tree init, tree origtype,
+ bool null_pointer_constant, bool strict_string,
+ int require_constant)
{
enum tree_code code = TREE_CODE (type);
tree inside_init = init;
maybe_warn_string_init (type, expr);
if (TYPE_DOMAIN (type) && !TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
- pedwarn_init (input_location, OPT_pedantic,
+ pedwarn_init (init_loc, OPT_pedantic,
"initialization of a flexible array member");
if (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
TREE_STRING_LENGTH (inside_init)
- (TYPE_PRECISION (typ1)
/ BITS_PER_UNIT)))
- pedwarn_init (input_location, 0,
+ pedwarn_init (init_loc, 0,
"initializer-string for array of chars is too long");
return inside_init;
{
if (TREE_CODE (inside_init) == STRING_CST
|| TREE_CODE (inside_init) == COMPOUND_LITERAL_EXPR)
- inside_init = array_to_pointer_conversion (inside_init);
+ inside_init = array_to_pointer_conversion
+ (init_loc, inside_init);
else
{
error_init ("invalid use of non-lvalue array");
if (inside_init == error_mark_node)
error_init ("initializer element is not constant");
else
- pedwarn_init (input_location, OPT_pedantic,
+ pedwarn_init (init_loc, OPT_pedantic,
"initializer element is not constant");
if (flag_pedantic_errors)
inside_init = error_mark_node;
inside_init = error_mark_node;
}
else if (require_constant && !maybe_const)
- pedwarn_init (input_location, 0,
+ pedwarn_init (init_loc, 0,
"initializer element is not a constant expression");
/* Added to enable additional -Wmissing-format-attribute warnings. */
if (TREE_CODE (TREE_TYPE (inside_init)) == POINTER_TYPE)
- inside_init = convert_for_assignment (input_location, type,
- inside_init, origtype,
+ inside_init = convert_for_assignment (init_loc, type, inside_init,
+ origtype,
ic_init, null_pointer_constant,
NULL_TREE, NULL_TREE, 0);
return inside_init;
if (TREE_CODE (TREE_TYPE (init)) == ARRAY_TYPE
&& (TREE_CODE (init) == STRING_CST
|| TREE_CODE (init) == COMPOUND_LITERAL_EXPR))
- inside_init = init = array_to_pointer_conversion (init);
+ inside_init = init = array_to_pointer_conversion (init_loc, init);
if (semantic_type)
inside_init = build1 (EXCESS_PRECISION_EXPR, semantic_type,
inside_init);
inside_init
- = convert_for_assignment (input_location, type, inside_init, origtype,
- ic_init, null_pointer_constant,
+ = convert_for_assignment (init_loc, type, inside_init, origtype,
+ ic_init, null_pointer_constant,
NULL_TREE, NULL_TREE, 0);
/* Check to see if we have already given an error message. */
inside_init = error_mark_node;
}
else if (require_constant && !maybe_const)
- pedwarn_init (input_location, 0,
+ pedwarn_init (init_loc, 0,
"initializer element is not a constant expression");
return inside_init;
&& INTEGRAL_TYPE_P (TREE_TYPE (type)))
&& !comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (value)),
TYPE_MAIN_VARIANT (type)))
- value = array_to_pointer_conversion (value);
+ value = array_to_pointer_conversion (input_location, value);
if (TREE_CODE (value) == COMPOUND_LITERAL_EXPR
&& require_constant_value && !flag_isoc99 && pending)
if (semantic_type)
value = build1 (EXCESS_PRECISION_EXPR, semantic_type, value);
- value = digest_init (type, value, origtype, npc, strict_string,
- require_constant_value);
+ value = digest_init (input_location, type, value, origtype, npc,
+ strict_string, require_constant_value);
if (value == error_mark_node)
{
constructor_erroneous = 1;
string in the asm expression -- asm("blah") and asm("blah" : )
are subtly different. We use a ASM_EXPR node to represent this. */
tree
-build_asm_expr (tree string, tree outputs, tree inputs, tree clobbers,
- bool simple)
+build_asm_expr (location_t loc, tree string, tree outputs, tree inputs,
+ tree clobbers, bool simple)
{
tree tail;
tree args;
TREE_VALUE (tail) = input;
}
- args = build_stmt (ASM_EXPR, string, outputs, inputs, clobbers);
+ args = build_stmt (loc, ASM_EXPR, string, outputs, inputs, clobbers);
/* asm statements without outputs, including simple ones, are treated
as volatile. */
return args;
}
\f
-/* Generate a goto statement to LABEL. */
+/* Generate a goto statement to LABEL. LOC is the location of the
+ GOTO. */
tree
-c_finish_goto_label (tree label)
+c_finish_goto_label (location_t loc, tree label)
{
tree decl = lookup_label (label);
if (!decl)
if (C_DECL_UNJUMPABLE_STMT_EXPR (decl))
{
- error ("jump into statement expression");
+ error_at (loc, "jump into statement expression");
return NULL_TREE;
}
if (C_DECL_UNJUMPABLE_VM (decl))
{
- error ("jump into scope of identifier with variably modified type");
+ error_at (loc,
+ "jump into scope of identifier with variably modified type");
return NULL_TREE;
}
}
TREE_USED (decl) = 1;
- return add_stmt (build1 (GOTO_EXPR, void_type_node, decl));
+ {
+ tree t = build1 (GOTO_EXPR, void_type_node, decl);
+ SET_EXPR_LOCATION (t, loc);
+ return add_stmt (t);
+ }
}
-/* Generate a computed goto statement to EXPR. */
+/* Generate a computed goto statement to EXPR. LOC is the location of
+ the GOTO. */
tree
-c_finish_goto_ptr (tree expr)
+c_finish_goto_ptr (location_t loc, tree expr)
{
- pedwarn (input_location, OPT_pedantic, "ISO C forbids %<goto *expr;%>");
+ tree t;
+ pedwarn (loc, OPT_pedantic, "ISO C forbids %<goto *expr;%>");
expr = c_fully_fold (expr, false, NULL);
expr = convert (ptr_type_node, expr);
- return add_stmt (build1 (GOTO_EXPR, void_type_node, expr));
+ t = build1 (GOTO_EXPR, void_type_node, expr);
+ SET_EXPR_LOCATION (t, loc);
+ return add_stmt (t);
}
/* Generate a C `return' statement. RETVAL is the expression for what
- to return, or a null pointer for `return;' with no value. If
- ORIGTYPE is not NULL_TREE, it is the original type of RETVAL. */
+ to return, or a null pointer for `return;' with no value. LOC is
+ the location of the return statement. If ORIGTYPE is not NULL_TREE, it
+ is the original type of RETVAL. */
tree
-c_finish_return (tree retval, tree origtype)
+c_finish_return (location_t loc, tree retval, tree origtype)
{
tree valtype = TREE_TYPE (TREE_TYPE (current_function_decl)), ret_stmt;
bool no_warning = false;
bool npc = false;
if (TREE_THIS_VOLATILE (current_function_decl))
- warning (0, "function declared %<noreturn%> has a %<return%> statement");
+ warning_at (loc, 0,
+ "function declared %<noreturn%> has a %<return%> statement");
if (retval)
{
if ((warn_return_type || flag_isoc99)
&& valtype != 0 && TREE_CODE (valtype) != VOID_TYPE)
{
- pedwarn_c99 (input_location, flag_isoc99 ? 0 : OPT_Wreturn_type,
+ pedwarn_c99 (loc, flag_isoc99 ? 0 : OPT_Wreturn_type,
"%<return%> with no value, in "
"function returning non-void");
no_warning = true;
{
current_function_returns_null = 1;
if (TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE)
- pedwarn (input_location, 0,
+ pedwarn (loc, 0,
"%<return%> with a value, in function returning void");
else
- pedwarn (input_location, OPT_pedantic, "ISO C forbids "
+ pedwarn (loc, OPT_pedantic, "ISO C forbids "
"%<return%> with expression, in function returning void");
}
else
{
- tree t = convert_for_assignment (input_location, valtype, retval,
- origtype, ic_return, npc,
- NULL_TREE, NULL_TREE, 0);
+ tree t = convert_for_assignment (loc, valtype, retval, origtype,
+ ic_return,
+ npc, NULL_TREE, NULL_TREE, 0);
tree res = DECL_RESULT (current_function_decl);
tree inner;
&& !DECL_EXTERNAL (inner)
&& !TREE_STATIC (inner)
&& DECL_CONTEXT (inner) == current_function_decl)
- warning (0, "function returns address of local variable");
+ warning_at (loc,
+ 0, "function returns address of local variable");
break;
default:
}
retval = build2 (MODIFY_EXPR, TREE_TYPE (res), res, t);
+ SET_EXPR_LOCATION (retval, loc);
if (warn_sequence_point)
verify_sequence_points (retval);
}
- ret_stmt = build_stmt (RETURN_EXPR, retval);
+ ret_stmt = build_stmt (loc, RETURN_EXPR, retval);
TREE_NO_WARNING (ret_stmt) |= no_warning;
return add_stmt (ret_stmt);
}
struct c_switch *c_switch_stack;
/* Start a C switch statement, testing expression EXP. Return the new
- SWITCH_EXPR. */
+ SWITCH_EXPR. SWITCH_LOC is the location of the `switch'.
+ SWITCH_COND_LOC is the location of the switch's condition. */
tree
-c_start_case (tree exp)
+c_start_case (location_t switch_loc,
+ location_t switch_cond_loc,
+ tree exp)
{
tree orig_type = error_mark_node;
struct c_switch *cs;
{
if (orig_type != error_mark_node)
{
- error ("switch quantity not an integer");
+ error_at (switch_cond_loc, "switch quantity not an integer");
orig_type = error_mark_node;
}
exp = integer_zero_node;
if (!in_system_header
&& (type == long_integer_type_node
|| type == long_unsigned_type_node))
- warning (OPT_Wtraditional, "%<long%> switch expression not "
- "converted to %<int%> in ISO C");
+ warning_at (switch_cond_loc,
+ OPT_Wtraditional, "%<long%> switch expression not "
+ "converted to %<int%> in ISO C");
exp = c_fully_fold (exp, false, NULL);
exp = default_conversion (exp);
/* Add this new SWITCH_EXPR to the stack. */
cs = XNEW (struct c_switch);
cs->switch_expr = build3 (SWITCH_EXPR, orig_type, exp, NULL_TREE, NULL_TREE);
+ SET_EXPR_LOCATION (cs->switch_expr, switch_loc);
cs->orig_type = orig_type;
cs->cases = splay_tree_new (case_compare, NULL, NULL);
cs->blocked_stmt_expr = 0;
return add_stmt (cs->switch_expr);
}
-/* Process a case label. */
+/* Process a case label at location LOC. */
tree
-do_case (tree low_value, tree high_value)
+do_case (location_t loc, tree low_value, tree high_value)
{
tree label = NULL_TREE;
if (c_switch_stack && !c_switch_stack->blocked_stmt_expr
&& !c_switch_stack->blocked_vm)
{
- label = c_add_case_label (c_switch_stack->cases,
+ label = c_add_case_label (loc, c_switch_stack->cases,
SWITCH_COND (c_switch_stack->switch_expr),
c_switch_stack->orig_type,
low_value, high_value);
else if (c_switch_stack && c_switch_stack->blocked_stmt_expr)
{
if (low_value)
- error ("case label in statement expression not containing "
- "enclosing switch statement");
+ error_at (loc, "case label in statement expression not containing "
+ "enclosing switch statement");
else
- error ("%<default%> label in statement expression not containing "
- "enclosing switch statement");
+ error_at (loc, "%<default%> label in statement expression not containing "
+ "enclosing switch statement");
}
else if (c_switch_stack && c_switch_stack->blocked_vm)
{
if (low_value)
- error ("case label in scope of identifier with variably modified "
- "type not containing enclosing switch statement");
+ error_at (loc, "case label in scope of identifier with variably "
+ "modified type not containing enclosing switch statement");
else
- error ("%<default%> label in scope of identifier with variably "
- "modified type not containing enclosing switch statement");
+ error_at (loc, "%<default%> label in scope of identifier with "
+ "variably modified type not containing enclosing switch "
+ "statement");
}
else if (low_value)
- error ("case label not within a switch statement");
+ error_at (loc, "case label not within a switch statement");
else
- error ("%<default%> label not within a switch statement");
+ error_at (loc, "%<default%> label not within a switch statement");
return label;
}
gcc_assert (!cs->blocked_stmt_expr);
/* Emit warnings as needed. */
- if (EXPR_HAS_LOCATION (cs->switch_expr))
- switch_location = EXPR_LOCATION (cs->switch_expr);
- else
- switch_location = input_location;
+ switch_location = EXPR_LOCATION (cs->switch_expr);
c_do_switch_warnings (cs->cases, switch_location,
TREE_TYPE (cs->switch_expr),
SWITCH_COND (cs->switch_expr));
}
tree
-c_finish_bc_stmt (tree *label_p, bool is_break)
+c_finish_bc_stmt (location_t loc, tree *label_p, bool is_break)
{
bool skip;
tree label = *label_p;
if (!label)
{
if (!skip)
- *label_p = label = create_artificial_label ();
+ *label_p = label = create_artificial_label (loc);
}
else if (TREE_CODE (label) == LABEL_DECL)
;
{
case 0:
if (is_break)
- error ("break statement not within loop or switch");
+ error_at (loc, "break statement not within loop or switch");
else
- error ("continue statement not within a loop");
+ error_at (loc, "continue statement not within a loop");
return NULL_TREE;
case 1:
gcc_assert (is_break);
- error ("break statement used with OpenMP for loop");
+ error_at (loc, "break statement used with OpenMP for loop");
return NULL_TREE;
default:
/* A helper routine for c_process_expr_stmt and c_finish_stmt_expr. */
static void
-emit_side_effect_warnings (tree expr)
+emit_side_effect_warnings (location_t loc, tree expr)
{
if (expr == error_mark_node)
;
else if (!TREE_SIDE_EFFECTS (expr))
{
if (!VOID_TYPE_P (TREE_TYPE (expr)) && !TREE_NO_WARNING (expr))
- warning (OPT_Wunused_value, "%Hstatement with no effect",
- EXPR_HAS_LOCATION (expr) ? EXPR_LOCUS (expr) : &input_location);
+ warning_at (loc, OPT_Wunused_value, "statement with no effect");
}
else
- warn_if_unused_value (expr, input_location);
+ warn_if_unused_value (expr, loc);
}
/* Process an expression as if it were a complete statement. Emit
- diagnostics, but do not call ADD_STMT. */
+ diagnostics, but do not call ADD_STMT. LOC is the location of the
+ statement. */
tree
-c_process_expr_stmt (tree expr)
+c_process_expr_stmt (location_t loc, tree expr)
{
if (!expr)
return NULL_TREE;
if (TREE_TYPE (expr) != error_mark_node
&& !COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (expr))
&& TREE_CODE (TREE_TYPE (expr)) != ARRAY_TYPE)
- error ("expression statement has incomplete type");
+ error_at (loc, "expression statement has incomplete type");
/* If we're not processing a statement expression, warn about unused values.
Warnings for statement expressions will be emitted later, once we figure
out which is the result. */
if (!STATEMENT_LIST_STMT_EXPR (cur_stmt_list)
&& warn_unused_value)
- emit_side_effect_warnings (expr);
+ emit_side_effect_warnings (loc, expr);
/* If the expression is not of a type to which we cannot assign a line
number, wrap the thing in a no-op NOP_EXPR. */
if (DECL_P (expr) || CONSTANT_CLASS_P (expr))
- expr = build1 (NOP_EXPR, TREE_TYPE (expr), expr);
-
- if (CAN_HAVE_LOCATION_P (expr))
- SET_EXPR_LOCATION (expr, input_location);
+ {
+ expr = build1 (NOP_EXPR, TREE_TYPE (expr), expr);
+ SET_EXPR_LOCATION (expr, loc);
+ }
return expr;
}
-/* Emit an expression as a statement. */
+/* Emit an expression as a statement. LOC is the location of the
+ expression. */
tree
-c_finish_expr_stmt (tree expr)
+c_finish_expr_stmt (location_t loc, tree expr)
{
if (expr)
- return add_stmt (c_process_expr_stmt (expr));
+ return add_stmt (c_process_expr_stmt (loc, expr));
else
return NULL;
}
return ret;
}
+/* LOC is the location of the compound statement to which this body
+ belongs. */
+
tree
-c_finish_stmt_expr (tree body)
+c_finish_stmt_expr (location_t loc, tree body)
{
tree last, type, tmp, val;
tree *last_p;
struct c_label_list *dlist, *glist, *glist_prev = NULL;
- body = c_end_compound_stmt (body, true);
+ body = c_end_compound_stmt (loc, body, true);
if (c_switch_stack)
{
gcc_assert (c_switch_stack->blocked_stmt_expr != 0);
if (warn_unused_value)
{
for (i = tsi_start (last); !tsi_one_before_end_p (i); tsi_next (&i))
- emit_side_effect_warnings (tsi_stmt (i));
+ {
+ location_t tloc;
+ tree t = tsi_stmt (i);
+
+ tloc = EXPR_HAS_LOCATION (t) ? EXPR_LOCATION (t) : loc;
+ emit_side_effect_warnings (tloc, t);
+ }
}
else
i = tsi_last (last);
*last_p = build2 (MODIFY_EXPR, void_type_node, tmp, val);
SET_EXPR_LOCUS (*last_p, EXPR_LOCUS (last));
- return build4 (TARGET_EXPR, type, tmp, body, NULL_TREE, NULL_TREE);
+ {
+ tree t = build4 (TARGET_EXPR, type, tmp, body, NULL_TREE, NULL_TREE);
+ SET_EXPR_LOCATION (t, loc);
+ return t;
+ }
}
/* Begin the scope of an identifier of variably modified type, scope
return stmt;
}
+/* End a compound statement. STMT is the statement. LOC is the
+ location of the compound statement-- this is usually the location
+ of the opening brace. */
+
tree
-c_end_compound_stmt (tree stmt, bool do_scope)
+c_end_compound_stmt (location_t loc, tree stmt, bool do_scope)
{
tree block = NULL;
}
stmt = pop_stmt_list (stmt);
- stmt = c_build_bind_expr (block, stmt);
+ stmt = c_build_bind_expr (loc, block, stmt);
/* If this compound statement is nested immediately inside a statement
expression, then force a BIND_EXPR to be created. Otherwise we'll
{
stmt = build3 (BIND_EXPR, void_type_node, NULL, stmt, NULL);
TREE_SIDE_EFFECTS (stmt) = 1;
+ SET_EXPR_LOCATION (stmt, loc);
}
return stmt;
meant to apply to normal control flow transfer. */
void
-push_cleanup (tree ARG_UNUSED (decl), tree cleanup, bool eh_only)
+push_cleanup (tree decl, tree cleanup, bool eh_only)
{
enum tree_code code;
tree stmt, list;
bool stmt_expr;
code = eh_only ? TRY_CATCH_EXPR : TRY_FINALLY_EXPR;
- stmt = build_stmt (code, NULL, cleanup);
+ stmt = build_stmt (DECL_SOURCE_LOCATION (decl), code, NULL, cleanup);
add_stmt (stmt);
stmt_expr = STATEMENT_LIST_STMT_EXPR (cur_stmt_list);
list = push_stmt_list ();
return block;
}
-/* Generate OMP_PARALLEL, with CLAUSES and BLOCK as its compound statement. */
+/* Generate OMP_PARALLEL, with CLAUSES and BLOCK as its compound
+ statement. LOC is the location of the OMP_PARALLEL. */
tree
-c_finish_omp_parallel (tree clauses, tree block)
+c_finish_omp_parallel (location_t loc, tree clauses, tree block)
{
tree stmt;
- block = c_end_compound_stmt (block, true);
+ block = c_end_compound_stmt (loc, block, true);
stmt = make_node (OMP_PARALLEL);
TREE_TYPE (stmt) = void_type_node;
OMP_PARALLEL_CLAUSES (stmt) = clauses;
OMP_PARALLEL_BODY (stmt) = block;
+ SET_EXPR_LOCATION (stmt, loc);
return add_stmt (stmt);
}
return block;
}
-/* Generate OMP_TASK, with CLAUSES and BLOCK as its compound statement. */
+/* Generate OMP_TASK, with CLAUSES and BLOCK as its compound
+ statement. LOC is the location of the #pragma. */
tree
-c_finish_omp_task (tree clauses, tree block)
+c_finish_omp_task (location_t loc, tree clauses, tree block)
{
tree stmt;
- block = c_end_compound_stmt (block, true);
+ block = c_end_compound_stmt (loc, block, true);
stmt = make_node (OMP_TASK);
TREE_TYPE (stmt) = void_type_node;
OMP_TASK_CLAUSES (stmt) = clauses;
OMP_TASK_BODY (stmt) = block;
+ SET_EXPR_LOCATION (stmt, loc);
return add_stmt (stmt);
}
if (AGGREGATE_TYPE_P (TREE_TYPE (t))
|| POINTER_TYPE_P (TREE_TYPE (t)))
{
- error ("%qE has invalid type for %<reduction%>", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE has invalid type for %<reduction%>", t);
remove = true;
}
else if (FLOAT_TYPE_P (TREE_TYPE (t)))
}
if (r_name)
{
- error ("%qE has invalid type for %<reduction(%s)%>",
- t, r_name);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE has invalid type for %<reduction(%s)%>",
+ t, r_name);
remove = true;
}
}
t = OMP_CLAUSE_DECL (c);
if (TREE_CODE (t) != VAR_DECL || !DECL_THREAD_LOCAL_P (t))
{
- error ("%qE must be %<threadprivate%> for %<copyin%>", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE must be %<threadprivate%> for %<copyin%>", t);
remove = true;
}
goto check_dup_generic;
t = OMP_CLAUSE_DECL (c);
if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL)
{
- error ("%qE is not a variable in clause %qs", t, name);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE is not a variable in clause %qs", t, name);
remove = true;
}
else if (bitmap_bit_p (&generic_head, DECL_UID (t))
|| bitmap_bit_p (&firstprivate_head, DECL_UID (t))
|| bitmap_bit_p (&lastprivate_head, DECL_UID (t)))
{
- error ("%qE appears more than once in data clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE appears more than once in data clauses", t);
remove = true;
}
else
need_implicitly_determined = true;
if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL)
{
- error ("%qE is not a variable in clause %<firstprivate%>", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE is not a variable in clause %<firstprivate%>", t);
remove = true;
}
else if (bitmap_bit_p (&generic_head, DECL_UID (t))
|| bitmap_bit_p (&firstprivate_head, DECL_UID (t)))
{
- error ("%qE appears more than once in data clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE appears more than once in data clauses", t);
remove = true;
}
else
need_implicitly_determined = true;
if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL)
{
- error ("%qE is not a variable in clause %<lastprivate%>", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE is not a variable in clause %<lastprivate%>", t);
remove = true;
}
else if (bitmap_bit_p (&generic_head, DECL_UID (t))
|| bitmap_bit_p (&lastprivate_head, DECL_UID (t)))
{
- error ("%qE appears more than once in data clauses", t);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE appears more than once in data clauses", t);
remove = true;
}
else
}
if (share_name)
{
- error ("%qE is predetermined %qs for %qs",
- t, share_name, name);
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE is predetermined %qs for %qs",
+ t, share_name, name);
remove = true;
}
}
/* Build a VA_ARG_EXPR for the C parser. */
tree
-c_build_va_arg (tree expr, tree type, location_t loc)
+c_build_va_arg (location_t loc, tree expr, tree type)
{
if (warn_cxx_compat && TREE_CODE (type) == ENUMERAL_TYPE)
warning_at (loc, OPT_Wc___compat,
"C++ requires promoted type, not enum type, in %<va_arg%>");
- return build_va_arg (expr, type);
+ return build_va_arg (loc, expr, type);
}
static void
create_stack_guard (void)
{
- tree guard = build_decl (VAR_DECL, NULL, ptr_type_node);
+ tree guard = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
+ VAR_DECL, NULL, ptr_type_node);
TREE_THIS_VOLATILE (guard) = 1;
TREE_USED (guard) = 1;
expand_one_stack_var (guard);
sprintf (which_buf, "%c_%.5d_%d", which, priority, counter++);
name = get_file_function_name (which_buf);
- decl = build_decl (FUNCTION_DECL, name,
+ decl = build_decl (input_location, FUNCTION_DECL, name,
build_function_type (void_type_node, void_list_node));
current_function_decl = decl;
- resdecl = build_decl (RESULT_DECL, NULL_TREE, void_type_node);
+ resdecl = build_decl (input_location,
+ RESULT_DECL, NULL_TREE, void_type_node);
DECL_ARTIFICIAL (resdecl) = 1;
DECL_RESULT (decl) = resdecl;
DECL_CONTEXT (resdecl) = decl;
return build_pointer_type (char_type_node);
record = (*lang_hooks.types.make_type) (RECORD_TYPE);
- type_decl = build_decl (TYPE_DECL, get_identifier ("__va_list_tag"), record);
+ type_decl = build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("__va_list_tag"), record);
- f_gpr = build_decl (FIELD_DECL, get_identifier ("gp_offset"),
+ f_gpr = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, get_identifier ("gp_offset"),
unsigned_type_node);
- f_fpr = build_decl (FIELD_DECL, get_identifier ("fp_offset"),
+ f_fpr = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, get_identifier ("fp_offset"),
unsigned_type_node);
- f_ovf = build_decl (FIELD_DECL, get_identifier ("overflow_arg_area"),
+ f_ovf = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, get_identifier ("overflow_arg_area"),
ptr_type_node);
- f_sav = build_decl (FIELD_DECL, get_identifier ("reg_save_area"),
+ f_sav = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, get_identifier ("reg_save_area"),
ptr_type_node);
va_list_gpr_counter_field = f_gpr;
bool need_temp;
tree int_addr, sse_addr;
- lab_false = create_artificial_label ();
- lab_over = create_artificial_label ();
+ lab_false = create_artificial_label (UNKNOWN_LOCATION);
+ lab_over = create_artificial_label (UNKNOWN_LOCATION);
examine_argument (nat_mode, type, 0, &needed_intregs, &needed_sseregs);
{
tree decl;
- decl = build_decl (FUNCTION_DECL, get_identifier (name),
+ decl = build_decl (BUILTINS_LOCATION,
+ FUNCTION_DECL, get_identifier (name),
error_mark_node);
TREE_PUBLIC (decl) = 1;
TREE_STATIC (decl) = 1;
*loc = h = GGC_NEW (struct tree_map);
h->hash = in.hash;
h->base.from = decl;
- h->to = to = build_decl (VAR_DECL, NULL, ptr_type_node);
+ h->to = to = build_decl (DECL_SOURCE_LOCATION (decl),
+ VAR_DECL, NULL, ptr_type_node);
DECL_ARTIFICIAL (to) = 1;
DECL_IGNORED_P (to) = 1;
DECL_EXTERNAL (to) = 1;
fntype = build_function_type_list (type_out, type_in, type_in, NULL);
/* Build a function declaration for the vectorized function. */
- new_fndecl = build_decl (FUNCTION_DECL, get_identifier (name), fntype);
+ new_fndecl = build_decl (BUILTINS_LOCATION,
+ FUNCTION_DECL, get_identifier (name), fntype);
TREE_PUBLIC (new_fndecl) = 1;
DECL_EXTERNAL (new_fndecl) = 1;
DECL_IS_NOVOPS (new_fndecl) = 1;
fntype = build_function_type_list (type_out, type_in, type_in, NULL);
/* Build a function declaration for the vectorized function. */
- new_fndecl = build_decl (FUNCTION_DECL, get_identifier (name), fntype);
+ new_fndecl = build_decl (BUILTINS_LOCATION,
+ FUNCTION_DECL, get_identifier (name), fntype);
TREE_PUBLIC (new_fndecl) = 1;
DECL_EXTERNAL (new_fndecl) = 1;
DECL_IS_NOVOPS (new_fndecl) = 1;
tree gcov_type_array_type
= build_array_type (gcov_type_node, NULL_TREE);
tree_ctr_tables[counter]
- = build_decl (VAR_DECL, NULL_TREE, gcov_type_array_type);
+ = build_decl (BUILTINS_LOCATION,
+ VAR_DECL, NULL_TREE, gcov_type_array_type);
TREE_STATIC (tree_ctr_tables[counter]) = 1;
ASM_GENERATE_INTERNAL_LABEL (buf, "LPBX", counter + 1);
DECL_NAME (tree_ctr_tables[counter]) = get_identifier (buf);
tree array_type;
/* ident */
- fields = build_decl (FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
+ fields = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
/* checksum */
- field = build_decl (FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
TREE_CHAIN (field) = fields;
fields = field;
array_type = build_array_type (get_gcov_unsigned_t (), array_type);
/* counters */
- field = build_decl (FIELD_DECL, NULL_TREE, array_type);
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, array_type);
TREE_CHAIN (field) = fields;
fields = field;
tree gcov_merge_fn_type;
/* counters */
- field = build_decl (FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
TREE_CHAIN (field) = fields;
fields = field;
/* values */
- field = build_decl (FIELD_DECL, NULL_TREE, gcov_ptr_type);
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, gcov_ptr_type);
TREE_CHAIN (field) = fields;
fields = field;
build_function_type_list (void_type_node,
gcov_ptr_type, get_gcov_unsigned_t (),
NULL_TREE);
- field = build_decl (FIELD_DECL, NULL_TREE,
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE,
build_pointer_type (gcov_merge_fn_type));
TREE_CHAIN (field) = fields;
fields = field;
value = tree_cons (fields, null_pointer_node, value);
fields = TREE_CHAIN (fields);
- fn = build_decl (FUNCTION_DECL,
+ fn = build_decl (BUILTINS_LOCATION,
+ FUNCTION_DECL,
get_identifier (ctr_merge_functions[counter]),
TREE_TYPE (TREE_TYPE (fields)));
DECL_EXTERNAL (fn) = 1;
const_type = build_qualified_type (type, TYPE_QUAL_CONST);
/* Version ident */
- field = build_decl (FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
TREE_CHAIN (field) = fields;
fields = field;
value = tree_cons (field, build_int_cstu (TREE_TYPE (field), GCOV_VERSION),
value);
/* next -- NULL */
- field = build_decl (FIELD_DECL, NULL_TREE, build_pointer_type (const_type));
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, build_pointer_type (const_type));
TREE_CHAIN (field) = fields;
fields = field;
value = tree_cons (field, null_pointer_node, value);
/* stamp */
- field = build_decl (FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
TREE_CHAIN (field) = fields;
fields = field;
value = tree_cons (field, build_int_cstu (TREE_TYPE (field), local_tick),
/* Filename */
string_type = build_pointer_type (build_qualified_type (char_type_node,
TYPE_QUAL_CONST));
- field = build_decl (FIELD_DECL, NULL_TREE, string_type);
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, string_type);
TREE_CHAIN (field) = fields;
fields = field;
da_file_name_len = strlen (da_file_name);
fn_info_value = null_pointer_node;
/* number of functions */
- field = build_decl (FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
TREE_CHAIN (field) = fields;
fields = field;
value = tree_cons (field,
value);
/* fn_info table */
- field = build_decl (FIELD_DECL, NULL_TREE, fn_info_ptr_type);
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, fn_info_ptr_type);
TREE_CHAIN (field) = fields;
fields = field;
value = tree_cons (field, fn_info_value, value);
/* counter_mask */
- field = build_decl (FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
TREE_CHAIN (field) = fields;
fields = field;
value = tree_cons (field,
ctr_info_value = build_constructor_from_list (ctr_info_ary_type,
nreverse (ctr_info_value));
- field = build_decl (FIELD_DECL, NULL_TREE, ctr_info_ary_type);
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, ctr_info_ary_type);
TREE_CHAIN (field) = fields;
fields = field;
value = tree_cons (field, ctr_info_value, value);
t = build_gcov_info ();
- gcov_info = build_decl (VAR_DECL, NULL_TREE, TREE_TYPE (t));
+ gcov_info = build_decl (BUILTINS_LOCATION,
+ VAR_DECL, NULL_TREE, TREE_TYPE (t));
TREE_STATIC (gcov_info) = 1;
ASM_GENERATE_INTERNAL_LABEL (name_buf, "LPBX", 0);
DECL_NAME (gcov_info) = get_identifier (name_buf);
/* Build a decl for __gcov_init. */
t = build_pointer_type (TREE_TYPE (gcov_info));
t = build_function_type_list (void_type_node, t, NULL);
- t = build_decl (FUNCTION_DECL, get_identifier ("__gcov_init"), t);
+ t = build_decl (BUILTINS_LOCATION,
+ FUNCTION_DECL, get_identifier ("__gcov_init"), t);
TREE_PUBLIC (t) = 1;
DECL_EXTERNAL (t) = 1;
gcov_init = t;
+2009-06-12 Aldy Hernandez <aldyh@redhat.com>
+
+ * typeck.c (cp_build_binary_op): Pass location to overflow_warning.
+ (build_modify_expr): New arg.
+ * semantics.c (finish_unary_op_expr): Pass location to
+ overflow_warning.
+ (handle_omp_for_class_iterator): Pass location to build_modify_expr.
+ * typeck.c (cxx_sizeof_or_alignof_type): Pass location to
+ c_sizeof_or_alignof_type.
+ (build_array_ref): New argument.
+ (build_compound_expr): Same.
+ (build_const_cast): Same.
+ (build_ptrmemfunc): Pass location to build_c_cast.
+ * init.c (avoid_placement_new_aliasing): Pass location to
+ build_stmt.
+ (build_vec_delete_1): Pass location to cp_build_modify_expr,
+ build_compound_expr.
+ * class.c (build_vtbl_ref_1): Pass location to build_array_ref.
+ * decl.c (poplevel): Pass location to c_build_bind_expr.
+ (finish_case_label): Pass location to build_case_label.
+ (finish_constructor_body): Same.
+ (finish_destructor_body): Pass location to build_stmt.
+ (cxx_maybe_build_cleanup): Same, but to build_compound_expr.
+ * call.c (build_new_op): Pass location to build_array_ref.
+ (build_x_va_arg): Pass location to build_va_arg.
+ * except.c (expand_end_catch_block): Pass location to
+ build_stmt.
+ * cp-tree.h (build_array_ref): New argument.
+ (build_compound_expr): Same.
+ (build_c_cast): Same.
+ * cp-gimplify.c (gimplify_if_stmt): Pass location on down.
+ (gimplify_switch_stmt): Same.
+ * typeck2.c (split_nonconstant_init_1): Same.
+ * pt.c (tsubst_copy): Same.
+ * semantics.c (add_decl_expr): Same.
+ (do_poplevel): Same.
+ (push_cleanup): Same.
+ (finish_goto_stmt): Same.
+ (finish_expr_stmt): Same.
+ (begin_if_stmt): Same.
+ (begin_while_stmt): Same.
+ (begin_do_stmt): Same.
+ (finish_return_stmt): Same.
+ (begin_for_stmt): Same.
+ (finish_break_stmt): Same.
+ (finish_continue_stmt): Same.
+ (begin_switch_stmt): Same.
+ (begin_try_block): Same.
+ (begin_handler): Same.
+ (finish_asm_stmt): Same.
+ (finish_label_stmt): Same.
+ (finish_stmt_expr_expr): Same.
+ (finalize_nrv_r): Same.
+ (finish_omp_atomic): Same.
+ * name-lookup.c (do_using_directive): Same.
+ * decl2.c (grok_array_decl): Same.
+ * parser.c (cp_parser_cast_expression): Same.
+ (cp_parser_selection_statement): Same.
+ (cp_parser_implicitly_scoped_statement): Same.
+ (cp_parser_objc_selector_expression): Same.
+ (cp_parser_objc_synchronized_statement): Same.
+ (cp_parser_objc_throw_statement): Same.
+ (cp_parser_omp_critical): Same.
+ (cp_parser_omp_master): Same.
+ * typeck.c (build_function_call): Add location argument.
+ * init.c: Add location argument to all build_decl calls.
+ * class.c: Same.
+ * method.c: Same.
+ * rtti.c: Same.
+ * tree.c: Same.
+ * pt.c: Same.
+ * semantics.c: Same.
+ * lex.c: Same.
+ * decl2.c: Same.
+ * cp-gimplify.c: Same.
+ * decl.c: Same.
+ (cp_make_fname_decl): Add location argument. Pass location ot
+ build_decl.
+ (finish_case_label): Same.
+ * cp-tree.h (finish_case_label): Add location argument.
+ * parser.c (cp_parser_label_for_labeled_statement): Pass location to
+ finish_case_label.
+
2009-06-09 Jason Merrill <jason@redhat.com>
PR c++/40381
return cp_build_unary_op (code, arg1, candidates != 0, complain);
case ARRAY_REF:
- return build_array_ref (arg1, arg2, input_location);
+ return build_array_ref (input_location, arg1, arg2);
case COND_EXPR:
return build_conditional_expr (arg1, arg2, arg3, complain);
return expr;
}
- return build_va_arg (expr, type);
+ return build_va_arg (input_location, expr, type);
}
/* TYPE has been given to va_arg. Apply the default conversions which
vtbl = build_vfield_ref (instance, basetype);
- aref = build_array_ref (vtbl, idx, input_location);
+ aref = build_array_ref (input_location, vtbl, idx);
TREE_CONSTANT (aref) |= TREE_CONSTANT (vtbl) && TREE_CONSTANT (idx);
return aref;
CLASSTYPE_EMPTY_P (t) = 0;
/* Create the FIELD_DECL. */
- decl = build_decl (FIELD_DECL, NULL_TREE, CLASSTYPE_AS_BASE (basetype));
+ decl = build_decl (input_location,
+ FIELD_DECL, NULL_TREE, CLASSTYPE_AS_BASE (basetype));
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
DECL_FIELD_CONTEXT (decl) = t;
stores cannot alias stores to void*! */
tree field;
- field = build_decl (FIELD_DECL, get_vfield_name (t), vtbl_ptr_type_node);
+ field = build_decl (input_location,
+ FIELD_DECL, get_vfield_name (t), vtbl_ptr_type_node);
DECL_VIRTUAL_P (field) = 1;
DECL_ARTIFICIAL (field) = 1;
DECL_FIELD_CONTEXT (field) = t;
{
tree padding_field;
- padding_field = build_decl (FIELD_DECL,
+ padding_field = build_decl (input_location,
+ FIELD_DECL,
NULL_TREE,
char_type_node);
DECL_BIT_FIELD (padding_field) = 1;
for (field = TYPE_FIELDS (t); field; field = TREE_CHAIN (field))
if (TREE_CODE (field) == FIELD_DECL)
{
- *next_field = build_decl (FIELD_DECL,
+ *next_field = build_decl (input_location,
+ FIELD_DECL,
DECL_NAME (field),
TREE_TYPE (field));
DECL_CONTEXT (*next_field) = base_t;
/* Make sure not to create any structures with zero size. */
if (integer_zerop (rli_size_unit_so_far (rli)) && CLASSTYPE_EMPTY_P (t))
place_field (rli,
- build_decl (FIELD_DECL, NULL_TREE, char_type_node));
+ build_decl (input_location,
+ FIELD_DECL, NULL_TREE, char_type_node));
/* Let the back end lay out the type. */
finish_record_layout (rli, /*free_p=*/true);
static tree
begin_bc_block (enum bc_t bc)
{
- tree label = create_artificial_label ();
+ tree label = create_artificial_label (input_location);
TREE_CHAIN (label) = bc_label[bc];
bc_label[bc] = label;
return label;
else_ = ELSE_CLAUSE (stmt);
if (!then_)
- then_ = build_empty_stmt ();
+ then_ = build_empty_stmt (locus);
if (!else_)
- else_ = build_empty_stmt ();
+ else_ = build_empty_stmt (locus);
if (integer_nonzerop (cond) && !TREE_SIDE_EFFECTS (else_))
stmt = then_;
back through the main gimplifier to lower it. Given that we
have to gimplify the loop body NOW so that we can resolve
break/continue stmts, seems easier to just expand to gotos. */
- top = gimple_build_label (create_artificial_label ());
+ top = gimple_build_label (create_artificial_label (stmt_locus));
/* If we have an exit condition, then we build an IF with gotos either
out of the loop, or to the top of it. If there's no exit condition,
{
if (incr)
{
- entry = gimple_build_label (create_artificial_label ());
+ entry = gimple_build_label
+ (create_artificial_label (stmt_locus));
stmt = gimple_build_goto (gimple_label_label (entry));
}
else
body = SWITCH_STMT_BODY (stmt);
if (!body)
- body = build_empty_stmt ();
+ body = build_empty_stmt (stmt_locus);
t = build3 (SWITCH_EXPR, SWITCH_STMT_TYPE (stmt),
SWITCH_STMT_COND (stmt), body, NULL_TREE);
append_to_statement_list (t, &ret);
}
- lab = create_artificial_label ();
+ lab = create_artificial_label (input_location);
t = build1 (LABEL_EXPR, void_type_node, lab);
append_to_statement_list (t, &ret);
extern bool defer_mark_used_calls;
extern GTY(()) VEC(tree, gc) *deferred_mark_used_calls;
-extern tree finish_case_label (tree, tree);
+extern tree finish_case_label (location_t, tree, tree);
extern tree cxx_maybe_build_cleanup (tree);
/* in decl2.c */
extern void append_type_to_template_for_access_check (tree, tree, tree);
extern tree splice_late_return_type (tree, tree);
extern bool is_auto (const_tree);
-extern tree process_template_parm (tree, tree, bool, bool);
+extern tree process_template_parm (tree, location_t, tree,
+ bool, bool);
extern tree end_template_parm_list (tree);
extern void end_template_decl (void);
extern bool check_default_tmpl_args (tree, tree, int, int, int);
tsubst_flags_t);
extern tree cp_build_indirect_ref (tree, const char *,
tsubst_flags_t);
-extern tree build_array_ref (tree, tree, location_t);
+extern tree build_array_ref (location_t, tree, tree);
extern tree get_member_function_from_ptrfunc (tree *, tree);
extern tree cp_build_function_call (tree, tree, tsubst_flags_t);
extern tree cp_build_function_call_vec (tree, VEC(tree,gc) **,
extern tree build_x_compound_expr_from_list (tree, const char *);
extern tree build_x_compound_expr_from_vec (VEC(tree,gc) *, const char *);
extern tree build_x_compound_expr (tree, tree, tsubst_flags_t);
-extern tree build_compound_expr (tree, tree);
+extern tree build_compound_expr (location_t, tree, tree);
extern tree cp_build_compound_expr (tree, tree, tsubst_flags_t);
extern tree build_static_cast (tree, tree, tsubst_flags_t);
extern tree build_reinterpret_cast (tree, tree, tsubst_flags_t);
extern tree build_const_cast (tree, tree, tsubst_flags_t);
-extern tree build_c_cast (tree, tree);
+extern tree build_c_cast (location_t, tree, tree);
extern tree cp_build_c_cast (tree, tree, tsubst_flags_t);
extern tree build_x_modify_expr (tree, enum tree_code, tree,
tsubst_flags_t);
static tree get_dso_handle_node (void);
static tree start_cleanup_fn (void);
static void end_cleanup_fn (void);
-static tree cp_make_fname_decl (tree, int);
+static tree cp_make_fname_decl (location_t, tree, int);
static void initialize_predefined_identifiers (void);
static tree check_special_function_return_type
(special_function_kind, tree, tree);
have pushed a statement list level. Pop that, create a new
BIND_EXPR for the block, and insert it into the stream. */
stmt = pop_stmt_list (current_binding_level->statement_list);
- stmt = c_build_bind_expr (block, stmt);
+ stmt = c_build_bind_expr (input_location, block, stmt);
add_stmt (stmt);
}
{
tree decl;
- decl = build_decl (TYPE_DECL, name, type);
+ decl = build_decl (input_location, TYPE_DECL, name, type);
DECL_ARTIFICIAL (decl) = 1;
/* There are other implicit type declarations, like the one *within*
a class that allows you to write `S::S'. We must distinguish
void **slot;
tree decl;
- decl = build_decl (LABEL_DECL, id, void_type_node);
+ decl = build_decl (input_location, LABEL_DECL, id, void_type_node);
DECL_CONTEXT (decl) = current_function_decl;
DECL_MODE (decl) = VOIDmode;
is a bad place for one. */
tree
-finish_case_label (tree low_value, tree high_value)
+finish_case_label (location_t loc, tree low_value, tree high_value)
{
tree cond, r;
struct cp_binding_level *p;
/* For templates, just add the case label; we'll do semantic
analysis at instantiation-time. */
- label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
- return add_stmt (build_case_label (low_value, high_value, label));
+ label = build_decl (loc, LABEL_DECL, NULL_TREE, NULL_TREE);
+ return add_stmt (build_case_label (loc, low_value, high_value, label));
}
/* Find the condition on which this switch statement depends. */
if (!check_switch_goto (switch_stack->level))
return error_mark_node;
- r = c_add_case_label (switch_stack->cases, cond,
+ r = c_add_case_label (loc, switch_stack->cases, cond,
SWITCH_STMT_TYPE (switch_stack->switch_stmt),
low_value, high_value);
TYPENAME_IS_CLASS_P (t) = ti.class_p;
/* Build the corresponding TYPE_DECL. */
- d = build_decl (TYPE_DECL, name, t);
+ d = build_decl (input_location, TYPE_DECL, name, t);
TYPE_NAME (TREE_TYPE (d)) = d;
TYPE_STUB_DECL (TREE_TYPE (d)) = d;
DECL_CONTEXT (d) = FROB_CONTEXT (context);
SET_TYPE_STRUCTURAL_EQUALITY (t);
/* Build the corresponding TEMPLATE_DECL. */
- d = build_decl (TEMPLATE_DECL, name, t);
+ d = build_decl (input_location, TEMPLATE_DECL, name, t);
TYPE_NAME (TREE_TYPE (d)) = d;
TYPE_STUB_DECL (TREE_TYPE (d)) = d;
DECL_CONTEXT (d) = FROB_CONTEXT (context);
up built-in types by name. */
if (tname)
{
- tdecl = build_decl (TYPE_DECL, tname, type);
+ tdecl = build_decl (BUILTINS_LOCATION, TYPE_DECL, tname, type);
DECL_ARTIFICIAL (tdecl) = 1;
SET_IDENTIFIER_GLOBAL_VALUE (tname, tdecl);
}
{
if (!tdecl)
{
- tdecl = build_decl (TYPE_DECL, rname, type);
+ tdecl = build_decl (BUILTINS_LOCATION, TYPE_DECL, rname, type);
DECL_ARTIFICIAL (tdecl) = 1;
}
SET_IDENTIFIER_GLOBAL_VALUE (rname, tdecl);
static void
record_unknown_type (tree type, const char* name)
{
- tree decl = pushdecl (build_decl (TYPE_DECL, get_identifier (name), type));
+ tree decl = pushdecl (build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, get_identifier (name), type));
/* Make sure the "unknown type" typedecl gets ignored for debug info. */
DECL_IGNORED_P (decl) = 1;
TYPE_DECL_SUPPRESS_DEBUG (decl) = 1;
return init;
}
-/* Create the VAR_DECL for __FUNCTION__ etc. ID is the name to give the
- decl, NAME is the initialization string and TYPE_DEP indicates whether
- NAME depended on the type of the function. We make use of that to detect
- __PRETTY_FUNCTION__ inside a template fn. This is being done
- lazily at the point of first use, so we mustn't push the decl now. */
+/* Create the VAR_DECL for __FUNCTION__ etc. ID is the name to give
+ the decl, LOC is the location to give the decl, NAME is the
+ initialization string and TYPE_DEP indicates whether NAME depended
+ on the type of the function. We make use of that to detect
+ __PRETTY_FUNCTION__ inside a template fn. This is being done lazily
+ at the point of first use, so we mustn't push the decl now. */
static tree
-cp_make_fname_decl (tree id, int type_dep)
+cp_make_fname_decl (location_t loc, tree id, int type_dep)
{
const char *const name = (type_dep && processing_template_decl
? NULL : fname_as_string (type_dep));
tree type;
tree init = cp_fname_init (name, &type);
- tree decl = build_decl (VAR_DECL, id, type);
+ tree decl = build_decl (loc, VAR_DECL, id, type);
if (name)
free (CONST_CAST (char *, name));
tree decl;
push_to_top_level ();
- decl = build_decl (VAR_DECL, name, type);
+ decl = build_decl (input_location, VAR_DECL, name, type);
TREE_PUBLIC (decl) = 1;
DECL_EXTERNAL (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
|| TYPE_P (scope)))
decl = build_lang_decl (VAR_DECL, name, type);
else
- decl = build_decl (VAR_DECL, name, type);
+ decl = build_decl (input_location, VAR_DECL, name, type);
if (explicit_scope && TREE_CODE (explicit_scope) == NAMESPACE_DECL)
set_decl_namespace (decl, explicit_scope, 0);
/* ... and not really a class type. */
SET_CLASS_TYPE_P (t, 0);
- field = build_decl (FIELD_DECL, pfn_identifier, type);
+ field = build_decl (input_location, FIELD_DECL, pfn_identifier, type);
fields = field;
- field = build_decl (FIELD_DECL, delta_identifier, delta_type_node);
+ field = build_decl (input_location, FIELD_DECL, delta_identifier,
+ delta_type_node);
TREE_CHAIN (field) = fields;
fields = field;
if (decl_context == FIELD)
decl = build_lang_decl (TYPE_DECL, unqualified_id, type);
else
- decl = build_decl (TYPE_DECL, unqualified_id, type);
+ decl = build_decl (input_location, TYPE_DECL, unqualified_id, type);
if (id_declarator && declarator->u.id.qualifying_scope) {
error ("%Jtypedef name may not be a nested-name-specifier", decl);
TREE_TYPE (decl) = error_mark_node;
}
else
{
- decl = build_decl (FIELD_DECL, unqualified_id, type);
+ decl = build_decl (input_location,
+ FIELD_DECL, unqualified_id, type);
DECL_NONADDRESSABLE_P (decl) = bitfield;
if (bitfield && !unqualified_id)
TREE_NO_WARNING (decl) = 1;
else
/* It's a global enum, or it's local to a function. (Note local to
a function could mean local to a class method. */
- decl = build_decl (CONST_DECL, name, type);
+ decl = build_decl (input_location, CONST_DECL, name, type);
DECL_CONTEXT (decl) = FROB_CONTEXT (context);
TREE_CONSTANT (decl) = 1;
{
tree resdecl;
- resdecl = build_decl (RESULT_DECL, 0, restype);
+ resdecl = build_decl (input_location, RESULT_DECL, 0, restype);
DECL_ARTIFICIAL (resdecl) = 1;
DECL_IGNORED_P (resdecl) = 1;
DECL_RESULT (decl1) = resdecl;
|| (DECL_CONSTRUCTOR_P (decl1)
&& targetm.cxx.cdtor_returns_this ()))
{
- cdtor_label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
+ cdtor_label = build_decl (input_location,
+ LABEL_DECL, NULL_TREE, NULL_TREE);
DECL_CONTEXT (cdtor_label) = current_function_decl;
}
&& (! TYPE_FOR_JAVA (current_class_type)))
{
/* Any return from a constructor will end up here. */
- add_stmt (build_stmt (LABEL_EXPR, cdtor_label));
+ add_stmt (build_stmt (input_location, LABEL_EXPR, cdtor_label));
val = DECL_ARGUMENTS (current_function_decl);
val = build2 (MODIFY_EXPR, TREE_TYPE (val),
DECL_RESULT (current_function_decl), val);
/* Return the address of the object. */
- exprstmt = build_stmt (RETURN_EXPR, val);
+ exprstmt = build_stmt (input_location, RETURN_EXPR, val);
add_stmt (exprstmt);
}
}
/* Any return from a destructor will end up here; that way all base
and member cleanups will be run when the function returns. */
- add_stmt (build_stmt (LABEL_EXPR, cdtor_label));
+ add_stmt (build_stmt (input_location, LABEL_EXPR, cdtor_label));
/* In a virtual destructor, we must call delete. */
if (DECL_VIRTUAL_P (current_function_decl))
val = build2 (MODIFY_EXPR, TREE_TYPE (val),
DECL_RESULT (current_function_decl), val);
/* Return the address of the object. */
- exprstmt = build_stmt (RETURN_EXPR, val);
+ exprstmt = build_stmt (input_location, RETURN_EXPR, val);
add_stmt (exprstmt);
}
}
call = build_delete (TREE_TYPE (addr), addr,
sfk_complete_destructor, flags, 0);
if (cleanup)
- cleanup = build_compound_expr (cleanup, call);
+ cleanup = build_compound_expr (input_location, cleanup, call);
else
cleanup = call;
}
tree
cp_build_parm_decl (tree name, tree type)
{
- tree parm = build_decl (PARM_DECL, name, type);
+ tree parm = build_decl (input_location,
+ PARM_DECL, name, type);
/* DECL_ARG_TYPE is only used by the back end and the back end never
sees templates. */
if (!processing_template_decl)
if (array_expr == error_mark_node || index_exp == error_mark_node)
error ("ambiguous conversion for array subscript");
- expr = build_array_ref (array_expr, index_exp, input_location);
+ expr = build_array_ref (input_location, array_expr, index_exp);
}
if (processing_template_decl && expr != error_mark_node)
return build_min_non_dep (ARRAY_REF, expr, orig_array_expr, orig_index_exp,
{
tree base;
- decl = build_decl (VAR_DECL, DECL_NAME (field), TREE_TYPE (field));
+ decl = build_decl (input_location,
+ VAR_DECL, DECL_NAME (field), TREE_TYPE (field));
DECL_ANON_UNION_VAR_P (decl) = 1;
base = get_base_address (object);
/* We use a type that is big enough to contain a mutex as well
as an integer counter. */
guard_type = targetm.cxx.guard_type ();
- guard = build_decl (VAR_DECL, sname, guard_type);
+ guard = build_decl (DECL_SOURCE_LOCATION (decl),
+ VAR_DECL, sname, guard_type);
/* The guard should have the same linkage as what it guards. */
TREE_PUBLIC (guard) = TREE_PUBLIC (decl);
tree
begin_eh_spec_block (void)
{
- tree r = build_stmt (EH_SPEC_BLOCK, NULL_TREE, NULL_TREE);
+ tree r = build_stmt (input_location, EH_SPEC_BLOCK, NULL_TREE, NULL_TREE);
add_stmt (r);
EH_SPEC_STMTS (r) = push_stmt_list ();
return r;
class_decl = IDENTIFIER_GLOBAL_VALUE (name);
if (class_decl == NULL_TREE)
{
- class_decl = build_decl (VAR_DECL, name, TREE_TYPE (jclass_node));
+ class_decl = build_decl (input_location,
+ VAR_DECL, name, TREE_TYPE (jclass_node));
TREE_STATIC (class_decl) = 1;
DECL_EXTERNAL (class_decl) = 1;
TREE_PUBLIC (class_decl) = 1;
fold_convert (ptype, base)));
tmp = fold_build1 (NEGATE_EXPR, sizetype, size_exp);
body = build_compound_expr
- (body, cp_build_modify_expr (tbase, NOP_EXPR,
+ (input_location,
+ body, cp_build_modify_expr (tbase, NOP_EXPR,
build2 (POINTER_PLUS_EXPR, ptype, tbase, tmp),
tf_warning_or_error));
body = build_compound_expr
- (body, build_delete (ptype, tbase, sfk_complete_destructor,
+ (input_location,
+ body, build_delete (ptype, tbase, sfk_complete_destructor,
LOOKUP_NORMAL|LOOKUP_DESTRUCTOR, 1));
loop = build1 (LOOP_EXPR, void_type_node, body);
- loop = build_compound_expr (tbase_init, loop);
+ loop = build_compound_expr (input_location, tbase_init, loop);
no_destructor:
/* If the delete flag is one, or anything else with the low bit set,
else if (!body)
body = deallocate_expr;
else
- body = build_compound_expr (body, deallocate_expr);
+ body = build_compound_expr (input_location, body, deallocate_expr);
if (!body)
body = integer_zero_node;
{
tree decl;
- decl = build_decl (VAR_DECL, NULL_TREE, type);
+ decl = build_decl (input_location,
+ VAR_DECL, NULL_TREE, type);
TREE_USED (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
- DECL_SOURCE_LOCATION (decl) = input_location;
DECL_CONTEXT (decl) = current_function_decl;
return decl;
if (current_function_decl)
{
tree decl;
- decl = build_decl (VAR_DECL, name, error_mark_node);
+ decl = build_decl (input_location,
+ VAR_DECL, name, error_mark_node);
DECL_CONTEXT (decl) = current_function_decl;
push_local_binding (name, decl, 0);
/* Mark the variable as used so that we do not get warnings
{
tree t;
- t = build_decl (code, name, type);
+ t = build_decl (input_location,
+ code, name, type);
retrofit_lang_decl (t);
/* All nesting of C++ functions is lexical; there is never a "static
gcc_assert (TYPE_SIZE (DECL_CONTEXT (function))
&& TYPE_BEING_DEFINED (DECL_CONTEXT (function)));
- thunk = build_decl (FUNCTION_DECL, NULL_TREE, TREE_TYPE (function));
+ thunk = build_decl (DECL_SOURCE_LOCATION (function),
+ FUNCTION_DECL, NULL_TREE, TREE_TYPE (function));
DECL_LANG_SPECIFIC (thunk) = DECL_LANG_SPECIFIC (function);
cxx_dup_lang_specific_decl (thunk);
DECL_THUNKS (thunk) = NULL_TREE;
tree
make_alias_for (tree function, tree newid)
{
- tree alias = build_decl (FUNCTION_DECL, newid, TREE_TYPE (function));
+ tree alias = build_decl (DECL_SOURCE_LOCATION (function),
+ FUNCTION_DECL, newid, TREE_TYPE (function));
DECL_LANG_SPECIFIC (alias) = DECL_LANG_SPECIFIC (function);
cxx_dup_lang_specific_decl (alias);
DECL_CONTEXT (alias) = NULL;
current_function_decl = thunk_fndecl;
DECL_RESULT (thunk_fndecl)
- = build_decl (RESULT_DECL, 0, integer_type_node);
+ = build_decl (DECL_SOURCE_LOCATION (thunk_fndecl),
+ RESULT_DECL, 0, integer_type_node);
fnname = IDENTIFIER_POINTER (DECL_NAME (thunk_fndecl));
/* The back end expects DECL_INITIAL to contain a BLOCK, so we
create one. */
gcc_assert (TREE_CODE (name_space) == NAMESPACE_DECL);
if (building_stmt_tree ())
- add_stmt (build_stmt (USING_STMT, name_space));
+ add_stmt (build_stmt (input_location, USING_STMT, name_space));
name_space = ORIGINAL_NAMESPACE (name_space);
if (!toplevel_bindings_p ())
if (TREE_CODE (t) != TEMPLATE_DECL)
{
if (building_stmt_tree ())
- add_stmt (build_stmt (USING_STMT, t));
+ add_stmt (build_stmt (input_location, USING_STMT, t));
else
(*debug_hooks->imported_module_or_decl) (t, NULL_TREE, context, false);
}
return error_mark_node;
/* Perform the cast. */
- expr = build_c_cast (type, expr);
+ expr = build_c_cast (input_location, type, expr);
return expr;
}
else
expr_hi = NULL_TREE;
if (parser->in_switch_statement_p)
- finish_case_label (expr, expr_hi);
+ finish_case_label (token->location, expr, expr_hi);
else
error ("%Hcase label %qE not within a switch statement",
&token->location, expr);
cp_lexer_consume_token (parser->lexer);
if (parser->in_switch_statement_p)
- finish_case_label (NULL_TREE, NULL_TREE);
+ finish_case_label (token->location, NULL_TREE, NULL_TREE);
else
error ("%Hcase label not within a switch statement", &token->location);
break;
if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
{
location_t loc = cp_lexer_peek_token (parser->lexer)->location;
- add_stmt (build_empty_stmt ());
+ add_stmt (build_empty_stmt (loc));
cp_lexer_consume_token (parser->lexer);
if (!cp_lexer_next_token_is_keyword (parser->lexer, RID_ELSE))
warning_at (loc, OPT_Wempty_body, "suggest braces around "
/* Parse the else-clause. */
if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
{
- warning_at (cp_lexer_peek_token (parser->lexer)->location,
+ location_t loc;
+ loc = cp_lexer_peek_token (parser->lexer)->location;
+ warning_at (loc,
OPT_Wempty_body, "suggest braces around "
"empty body in an %<else%> statement");
- add_stmt (build_empty_stmt ());
+ add_stmt (build_empty_stmt (loc));
cp_lexer_consume_token (parser->lexer);
}
else
/* Mark if () ; with a special NOP_EXPR. */
if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
{
+ location_t loc = cp_lexer_peek_token (parser->lexer)->location;
cp_lexer_consume_token (parser->lexer);
- statement = add_stmt (build_empty_stmt ());
+ statement = add_stmt (build_empty_stmt (loc));
}
/* if a compound is opened, we simply parse the statement directly. */
else if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE))
tree parameter;
bool is_non_type;
bool is_parameter_pack;
+ location_t parm_loc;
/* Parse the template-parameter. */
+ parm_loc = cp_lexer_peek_token (parser->lexer)->location;
parameter = cp_parser_template_parameter (parser,
&is_non_type,
&is_parameter_pack);
/* Add it to the list. */
if (parameter != error_mark_node)
parameter_list = process_template_parm (parameter_list,
+ parm_loc,
parameter,
is_non_type,
is_parameter_pack);
know it is an anonymous aggregate. */
fixup_anonymous_aggr (type);
/* And make the corresponding data member. */
- decl = build_decl (FIELD_DECL, NULL_TREE, type);
+ decl = build_decl (decl_spec_token_start->location,
+ FIELD_DECL, NULL_TREE, type);
/* Add it to the class. */
finish_member_declaration (decl);
}
tree sel_seq = NULL_TREE;
bool maybe_unary_selector_p = true;
cp_token *token;
+ location_t loc = cp_lexer_peek_token (parser->lexer)->location;
cp_lexer_consume_token (parser->lexer); /* Eat '@selector'. */
cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>");
finish_selector:
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>");
- return objc_build_selector_expr (sel_seq);
+ return objc_build_selector_expr (loc, sel_seq);
}
/* Parse a list of identifiers.
static tree
cp_parser_objc_throw_statement (cp_parser *parser) {
tree expr = NULL_TREE;
+ location_t loc = cp_lexer_peek_token (parser->lexer)->location;
cp_parser_require_keyword (parser, RID_AT_THROW, "%<@throw%>");
cp_parser_consume_semicolon_at_end_of_statement (parser);
- return objc_build_throw_stmt (expr);
+ return objc_build_throw_stmt (loc, expr);
}
/* Parse an Objective-C statement. */
cp_parser_name_lookup_error (parser, name, decl, NULL, token->location);
else if (kind != 0)
{
- tree u = build_omp_clause (kind);
+ tree u = build_omp_clause (token->location, kind);
OMP_CLAUSE_DECL (u) = decl;
OMP_CLAUSE_CHAIN (u) = list;
list = u;
}
check_no_duplicate_clause (list, OMP_CLAUSE_COLLAPSE, "collapse", location);
- c = build_omp_clause (OMP_CLAUSE_COLLAPSE);
+ c = build_omp_clause (loc, OMP_CLAUSE_COLLAPSE);
OMP_CLAUSE_CHAIN (c) = list;
OMP_CLAUSE_COLLAPSE_EXPR (c) = num;
return list;
check_no_duplicate_clause (list, OMP_CLAUSE_DEFAULT, "default", location);
- c = build_omp_clause (OMP_CLAUSE_DEFAULT);
+ c = build_omp_clause (location, OMP_CLAUSE_DEFAULT);
OMP_CLAUSE_CHAIN (c) = list;
OMP_CLAUSE_DEFAULT_KIND (c) = kind;
check_no_duplicate_clause (list, OMP_CLAUSE_IF, "if", location);
- c = build_omp_clause (OMP_CLAUSE_IF);
+ c = build_omp_clause (location, OMP_CLAUSE_IF);
OMP_CLAUSE_IF_EXPR (c) = t;
OMP_CLAUSE_CHAIN (c) = list;
check_no_duplicate_clause (list, OMP_CLAUSE_NOWAIT, "nowait", location);
- c = build_omp_clause (OMP_CLAUSE_NOWAIT);
+ c = build_omp_clause (location, OMP_CLAUSE_NOWAIT);
OMP_CLAUSE_CHAIN (c) = list;
return c;
}
check_no_duplicate_clause (list, OMP_CLAUSE_NUM_THREADS,
"num_threads", location);
- c = build_omp_clause (OMP_CLAUSE_NUM_THREADS);
+ c = build_omp_clause (location, OMP_CLAUSE_NUM_THREADS);
OMP_CLAUSE_NUM_THREADS_EXPR (c) = t;
OMP_CLAUSE_CHAIN (c) = list;
check_no_duplicate_clause (list, OMP_CLAUSE_ORDERED,
"ordered", location);
- c = build_omp_clause (OMP_CLAUSE_ORDERED);
+ c = build_omp_clause (location, OMP_CLAUSE_ORDERED);
OMP_CLAUSE_CHAIN (c) = list;
return c;
}
if (!cp_parser_require (parser, CPP_OPEN_PAREN, "%<(%>"))
return list;
- c = build_omp_clause (OMP_CLAUSE_SCHEDULE);
+ c = build_omp_clause (location, OMP_CLAUSE_SCHEDULE);
if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
{
check_no_duplicate_clause (list, OMP_CLAUSE_UNTIED, "untied", location);
- c = build_omp_clause (OMP_CLAUSE_UNTIED);
+ c = build_omp_clause (location, OMP_CLAUSE_UNTIED);
OMP_CLAUSE_CHAIN (c) = list;
return c;
}
cp_parser_require_pragma_eol (parser, pragma_tok);
stmt = cp_parser_omp_structured_block (parser);
- return c_finish_omp_critical (stmt, name);
+ return c_finish_omp_critical (input_location, stmt, name);
}
/* OpenMP 2.5:
{
/* Add lastprivate (decl) clause to OMP_FOR_CLAUSES,
change it to shared (decl) in OMP_PARALLEL_CLAUSES. */
- tree l = build_omp_clause (OMP_CLAUSE_LASTPRIVATE);
+ tree l = build_omp_clause (loc, OMP_CLAUSE_LASTPRIVATE);
OMP_CLAUSE_DECL (l) = real_decl;
OMP_CLAUSE_CHAIN (l) = clauses;
CP_OMP_CLAUSE_INFO (l) = CP_OMP_CLAUSE_INFO (*c);
}
if (c == NULL)
{
- c = build_omp_clause (OMP_CLAUSE_PRIVATE);
+ c = build_omp_clause (loc, OMP_CLAUSE_PRIVATE);
OMP_CLAUSE_DECL (c) = decl;
c = finish_omp_clauses (c);
if (c)
cp_parser_omp_master (cp_parser *parser, cp_token *pragma_tok)
{
cp_parser_require_pragma_eol (parser, pragma_tok);
- return c_finish_omp_master (cp_parser_omp_structured_block (parser));
+ return c_finish_omp_master (input_location,
+ cp_parser_omp_structured_block (parser));
}
/* OpenMP 2.5:
static tree
cp_parser_omp_ordered (cp_parser *parser, cp_token *pragma_tok)
{
+ location_t loc = cp_lexer_peek_token (parser->lexer)->location;
cp_parser_require_pragma_eol (parser, pragma_tok);
- return c_finish_omp_ordered (cp_parser_omp_structured_block (parser));
+ return c_finish_omp_ordered (loc, cp_parser_omp_structured_block (parser));
}
/* OpenMP 2.5:
tree stmt, clauses, par_clause, ws_clause, block;
unsigned int mask = OMP_PARALLEL_CLAUSE_MASK;
unsigned int save;
+ location_t loc = cp_lexer_peek_token (parser->lexer)->location;
if (cp_lexer_next_token_is_keyword (parser->lexer, RID_FOR))
{
break;
case PRAGMA_OMP_PARALLEL_FOR:
- c_split_parallel_clauses (clauses, &par_clause, &ws_clause);
+ c_split_parallel_clauses (loc, clauses, &par_clause, &ws_clause);
cp_parser_omp_for_loop (parser, ws_clause, &par_clause);
break;
case PRAGMA_OMP_PARALLEL_SECTIONS:
- c_split_parallel_clauses (clauses, &par_clause, &ws_clause);
+ c_split_parallel_clauses (loc, clauses, &par_clause, &ws_clause);
stmt = cp_parser_omp_sections_scope (parser);
if (stmt)
OMP_SECTIONS_CLAUSES (stmt) = ws_clause;
It is ugly that we recreate this here; the original
version built in process_template_parm is no longer
available. */
- tree decl = build_decl (CONST_DECL, DECL_NAME (parm),
+ tree decl = build_decl (DECL_SOURCE_LOCATION (parm),
+ CONST_DECL, DECL_NAME (parm),
TREE_TYPE (parm));
DECL_ARTIFICIAL (decl) = 1;
TREE_CONSTANT (decl) = 1;
tree orig_decl = TEMPLATE_PARM_DECL (index);
tree decl, t;
- decl = build_decl (TREE_CODE (orig_decl), DECL_NAME (orig_decl), type);
+ decl = build_decl (DECL_SOURCE_LOCATION (orig_decl),
+ TREE_CODE (orig_decl), DECL_NAME (orig_decl), type);
TREE_CONSTANT (decl) = TREE_CONSTANT (orig_decl);
TREE_READONLY (decl) = TREE_READONLY (orig_decl);
DECL_ARTIFICIAL (decl) = 1;
/* Process information from new template parameter PARM and append it to the
LIST being built. This new parameter is a non-type parameter iff
IS_NON_TYPE is true. This new parameter is a parameter
- pack iff IS_PARAMETER_PACK is true. */
+ pack iff IS_PARAMETER_PACK is true. The location of PARM is in
+ PARM_LOC. */
tree
-process_template_parm (tree list, tree parm, bool is_non_type,
+process_template_parm (tree list, location_t parm_loc, tree parm, bool is_non_type,
bool is_parameter_pack)
{
tree decl = 0;
/* A template parameter is not modifiable. */
TREE_CONSTANT (parm) = 1;
TREE_READONLY (parm) = 1;
- decl = build_decl (CONST_DECL, DECL_NAME (parm), TREE_TYPE (parm));
+ decl = build_decl (parm_loc,
+ CONST_DECL, DECL_NAME (parm), TREE_TYPE (parm));
TREE_CONSTANT (decl) = 1;
TREE_READONLY (decl) = 1;
DECL_INITIAL (parm) = DECL_INITIAL (decl)
{
t = cxx_make_type (TEMPLATE_TYPE_PARM);
/* parm is either IDENTIFIER_NODE or NULL_TREE. */
- decl = build_decl (TYPE_DECL, parm, t);
+ decl = build_decl (parm_loc,
+ TYPE_DECL, parm, t);
}
TYPE_NAME (t) = decl;
TREE_CHAIN (r) = NULL_TREE;
TREE_TYPE (r) = new_type;
DECL_TEMPLATE_RESULT (r)
- = build_decl (TYPE_DECL, DECL_NAME (decl), new_type);
+ = build_decl (DECL_SOURCE_LOCATION (decl),
+ TYPE_DECL, DECL_NAME (decl), new_type);
DECL_TEMPLATE_PARMS (r)
= tsubst_template_parms (DECL_TEMPLATE_PARMS (t), args,
complain);
}
if (c == NULL)
{
- c = build_omp_clause (OMP_CLAUSE_PRIVATE);
+ c = build_omp_clause (input_location, OMP_CLAUSE_PRIVATE);
OMP_CLAUSE_DECL (c) = decl;
c = finish_omp_clauses (c);
if (c)
break;
case CASE_LABEL_EXPR:
- finish_case_label (RECUR (CASE_LOW (t)),
+ finish_case_label (EXPR_LOCATION (t),
+ RECUR (CASE_LOW (t)),
RECUR (CASE_HIGH (t)));
break;
/* ??? Is it worth caching this for multiple autos at the same level? */
au = cxx_make_type (TEMPLATE_TYPE_PARM);
- TYPE_NAME (au) = build_decl (TYPE_DECL, get_identifier ("auto"), au);
+ TYPE_NAME (au) = build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("auto"), au);
TYPE_STUB_DECL (au) = TYPE_NAME (au);
TEMPLATE_TYPE_PARM_INDEX (au) = build_template_parm_index
(0, processing_template_decl + 1, processing_template_decl + 1,
sprintf (pseudo_name + strlen (pseudo_name), "%d", tk - TK_FIXED);
/* First field is the pseudo type_info base class. */
- fields = build_decl (FIELD_DECL, NULL_TREE,
+ fields = build_decl (input_location,
+ FIELD_DECL, NULL_TREE,
VEC_index (tinfo_s, tinfo_descs,
TK_TYPE_INFO_TYPE)->type);
push_abi_namespace ();
create_pseudo_type_info
(ix, "__vmi_class_type_info",
- build_decl (FIELD_DECL, NULL_TREE, integer_type_node),
- build_decl (FIELD_DECL, NULL_TREE, integer_type_node),
- build_decl (FIELD_DECL, NULL_TREE, base_array),
+ build_decl (input_location,
+ FIELD_DECL, NULL_TREE, integer_type_node),
+ build_decl (input_location,
+ FIELD_DECL, NULL_TREE, integer_type_node),
+ build_decl (input_location,
+ FIELD_DECL, NULL_TREE, base_array),
NULL);
pop_abi_namespace ();
break;
{
tree field, fields;
- field = build_decl (FIELD_DECL, NULL_TREE, const_ptr_type_node);
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, const_ptr_type_node);
fields = field;
- field = build_decl (FIELD_DECL, NULL_TREE, const_string_type_node);
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, const_string_type_node);
TREE_CHAIN (field) = fields;
fields = field;
/* Single public non-virtual base class. Add pointer to base class.
This is really a descendant of __class_type_info. */
create_pseudo_type_info (TK_SI_CLASS_TYPE, "__si_class_type_info",
- build_decl (FIELD_DECL, NULL_TREE, type_info_ptr_type),
+ build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, type_info_ptr_type),
NULL);
/* Base class internal helper. Pointer to base type, offset to base,
{
tree field, fields;
- field = build_decl (FIELD_DECL, NULL_TREE, type_info_ptr_type);
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, type_info_ptr_type);
fields = field;
- field = build_decl (FIELD_DECL, NULL_TREE, integer_types[itk_long]);
+ field = build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, integer_types[itk_long]);
TREE_CHAIN (field) = fields;
fields = field;
and pointer to the pointed to type. This is really a descendant of
__pbase_type_info. */
create_pseudo_type_info (TK_POINTER_TYPE, "__pointer_type_info",
- build_decl (FIELD_DECL, NULL_TREE, integer_type_node),
- build_decl (FIELD_DECL, NULL_TREE, type_info_ptr_type),
+ build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, integer_type_node),
+ build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, type_info_ptr_type),
NULL);
/* Pointer to member data type_info. Add qualifications flags,
This is really a descendant of __pbase_type_info. */
create_pseudo_type_info (TK_POINTER_MEMBER_TYPE,
"__pointer_to_member_type_info",
- build_decl (FIELD_DECL, NULL_TREE, integer_type_node),
- build_decl (FIELD_DECL, NULL_TREE, type_info_ptr_type),
- build_decl (FIELD_DECL, NULL_TREE, type_info_ptr_type),
+ build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, integer_type_node),
+ build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, type_info_ptr_type),
+ build_decl (BUILTINS_LOCATION,
+ FIELD_DECL, NULL_TREE, type_info_ptr_type),
NULL);
pop_abi_namespace ();
void
add_decl_expr (tree decl)
{
- tree r = build_stmt (DECL_EXPR, decl);
+ tree r = build_stmt (input_location, DECL_EXPR, decl);
if (DECL_INITIAL (decl)
|| (DECL_SIZE (decl) && TREE_SIDE_EFFECTS (DECL_SIZE (decl))))
r = maybe_cleanup_point_expr_void (r);
if (!processing_template_decl)
{
- stmt_list = c_build_bind_expr (block, stmt_list);
+ stmt_list = c_build_bind_expr (input_location, block, stmt_list);
/* ??? See c_end_compound_stmt re statement expressions. */
}
void
push_cleanup (tree decl, tree cleanup, bool eh_only)
{
- tree stmt = build_stmt (CLEANUP_STMT, NULL, cleanup, decl);
+ tree stmt = build_stmt (input_location, CLEANUP_STMT, NULL, cleanup, decl);
CLEANUP_EH_ONLY (stmt) = eh_only;
add_stmt (stmt);
CLEANUP_BODY (stmt) = push_stmt_list ();
check_goto (destination);
- return add_stmt (build_stmt (GOTO_EXPR, destination));
+ return add_stmt (build_stmt (input_location, GOTO_EXPR, destination));
}
/* COND is the condition-expression for an if, while, etc.,
if (TREE_CODE (expr) != CLEANUP_POINT_EXPR)
{
if (TREE_CODE (expr) != EXPR_STMT)
- expr = build_stmt (EXPR_STMT, expr);
+ expr = build_stmt (input_location, EXPR_STMT, expr);
expr = maybe_cleanup_point_expr_void (expr);
}
{
tree r, scope;
scope = do_pushlevel (sk_block);
- r = build_stmt (IF_STMT, NULL_TREE, NULL_TREE, NULL_TREE);
+ r = build_stmt (input_location, IF_STMT, NULL_TREE, NULL_TREE, NULL_TREE);
TREE_CHAIN (r) = scope;
begin_cond (&IF_COND (r));
return r;
begin_while_stmt (void)
{
tree r;
- r = build_stmt (WHILE_STMT, NULL_TREE, NULL_TREE);
+ r = build_stmt (input_location, WHILE_STMT, NULL_TREE, NULL_TREE);
add_stmt (r);
WHILE_BODY (r) = do_pushlevel (sk_block);
begin_cond (&WHILE_COND (r));
tree
begin_do_stmt (void)
{
- tree r = build_stmt (DO_STMT, NULL_TREE, NULL_TREE);
+ tree r = build_stmt (input_location, DO_STMT, NULL_TREE, NULL_TREE);
add_stmt (r);
DO_BODY (r) = push_stmt_list ();
return r;
}
}
- r = build_stmt (RETURN_EXPR, expr);
+ r = build_stmt (input_location, RETURN_EXPR, expr);
TREE_NO_WARNING (r) |= no_warning;
r = maybe_cleanup_point_expr_void (r);
r = add_stmt (r);
{
tree r;
- r = build_stmt (FOR_STMT, NULL_TREE, NULL_TREE,
+ r = build_stmt (input_location, FOR_STMT, NULL_TREE, NULL_TREE,
NULL_TREE, NULL_TREE);
if (flag_new_for_scope > 0)
tree
finish_break_stmt (void)
{
- return add_stmt (build_stmt (BREAK_STMT));
+ return add_stmt (build_stmt (input_location, BREAK_STMT));
}
/* Finish a continue-statement. */
tree
finish_continue_stmt (void)
{
- return add_stmt (build_stmt (CONTINUE_STMT));
+ return add_stmt (build_stmt (input_location, CONTINUE_STMT));
}
/* Begin a switch-statement. Returns a new SWITCH_STMT if
{
tree r, scope;
- r = build_stmt (SWITCH_STMT, NULL_TREE, NULL_TREE, NULL_TREE);
+ r = build_stmt (input_location, SWITCH_STMT, NULL_TREE, NULL_TREE, NULL_TREE);
scope = do_pushlevel (sk_block);
TREE_CHAIN (r) = scope;
tree
begin_try_block (void)
{
- tree r = build_stmt (TRY_BLOCK, NULL_TREE, NULL_TREE);
+ tree r = build_stmt (input_location, TRY_BLOCK, NULL_TREE, NULL_TREE);
add_stmt (r);
TRY_STMTS (r) = push_stmt_list ();
return r;
{
tree r;
- r = build_stmt (HANDLER, NULL_TREE, NULL_TREE);
+ r = build_stmt (input_location, HANDLER, NULL_TREE, NULL_TREE);
add_stmt (r);
/* Create a binding level for the eh_info and the exception object
}
}
- r = build_stmt (ASM_EXPR, string,
+ r = build_stmt (input_location, ASM_EXPR, string,
output_operands, input_operands,
clobbers);
ASM_VOLATILE_P (r) = volatile_p || noutputs == 0;
if (decl == error_mark_node)
return error_mark_node;
- add_stmt (build_stmt (LABEL_EXPR, decl));
+ add_stmt (build_stmt (input_location, LABEL_EXPR, decl));
return decl;
}
if (processing_template_decl)
{
- expr = build_stmt (EXPR_STMT, expr);
+ expr = build_stmt (input_location, EXPR_STMT, expr);
expr = add_stmt (expr);
/* Mark the last statement so that we can recognize it as such at
template-instantiation time. */
if (TREE_CODE (fn) == FUNCTION_DECL
&& (DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
|| DECL_BUILT_IN_CLASS (fn) == BUILT_IN_MD))
- result = resolve_overloaded_builtin (fn, *args);
+ result = resolve_overloaded_builtin (input_location, fn, *args);
if (!result)
/* A call to a namespace-scope function. */
TREE_NEGATED_INT (result) = 1;
}
if (TREE_OVERFLOW_P (result) && !TREE_OVERFLOW_P (expr))
- overflow_warning (result);
+ overflow_warning (input_location, result);
return result;
}
tree
finish_template_template_parm (tree aggr, tree identifier)
{
- tree decl = build_decl (TYPE_DECL, identifier, NULL_TREE);
+ tree decl = build_decl (input_location,
+ TYPE_DECL, identifier, NULL_TREE);
tree tmpl = build_lang_decl (TEMPLATE_DECL, identifier, NULL_TREE);
DECL_TEMPLATE_PARMS (tmpl) = current_template_parms;
DECL_TEMPLATE_RESULT (tmpl) = decl;
init = build2 (INIT_EXPR, void_type_node, dp->result,
DECL_INITIAL (dp->var));
else
- init = build_empty_stmt ();
+ init = build_empty_stmt (EXPR_LOCATION (*tp));
DECL_INITIAL (dp->var) = NULL_TREE;
SET_EXPR_LOCUS (init, EXPR_LOCUS (*tp));
*tp = init;
TREE_CODE (cond), decl, diff,
tf_warning_or_error);
incr = build_modify_expr (elocus, decl, NULL_TREE, PLUS_EXPR,
- incr, NULL_TREE);
+ elocus, incr, NULL_TREE);
orig_body = *body;
*body = push_stmt_list ();
}
if (!dependent_p)
{
- stmt = c_finish_omp_atomic (code, lhs, rhs);
+ stmt = c_finish_omp_atomic (input_location, code, lhs, rhs);
if (stmt == error_mark_node)
return;
}
static tree
build_local_temp (tree type)
{
- tree slot = build_decl (VAR_DECL, NULL_TREE, type);
+ tree slot = build_decl (input_location,
+ VAR_DECL, NULL_TREE, type);
DECL_ARTIFICIAL (slot) = 1;
DECL_IGNORED_P (slot) = 1;
DECL_CONTEXT (slot) = current_function_decl;
tree t2;
t2 = cxx_make_type (BOUND_TEMPLATE_TEMPLATE_PARM);
- decl = build_decl (TYPE_DECL, DECL_NAME (decl), NULL_TREE);
+ decl = build_decl (input_location,
+ TYPE_DECL, DECL_NAME (decl), NULL_TREE);
/* These nodes have to be created to reflect new TYPE_DECL and template
arguments. */
return value;
}
- return c_sizeof_or_alignof_type (complete_type (type),
+ return c_sizeof_or_alignof_type (input_location, complete_type (type),
op == SIZEOF_EXPR,
complain);
}
LOC is the location to use in building the array reference. */
tree
-build_array_ref (tree array, tree idx, location_t loc)
+build_array_ref (location_t loc, tree array, tree idx)
{
tree ret;
{
case COMPOUND_EXPR:
{
- tree value = build_array_ref (TREE_OPERAND (array, 1), idx, loc);
+ tree value = build_array_ref (loc, TREE_OPERAND (array, 1), idx);
ret = build2 (COMPOUND_EXPR, TREE_TYPE (value),
TREE_OPERAND (array, 0), value);
SET_EXPR_LOCATION (ret, loc);
case COND_EXPR:
ret = build_conditional_expr
(TREE_OPERAND (array, 0),
- build_array_ref (TREE_OPERAND (array, 1), idx, loc),
- build_array_ref (TREE_OPERAND (array, 2), idx, loc),
- tf_warning_or_error);
+ build_array_ref (loc, TREE_OPERAND (array, 1), idx),
+ build_array_ref (loc, TREE_OPERAND (array, 2), idx),
+ tf_warning_or_error);
protected_set_expr_location (ret, loc);
return ret;
/* Used by the C-common bits. */
tree
-build_function_call (tree function, tree params)
+build_function_call (location_t loc ATTRIBUTE_UNUSED,
+ tree function, tree params)
{
return cp_build_function_call (function, params, tf_warning_or_error);
}
/* Used by the C-common bits. */
tree
-build_function_call_vec (tree function, VEC(tree,gc) *params,
+build_function_call_vec (location_t loc ATTRIBUTE_UNUSED,
+ tree function, VEC(tree,gc) *params,
VEC(tree,gc) *origtypes ATTRIBUTE_UNUSED)
{
VEC(tree,gc) *orig_params = params;
if (TREE_OVERFLOW_P (result)
&& !TREE_OVERFLOW_P (op0)
&& !TREE_OVERFLOW_P (op1))
- overflow_warning (result);
+ overflow_warning (location, result);
return result;
}
/* Like cp_build_compound_expr, but for the c-common bits. */
tree
-build_compound_expr (tree lhs, tree rhs)
+build_compound_expr (location_t loc ATTRIBUTE_UNUSED, tree lhs, tree rhs)
{
return cp_build_compound_expr (lhs, rhs, tf_warning_or_error);
}
/* Like cp_build_c_cast, but for the c-common bits. */
tree
-build_c_cast (tree type, tree expr)
+build_c_cast (location_t loc ATTRIBUTE_UNUSED, tree type, tree expr)
{
return cp_build_c_cast (type, expr, tf_warning_or_error);
}
tree
build_modify_expr (location_t location ATTRIBUTE_UNUSED,
tree lhs, tree lhs_origtype ATTRIBUTE_UNUSED,
- enum tree_code modifycode, tree rhs,
+ enum tree_code modifycode,
+ location_t rhs_location ATTRIBUTE_UNUSED, tree rhs,
tree rhs_origtype ATTRIBUTE_UNUSED)
{
return cp_build_modify_expr (lhs, modifycode, rhs, tf_warning_or_error);
/* Handle null pointer to member function conversions. */
if (integer_zerop (pfn))
{
- pfn = build_c_cast (type, integer_zero_node);
+ pfn = build_c_cast (input_location, type, integer_zero_node);
return build_ptrmemfunc1 (to_type,
integer_zero_node,
pfn);
NULL_TREE);
code = build2 (INIT_EXPR, inner_type, sub, value);
- code = build_stmt (EXPR_STMT, code);
+ code = build_stmt (input_location, EXPR_STMT, code);
add_stmt (code);
continue;
}
tree cons = copy_node (init);
CONSTRUCTOR_ELTS (init) = NULL;
code = build2 (MODIFY_EXPR, type, dest, cons);
- code = build_stmt (EXPR_STMT, code);
+ code = build_stmt (input_location, EXPR_STMT, code);
add_stmt (code);
}
break;
sym = (const char *) node->key;
id = (tree) node->value;
- decl = build_decl (VAR_DECL, id, ptr_type_node);
+ decl = build_decl (UNKNOWN_LOCATION, VAR_DECL, id, ptr_type_node);
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
DECL_INITIAL (decl) = decl;
if (d || !force_build_p)
return d;
- d = build_decl (VAR_DECL, get_identifier ("%sfp"), void_type_node);
+ d = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
+ VAR_DECL, get_identifier ("%sfp"), void_type_node);
DECL_ARTIFICIAL (d) = 1;
DECL_IGNORED_P (d) = 1;
TREE_USED (d) = 1;
sjlj_fc_type_node = lang_hooks.types.make_type (RECORD_TYPE);
- f_prev = build_decl (FIELD_DECL, get_identifier ("__prev"),
+ f_prev = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
+ FIELD_DECL, get_identifier ("__prev"),
build_pointer_type (sjlj_fc_type_node));
DECL_FIELD_CONTEXT (f_prev) = sjlj_fc_type_node;
- f_cs = build_decl (FIELD_DECL, get_identifier ("__call_site"),
+ f_cs = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
+ FIELD_DECL, get_identifier ("__call_site"),
integer_type_node);
DECL_FIELD_CONTEXT (f_cs) = sjlj_fc_type_node;
tmp = build_array_type (lang_hooks.types.type_for_mode
(targetm.unwind_word_mode (), 1),
tmp);
- f_data = build_decl (FIELD_DECL, get_identifier ("__data"), tmp);
+ f_data = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
+ FIELD_DECL, get_identifier ("__data"), tmp);
DECL_FIELD_CONTEXT (f_data) = sjlj_fc_type_node;
- f_per = build_decl (FIELD_DECL, get_identifier ("__personality"),
+ f_per = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
+ FIELD_DECL, get_identifier ("__personality"),
ptr_type_node);
DECL_FIELD_CONTEXT (f_per) = sjlj_fc_type_node;
- f_lsda = build_decl (FIELD_DECL, get_identifier ("__lsda"),
+ f_lsda = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
+ FIELD_DECL, get_identifier ("__lsda"),
ptr_type_node);
DECL_FIELD_CONTEXT (f_lsda) = sjlj_fc_type_node;
#endif
tmp = build_index_type (tmp);
tmp = build_array_type (ptr_type_node, tmp);
- f_jbuf = build_decl (FIELD_DECL, get_identifier ("__jbuf"), tmp);
+ f_jbuf = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
+ FIELD_DECL, get_identifier ("__jbuf"), tmp);
#ifdef DONT_USE_BUILTIN_SETJMP
/* We don't know what the alignment requirements of the
runtime's jmp_buf has. Overestimate. */
/* else fall through. */
default:
- t = build_decl (VAR_DECL, NULL_TREE, type);
+ t = build_decl (RTL_LOCATION (x), VAR_DECL, NULL_TREE, type);
/* If TYPE is a POINTER_TYPE, X might be Pmode with TYPE_MODE being
ptr_mode. So convert. */
const_ptr_type_node, sizetype,
NULL_TREE);
- fn = build_decl (FUNCTION_DECL, fn, args);
+ fn = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL, fn, args);
DECL_EXTERNAL (fn) = 1;
TREE_PUBLIC (fn) = 1;
DECL_ARTIFICIAL (fn) = 1;
integer_type_node, sizetype,
NULL_TREE);
- fn = build_decl (FUNCTION_DECL, fn, args);
+ fn = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL, fn, args);
DECL_EXTERNAL (fn) = 1;
TREE_PUBLIC (fn) = 1;
DECL_ARTIFICIAL (fn) = 1;
expand_normal (hi_index);
unsignedp = TYPE_UNSIGNED (domain);
- index = build_decl (VAR_DECL, NULL_TREE, domain);
+ index = build_decl (EXPR_LOCATION (exp),
+ VAR_DECL, NULL_TREE, domain);
index_r
= gen_reg_rtx (promote_mode (domain, DECL_MODE (index),
with non-BLKmode values. */
gcc_assert (GET_MODE (ret) != BLKmode);
- val = build_decl (VAR_DECL, NULL, TREE_TYPE (exp));
+ val = build_decl (EXPR_LOCATION (exp),
+ VAR_DECL, NULL, TREE_TYPE (exp));
DECL_ARTIFICIAL (val) = 1;
DECL_IGNORED_P (val) = 1;
TREE_OPERAND (exp, 0) = val;
+2009-06-12 Aldy Hernandez <aldyh@redhat.com>
+
+ * trans-array.c (gfc_trans_allocate_array_storage): Pass
+ location on down.
+ (gfc_trans_array_constructor_value): Same.
+ (gfc_trans_scalarized_loop_end): Same.
+ (gfc_conv_ss_startstride): Same.
+ (gfc_trans_g77_array): Same.
+ (gfc_trans_dummy_array_bias): Same.
+ (gfc_conv_array_parameter): Same.
+ (structure_alloc_comps): Same.
+ * trans-expr.c (gfc_conv_function_call): Same.
+ (fill_with_spaces): Same.
+ (gfc_trans_string_copy): Same.
+ (gfc_trans_scalar_assign): Same.
+ * trans-stmt.c (gfc_trans_goto): Same.
+ (gfc_trans_if_1): Same.
+ (gfc_trans_simple_do): Same.
+ (gfc_trans_do): Same.
+ (gfc_trans_do_while): Same.
+ (gfc_trans_logical_select): Same.
+ (gfc_trans_select): Same.
+ (gfc_trans_forall_loop): Same.
+ (gfc_trans_nested_forall_loop): Same.
+ (generate_loop_for_temp_to_lhs): Same.
+ (generate_loop_for_rhs_to_temp): Same.
+ (gfc_trans_forall_1): Same.
+ (gfc_trans_where_assign): Same.
+ (gfc_trans_where_3): Same.
+ (gfc_trans_allocate): Same.
+ * trans.c (gfc_finish_block): Same.
+ (gfc_trans_runtime_check): Same.
+ (gfc_call_malloc): Same.
+ (gfc_allocate_with_status): Same.
+ (gfc_call_free): Same.
+ (gfc_deallocate_with_status): Same.
+ (gfc_call_realloc): Same.
+ (gfc_trans_code): Same.
+ * trans-decl.c (gfc_init_default_dt): Same.
+ (gfc_generate_constructors): Same.
+ * trans-io.c (gfc_trans_io_runtime_check): Same.
+ * trans-intrinsic.c (gfc_conv_intrinsic_ctime): Same.
+ (gfc_conv_intrinsic_fdate): Same.
+ (gfc_conv_intrinsic_ttynam): Same.
+ (gfc_conv_intrinsic_minmax): Same.
+ (gfc_conv_intrinsic_minmax_char): Same.
+ (gfc_conv_intrinsic_anyall): Same.
+ (gfc_conv_intrinsic_count): Same.
+ (gfc_conv_intrinsic_arith): Same.
+ (gfc_conv_intrinsic_minmaxloc): Same.
+ (gfc_conv_intrinsic_minmaxval): Same.
+ (gfc_conv_intrinsic_rrspacing): Same.
+ (gfc_conv_intrinsic_array_transfer): Same.
+ (gfc_conv_intrinsic_trim): Same.
+ (gfc_conv_intrinsic_repeat): Same.
+
2009-06-12 Janus Weil <janus@gcc.gnu.org>
PR fortran/40176
was_packed = fold_build2 (EQ_EXPR, boolean_type_node,
packed, source_data);
tmp = gfc_finish_block (&do_copying);
- tmp = build3_v (COND_EXPR, was_packed, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, was_packed, tmp,
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (pre, tmp);
tmp = fold_convert (pvoid_type_node, packed);
shadow_loopvar, end));
tmp = build1_v (GOTO_EXPR, exit_label);
TREE_USED (exit_label) = 1;
- tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, cond, tmp,
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&body, tmp);
/* The main loop body. */
TREE_TYPE (stmt) = void_type_node;
OMP_FOR_BODY (stmt) = loopbody = gfc_finish_block (pbody);
- OMP_FOR_CLAUSES (stmt) = build_omp_clause (OMP_CLAUSE_SCHEDULE);
+ OMP_FOR_CLAUSES (stmt) = build_omp_clause (input_location,
+ OMP_CLAUSE_SCHEDULE);
OMP_CLAUSE_SCHEDULE_KIND (OMP_FOR_CLAUSES (stmt))
= OMP_CLAUSE_SCHEDULE_STATIC;
if (ompws_flags & OMPWS_NOWAIT)
OMP_CLAUSE_CHAIN (OMP_FOR_CLAUSES (stmt))
- = build_omp_clause (OMP_CLAUSE_NOWAIT);
+ = build_omp_clause (input_location, OMP_CLAUSE_NOWAIT);
/* Initialize the loopvar. */
TREE_VEC_ELT (init, 0) = build2_v (MODIFY_EXPR, loop->loopvar[n],
loop->loopvar[n], loop->to[n]);
tmp = build1_v (GOTO_EXPR, exit_label);
TREE_USED (exit_label) = 1;
- tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
/* The main body. */
|| ss->expr->symtree->n.sym->attr.not_always_present)
tmp = build3_v (COND_EXPR,
gfc_conv_expr_present (ss->expr->symtree->n.sym),
- tmp, build_empty_stmt ());
+ tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
if (sym->attr.optional || sym->attr.not_always_present)
{
tmp = gfc_conv_expr_present (sym);
- stmt = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt ());
+ stmt = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt (input_location));
}
gfc_add_expr_to_block (&block, stmt);
if (optional_arg)
{
tmp = gfc_conv_expr_present (sym);
- stmt = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt ());
+ stmt = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt (input_location));
}
gfc_add_expr_to_block (&block, stmt);
tmp = build_fold_indirect_ref (dumdesc);
tmp = gfc_conv_descriptor_data_get (tmp);
tmp = fold_build2 (NE_EXPR, boolean_type_node, tmp, tmpdesc);
- stmt = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt ());
+ stmt = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt (input_location));
if (optional_arg)
{
tmp = gfc_conv_expr_present (sym);
- stmt = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt ());
+ stmt = build3_v (COND_EXPR, tmp, stmt,
+ build_empty_stmt (input_location));
}
gfc_add_expr_to_block (&block, stmt);
}
tmp = fold_build2 (TRUTH_AND_EXPR, boolean_type_node,
gfc_conv_expr_present (sym), tmp);
- tmp = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
gfc_add_block_to_block (&block, &se->post);
tmp = gfc_finish_block (&fnblock);
if (null_cond != NULL_TREE)
- tmp = build3_v (COND_EXPR, null_cond, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, null_cond, tmp,
+ build_empty_stmt (input_location));
return tmp;
}
unsigned HOST_WIDE_INT desired_align, known_align;
name = get_identifier (h->sym->name);
- field = build_decl (FIELD_DECL, name, h->field);
- gfc_set_decl_location (field, &h->sym->declared_at);
+ field = build_decl (h->sym->declared_at.lb->location,
+ FIELD_DECL, name, h->field);
known_align = (offset & -offset) * BITS_PER_UNIT;
if (known_align == 0 || known_align > BIGGEST_ALIGNMENT)
known_align = BIGGEST_ALIGNMENT;
}
snprintf (name, sizeof (name), "equiv.%d", serial++);
- decl = build_decl (VAR_DECL, get_identifier (name), union_type);
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (name), union_type);
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
/* If there is no backend_decl for the common block, build it. */
if (decl == NULL_TREE)
{
- decl = build_decl (VAR_DECL, get_identifier (com->name), union_type);
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (com->name), union_type);
SET_DECL_ASSEMBLER_NAME (decl, gfc_sym_mangled_common_id (com));
TREE_PUBLIC (decl) = 1;
TREE_STATIC (decl) = 1;
tmp = build_range_type (gfc_array_index_type,
gfc_index_zero_node, tmp);
tmp = build_array_type (type, tmp);
- field = build_decl (FIELD_DECL, NULL_TREE, tmp);
- gfc_set_decl_location (field, &gfc_current_locus);
+ field = build_decl (gfc_current_locus.lb->location,
+ FIELD_DECL, NULL_TREE, tmp);
known_align = BIGGEST_ALIGNMENT;
{
tree var_decl;
- var_decl = build_decl (VAR_DECL, DECL_NAME (s->field),
+ var_decl = build_decl (s->sym->declared_at.lb->location,
+ VAR_DECL, DECL_NAME (s->field),
TREE_TYPE (s->field));
- gfc_set_decl_location (var_decl, &s->sym->declared_at);
TREE_PUBLIC (var_decl) = TREE_PUBLIC (decl);
TREE_STATIC (var_decl) = TREE_STATIC (decl);
TREE_USED (var_decl) = TREE_USED (decl);
label_name = NULL;
/* Build the LABEL_DECL node. Labels have no type. */
- label_decl = build_decl (LABEL_DECL, label_id, void_type_node);
+ label_decl = build_decl (input_location,
+ LABEL_DECL, label_id, void_type_node);
DECL_CONTEXT (label_decl) = current_function_decl;
DECL_MODE (label_decl) = VOIDmode;
DECL_IGNORED_P (GFC_TYPE_ARRAY_UBOUND (type, dim)) = 0;
}
}
- TYPE_NAME (type) = type_decl = build_decl (TYPE_DECL, NULL, gtype);
+ TYPE_NAME (type) = type_decl = build_decl (input_location,
+ TYPE_DECL, NULL, gtype);
DECL_ORIGINAL_TYPE (type_decl) = gtype;
}
}
}
ASM_FORMAT_PRIVATE_NAME (name, IDENTIFIER_POINTER (DECL_NAME (dummy)), 0);
- decl = build_decl (VAR_DECL, get_identifier (name), type);
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (name), type);
DECL_ARTIFICIAL (decl) = 1;
TREE_PUBLIC (decl) = 0;
return;
dummy = GFC_DECL_SAVED_DESCRIPTOR (sym->backend_decl);
- decl = build_decl (VAR_DECL, DECL_NAME (dummy),
+ decl = build_decl (input_location, VAR_DECL, DECL_NAME (dummy),
TREE_TYPE (sym->backend_decl));
DECL_ARTIFICIAL (decl) = 0;
TREE_USED (decl) = 1;
/* Also prefix the mangled name. */
strcpy (&name[1], sym->name);
name[0] = '.';
- length = build_decl (VAR_DECL, get_identifier (name),
+ length = build_decl (input_location,
+ VAR_DECL, get_identifier (name),
gfc_charlen_type_node);
DECL_ARTIFICIAL (length) = 1;
TREE_USED (length) = 1;
decl = sym->backend_decl;
gfc_allocate_lang_decl (decl);
GFC_DECL_ASSIGN (decl) = 1;
- length = build_decl (VAR_DECL, create_tmp_var_name (sym->name),
+ length = build_decl (input_location,
+ VAR_DECL, create_tmp_var_name (sym->name),
gfc_charlen_type_node);
- addr = build_decl (VAR_DECL, create_tmp_var_name (sym->name),
+ addr = build_decl (input_location,
+ VAR_DECL, create_tmp_var_name (sym->name),
pvoid_type_node);
gfc_finish_var_decl (length, sym);
gfc_finish_var_decl (addr, sym);
length = gfc_create_string_length (sym);
/* Create the decl for the variable. */
- decl = build_decl (VAR_DECL, gfc_sym_identifier (sym), gfc_sym_type (sym));
-
- gfc_set_decl_location (decl, &sym->declared_at);
+ decl = build_decl (sym->declared_at.lb->location,
+ VAR_DECL, gfc_sym_identifier (sym), gfc_sym_type (sym));
/* Symbols from modules should have their assembler names mangled.
This is done here rather than in gfc_finish_var_decl because it
{
tree span;
GFC_DECL_SUBREF_ARRAY_P (decl) = 1;
- span = build_decl (VAR_DECL, create_tmp_var_name ("span"),
+ span = build_decl (input_location,
+ VAR_DECL, create_tmp_var_name ("span"),
gfc_array_index_type);
gfc_finish_var_decl (span, sym);
TREE_STATIC (span) = TREE_STATIC (decl);
if (decl)
return decl;
- decl = build_decl (VAR_DECL, get_identifier (sym->name),
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (sym->name),
build_pointer_type (gfc_get_function_type (sym)));
if ((sym->ns->proc_name
}
type = gfc_get_function_type (sym);
- fndecl = build_decl (FUNCTION_DECL, name, type);
+ fndecl = build_decl (input_location,
+ FUNCTION_DECL, name, type);
SET_DECL_ASSEMBLER_NAME (fndecl, mangled_name);
/* If the return type is a pointer, avoid alias issues by setting
== NAMESPACE_DECL);
type = gfc_get_function_type (sym);
- fndecl = build_decl (FUNCTION_DECL, gfc_sym_identifier (sym), type);
+ fndecl = build_decl (input_location,
+ FUNCTION_DECL, gfc_sym_identifier (sym), type);
/* Perform name mangling if this is a top level or module procedure. */
if (current_function_decl == NULL_TREE)
type = void_type_node;
}
- result_decl = build_decl (RESULT_DECL, result_decl, type);
+ result_decl = build_decl (input_location,
+ RESULT_DECL, result_decl, type);
DECL_ARTIFICIAL (result_decl) = 1;
DECL_IGNORED_P (result_decl) = 1;
DECL_CONTEXT (result_decl) = fndecl;
if (sym->attr.entry_master)
{
type = TREE_VALUE (typelist);
- parm = build_decl (PARM_DECL, get_identifier ("__entry"), type);
+ parm = build_decl (input_location,
+ PARM_DECL, get_identifier ("__entry"), type);
DECL_CONTEXT (parm) = fndecl;
DECL_ARG_TYPE (parm) = type;
tree len_type = TREE_VALUE (TREE_CHAIN (typelist));
gcc_assert (len_type == gfc_charlen_type_node);
- length = build_decl (PARM_DECL,
+ length = build_decl (input_location,
+ PARM_DECL,
get_identifier (".__result"),
len_type);
if (!sym->ts.cl->length)
if (sym->ts.cl->backend_decl == NULL)
{
- tree len = build_decl (VAR_DECL,
+ tree len = build_decl (input_location,
+ VAR_DECL,
get_identifier ("..__result"),
gfc_charlen_type_node);
DECL_ARTIFICIAL (len) = 1;
}
}
- parm = build_decl (PARM_DECL, get_identifier ("__result"), type);
+ parm = build_decl (input_location,
+ PARM_DECL, get_identifier ("__result"), type);
DECL_CONTEXT (parm) = fndecl;
DECL_ARG_TYPE (parm) = TREE_VALUE (typelist);
strcpy (&name[1], f->sym->name);
name[0] = '_';
- length = build_decl (PARM_DECL, get_identifier (name), len_type);
+ length = build_decl (input_location,
+ PARM_DECL, get_identifier (name), len_type);
hidden_arglist = chainon (hidden_arglist, length);
DECL_CONTEXT (length) = fndecl;
type = build_pointer_type (type);
/* Build the argument declaration. */
- parm = build_decl (PARM_DECL, gfc_sym_identifier (f->sym), type);
+ parm = build_decl (input_location,
+ PARM_DECL, gfc_sym_identifier (f->sym), type);
/* Fill in arg stuff. */
DECL_CONTEXT (parm) = fndecl;
tree union_decl, field;
tree master_type = TREE_TYPE (ns->proc_name->backend_decl);
- union_decl = build_decl (VAR_DECL, get_identifier ("__result"),
+ union_decl = build_decl (input_location,
+ VAR_DECL, get_identifier ("__result"),
TREE_TYPE (master_type));
DECL_ARTIFICIAL (union_decl) = 1;
DECL_EXTERNAL (union_decl) = 0;
IDENTIFIER_POINTER (DECL_NAME (this_function_decl)));
if (!sym->attr.mixed_entry_master && sym->attr.function)
- decl = build_decl (VAR_DECL, get_identifier (name),
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (name),
gfc_sym_type (sym));
else
- decl = build_decl (VAR_DECL, get_identifier (name),
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (name),
TREE_TYPE (TREE_TYPE (this_function_decl)));
DECL_ARTIFICIAL (decl) = 1;
DECL_EXTERNAL (decl) = 0;
/* Build the function type and decl. */
fntype = build_function_type (rettype, arglist);
- fndecl = build_decl (FUNCTION_DECL, name, fntype);
+ fndecl = build_decl (input_location,
+ FUNCTION_DECL, name, fntype);
/* Mark this decl as external. */
DECL_EXTERNAL (fndecl) = 1;
{
present = gfc_conv_expr_present (sym);
tmp = build3 (COND_EXPR, TREE_TYPE (tmp), present,
- tmp, build_empty_stmt ());
+ tmp, build_empty_stmt (input_location));
}
gfc_add_expr_to_block (&fnblock, tmp);
gfc_free_expr (e);
present = gfc_conv_expr_present (f->sym);
tmp = build3 (COND_EXPR, TREE_TYPE (tmp), present,
- tmp, build_empty_stmt ());
+ tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&fnblock, tmp);
}
if (entry->namespace_decl == NULL)
{
entry->namespace_decl
- = build_decl (NAMESPACE_DECL,
+ = build_decl (input_location,
+ NAMESPACE_DECL,
get_identifier (use_stmt->module_name),
void_type_node);
DECL_EXTERNAL (entry->namespace_decl) = 1;
return;
/* Create the decl for the variable or constant. */
- decl = build_decl (sym->attr.flavor == FL_PARAMETER ? CONST_DECL : VAR_DECL,
+ decl = build_decl (input_location,
+ sym->attr.flavor == FL_PARAMETER ? CONST_DECL : VAR_DECL,
gfc_sym_identifier (sym), gfc_sym_type (sym));
if (sym->attr.flavor == FL_PARAMETER)
TREE_READONLY (decl) = 1;
build_pointer_type (pchar_type_node),
NULL_TREE);
main_identifier_node = get_identifier ("main");
- ftn_main = build_decl (FUNCTION_DECL, main_identifier_node, tmp);
+ ftn_main = build_decl (input_location, FUNCTION_DECL,
+ main_identifier_node, tmp);
DECL_EXTERNAL (ftn_main) = 0;
TREE_PUBLIC (ftn_main) = 1;
TREE_STATIC (ftn_main) = 1;
= tree_cons (get_identifier("externally_visible"), NULL_TREE, NULL_TREE);
/* Setup the result declaration (for "return 0"). */
- result_decl = build_decl (RESULT_DECL, NULL_TREE, integer_type_node);
+ result_decl = build_decl (input_location,
+ RESULT_DECL, NULL_TREE, integer_type_node);
DECL_ARTIFICIAL (result_decl) = 1;
DECL_IGNORED_P (result_decl) = 1;
DECL_CONTEXT (result_decl) = ftn_main;
typelist = TYPE_ARG_TYPES (TREE_TYPE (ftn_main));
tmp = TREE_VALUE (typelist);
- argc = build_decl (PARM_DECL, get_identifier ("argc"), tmp);
+ argc = build_decl (input_location, PARM_DECL, get_identifier ("argc"), tmp);
DECL_CONTEXT (argc) = ftn_main;
DECL_ARG_TYPE (argc) = TREE_VALUE (typelist);
TREE_READONLY (argc) = 1;
typelist = TREE_CHAIN (typelist);
tmp = TREE_VALUE (typelist);
- argv = build_decl (PARM_DECL, get_identifier ("argv"), tmp);
+ argv = build_decl (input_location, PARM_DECL, get_identifier ("argv"), tmp);
DECL_CONTEXT (argv) = ftn_main;
DECL_ARG_TYPE (argv) = TREE_VALUE (typelist);
TREE_READONLY (argv) = 1;
type = build_function_type (void_type_node,
gfc_chainon_list (NULL_TREE, void_type_node));
- fndecl = build_decl (FUNCTION_DECL, fnname, type);
+ fndecl = build_decl (input_location,
+ FUNCTION_DECL, fnname, type);
TREE_PUBLIC (fndecl) = 1;
- decl = build_decl (RESULT_DECL, NULL_TREE, void_type_node);
+ decl = build_decl (input_location,
+ RESULT_DECL, NULL_TREE, void_type_node);
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
DECL_CONTEXT (decl) = fndecl;
for (; gfc_static_ctors; gfc_static_ctors = TREE_CHAIN (gfc_static_ctors))
{
tmp = build_call_expr (TREE_VALUE (gfc_static_ctors), 0);
- DECL_SAVED_TREE (fndecl) = build_stmt (EXPR_STMT, tmp);
+ DECL_SAVED_TREE (fndecl) = build_stmt (input_location, EXPR_STMT, tmp);
}
decl = getdecls ();
else
id = get_identifier ("__BLOCK_DATA__");
- decl = build_decl (VAR_DECL, id, gfc_array_index_type);
+ decl = build_decl (input_location,
+ VAR_DECL, id, gfc_array_index_type);
TREE_PUBLIC (decl) = 1;
TREE_STATIC (decl) = 1;
DECL_IGNORED_P (decl) = 1;
cond = fold_build2 (LE_EXPR, boolean_type_node, i,
fold_convert (sizetype, integer_zero_node));
tmp = build1_v (GOTO_EXPR, exit_label);
- tmp = fold_build3 (COND_EXPR, void_type_node, cond, tmp, build_empty_stmt ());
+ tmp = fold_build3 (COND_EXPR, void_type_node, cond, tmp,
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&loop, tmp);
/* Assignment. */
/* The whole copy_string function is there. */
tmp = fold_build3 (COND_EXPR, void_type_node, cond2, tmp2, tmp3);
- tmp = fold_build3 (COND_EXPR, void_type_node, cond, tmp, build_empty_stmt ());
+ tmp = fold_build3 (COND_EXPR, void_type_node, cond, tmp,
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (block, tmp);
}
{
tree tmp = se->expr;
STRIP_TYPE_NOPS (tmp);
- var = build_decl (CONST_DECL, NULL, TREE_TYPE (tmp));
+ var = build_decl (input_location,
+ CONST_DECL, NULL, TREE_TYPE (tmp));
DECL_INITIAL (var) = tmp;
TREE_STATIC (var) = 1;
pushdecl (var);
tmp = gfc_evaluate_now (lse->expr, &lse->pre);
tmp = gfc_deallocate_alloc_comp (ts.derived, tmp, 0);
if (r_is_var)
- tmp = build3_v (COND_EXPR, cond, build_empty_stmt (), tmp);
+ tmp = build3_v (COND_EXPR, cond, build_empty_stmt (input_location),
+ tmp);
gfc_add_expr_to_block (&lse->post, tmp);
}
if (r_is_var)
{
tmp = gfc_copy_alloc_comp (ts.derived, rse->expr, lse->expr, 0);
- tmp = build3_v (COND_EXPR, cond, build_empty_stmt (), tmp);
+ tmp = build3_v (COND_EXPR, cond, build_empty_stmt (input_location),
+ tmp);
gfc_add_expr_to_block (&block, tmp);
}
}
}
argtypes = gfc_chainon_list (argtypes, void_type_node);
type = build_function_type (gfc_typenode_for_spec (ts), argtypes);
- fndecl = build_decl (FUNCTION_DECL, get_identifier (name), type);
+ fndecl = build_decl (input_location,
+ FUNCTION_DECL, get_identifier (name), type);
/* Mark the decl as external. */
DECL_EXTERNAL (fndecl) = 1;
cond = fold_build2 (GT_EXPR, boolean_type_node,
len, build_int_cst (TREE_TYPE (len), 0));
tmp = gfc_call_free (var);
- tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&se->post, tmp);
se->expr = var;
cond = fold_build2 (GT_EXPR, boolean_type_node,
len, build_int_cst (TREE_TYPE (len), 0));
tmp = gfc_call_free (var);
- tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&se->post, tmp);
se->expr = var;
cond = fold_build2 (GT_EXPR, boolean_type_node,
len, build_int_cst (TREE_TYPE (len), 0));
tmp = gfc_call_free (var);
- tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&se->post, tmp);
se->expr = var;
tmp = fold_build2 (TRUTH_OR_EXPR, boolean_type_node, tmp,
fold_convert (boolean_type_node, isnan));
}
- tmp = build3_v (COND_EXPR, tmp, thencase, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, tmp, thencase,
+ build_empty_stmt (input_location));
if (cond != NULL_TREE)
- tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, cond, tmp,
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&se->pre, tmp);
argexpr = argexpr->next;
cond = fold_build2 (GT_EXPR, boolean_type_node,
len, build_int_cst (TREE_TYPE (len), 0));
tmp = gfc_call_free (var);
- tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&se->post, tmp);
se->expr = var;
gfc_add_block_to_block (&body, &arrayse.pre);
tmp = fold_build2 (op, boolean_type_node, arrayse.expr,
build_int_cst (TREE_TYPE (arrayse.expr), 0));
- tmp = build3_v (COND_EXPR, tmp, found, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, tmp, found, build_empty_stmt (input_location));
gfc_add_expr_to_block (&body, tmp);
gfc_add_block_to_block (&body, &arrayse.post);
gfc_copy_loopinfo_to_se (&arrayse, &loop);
arrayse.ss = arrayss;
gfc_conv_expr_val (&arrayse, actual->expr);
- tmp = build3_v (COND_EXPR, arrayse.expr, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, arrayse.expr, tmp,
+ build_empty_stmt (input_location));
gfc_add_block_to_block (&body, &arrayse.pre);
gfc_add_expr_to_block (&body, tmp);
/* We enclose the above in if (mask) {...} . */
tmp = gfc_finish_block (&block);
- tmp = build3_v (COND_EXPR, maskse.expr, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, maskse.expr, tmp,
+ build_empty_stmt (input_location));
}
else
tmp = gfc_finish_block (&block);
gfc_add_block_to_block (&block, &loop.post);
tmp = gfc_finish_block (&block);
- tmp = build3_v (COND_EXPR, maskse.expr, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, maskse.expr, tmp,
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
gfc_add_block_to_block (&se->pre, &block);
}
tmp = fold_build2 (TRUTH_OR_EXPR, boolean_type_node,
fold_build2 (op, boolean_type_node,
arrayse.expr, limit), tmp);
- tmp = build3_v (COND_EXPR, tmp, ifbody, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, tmp, ifbody, build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
if (maskss)
/* We enclose the above in if (mask) {...}. */
tmp = gfc_finish_block (&block);
- tmp = build3_v (COND_EXPR, maskse.expr, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, maskse.expr, tmp,
+ build_empty_stmt (input_location));
}
else
tmp = gfc_finish_block (&block);
/* If it is a more extreme value. */
tmp = fold_build2 (op, boolean_type_node, arrayse.expr, limit);
- tmp = build3_v (COND_EXPR, tmp, ifbody, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, tmp, ifbody, build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
gfc_add_block_to_block (&block, &arrayse.post);
tmp = gfc_finish_block (&block);
if (maskss)
/* We enclose the above in if (mask) {...}. */
- tmp = build3_v (COND_EXPR, maskse.expr, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, maskse.expr, tmp,
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&body, tmp);
gfc_trans_scalarizing_loops (&loop, &body);
gfc_add_block_to_block (&block, &loop.post);
tmp = gfc_finish_block (&block);
- tmp = build3_v (COND_EXPR, maskse.expr, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, maskse.expr, tmp,
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
gfc_add_block_to_block (&se->pre, &block);
}
cond = fold_build2 (NE_EXPR, boolean_type_node, x,
build_real_from_int_cst (type, integer_zero_node));
- tmp = build3_v (COND_EXPR, cond, stmt, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, cond, stmt, build_empty_stmt (input_location));
gfc_add_expr_to_block (&se->pre, tmp);
se->expr = fold_convert (type, x);
gfc_init_block (&block);
tmp = gfc_conv_array_data (argse.expr);
tmp = fold_build2 (NE_EXPR, boolean_type_node, source, tmp);
- tmp = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, tmp, stmt,
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
gfc_add_block_to_block (&block, &se->post);
gfc_init_block (&se->post);
cond = fold_build2 (GT_EXPR, boolean_type_node,
len, build_int_cst (TREE_TYPE (len), 0));
tmp = gfc_call_free (var);
- tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&se->post, tmp);
se->expr = var;
tmp = build1_v (GOTO_EXPR, exit_label);
TREE_USED (exit_label) = 1;
tmp = fold_build3 (COND_EXPR, void_type_node, cond, tmp,
- build_empty_stmt ());
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&body, tmp);
/* Call memmove (dest + (i*slen*size), src, slen*size). */
cond = build_call_expr (built_in_decls[BUILT_IN_EXPECT], 2, cond, tmp);
cond = fold_convert (boolean_type_node, cond);
- tmp = build3_v (COND_EXPR, cond, body, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, cond, body, build_empty_stmt (input_location));
gfc_add_expr_to_block (pblock, tmp);
}
}
tree t = gfc_trans_omp_variable (namelist->sym);
if (t != error_mark_node)
{
- tree node = build_omp_clause (code);
+ tree node = build_omp_clause (input_location, code);
OMP_CLAUSE_DECL (node) = t;
list = gfc_trans_add_clause (node, list);
}
tree t = gfc_trans_omp_variable (namelist->sym);
if (t != error_mark_node)
{
- tree node = build_omp_clause (OMP_CLAUSE_REDUCTION);
+ tree node = build_omp_clause (where.lb->location,
+ OMP_CLAUSE_REDUCTION);
OMP_CLAUSE_DECL (node) = t;
OMP_CLAUSE_REDUCTION_CODE (node) = reduction_code;
if (namelist->sym->attr.dimension)
if_var = gfc_evaluate_now (se.expr, block);
gfc_add_block_to_block (block, &se.post);
- c = build_omp_clause (OMP_CLAUSE_IF);
+ c = build_omp_clause (where.lb->location, OMP_CLAUSE_IF);
OMP_CLAUSE_IF_EXPR (c) = if_var;
omp_clauses = gfc_trans_add_clause (c, omp_clauses);
}
num_threads = gfc_evaluate_now (se.expr, block);
gfc_add_block_to_block (block, &se.post);
- c = build_omp_clause (OMP_CLAUSE_NUM_THREADS);
+ c = build_omp_clause (where.lb->location, OMP_CLAUSE_NUM_THREADS);
OMP_CLAUSE_NUM_THREADS_EXPR (c) = num_threads;
omp_clauses = gfc_trans_add_clause (c, omp_clauses);
}
if (clauses->sched_kind != OMP_SCHED_NONE)
{
- c = build_omp_clause (OMP_CLAUSE_SCHEDULE);
+ c = build_omp_clause (where.lb->location, OMP_CLAUSE_SCHEDULE);
OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (c) = chunk_size;
switch (clauses->sched_kind)
{
if (clauses->default_sharing != OMP_DEFAULT_UNKNOWN)
{
- c = build_omp_clause (OMP_CLAUSE_DEFAULT);
+ c = build_omp_clause (where.lb->location, OMP_CLAUSE_DEFAULT);
switch (clauses->default_sharing)
{
case OMP_DEFAULT_NONE:
if (clauses->nowait)
{
- c = build_omp_clause (OMP_CLAUSE_NOWAIT);
+ c = build_omp_clause (where.lb->location, OMP_CLAUSE_NOWAIT);
omp_clauses = gfc_trans_add_clause (c, omp_clauses);
}
if (clauses->ordered)
{
- c = build_omp_clause (OMP_CLAUSE_ORDERED);
+ c = build_omp_clause (where.lb->location, OMP_CLAUSE_ORDERED);
omp_clauses = gfc_trans_add_clause (c, omp_clauses);
}
if (clauses->untied)
{
- c = build_omp_clause (OMP_CLAUSE_UNTIED);
+ c = build_omp_clause (where.lb->location, OMP_CLAUSE_UNTIED);
omp_clauses = gfc_trans_add_clause (c, omp_clauses);
}
if (clauses->collapse)
{
- c = build_omp_clause (OMP_CLAUSE_COLLAPSE);
+ c = build_omp_clause (where.lb->location, OMP_CLAUSE_COLLAPSE);
OMP_CLAUSE_COLLAPSE_EXPR (c) = build_int_cst (NULL, clauses->collapse);
omp_clauses = gfc_trans_add_clause (c, omp_clauses);
}
if (!dovar_found)
{
- tmp = build_omp_clause (OMP_CLAUSE_PRIVATE);
+ tmp = build_omp_clause (input_location, OMP_CLAUSE_PRIVATE);
OMP_CLAUSE_DECL (tmp) = dovar;
omp_clauses = gfc_trans_add_clause (tmp, omp_clauses);
}
if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE
&& OMP_CLAUSE_DECL (c) == dovar)
{
- tree l = build_omp_clause (OMP_CLAUSE_LASTPRIVATE);
+ tree l = build_omp_clause (input_location,
+ OMP_CLAUSE_LASTPRIVATE);
OMP_CLAUSE_DECL (l) = dovar;
OMP_CLAUSE_CHAIN (l) = omp_clauses;
OMP_CLAUSE_LASTPRIVATE_STMT (l) = tmp;
}
if (!simple)
{
- tmp = build_omp_clause (OMP_CLAUSE_PRIVATE);
+ tmp = build_omp_clause (input_location, OMP_CLAUSE_PRIVATE);
OMP_CLAUSE_DECL (tmp) = count;
omp_clauses = gfc_trans_add_clause (tmp, omp_clauses);
}
pushlevel (0);
if (!code)
- return build_empty_stmt ();
+ return build_empty_stmt (input_location);
gfc_start_block (&block);
pblock = █
tmp = gfc_finish_block (&singleblock);
tmp = build2 (OMP_SINGLE, void_type_node, tmp,
clauses->nowait
- ? build_omp_clause (OMP_CLAUSE_NOWAIT) : NULL_TREE);
+ ? build_omp_clause (input_location, OMP_CLAUSE_NOWAIT)
+ : NULL_TREE);
gfc_add_expr_to_block (pblock, tmp);
}
tmp = fold_build2 (EQ_EXPR, boolean_type_node, tmp, assigned_goto);
tmp = build3_v (COND_EXPR, tmp,
fold_build1 (GOTO_EXPR, void_type_node, target),
- build_empty_stmt ());
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&se.pre, tmp);
code = code->block;
}
if (mask && count1)
{
tmp = build3_v (COND_EXPR, maskexpr, loopse.expr,
- build_empty_stmt ());
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&loopse.pre, tmp);
tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type,
count1, gfc_index_one_node);
if (code->block)
elsestmt = gfc_trans_if_1 (code->block);
else
- elsestmt = build_empty_stmt ();
+ elsestmt = build_empty_stmt (input_location);
/* Build the condition expression and add it to the condition block. */
stmt = fold_build3 (COND_EXPR, void_type_node, if_se.expr, stmt, elsestmt);
tmp = build1_v (GOTO_EXPR, exit_label);
TREE_USED (exit_label) = 1;
tmp = fold_build3 (COND_EXPR, void_type_node,
- cond, tmp, build_empty_stmt ());
+ cond, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&body, tmp);
/* Finish the loop body. */
else
cond = fold_build2 (GE_EXPR, boolean_type_node, dovar, to);
tmp = fold_build3 (COND_EXPR, void_type_node,
- cond, tmp, build_empty_stmt ());
+ cond, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (pblock, tmp);
/* Add the exit label. */
tmp = fold_build2 (LT_EXPR, boolean_type_node, to, from);
pos = fold_build3 (COND_EXPR, void_type_node, tmp,
build1_v (GOTO_EXPR, exit_label),
- build_empty_stmt ());
+ build_empty_stmt (input_location));
tmp = fold_build2 (MINUS_EXPR, type, to, from);
tmp = fold_convert (utype, tmp);
tmp = fold_build2 (TRUNC_DIV_EXPR, utype, tmp,
tmp = fold_build2 (GT_EXPR, boolean_type_node, to, from);
neg = fold_build3 (COND_EXPR, void_type_node, tmp,
build1_v (GOTO_EXPR, exit_label),
- build_empty_stmt ());
+ build_empty_stmt (input_location));
tmp = fold_build2 (MINUS_EXPR, type, from, to);
tmp = fold_convert (utype, tmp);
tmp = fold_build2 (TRUNC_DIV_EXPR, utype, tmp,
/* If the loop is empty, go directly to the exit label. */
tmp = fold_build3 (COND_EXPR, void_type_node, tmp,
build1_v (GOTO_EXPR, exit_label),
- build_empty_stmt ());
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
}
build_int_cst (utype, 0));
tmp = build1_v (GOTO_EXPR, exit_label);
tmp = fold_build3 (COND_EXPR, void_type_node,
- cond, tmp, build_empty_stmt ());
+ cond, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&body, tmp);
/* Decrement the loop count. */
tmp = build1_v (GOTO_EXPR, exit_label);
TREE_USED (exit_label) = 1;
tmp = fold_build3 (COND_EXPR, void_type_node,
- cond.expr, tmp, build_empty_stmt ());
+ cond.expr, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
/* The main body of the loop. */
{
tree true_tree, false_tree, stmt;
- true_tree = build_empty_stmt ();
- false_tree = build_empty_stmt ();
+ true_tree = build_empty_stmt (input_location);
+ false_tree = build_empty_stmt (input_location);
/* If we have a case for .TRUE. and for .FALSE., discard the default case.
Otherwise, if .TRUE. or .FALSE. is missing and there is a default case,
/* Empty SELECT constructs are legal. */
if (code->block == NULL)
- return build_empty_stmt ();
+ return build_empty_stmt (input_location);
/* Select the correct translation function. */
switch (code->expr1->ts.type)
count, build_int_cst (TREE_TYPE (count), 0));
tmp = build1_v (GOTO_EXPR, exit_label);
tmp = fold_build3 (COND_EXPR, void_type_node,
- cond, tmp, build_empty_stmt ());
+ cond, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
/* The main loop body. */
if (mask)
{
tmp = gfc_build_array_ref (mask, maskindex, NULL);
- body = build3_v (COND_EXPR, tmp, body, build_empty_stmt ());
+ body = build3_v (COND_EXPR, tmp, body,
+ build_empty_stmt (input_location));
}
}
body = gfc_trans_forall_loop (forall_tmp, body, mask_flag, &header);
TREE_TYPE (wheremaskexpr),
wheremaskexpr);
tmp = fold_build3 (COND_EXPR, void_type_node,
- wheremaskexpr, tmp, build_empty_stmt ());
+ wheremaskexpr, tmp,
+ build_empty_stmt (input_location));
}
gfc_add_expr_to_block (&body, tmp);
TREE_TYPE (wheremaskexpr),
wheremaskexpr);
tmp = fold_build3 (COND_EXPR, void_type_node,
- wheremaskexpr, tmp, build_empty_stmt ());
+ wheremaskexpr, tmp, build_empty_stmt (input_location));
}
gfc_add_expr_to_block (&body1, tmp);
if (code->expr1
&& code->expr1->expr_type == EXPR_CONSTANT
&& !code->expr1->value.logical)
- return build_empty_stmt ();
+ return build_empty_stmt (input_location);
n = 0;
/* Count the FORALL index number. */
tmp = gfc_trans_scalar_assign (&lse, &rse, expr1->ts,
loop.temp_ss != NULL, false);
- tmp = build3_v (COND_EXPR, maskexpr, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, maskexpr, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&body, tmp);
/* Use the scalar assignment as is. */
tmp = gfc_trans_scalar_assign (&lse, &rse, expr1->ts, false, false);
- tmp = build3_v (COND_EXPR, maskexpr, tmp, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, maskexpr, tmp,
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&body, tmp);
/* Increment count2. */
tstmt = gfc_trans_scalar_assign (&tdse, &tsse, tdst->ts, false, false);
estmt = eblock ? gfc_trans_scalar_assign (&edse, &esse, edst->ts, false, false)
- : build_empty_stmt ();
+ : build_empty_stmt (input_location);
tmp = build3_v (COND_EXPR, cexpr, tstmt, estmt);
gfc_add_expr_to_block (&body, tmp);
gfc_add_block_to_block (&body, &cse.post);
parm = fold_build2 (NE_EXPR, boolean_type_node,
stat, build_int_cst (TREE_TYPE (stat), 0));
tmp = fold_build3 (COND_EXPR, void_type_node,
- parm, tmp, build_empty_stmt ());
+ parm, tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&se.pre, tmp);
}
tmp = fold_build2 (NE_EXPR, boolean_type_node, stat,
build_int_cst (TREE_TYPE (stat), 0));
- tmp = build3_v (COND_EXPR, tmp, dlen, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, tmp, dlen, build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
}
tmp = fold_build2 (NE_EXPR, boolean_type_node, astat,
build_int_cst (TREE_TYPE (astat), 0));
- tmp = build3_v (COND_EXPR, tmp, dlen, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, tmp, dlen, build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
}
/* Create and name the types. */
#define PUSH_TYPE(name, node) \
- pushdecl (build_decl (TYPE_DECL, get_identifier (name), node))
+ pushdecl (build_decl (input_location, \
+ TYPE_DECL, get_identifier (name), node))
for (index = 0; gfc_integer_kinds[index].kind != 0; ++index)
{
TYPE_PACKED (type) = 1;
/* Consists of the stride, lbound and ubound members. */
- decl = build_decl (FIELD_DECL,
+ decl = build_decl (input_location,
+ FIELD_DECL,
get_identifier ("stride"), gfc_array_index_type);
DECL_CONTEXT (decl) = type;
TREE_NO_WARNING (decl) = 1;
fieldlist = decl;
- decl = build_decl (FIELD_DECL,
+ decl = build_decl (input_location,
+ FIELD_DECL,
get_identifier ("lbound"), gfc_array_index_type);
DECL_CONTEXT (decl) = type;
TREE_NO_WARNING (decl) = 1;
fieldlist = chainon (fieldlist, decl);
- decl = build_decl (FIELD_DECL,
+ decl = build_decl (input_location,
+ FIELD_DECL,
get_identifier ("ubound"), gfc_array_index_type);
DECL_CONTEXT (decl) = type;
TREE_NO_WARNING (decl) = 1;
GFC_TYPE_ARRAY_UBOUND (type, n));
gtype = build_array_type (gtype, rtype);
}
- TYPE_NAME (type) = type_decl = build_decl (TYPE_DECL, NULL, gtype);
+ TYPE_NAME (type) = type_decl = build_decl (input_location,
+ TYPE_DECL, NULL, gtype);
DECL_ORIGINAL_TYPE (type_decl) = gtype;
}
TYPE_NAME (fat_type) = get_identifier (name);
/* Add the data member as the first element of the descriptor. */
- decl = build_decl (FIELD_DECL, get_identifier ("data"), ptr_type_node);
+ decl = build_decl (input_location,
+ FIELD_DECL, get_identifier ("data"), ptr_type_node);
DECL_CONTEXT (decl) = fat_type;
fieldlist = decl;
/* Add the base component. */
- decl = build_decl (FIELD_DECL, get_identifier ("offset"),
+ decl = build_decl (input_location,
+ FIELD_DECL, get_identifier ("offset"),
gfc_array_index_type);
DECL_CONTEXT (decl) = fat_type;
TREE_NO_WARNING (decl) = 1;
fieldlist = chainon (fieldlist, decl);
/* Add the dtype component. */
- decl = build_decl (FIELD_DECL, get_identifier ("dtype"),
+ decl = build_decl (input_location,
+ FIELD_DECL, get_identifier ("dtype"),
gfc_array_index_type);
DECL_CONTEXT (decl) = fat_type;
TREE_NO_WARNING (decl) = 1;
gfc_index_zero_node,
gfc_rank_cst[dimen - 1]));
- decl = build_decl (FIELD_DECL, get_identifier ("dim"), arraytype);
+ decl = build_decl (input_location,
+ FIELD_DECL, get_identifier ("dim"), arraytype);
DECL_CONTEXT (decl) = fat_type;
TREE_NO_WARNING (decl) = 1;
fieldlist = chainon (fieldlist, decl);
{
tree decl;
- decl = build_decl (TYPE_DECL, NULL_TREE, type);
+ decl = build_decl (input_location,
+ TYPE_DECL, NULL_TREE, type);
TYPE_STUB_DECL (type) = decl;
layout_type (type);
rest_of_type_compilation (type, 1);
{
tree decl;
- decl = build_decl (FIELD_DECL, name, type);
+ decl = build_decl (input_location,
+ FIELD_DECL, name, type);
DECL_CONTEXT (decl) = context;
DECL_INITIAL (decl) = 0;
if (el == el2)
{
- decl = build_decl (FIELD_DECL,
+ decl = build_decl (input_location,
+ FIELD_DECL,
get_identifier (el->sym->result->name),
gfc_sym_type (el->sym->result));
DECL_CONTEXT (decl) = type;
base_decl = GFC_TYPE_ARRAY_BASE_DECL (type, indirect);
if (!base_decl)
{
- base_decl = build_decl (VAR_DECL, NULL_TREE,
+ base_decl = build_decl (input_location, VAR_DECL, NULL_TREE,
indirect ? build_pointer_type (ptype) : ptype);
GFC_TYPE_ARRAY_BASE_DECL (type, indirect) = base_decl;
}
expr = stmtblock->head;
if (!expr)
- expr = build_empty_stmt ();
+ expr = build_empty_stmt (input_location);
stmtblock->head = NULL_TREE;
cond = build_call_expr (built_in_decls[BUILT_IN_EXPECT], 2, cond, tmp);
cond = fold_convert (boolean_type_node, cond);
- tmp = build3_v (COND_EXPR, cond, body, build_empty_stmt ());
+ tmp = build3_v (COND_EXPR, cond, body, build_empty_stmt (input_location));
gfc_add_expr_to_block (pblock, tmp);
}
}
("Attempt to allocate a negative amount of memory."));
tmp = fold_build3 (COND_EXPR, void_type_node, negative,
build_call_expr (gfor_fndecl_runtime_error, 1, msg),
- build_empty_stmt ());
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (block, tmp);
/* Call malloc and check the result. */
("Memory allocation failed"));
tmp = fold_build3 (COND_EXPR, void_type_node, null_result,
build_call_expr (gfor_fndecl_os_error, 1, msg),
- build_empty_stmt ());
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&block2, tmp);
malloc_result = gfc_finish_block (&block2);
tmp = fold_build3 (COND_EXPR, void_type_node,
fold_build2 (NE_EXPR, boolean_type_node, status,
build_int_cst (TREE_TYPE (status), 0)),
- tmp, build_empty_stmt ());
+ tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (block, tmp);
}
tmp = fold_build3 (COND_EXPR, void_type_node,
fold_build2 (EQ_EXPR, boolean_type_node, res,
build_int_cst (pvoid_type_node, 0)),
- tmp, build_empty_stmt ());
+ tmp, build_empty_stmt (input_location));
gfc_add_expr_to_block (&alloc_block, tmp);
cond = fold_build2 (LT_EXPR, boolean_type_node, size,
build_int_cst (pvoid_type_node, 0));
call = build_call_expr (built_in_decls[BUILT_IN_FREE], 1, var);
tmp = fold_build3 (COND_EXPR, void_type_node, cond, call,
- build_empty_stmt ());
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&block, tmp);
return gfc_finish_block (&block);
varname);
}
else
- error = build_empty_stmt ();
+ error = build_empty_stmt (input_location);
if (status != NULL_TREE && !integer_zerop (status))
{
fold_build1 (INDIRECT_REF, status_type, status),
build_int_cst (status_type, 0));
tmp = fold_build3 (COND_EXPR, void_type_node, cond2, tmp,
- build_empty_stmt ());
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (&non_null, tmp);
}
("Attempt to allocate a negative amount of memory."));
tmp = fold_build3 (COND_EXPR, void_type_node, negative,
build_call_expr (gfor_fndecl_runtime_error, 1, msg),
- build_empty_stmt ());
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (block, tmp);
/* Call realloc and check the result. */
("Out of memory"));
tmp = fold_build3 (COND_EXPR, void_type_node, null_result,
build_call_expr (gfor_fndecl_os_error, 1, msg),
- build_empty_stmt ());
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (block, tmp);
/* if (size == 0) then the result is NULL. */
tmp = fold_build2 (MODIFY_EXPR, type, res, build_int_cst (type, 0));
zero = fold_build1 (TRUTH_NOT_EXPR, boolean_type_node, nonzero);
tmp = fold_build3 (COND_EXPR, void_type_node, zero, tmp,
- build_empty_stmt ());
+ build_empty_stmt (input_location));
gfc_add_expr_to_block (block, tmp);
return res;
tree res;
if (!code)
- return build_empty_stmt ();
+ return build_empty_stmt (input_location);
gfc_start_block (&block);
gcc_assert (ns->proc_name->backend_decl == NULL);
ns->proc_name->backend_decl
- = build_decl (NAMESPACE_DECL, get_identifier (ns->proc_name->name),
+ = build_decl (ns->proc_name->declared_at.lb->location,
+ NAMESPACE_DECL, get_identifier (ns->proc_name->name),
void_type_node);
- gfc_set_decl_location (ns->proc_name->backend_decl,
- &ns->proc_name->declared_at);
entry = gfc_find_module (ns->proc_name->name);
if (entry->namespace_decl)
/* Buggy sourcecode, using a module before defining it? */
layout_decl (p, 0);
/* Build a second synthetic decl. */
- decl = build_decl (PARM_DECL, NULL_TREE, subtype);
+ decl = build_decl (EXPR_LOCATION (p),
+ PARM_DECL, NULL_TREE, subtype);
DECL_ARG_TYPE (decl) = DECL_ARG_TYPE (p);
DECL_ARTIFICIAL (decl) = addressable;
DECL_IGNORED_P (decl) = addressable;
tree type = build_pointer_type (TREE_TYPE (fntype));
tree decl;
- decl = build_decl (PARM_DECL, NULL_TREE, type);
+ decl = build_decl (DECL_SOURCE_LOCATION (fndecl),
+ PARM_DECL, NULL_TREE, type);
DECL_ARG_TYPE (decl) = type;
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
tree disp_label, disp_var, arg;
/* Build 'DISP_LABEL:' and insert. */
- disp_label = create_artificial_label ();
+ disp_label = create_artificial_label (cfun->function_end_locus);
/* This mark will create forward edges from every call site. */
DECL_NONLOCAL (disp_label) = 1;
cfun->has_nonlocal_label = 1;
}
/* Not found. Create a new label and record the return statement. */
- tmp_rs.label = create_artificial_label ();
+ tmp_rs.label = create_artificial_label (cfun->function_end_locus);
tmp_rs.stmt = stmt;
VEC_safe_push (return_statements_t, heap, data->return_statements, &tmp_rs);
lower_builtin_setjmp (gimple_stmt_iterator *gsi)
{
gimple stmt = gsi_stmt (*gsi);
- tree cont_label = create_artificial_label ();
- tree next_label = create_artificial_label ();
+ location_t loc = gimple_location (stmt);
+ tree cont_label = create_artificial_label (loc);
+ tree next_label = create_artificial_label (loc);
tree dest, t, arg;
gimple g;
pp_string (buffer, " : ");
}
pp_decimal_int (buffer, xloc.line);
+ pp_string (buffer, ":");
+ pp_decimal_int (buffer, xloc.column);
pp_string (buffer, "] ");
}
pp_string (buffer, " : ");
}
pp_decimal_int (buffer, goto_xloc.line);
+ pp_string (buffer, " : ");
+ pp_decimal_int (buffer, goto_xloc.column);
pp_string (buffer, "] ");
}
new_type = build_type_variant (type, 0, 0);
TYPE_ATTRIBUTES (new_type) = TYPE_ATTRIBUTES (type);
- tmp_var = build_decl (VAR_DECL, prefix ? create_tmp_var_name (prefix) : NULL,
+ tmp_var = build_decl (input_location,
+ VAR_DECL, prefix ? create_tmp_var_name (prefix) : NULL,
type);
/* The variable was declared by the compiler. */
gimplify_loop_expr (tree *expr_p, gimple_seq *pre_p)
{
tree saved_label = gimplify_ctxp->exit_label;
- tree start_label = create_artificial_label ();
+ tree start_label = create_artificial_label (UNKNOWN_LOCATION);
gimplify_seq_add_stmt (pre_p, gimple_build_label (start_label));
{
gimple new_default;
- default_case = build3 (CASE_LABEL_EXPR, void_type_node,
- NULL_TREE, NULL_TREE,
- create_artificial_label ());
+ default_case
+ = build3 (CASE_LABEL_EXPR, void_type_node,
+ NULL_TREE, NULL_TREE,
+ create_artificial_label (UNKNOWN_LOCATION));
new_default = gimple_build_label (CASE_LABEL (default_case));
gimplify_seq_add_stmt (&switch_body_seq, new_default);
}
if (*label_p == NULL_TREE)
{
- tree label = create_artificial_label ();
+ tree label = create_artificial_label (UNKNOWN_LOCATION);
*label_p = label;
}
{
tree tem;
gcc_assert (CONVERT_EXPR_P (*expr_p));
-
+
/* Then strip away all but the outermost conversion. */
STRIP_SIGN_NOPS (TREE_OPERAND (*expr_p, 0));
&& POINTER_TYPE_P (TREE_TYPE (*expr_p))
&& POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (*expr_p, 0)))
&& (tem = maybe_fold_offset_to_address
- (TREE_OPERAND (*expr_p, 0),
- integer_zero_node, TREE_TYPE (*expr_p))) != NULL_TREE)
+ (EXPR_LOCATION (*expr_p), TREE_OPERAND (*expr_p, 0),
+ integer_zero_node, TREE_TYPE (*expr_p))) != NULL_TREE)
*expr_p = tem;
/* If we still have a conversion at the toplevel,
/* If this is a variable sized type, we must remember the size. */
maybe_with_size_expr (arg_p);
+ /* FIXME diagnostics: This will mess up gcc.dg/Warray-bounds.c. */
/* Make sure arguments have the same location as the function call
itself. */
protected_set_expr_location (*arg_p, call_location);
if (call_expr_nargs (*expr_p) < 2)
{
error ("too few arguments to function %<va_start%>");
- *expr_p = build_empty_stmt ();
+ *expr_p = build_empty_stmt (EXPR_LOCATION (*expr_p));
return GS_OK;
}
if (fold_builtin_next_arg (*expr_p, true))
{
- *expr_p = build_empty_stmt ();
+ *expr_p = build_empty_stmt (EXPR_LOCATION (*expr_p));
return GS_OK;
}
}
have_then_clause_p = true;
}
else
- label_true = create_artificial_label ();
+ label_true = create_artificial_label (UNKNOWN_LOCATION);
if (TREE_OPERAND (expr, 2) != NULL
&& TREE_CODE (TREE_OPERAND (expr, 2)) == GOTO_EXPR
&& TREE_CODE (GOTO_DESTINATION (TREE_OPERAND (expr, 2))) == LABEL_DECL
have_else_clause_p = true;
}
else
- label_false = create_artificial_label ();
+ label_false = create_artificial_label (UNKNOWN_LOCATION);
gimple_cond_get_ops_from_tree (COND_EXPR_COND (expr), &pred_code, &arm1,
&arm2);
&& gimple_seq_may_fallthru (seq))
{
gimple g;
- label_cont = create_artificial_label ();
+ label_cont = create_artificial_label (UNKNOWN_LOCATION);
g = gimple_build_goto (label_cont);
tree loop_entry_label, loop_exit_label, fall_thru_label;
tree var, var_type, cref, tmp;
- loop_entry_label = create_artificial_label ();
- loop_exit_label = create_artificial_label ();
- fall_thru_label = create_artificial_label ();
+ loop_entry_label = create_artificial_label (UNKNOWN_LOCATION);
+ loop_exit_label = create_artificial_label (UNKNOWN_LOCATION);
+ fall_thru_label = create_artificial_label (UNKNOWN_LOCATION);
/* Create and initialize the index variable. */
var_type = TREE_TYPE (upper);
gimple_call_set_lhs (assign, *to_p);
}
else
- assign = gimple_build_assign (*to_p, *from_p);
+ {
+ assign = gimple_build_assign (*to_p, *from_p);
+ gimple_set_location (assign, EXPR_LOCATION (*expr_p));
+ }
gimplify_seq_add_stmt (pre_p, assign);
else
gcc_unreachable ();
- clause = build_omp_clause (code);
+ clause = build_omp_clause (input_location, code);
OMP_CLAUSE_DECL (clause) = decl;
OMP_CLAUSE_CHAIN (clause) = *list_p;
if (private_debug)
*/
if (TREE_CODE (TREE_OPERAND (*expr_p, 1)) == INTEGER_CST
&& (tmp = maybe_fold_offset_to_address
- (TREE_OPERAND (*expr_p, 0), TREE_OPERAND (*expr_p, 1),
- TREE_TYPE (*expr_p))))
+ (EXPR_LOCATION (*expr_p),
+ TREE_OPERAND (*expr_p, 0), TREE_OPERAND (*expr_p, 1),
+ TREE_TYPE (*expr_p))))
{
*expr_p = tmp;
break;
&& POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (*expr_p,
0),0)))
&& (tmp = maybe_fold_offset_to_address
- (TREE_OPERAND (TREE_OPERAND (*expr_p, 0), 0),
- TREE_OPERAND (*expr_p, 1),
- TREE_TYPE (TREE_OPERAND (TREE_OPERAND (*expr_p, 0),
- 0)))))
+ (EXPR_LOCATION (*expr_p),
+ TREE_OPERAND (TREE_OPERAND (*expr_p, 0), 0),
+ TREE_OPERAND (*expr_p, 1),
+ TREE_TYPE (TREE_OPERAND (TREE_OPERAND (*expr_p, 0),
+ 0)))))
{
*expr_p = fold_convert (TREE_TYPE (*expr_p), tmp);
break;
type = gen_struct_type (orig_decl, type);
if (is_global_var (orig_decl))
- new_decl = build_decl (VAR_DECL, new_name, type);
+ new_decl = build_decl (DECL_SOURCE_LOCATION (orig_decl),
+ VAR_DECL, new_name, type);
else
{
const char *name = new_name ? IDENTIFIER_POINTER (new_name) : NULL;
+2009-06-12 Aldy Hernandez <aldyh@redhat.com>
+
+ * java-gimplify.c (java_gimplify_block): New argument to
+ build_empty_stmt.
+ * expr.c (force_evaluation_order): Same.
+ * typeck.c: Add location to build_decl or PUSH_FIELD calls.
+ * class.c: Same.
+ * decl.c: Same.
+ * jcf-parse.c: Same.
+ * constants.c: Same.
+ * resource.c: Same.
+ * except.c: Same.
+ * builtins.c: Same.
+ * expr.c: Same.
+ * java-tree.h (PUSH_FIELD): Add location field.
+
2009-06-09 Ian Lance Taylor <iant@google.com>
* verify.h: Remove extern "C".
stmt = build_call_expr (built_in_decls[BUILT_IN_SYNCHRONIZE], 0);
- tmp = build_decl (VAR_DECL, NULL, method_return_type);
+ tmp = build_decl (BUILTINS_LOCATION, VAR_DECL, NULL, method_return_type);
DECL_IGNORED_P (tmp) = 1;
DECL_ARTIFICIAL (tmp) = 1;
pushdecl (tmp);
{
tree decl;
- decl = build_decl (FUNCTION_DECL, get_identifier (name), type);
+ decl = build_decl (BUILTINS_LOCATION,
+ FUNCTION_DECL, get_identifier (name), type);
DECL_EXTERNAL (decl) = 1;
TREE_PUBLIC (decl) = 1;
SET_DECL_ASSEMBLER_NAME (decl, get_identifier (libname));
\
sprintf (buf, #NAME "_%s", type_name); \
TYPE_## TABLE ##_DECL (type) = decl = \
- build_decl (VAR_DECL, get_identifier (buf), TABLE_TYPE); \
+ build_decl (input_location, VAR_DECL, get_identifier (buf), TABLE_TYPE); \
DECL_EXTERNAL (decl) = 1; \
TREE_STATIC (decl) = 1; \
TREE_READONLY (decl) = 1; \
DECL_OWNER (decl) = TYPE; \
sprintf (buf, #NAME "_syms_%s", type_name); \
TYPE_## TABLE ##_SYMS_DECL (TYPE) = \
- build_decl (VAR_DECL, get_identifier (buf), symbols_array_type); \
+ build_decl (input_location, VAR_DECL, get_identifier (buf), symbols_array_type); \
TREE_STATIC (TYPE_## TABLE ##_SYMS_DECL (TYPE)) = 1; \
TREE_CONSTANT (TYPE_## TABLE ##_SYMS_DECL (TYPE)) = 1; \
DECL_IGNORED_P (TYPE_## TABLE ##_SYMS_DECL (TYPE)) = 1; \
tree catch_class_type = make_node (RECORD_TYPE);
sprintf (buf, "_catch_classes_%s", type_name);
- PUSH_FIELD (catch_class_type, field, "address", utf8const_ptr_type);
- PUSH_FIELD (catch_class_type, field, "classname", ptr_type_node);
+ PUSH_FIELD (input_location,
+ catch_class_type, field, "address", utf8const_ptr_type);
+ PUSH_FIELD (input_location,
+ catch_class_type, field, "classname", ptr_type_node);
FINISH_RECORD (catch_class_type);
TYPE_CTABLE_DECL (type)
- = build_decl (VAR_DECL, get_identifier (buf),
+ = build_decl (input_location, VAR_DECL, get_identifier (buf),
build_array_type (catch_class_type, 0));
DECL_EXTERNAL (TYPE_CTABLE_DECL (type)) = 1;
TREE_STATIC (TYPE_CTABLE_DECL (type)) = 1;
tree decl, signature;
location_t saved_loc = input_location;
CLASS_P (class_type) = 1;
- decl = build_decl (TYPE_DECL, class_name, class_type);
+ decl = build_decl (input_location, TYPE_DECL, class_name, class_type);
TYPE_DECL_SUPPRESS_DEBUG (decl) = 1;
/* dbxout needs a DECL_SIZE if in gstabs mode */
method_type = build_java_method_type (function_type,
this_class, access_flags);
- fndecl = build_decl (FUNCTION_DECL, name, method_type);
+ fndecl = build_decl (input_location, FUNCTION_DECL, name, method_type);
DECL_CONTEXT (fndecl) = this_class;
DECL_LANG_SPECIFIC (fndecl)
{
int is_static = (flags & ACC_STATIC) != 0;
tree field;
- field = build_decl (is_static ? VAR_DECL : FIELD_DECL, name, field_type);
+ field = build_decl (input_location,
+ is_static ? VAR_DECL : FIELD_DECL, name, field_type);
TREE_CHAIN (field) = TYPE_FIELDS (klass);
TYPE_FIELDS (klass) = field;
DECL_CONTEXT (field) = klass;
- (name_len & (TYPE_ALIGN_UNIT (utf8const_type) - 1));
str_type = build_prim_array_type (unsigned_byte_type_node,
name_len + name_pad);
- PUSH_FIELD (ctype, field, "hash", unsigned_short_type_node);
- PUSH_FIELD (ctype, field, "length", unsigned_short_type_node);
- PUSH_FIELD (ctype, field, "data", str_type);
+ PUSH_FIELD (input_location, ctype, field, "hash", unsigned_short_type_node);
+ PUSH_FIELD (input_location,
+ ctype, field, "length", unsigned_short_type_node);
+ PUSH_FIELD (input_location, ctype, field, "data", str_type);
FINISH_RECORD (ctype);
START_RECORD_CONSTRUCTOR (cinit, ctype);
name_hash = hashUtf8String (name_ptr, name_len) & 0xFFFF;
/* Generate a unique-enough identifier. */
sprintf(buf, "_Utf%d", ++utf8_count);
- decl = build_decl (VAR_DECL, get_identifier (buf), utf8const_type);
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (buf), utf8const_type);
TREE_STATIC (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
decl = IDENTIFIER_GLOBAL_VALUE (decl_name);
if (decl == NULL_TREE)
{
- decl = build_decl (VAR_DECL, decl_name, class_type_node);
+ decl = build_decl (input_location, VAR_DECL, decl_name, class_type_node);
TREE_STATIC (decl) = 1;
if (! flag_indirect_classes)
{
if (decl == NULL_TREE)
{
decl
- = build_decl (VAR_DECL, decl_name,
+ = build_decl (input_location,
+ VAR_DECL, decl_name,
(build_type_variant
(build_pointer_type
(build_type_variant (class_type_node,
else
classdollar_field = build_static_class_ref (output_class);
- this_classdollar = build_decl (VAR_DECL, NULL_TREE,
+ this_classdollar = build_decl (input_location,
+ VAR_DECL, NULL_TREE,
TREE_TYPE (classdollar_field));
java_add_local_var (this_classdollar);
decl = IDENTIFIER_GLOBAL_VALUE (decl_name);
if (decl == NULL_TREE)
{
- decl = build_decl (VAR_DECL, decl_name, class_type_node);
+ decl = build_decl (input_location,
+ VAR_DECL, decl_name, class_type_node);
TREE_STATIC (decl) = 1;
TREE_PUBLIC (decl) = 1;
DECL_EXTERNAL (decl) = 1;
decl = IDENTIFIER_GLOBAL_VALUE (decl_name);
if (decl == NULL_TREE)
{
- decl = build_decl (VAR_DECL, decl_name, ptr_type_node);
+ decl = build_decl (input_location,
+ VAR_DECL, decl_name, ptr_type_node);
TREE_STATIC (decl) = 1;
TREE_PUBLIC (decl) = 0;
DECL_EXTERNAL (decl) = 0;
strcpy (name + 1, method_name);
ASM_GENERATE_INTERNAL_LABEL (buf, name, alias_labelno++);
- alias = build_decl (FUNCTION_DECL, get_identifier (buf),
+ alias = build_decl (input_location,
+ FUNCTION_DECL, get_identifier (buf),
TREE_TYPE (method));
DECL_CONTEXT (alias) = NULL;
TREE_READONLY (alias) = TREE_READONLY (method);
table = build_constructor_from_list (type, table);
/* Compute something unique enough. */
sprintf (buf, "_methods%d", method_name_count++);
- array = build_decl (VAR_DECL, get_identifier (buf), type);
+ array = build_decl (input_location,
+ VAR_DECL, get_identifier (buf), type);
DECL_INITIAL (array) = table;
TREE_STATIC (array) = 1;
DECL_ARTIFICIAL (array) = 1;
instance_fields = nreverse (instance_fields);
static_fields = chainon (static_fields, instance_fields);
field_array_type = build_prim_array_type (field_type_node, field_count);
- fields_decl = build_decl (VAR_DECL, mangled_classname ("_FL_", type),
+ fields_decl = build_decl (input_location,
+ VAR_DECL, mangled_classname ("_FL_", type),
field_array_type);
DECL_INITIAL (fields_decl) = build_constructor_from_list
(field_array_type, static_fields);
}
}
method_array_type = build_prim_array_type (method_type_node, method_count);
- methods_decl = build_decl (VAR_DECL, mangled_classname ("_MT_", type),
+ methods_decl = build_decl (input_location,
+ VAR_DECL, mangled_classname ("_MT_", type),
method_array_type);
DECL_INITIAL (methods_decl) = build_constructor_from_list
(method_array_type, nreverse (methods));
tree interface_array_type, idecl;
interface_array_type
= build_prim_array_type (class_ptr_type, interface_len);
- idecl = build_decl (VAR_DECL, mangled_classname ("_IF_", type),
+ idecl = build_decl (input_location,
+ VAR_DECL, mangled_classname ("_IF_", type),
interface_array_type);
for (i = interface_len; i > 0; i--)
static int reflection_data_count;
sprintf (buf, "_reflection_data_%d", reflection_data_count++);
- array = build_decl (VAR_DECL, get_identifier (buf), type);
+ array = build_decl (input_location,
+ VAR_DECL, get_identifier (buf), type);
rewrite_reflection_indexes (field_indexes);
dtype = make_node (RECORD_TYPE);
- PUSH_FIELD (dtype, dummy, "top_offset", ptr_type_node);
- PUSH_FIELD (dtype, dummy, "type_info", ptr_type_node);
+ PUSH_FIELD (input_location, dtype, dummy, "top_offset", ptr_type_node);
+ PUSH_FIELD (input_location, dtype, dummy, "type_info", ptr_type_node);
- PUSH_FIELD (dtype, dummy, "class", class_ptr_type);
+ PUSH_FIELD (input_location, dtype, dummy, "class", class_ptr_type);
for (n = 1; n < TARGET_VTABLE_USES_DESCRIPTORS; ++n)
{
- tree tmp_field = build_decl (FIELD_DECL, NULL_TREE, ptr_type_node);
+ tree tmp_field = build_decl (input_location,
+ FIELD_DECL, NULL_TREE, ptr_type_node);
TREE_CHAIN (dummy) = tmp_field;
DECL_CONTEXT (tmp_field) = dtype;
DECL_ARTIFICIAL (tmp_field) = 1;
dummy = tmp_field;
}
- PUSH_FIELD (dtype, dummy, "gc_descr", ptr_type_node);
+ PUSH_FIELD (input_location, dtype, dummy, "gc_descr", ptr_type_node);
for (n = 1; n < TARGET_VTABLE_USES_DESCRIPTORS; ++n)
{
- tree tmp_field = build_decl (FIELD_DECL, NULL_TREE, ptr_type_node);
+ tree tmp_field = build_decl (input_location,
+ FIELD_DECL, NULL_TREE, ptr_type_node);
TREE_CHAIN (dummy) = tmp_field;
DECL_CONTEXT (tmp_field) = dtype;
DECL_ARTIFICIAL (tmp_field) = 1;
if (TARGET_VTABLE_USES_DESCRIPTORS)
n *= TARGET_VTABLE_USES_DESCRIPTORS;
- PUSH_FIELD (dtype, dummy, "methods",
+ PUSH_FIELD (input_location, dtype, dummy, "methods",
build_prim_array_type (nativecode_ptr_type_node, n));
layout_type (dtype);
}
else
dtype = dtable_type;
- decl = build_decl (VAR_DECL, get_identifier ("vt$"), dtype);
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier ("vt$"), dtype);
DECL_CONTEXT (decl) = type;
MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl);
DECL_VTABLE_P (decl) = 1;
/* Don't insert the field if we're just re-laying the class out. */
if (TYPE_FIELDS (this_class) && !DECL_NAME (TYPE_FIELDS (this_class)))
return;
- base_decl = build_decl (FIELD_DECL, NULL_TREE, super_class);
+ base_decl = build_decl (input_location,
+ FIELD_DECL, NULL_TREE, super_class);
DECL_IGNORED_P (base_decl) = 1;
TREE_CHAIN (base_decl) = TYPE_FIELDS (this_class);
TYPE_FIELDS (this_class) = base_decl;
int size = VEC_length (tree, registered_class) * 2 + 1;
tree class_array_type
= build_prim_array_type (ptr_type_node, size);
- tree cdecl = build_decl (VAR_DECL, get_identifier ("_Jv_CLS"),
+ tree cdecl = build_decl (input_location,
+ VAR_DECL, get_identifier ("_Jv_CLS"),
class_array_type);
tree reg_class_list;
for (i = 0; VEC_iterate (tree, registered_class, i, klass); ++i)
t = build_function_type_list (void_type_node,
build_pointer_type (ptr_type_node), NULL);
- t = build_decl (FUNCTION_DECL,
+ t = build_decl (input_location,
+ FUNCTION_DECL,
get_identifier ("_Jv_RegisterNewClasses"), t);
TREE_PUBLIC (t) = 1;
DECL_EXTERNAL (t) = 1;
int i;
t = build_function_type_list (void_type_node, class_ptr_type, NULL);
- t = build_decl (FUNCTION_DECL, get_identifier ("_Jv_RegisterClass"), t);
+ t = build_decl (input_location,
+ FUNCTION_DECL, get_identifier ("_Jv_RegisterClass"), t);
TREE_PUBLIC (t) = 1;
DECL_EXTERNAL (t) = 1;
register_class_fn = t;
table_size
= build_index_type (build_int_cst (NULL_TREE, index * element_size + 1));
the_array_type = build_array_type (the_array_element_type, table_size);
- the_table = build_decl (VAR_DECL, name, the_array_type);
+ the_table = build_decl (input_location,
+ VAR_DECL, name, the_array_type);
TREE_STATIC (the_table) = 1;
TREE_READONLY (the_table) = 1;
rest_of_decl_compilation (the_table, 1, 0);
= build_array_type (TREE_TYPE (TREE_TYPE (TYPE_CTABLE_DECL (this_class))),
table_size);
table =
- build_decl (VAR_DECL, DECL_NAME (TYPE_CTABLE_DECL (this_class)), array_type);
+ build_decl (input_location,
+ VAR_DECL, DECL_NAME (TYPE_CTABLE_DECL (this_class)), array_type);
DECL_INITIAL (table) =
build_constructor_from_list (array_type, TYPE_CATCH_CLASSES (this_class));
TREE_STATIC (table) = 1;
list = nreverse (list);
ctor = build_constructor_from_list (assertion_table_type, list);
- table_decl = build_decl (VAR_DECL, mangled_classname ("_type_assert_", klass),
+ table_decl = build_decl (input_location,
+ VAR_DECL, mangled_classname ("_type_assert_", klass),
assertion_table_type);
TREE_STATIC (table_decl) = 1;
thinks the type is incomplete. */
layout_type (type);
- decl = build_decl (VAR_DECL, decl_name, type);
+ decl = build_decl (input_location, VAR_DECL, decl_name, type);
TREE_STATIC (decl) = 1;
IDENTIFIER_GLOBAL_VALUE (decl_name) = decl;
}
data_value = build_address_of (data_decl);
tags_type = build_array_type (unsigned_byte_type_node, index_type);
- tags_decl = build_decl (VAR_DECL, mangled_classname ("_CT_",
+ tags_decl = build_decl (input_location,
+ VAR_DECL, mangled_classname ("_CT_",
current_class),
tags_type);
TREE_STATIC (tags_decl) = 1;
tree name;
sprintf (buf, "#slot#%d#%d", index, uniq++);
name = get_identifier (buf);
- decl = build_decl (VAR_DECL, name, type);
+ decl = build_decl (input_location, VAR_DECL, name, type);
DECL_IGNORED_P (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
decl = push_jvm_slot (index, decl);
name = get_identifier (buf);
base_decl
= TREE_VEC_ELT (base_decl_map, index)
- = build_decl (VAR_DECL, name, ptr_type_node);
+ = build_decl (input_location, VAR_DECL, name, ptr_type_node);
pushdecl_function_level (base_decl);
DECL_IGNORED_P (base_decl) = 1;
DECL_ARTIFICIAL (base_decl) = 1;
TYPE_PRECISION (type) = TYPE_PRECISION (int_type_node);
TYPE_STRING_FLAG (type) = TYPE_STRING_FLAG (actual_type);
layout_type (type);
- pushdecl (build_decl (TYPE_DECL, get_identifier (name), type));
+ pushdecl (build_decl (input_location,
+ TYPE_DECL, get_identifier (name), type));
return type;
}
char buf[50];
sprintf (buf, "_Jv_%sVTable", name);
- r = build_decl (VAR_DECL, get_identifier (buf), ptr_type_node);
+ r = build_decl (input_location,
+ VAR_DECL, get_identifier (buf), ptr_type_node);
DECL_EXTERNAL (r) = 1;
return r;
}
initialize_sizetypes (false);
byte_type_node = make_signed_type (8);
- pushdecl (build_decl (TYPE_DECL, get_identifier ("byte"), byte_type_node));
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("byte"), byte_type_node));
short_type_node = make_signed_type (16);
- pushdecl (build_decl (TYPE_DECL, get_identifier ("short"), short_type_node));
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("short"), short_type_node));
int_type_node = make_signed_type (32);
- pushdecl (build_decl (TYPE_DECL, get_identifier ("int"), int_type_node));
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("int"), int_type_node));
long_type_node = make_signed_type (64);
- pushdecl (build_decl (TYPE_DECL, get_identifier ("long"), long_type_node));
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("long"), long_type_node));
unsigned_byte_type_node = make_unsigned_type (8);
- pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned byte"),
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("unsigned byte"),
unsigned_byte_type_node));
unsigned_short_type_node = make_unsigned_type (16);
- pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned short"),
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("unsigned short"),
unsigned_short_type_node));
unsigned_int_type_node = make_unsigned_type (32);
- pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned int"),
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("unsigned int"),
unsigned_int_type_node));
unsigned_long_type_node = make_unsigned_type (64);
- pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned long"),
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("unsigned long"),
unsigned_long_type_node));
/* This is not a java type, however tree-dfa requires a definition for
long_zero_node = build_int_cst (long_type_node, 0);
void_type_node = make_node (VOID_TYPE);
- pushdecl (build_decl (TYPE_DECL, get_identifier ("void"), void_type_node));
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("void"), void_type_node));
layout_type (void_type_node); /* Uses size_zero_node */
ptr_type_node = build_pointer_type (void_type_node);
TYPE_STRING_FLAG (char_type_node) = 1;
TYPE_PRECISION (char_type_node) = 16;
fixup_unsigned_type (char_type_node);
- pushdecl (build_decl (TYPE_DECL, get_identifier ("char"), char_type_node));
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("char"), char_type_node));
boolean_type_node = make_node (BOOLEAN_TYPE);
TYPE_PRECISION (boolean_type_node) = 1;
fixup_unsigned_type (boolean_type_node);
- pushdecl (build_decl (TYPE_DECL, get_identifier ("boolean"),
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("boolean"),
boolean_type_node));
boolean_false_node = TYPE_MIN_VALUE (boolean_type_node);
boolean_true_node = TYPE_MAX_VALUE (boolean_type_node);
float_type_node = make_node (REAL_TYPE);
TYPE_PRECISION (float_type_node) = 32;
- pushdecl (build_decl (TYPE_DECL, get_identifier ("float"),
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("float"),
float_type_node));
layout_type (float_type_node);
double_type_node = make_node (REAL_TYPE);
TYPE_PRECISION (double_type_node) = 64;
- pushdecl (build_decl (TYPE_DECL, get_identifier ("double"),
+ pushdecl (build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("double"),
double_type_node));
layout_type (double_type_node);
one_elt_array_domain_type = build_index_type (integer_one_node);
utf8const_type = make_node (RECORD_TYPE);
- PUSH_FIELD (utf8const_type, field, "hash", unsigned_short_type_node);
- PUSH_FIELD (utf8const_type, field, "length", unsigned_short_type_node);
+ PUSH_FIELD (input_location,
+ utf8const_type, field, "hash", unsigned_short_type_node);
+ PUSH_FIELD (input_location,
+ utf8const_type, field, "length", unsigned_short_type_node);
FINISH_RECORD (utf8const_type);
utf8const_ptr_type = build_pointer_type (utf8const_type);
itable_ptr_type = build_pointer_type (itable_type);
symbol_type = make_node (RECORD_TYPE);
- PUSH_FIELD (symbol_type, field, "clname", utf8const_ptr_type);
- PUSH_FIELD (symbol_type, field, "name", utf8const_ptr_type);
- PUSH_FIELD (symbol_type, field, "signature", utf8const_ptr_type);
+ PUSH_FIELD (input_location,
+ symbol_type, field, "clname", utf8const_ptr_type);
+ PUSH_FIELD (input_location, symbol_type, field, "name", utf8const_ptr_type);
+ PUSH_FIELD (input_location,
+ symbol_type, field, "signature", utf8const_ptr_type);
FINISH_RECORD (symbol_type);
symbols_array_type = build_array_type (symbol_type,
symbols_array_ptr_type = build_pointer_type (symbols_array_type);
assertion_entry_type = make_node (RECORD_TYPE);
- PUSH_FIELD (assertion_entry_type, field, "assertion_code", integer_type_node);
- PUSH_FIELD (assertion_entry_type, field, "op1", utf8const_ptr_type);
- PUSH_FIELD (assertion_entry_type, field, "op2", utf8const_ptr_type);
+ PUSH_FIELD (input_location,
+ assertion_entry_type, field, "assertion_code", integer_type_node);
+ PUSH_FIELD (input_location,
+ assertion_entry_type, field, "op1", utf8const_ptr_type);
+ PUSH_FIELD (input_location,
+ assertion_entry_type, field, "op2", utf8const_ptr_type);
FINISH_RECORD (assertion_entry_type);
assertion_table_type = build_array_type (assertion_entry_type,
methodtable_type = make_node (RECORD_TYPE);
layout_type (methodtable_type);
- build_decl (TYPE_DECL, get_identifier ("methodtable"), methodtable_type);
+ build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("methodtable"), methodtable_type);
methodtable_ptr_type = build_pointer_type (methodtable_type);
TYPE_identifier_node = get_identifier ("TYPE");
init_expr_processing();
constants_type_node = make_node (RECORD_TYPE);
- PUSH_FIELD (constants_type_node, field, "size", unsigned_int_type_node);
- PUSH_FIELD (constants_type_node, field, "tags", ptr_type_node);
- PUSH_FIELD (constants_type_node, field, "data", ptr_type_node);
+ PUSH_FIELD (input_location,
+ constants_type_node, field, "size", unsigned_int_type_node);
+ PUSH_FIELD (input_location,
+ constants_type_node, field, "tags", ptr_type_node);
+ PUSH_FIELD (input_location,
+ constants_type_node, field, "data", ptr_type_node);
constants_data_field_decl_node = field;
FINISH_RECORD (constants_type_node);
- build_decl (TYPE_DECL, get_identifier ("constants"), constants_type_node);
+ build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("constants"), constants_type_node);
access_flags_type_node = unsigned_short_type_node;
TYPE_NONALIASED_COMPONENT (otable_type) = 1;
otable_ptr_type = build_pointer_type (otable_type);
- PUSH_FIELD (object_type_node, field, "vtable", dtable_ptr_type);
+ PUSH_FIELD (input_location,
+ object_type_node, field, "vtable", dtable_ptr_type);
DECL_FCONTEXT (field) = object_type_node;
TYPE_VFIELD (object_type_node) = field;
There is an unresolved issue here, which is whether the vtable
should be marked by the GC. */
if (! flag_hash_synchronization)
- PUSH_FIELD (object_type_node, field, "sync_info",
+ PUSH_FIELD (input_location, object_type_node, field, "sync_info",
build_pointer_type (object_type_node));
for (t = TYPE_FIELDS (object_type_node); t != NULL_TREE; t = TREE_CHAIN (t))
FIELD_PRIVATE (t) = 1;
set_super_info (0, string_type_node, object_type_node, 0);
class_ptr_type = build_pointer_type (class_type_node);
- PUSH_FIELD (class_type_node, field, "next_or_version", class_ptr_type);
- PUSH_FIELD (class_type_node, field, "name", utf8const_ptr_type);
- PUSH_FIELD (class_type_node, field, "accflags", access_flags_type_node);
- PUSH_FIELD (class_type_node, field, "superclass", class_ptr_type);
- PUSH_FIELD (class_type_node, field, "constants", constants_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "next_or_version", class_ptr_type);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "name", utf8const_ptr_type);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "accflags", access_flags_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "superclass", class_ptr_type);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "constants", constants_type_node);
constants_field_decl_node = field;
- PUSH_FIELD (class_type_node, field, "methods", method_ptr_type_node);
- PUSH_FIELD (class_type_node, field, "method_count", short_type_node);
- PUSH_FIELD (class_type_node, field, "vtable_method_count", short_type_node);
- PUSH_FIELD (class_type_node, field, "fields", field_ptr_type_node);
- PUSH_FIELD (class_type_node, field, "size_in_bytes", int_type_node);
- PUSH_FIELD (class_type_node, field, "field_count", short_type_node);
- PUSH_FIELD (class_type_node, field, "static_field_count", short_type_node);
- PUSH_FIELD (class_type_node, field, "vtable", dtable_ptr_type);
- PUSH_FIELD (class_type_node, field, "otable", otable_ptr_type);
- PUSH_FIELD (class_type_node, field, "otable_syms",
+ PUSH_FIELD (input_location,
+ class_type_node, field, "methods", method_ptr_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "method_count", short_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "vtable_method_count", short_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "fields", field_ptr_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "size_in_bytes", int_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "field_count", short_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "static_field_count", short_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "vtable", dtable_ptr_type);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "otable", otable_ptr_type);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "otable_syms",
symbols_array_ptr_type);
- PUSH_FIELD (class_type_node, field, "atable", atable_ptr_type);
- PUSH_FIELD (class_type_node, field, "atable_syms",
+ PUSH_FIELD (input_location,
+ class_type_node, field, "atable", atable_ptr_type);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "atable_syms",
symbols_array_ptr_type);
- PUSH_FIELD (class_type_node, field, "itable", itable_ptr_type);
- PUSH_FIELD (class_type_node, field, "itable_syms",
+ PUSH_FIELD (input_location,
+ class_type_node, field, "itable", itable_ptr_type);
+ PUSH_FIELD (input_location, class_type_node, field, "itable_syms",
symbols_array_ptr_type);
- PUSH_FIELD (class_type_node, field, "catch_classes", ptr_type_node);
- PUSH_FIELD (class_type_node, field, "interfaces",
+ PUSH_FIELD (input_location,
+ class_type_node, field, "catch_classes", ptr_type_node);
+ PUSH_FIELD (input_location, class_type_node, field, "interfaces",
build_pointer_type (class_ptr_type));
- PUSH_FIELD (class_type_node, field, "loader", ptr_type_node);
- PUSH_FIELD (class_type_node, field, "interface_count", short_type_node);
- PUSH_FIELD (class_type_node, field, "state", byte_type_node);
- PUSH_FIELD (class_type_node, field, "thread", ptr_type_node);
- PUSH_FIELD (class_type_node, field, "depth", short_type_node);
- PUSH_FIELD (class_type_node, field, "ancestors", ptr_type_node);
- PUSH_FIELD (class_type_node, field, "idt", ptr_type_node);
- PUSH_FIELD (class_type_node, field, "arrayclass", ptr_type_node);
- PUSH_FIELD (class_type_node, field, "protectionDomain", ptr_type_node);
- PUSH_FIELD (class_type_node, field, "assertion_table", ptr_type_node);
- PUSH_FIELD (class_type_node, field, "hack_signers", ptr_type_node);
- PUSH_FIELD (class_type_node, field, "chain", ptr_type_node);
- PUSH_FIELD (class_type_node, field, "aux_info", ptr_type_node);
- PUSH_FIELD (class_type_node, field, "engine", ptr_type_node);
- PUSH_FIELD (class_type_node, field, "reflection_data", ptr_type_node);
+ PUSH_FIELD (input_location, class_type_node, field, "loader", ptr_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "interface_count", short_type_node);
+ PUSH_FIELD (input_location, class_type_node, field, "state", byte_type_node);
+ PUSH_FIELD (input_location, class_type_node, field, "thread", ptr_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "depth", short_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "ancestors", ptr_type_node);
+ PUSH_FIELD (input_location, class_type_node, field, "idt", ptr_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "arrayclass", ptr_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "protectionDomain", ptr_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "assertion_table", ptr_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "hack_signers", ptr_type_node);
+ PUSH_FIELD (input_location, class_type_node, field, "chain", ptr_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "aux_info", ptr_type_node);
+ PUSH_FIELD (input_location, class_type_node, field, "engine", ptr_type_node);
+ PUSH_FIELD (input_location,
+ class_type_node, field, "reflection_data", ptr_type_node);
for (t = TYPE_FIELDS (class_type_node); t != NULL_TREE; t = TREE_CHAIN (t))
FIELD_PRIVATE (t) = 1;
push_super_field (class_type_node, object_type_node);
FINISH_RECORD (class_type_node);
- build_decl (TYPE_DECL, get_identifier ("Class"), class_type_node);
+ build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("Class"), class_type_node);
field_info_union_node = make_node (UNION_TYPE);
- PUSH_FIELD (field_info_union_node, field, "boffset", int_type_node);
- PUSH_FIELD (field_info_union_node, field, "addr", ptr_type_node);
+ PUSH_FIELD (input_location,
+ field_info_union_node, field, "boffset", int_type_node);
+ PUSH_FIELD (input_location,
+ field_info_union_node, field, "addr", ptr_type_node);
layout_type (field_info_union_node);
- PUSH_FIELD (field_type_node, field, "name", utf8const_ptr_type);
- PUSH_FIELD (field_type_node, field, "type", class_ptr_type);
- PUSH_FIELD (field_type_node, field, "accflags", access_flags_type_node);
- PUSH_FIELD (field_type_node, field, "bsize", unsigned_short_type_node);
- PUSH_FIELD (field_type_node, field, "info", field_info_union_node);
+ PUSH_FIELD (input_location,
+ field_type_node, field, "name", utf8const_ptr_type);
+ PUSH_FIELD (input_location, field_type_node, field, "type", class_ptr_type);
+ PUSH_FIELD (input_location,
+ field_type_node, field, "accflags", access_flags_type_node);
+ PUSH_FIELD (input_location,
+ field_type_node, field, "bsize", unsigned_short_type_node);
+ PUSH_FIELD (input_location,
+ field_type_node, field, "info", field_info_union_node);
FINISH_RECORD (field_type_node);
- build_decl (TYPE_DECL, get_identifier ("Field"), field_type_node);
+ build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("Field"), field_type_node);
nativecode_ptr_array_type_node
= build_array_type (nativecode_ptr_type_node, one_elt_array_domain_type);
- PUSH_FIELD (dtable_type, field, "class", class_ptr_type);
- PUSH_FIELD (dtable_type, field, "methods", nativecode_ptr_array_type_node);
+ PUSH_FIELD (input_location,
+ dtable_type, field, "class", class_ptr_type);
+ PUSH_FIELD (input_location,
+ dtable_type, field, "methods", nativecode_ptr_array_type_node);
FINISH_RECORD (dtable_type);
- build_decl (TYPE_DECL, get_identifier ("dispatchTable"), dtable_type);
+ build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("dispatchTable"), dtable_type);
jexception_type = make_node (RECORD_TYPE);
- PUSH_FIELD (jexception_type, field, "start_pc", ptr_type_node);
- PUSH_FIELD (jexception_type, field, "end_pc", ptr_type_node);
- PUSH_FIELD (jexception_type, field, "handler_pc", ptr_type_node);
- PUSH_FIELD (jexception_type, field, "catch_type", class_ptr_type);
+ PUSH_FIELD (input_location,
+ jexception_type, field, "start_pc", ptr_type_node);
+ PUSH_FIELD (input_location, jexception_type, field, "end_pc", ptr_type_node);
+ PUSH_FIELD (input_location,
+ jexception_type, field, "handler_pc", ptr_type_node);
+ PUSH_FIELD (input_location,
+ jexception_type, field, "catch_type", class_ptr_type);
FINISH_RECORD (jexception_type);
- build_decl (TYPE_DECL, get_identifier ("jexception"), field_type_node);
+ build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("jexception"), field_type_node);
jexception_ptr_type = build_pointer_type (jexception_type);
lineNumberEntry_type = make_node (RECORD_TYPE);
- PUSH_FIELD (lineNumberEntry_type, field, "line_nr", unsigned_short_type_node);
- PUSH_FIELD (lineNumberEntry_type, field, "start_pc", ptr_type_node);
+ PUSH_FIELD (input_location,
+ lineNumberEntry_type, field, "line_nr", unsigned_short_type_node);
+ PUSH_FIELD (input_location,
+ lineNumberEntry_type, field, "start_pc", ptr_type_node);
FINISH_RECORD (lineNumberEntry_type);
lineNumbers_type = make_node (RECORD_TYPE);
- PUSH_FIELD (lineNumbers_type, field, "length", unsigned_int_type_node);
+ PUSH_FIELD (input_location,
+ lineNumbers_type, field, "length", unsigned_int_type_node);
FINISH_RECORD (lineNumbers_type);
- PUSH_FIELD (method_type_node, field, "name", utf8const_ptr_type);
- PUSH_FIELD (method_type_node, field, "signature", utf8const_ptr_type);
- PUSH_FIELD (method_type_node, field, "accflags", access_flags_type_node);
- PUSH_FIELD (method_type_node, field, "index", unsigned_short_type_node);
- PUSH_FIELD (method_type_node, field, "ncode", nativecode_ptr_type_node);
- PUSH_FIELD (method_type_node, field, "throws", ptr_type_node);
+ PUSH_FIELD (input_location,
+ method_type_node, field, "name", utf8const_ptr_type);
+ PUSH_FIELD (input_location,
+ method_type_node, field, "signature", utf8const_ptr_type);
+ PUSH_FIELD (input_location,
+ method_type_node, field, "accflags", access_flags_type_node);
+ PUSH_FIELD (input_location,
+ method_type_node, field, "index", unsigned_short_type_node);
+ PUSH_FIELD (input_location,
+ method_type_node, field, "ncode", nativecode_ptr_type_node);
+ PUSH_FIELD (input_location,
+ method_type_node, field, "throws", ptr_type_node);
FINISH_RECORD (method_type_node);
- build_decl (TYPE_DECL, get_identifier ("Method"), method_type_node);
+ build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier ("Method"), method_type_node);
endlink = end_params_node = tree_cons (NULL_TREE, void_type_node, NULL_TREE);
{
tree *ptr;
int end_pc = start_pc + length;
- tree decl = build_decl (VAR_DECL, name, type);
+ tree decl = build_decl (input_location, VAR_DECL, name, type);
if (end_pc > DECL_CODE_LENGTH (current_function_decl))
{
warning (0, "bad PC range for debug info for local %q+D",
tree result = DECL_RESULT (fndecl);
if (! result)
{
- result = build_decl (RESULT_DECL, NULL_TREE, restype);
+ result = build_decl (DECL_SOURCE_LOCATION (fndecl),
+ RESULT_DECL, NULL_TREE, restype);
DECL_ARTIFICIAL (result) = 1;
DECL_IGNORED_P (result) = 1;
DECL_CONTEXT (result) = fndecl;
tree parm_type = TREE_VALUE (tem);
gcc_assert (i < DECL_MAX_LOCALS (fndecl));
- parm_decl = build_decl (PARM_DECL, parm_name, parm_type);
+ parm_decl = build_decl (input_location, PARM_DECL, parm_name, parm_type);
DECL_CONTEXT (parm_decl) = fndecl;
if (targetm.calls.promote_prototypes (parm_type)
&& TYPE_PRECISION (parm_type) < TYPE_PRECISION (integer_type_node)
name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
buf = (char *) alloca (strlen (name) + 5);
sprintf (buf, "%s_ref", name);
- decl = build_decl (VAR_DECL, get_identifier (buf), ptr_type_node);
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (buf), ptr_type_node);
TREE_STATIC (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
name = IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (utf8_ref, 0)));
buf = (char *) alloca (strlen (name) + 5);
sprintf (buf, "%s_ref", name);
- decl = build_decl (VAR_DECL, get_identifier (buf), utf8const_ptr_type);
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (buf), utf8const_ptr_type);
TREE_STATIC (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
flush_quick_stack ();
decl1 = find_stack_slot (stack_pointer - 1, type1);
decl2 = find_stack_slot (stack_pointer - 2, type2);
- temp = build_decl (VAR_DECL, NULL_TREE, type1);
+ temp = build_decl (input_location, VAR_DECL, NULL_TREE, type1);
java_add_local_var (temp);
java_add_stmt (build2 (MODIFY_EXPR, type1, temp, decl1));
java_add_stmt (build2 (MODIFY_EXPR, type2,
MODIFY_EXPR to set the array element. */
access = build_java_arrayaccess (array, rhs_type_node, index);
- temp = build_decl (VAR_DECL, NULL_TREE,
+ temp = build_decl (input_location, VAR_DECL, NULL_TREE,
build_pointer_type (TREE_TYPE (access)));
java_add_local_var (temp);
java_add_stmt (build2 (MODIFY_EXPR, TREE_TYPE (temp),
generated. To avoid this we create a new local and copy our
value into it. Then we push this new local on the stack.
Hopefully this all gets optimized out. */
- copy = build_decl (VAR_DECL, NULL_TREE, type);
+ copy = build_decl (input_location, VAR_DECL, NULL_TREE, type);
if ((INTEGRAL_TYPE_P (type) || POINTER_TYPE_P (type))
&& TREE_TYPE (copy) != TREE_TYPE (var))
var = convert (type, var);
create_label_decl (tree name)
{
tree decl;
- decl = build_decl (LABEL_DECL, name,
+ decl = build_decl (input_location, LABEL_DECL, name,
TREE_TYPE (return_address_type_node));
DECL_CONTEXT (decl) = current_function_decl;
DECL_IGNORED_P (decl) = 1;
java_add_stmt (switch_expr);
x = build3 (CASE_LABEL_EXPR, void_type_node, NULL_TREE, NULL_TREE,
- create_artificial_label ());
+ create_artificial_label (input_location));
append_to_statement_list (x, &SWITCH_BODY (switch_expr));
x = build1 (GOTO_EXPR, void_type_node, lookup_label (default_pc));
value = build_int_cst (TREE_TYPE (switch_expr), match);
x = build3 (CASE_LABEL_EXPR, void_type_node, value, NULL_TREE,
- create_artificial_label ());
+ create_artificial_label (input_location));
append_to_statement_list (x, &SWITCH_BODY (switch_expr));
x = build1 (GOTO_EXPR, void_type_node, lookup_label (target_pc));
{
/* Build a declaration and mark it as a flag used to track
static class initializations. */
- decl = build_decl (VAR_DECL, NULL_TREE,
+ decl = build_decl (input_location, VAR_DECL, NULL_TREE,
boolean_type_node);
MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl);
DECL_CONTEXT (decl) = current_function_decl;
DECL_ARTIFICIAL (method) = 1;
DECL_EXTERNAL (method) = 0;
- env_var = build_decl (VAR_DECL, get_identifier ("env"), ptr_type_node);
+ env_var = build_decl (input_location,
+ VAR_DECL, get_identifier ("env"), ptr_type_node);
DECL_CONTEXT (env_var) = method;
if (TREE_TYPE (TREE_TYPE (method)) != void_type_node)
{
- res_var = build_decl (VAR_DECL, get_identifier ("res"),
+ res_var = build_decl (input_location, VAR_DECL, get_identifier ("res"),
TREE_TYPE (TREE_TYPE (method)));
DECL_CONTEXT (res_var) = method;
TREE_CHAIN (env_var) = res_var;
garbage-collected. If it is, we end up using canonical types
with different uids for equivalent function types, and this in
turn causes utf8 identifiers and output order to vary. */
- meth_var = build_decl (VAR_DECL, get_identifier ("meth"), jni_func_type);
+ meth_var = build_decl (input_location,
+ VAR_DECL, get_identifier ("meth"), jni_func_type);
TREE_STATIC (meth_var) = 1;
TREE_PUBLIC (meth_var) = 0;
DECL_EXTERNAL (meth_var) = 0;
}
else
{
- tree temp = build_decl (VAR_DECL, NULL_TREE, TREE_TYPE (field_ref));
+ tree temp = build_decl (input_location,
+ VAR_DECL, NULL_TREE, TREE_TYPE (field_ref));
java_add_local_var (temp);
if (TREE_THIS_VOLATILE (field_decl))
tree
build_java_empty_stmt (void)
{
- tree t = build_empty_stmt ();
+ tree t = build_empty_stmt (input_location);
return t;
}
{
tree cpool;
tree d = build_constant_data_ref (flag_indirect_classes);
- tree cpool_ptr = build_decl (VAR_DECL, NULL_TREE,
+ tree cpool_ptr = build_decl (input_location, VAR_DECL, NULL_TREE,
build_pointer_type (TREE_TYPE (d)));
java_add_local_var (cpool_ptr);
TREE_CONSTANT (cpool_ptr) = 1;
/* Don't bother with empty blocks. */
if (! body)
- return build_empty_stmt ();
+ return build_empty_stmt (input_location);
if (IS_EMPTY_STMT (body))
return body;
#define DECL_INNER_CLASS_LIST(NODE) DECL_INITIAL (TYPE_DECL_CHECK (NODE))
/* Add a FIELD_DECL to RECORD_TYPE RTYPE.
- The field has name NAME (a char*), and type FTYPE.
+ The field has name NAME (a char*), a type FTYPE, and a location of LOC.
Unless this is the first field, FIELD most hold the previous field.
FIELD is set to the newly created FIELD_DECL.
We set DECL_ARTIFICIAL so these fields get skipped by make_class_data
if compiling java.lang.Object or java.lang.Class. */
-#define PUSH_FIELD(RTYPE, FIELD, NAME, FTYPE) \
-{ tree _field = build_decl (FIELD_DECL, get_identifier ((NAME)), (FTYPE)); \
+#define PUSH_FIELD(LOC, RTYPE, FIELD, NAME, FTYPE) \
+{ tree _field = build_decl (LOC, FIELD_DECL, get_identifier ((NAME)), (FTYPE)); \
if (TYPE_FIELDS (RTYPE) == NULL_TREE) \
TYPE_FIELDS (RTYPE) = _field; \
else \
tree name = get_identifier ("_Jv_global_static_constructor");
tree decl
- = build_decl (FUNCTION_DECL, name,
+ = build_decl (input_location, FUNCTION_DECL, name,
build_function_type (void_type_node, void_list_node));
- tree resdecl = build_decl (RESULT_DECL, NULL_TREE, void_type_node);
+ tree resdecl = build_decl (input_location,
+ RESULT_DECL, NULL_TREE, void_type_node);
DECL_ARTIFICIAL (resdecl) = 1;
DECL_RESULT (decl) = resdecl;
current_function_decl = decl;
duplicate_class_warning (IDENTIFIER_POINTER (node));
else
{
- tree file_decl = build_decl (TRANSLATION_UNIT_DECL, node, NULL);
+ tree file_decl = build_decl (input_location,
+ TRANSLATION_UNIT_DECL, node, NULL);
TREE_CHAIN (file_decl) = current_file_list;
current_file_list = file_decl;
IS_A_COMMAND_LINE_FILENAME_P (node) = 1;
data_type = build_prim_array_type (unsigned_byte_type_node,
strlen (name) + length);
rtype = make_node (RECORD_TYPE);
- PUSH_FIELD (rtype, field, "name_length", unsigned_int_type_node);
- PUSH_FIELD (rtype, field, "resource_length", unsigned_int_type_node);
- PUSH_FIELD (rtype, field, "data", data_type);
+ PUSH_FIELD (input_location,
+ rtype, field, "name_length", unsigned_int_type_node);
+ PUSH_FIELD (input_location,
+ rtype, field, "resource_length", unsigned_int_type_node);
+ PUSH_FIELD (input_location, rtype, field, "data", data_type);
FINISH_RECORD (rtype);
START_RECORD_CONSTRUCTOR (rinit, rtype);
PUSH_FIELD_VALUE (rinit, "name_length",
FINISH_RECORD_CONSTRUCTOR (rinit);
TREE_CONSTANT (rinit) = 1;
- decl = build_decl (VAR_DECL, java_mangle_resource_name (name), rtype);
+ decl = build_decl (input_location,
+ VAR_DECL, java_mangle_resource_name (name), rtype);
TREE_STATIC (decl) = 1;
TREE_PUBLIC (decl) = 1;
java_hide_decl (decl);
return;
t = build_function_type_list (void_type_node, ptr_type_node, NULL);
- t = build_decl (FUNCTION_DECL, get_identifier ("_Jv_RegisterResource"), t);
+ t = build_decl (input_location,
+ FUNCTION_DECL, get_identifier ("_Jv_RegisterResource"), t);
TREE_PUBLIC (t) = 1;
DECL_EXTERNAL (t) = 1;
register_resource_fn = t;
strcpy (suffix, "[]");
TYPE_NAME (t)
= TYPE_STUB_DECL (t)
- = build_decl (TYPE_DECL,
+ = build_decl (input_location, TYPE_DECL,
identifier_subst (el_name, "", '.', '.', suffix),
t);
TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (t)) = true;
TYPE_ARRAY_ELEMENT (t) = element_type;
/* Add length pseudo-field. */
- fld = build_decl (FIELD_DECL, get_identifier ("length"), int_type_node);
+ fld = build_decl (input_location,
+ FIELD_DECL, get_identifier ("length"), int_type_node);
TYPE_FIELDS (t) = fld;
DECL_CONTEXT (fld) = t;
FIELD_PUBLIC (fld) = 1;
TREE_READONLY (fld) = 1;
atype = build_prim_array_type (element_type, length);
- arfld = build_decl (FIELD_DECL, get_identifier ("data"), atype);
+ arfld = build_decl (input_location,
+ FIELD_DECL, get_identifier ("data"), atype);
DECL_CONTEXT (arfld) = t;
TREE_CHAIN (fld) = arfld;
DECL_ALIGN (arfld) = TYPE_ALIGN (element_type);
pp_newline (context->printer);
if (s.file != NULL)
{
- if (flag_show_column && s.column != 0)
+ if (flag_show_column)
pp_printf (context->printer,
_(" inlined from %qs at %s:%d:%d"),
identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)),
tree (*hook) (tree))
{
tree id = get_identifier (name);
- tree decl = build_decl (FUNCTION_DECL, id, type);
+ tree decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL, id, type);
TREE_PUBLIC (decl) = 1;
DECL_EXTERNAL (decl) = 1;
+2009-06-12 Aldy Hernandez <aldyh@redhat.com>
+
+ * objc-act.c (finish_var_decl): Pass location to finish_decl.
+ (objc_get_parm_info): Same.
+ (get_super_receiver): Same.
+ * objc-act.c (objc_build_component_ref): Pass location to
+ build_compound_ref.
+ (build_module_initializer_routine): Pass location to
+ c_end_compound_stmt.
+ (objc_generate_static_init_call): Pass location to build_stmt.
+ (build_typed_selector_reference): New location argument.
+ (build_selector_reference): Same.
+ (objc_substitute_decl): Pass location to build_array_ref.
+ (next_sjlj_build_try_catch_finally): Pass location to build_stmt.
+ (objc_begin_catch_clause): Same.
+ (objc_finish_try_stmt): Same.
+ (objc_finish_catch_clause): Pass location to c_end_compound_stmt.
+ (objc_build_throw_stmt): New argument.
+ (generate_shared_structures): Pass location to build_c_cast.
+ (objc_build_message_expr): Use local location.
+ (objc_finish_message_expr): Use input_location.
+ (build_objc_method_call): New argument.
+ (objc_build_selector_expr): Same.
+ (get_super_receiver): Pass location to build_c_cast,
+ build_modify_expr, build_compound_expr.
+ * objc-act.c: Add location to all calls to start_struct, build_decl,
+ finish_struct.
+
2009-06-09 Ian Lance Taylor <iant@google.com>
* objc-act.c (objc_gimplify_expr): Change return type to int.
/* Code generation. */
static tree objc_build_constructor (tree, tree);
-static tree build_objc_method_call (int, tree, tree, tree, tree);
+static tree build_objc_method_call (location_t, int, tree, tree, tree, tree);
static tree get_proto_encoding (tree);
static tree lookup_interface (tree);
static tree objc_add_static_instance (tree, tree);
{
gcc_assert (!objc_building_struct);
objc_building_struct = true;
- return start_struct (RECORD_TYPE, name, &objc_in_struct, &objc_struct_types,
- UNKNOWN_LOCATION);
+ return start_struct (input_location, RECORD_TYPE,
+ name, &objc_in_struct, &objc_struct_types);
}
/* Finish building a struct for objc. */
{
gcc_assert (objc_building_struct);
objc_building_struct = false;
- return finish_struct (type, fieldlist, NULL_TREE, objc_in_struct,
- objc_struct_types);
+ return finish_struct (input_location, type, fieldlist, NULL_TREE,
+ objc_in_struct, objc_struct_types);
}
/* Some platforms pass small structures through registers versus
{
/* Prepend a packed variant of the base class into the layout. This
is necessary to preserve ObjC ABI compatibility. */
- tree base = build_decl (FIELD_DECL, NULL_TREE, super);
+ tree base = build_decl (input_location,
+ FIELD_DECL, NULL_TREE, super);
tree field = TYPE_FIELDS (super);
while (field && TREE_CHAIN (field)
return finish_class_member_access_expr (datum, component, false,
tf_warning_or_error);
#else
- return build_component_ref (datum, component);
+ return build_component_ref (input_location, datum, component);
#endif
}
static tree
create_field_decl (tree type, const char *name)
{
- return build_decl (FIELD_DECL, get_identifier (name), type);
+ return build_decl (input_location,
+ FIELD_DECL, get_identifier (name), type);
}
/* Create a global, static declaration for variable NAME of a given TYPE. The
static tree
start_var_decl (tree type, const char *name)
{
- tree var = build_decl (VAR_DECL, get_identifier (name), type);
+ tree var = build_decl (input_location,
+ VAR_DECL, get_identifier (name), type);
TREE_STATIC (var) = 1;
DECL_INITIAL (var) = error_mark_node; /* A real initializer is coming... */
static void
finish_var_decl (tree var, tree initializer)
{
- finish_decl (var, initializer, NULL_TREE, NULL_TREE);
+ finish_decl (var, input_location, initializer, NULL_TREE, NULL_TREE);
/* Ensure that the variable actually gets output. */
mark_decl_referenced (var);
/* Mark the decl to avoid "defined but not used" warning. */
/* Declare the 'id' and 'Class' typedefs. */
- type = lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
+ type = lang_hooks.decls.pushdecl (build_decl (input_location,
+ TYPE_DECL,
objc_object_name,
objc_object_type));
TREE_NO_WARNING (type) = 1;
- type = lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
+ type = lang_hooks.decls.pushdecl (build_decl (input_location,
+ TYPE_DECL,
objc_class_name,
objc_class_type));
TREE_NO_WARNING (type) = 1;
objc_build_internal_const_str_type (void)
{
tree type = (*lang_hooks.types.make_type) (RECORD_TYPE);
- tree fields = build_decl (FIELD_DECL, NULL_TREE, ptr_type_node);
- tree field = build_decl (FIELD_DECL, NULL_TREE, ptr_type_node);
+ tree fields = build_decl (input_location,
+ FIELD_DECL, NULL_TREE, ptr_type_node);
+ tree field = build_decl (input_location,
+ FIELD_DECL, NULL_TREE, ptr_type_node);
TREE_CHAIN (field) = fields; fields = field;
- field = build_decl (FIELD_DECL, NULL_TREE, unsigned_type_node);
+ field = build_decl (input_location,
+ FIELD_DECL, NULL_TREE, unsigned_type_node);
TREE_CHAIN (field) = fields; fields = field;
/* NB: The finish_builtin_struct() routine expects FIELD_DECLs in
reverse order! */
= objc_add_static_instance (constructor, constant_string_type);
else
{
- var = build_decl (CONST_DECL, NULL, TREE_TYPE (constructor));
+ var = build_decl (input_location,
+ CONST_DECL, NULL, TREE_TYPE (constructor));
DECL_INITIAL (var) = constructor;
TREE_STATIC (var) = 1;
pushdecl_top_level (var);
}
sprintf (buf, "_OBJC_INSTANCE_%d", num_static_inst++);
- decl = build_decl (VAR_DECL, get_identifier (buf), class_decl);
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (buf), class_decl);
DECL_COMMON (decl) = 1;
TREE_STATIC (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
push_lang_context (lang_name_c); /* extern "C" */
#endif
- objc_push_parm (build_decl (PARM_DECL, NULL_TREE, void_type_node));
+ objc_push_parm (build_decl (input_location,
+ PARM_DECL, NULL_TREE, void_type_node));
objc_start_function (get_identifier (TAG_GNUINIT),
build_function_type (void_type_node,
OBJC_VOID_AT_END),
body = c_begin_compound_stmt (true);
add_stmt (build_function_call
- (execclass_decl,
+ (input_location,
+ execclass_decl,
build_tree_list
(NULL_TREE,
build_unary_op (input_location, ADDR_EXPR,
UOBJC_MODULES_decl, 0))));
- add_stmt (c_end_compound_stmt (body, true));
+ add_stmt (c_end_compound_stmt (input_location, body, true));
TREE_PUBLIC (current_function_decl) = 0;
tree
objc_generate_static_init_call (tree ctors ATTRIBUTE_UNUSED)
{
- add_stmt (build_stmt (EXPR_STMT,
- build_function_call (GNU_INIT_decl, NULL_TREE)));
+ add_stmt (build_stmt (input_location, EXPR_STMT,
+ build_function_call (input_location,
+ GNU_INIT_decl, NULL_TREE)));
return ctors;
}
}
/* sel_ref_chain is a list whose "value" fields will be instances of
- identifier_node that represent the selector. */
+ identifier_node that represent the selector. LOC is the location of
+ the @selector. */
static tree
-build_typed_selector_reference (tree ident, tree prototype)
+build_typed_selector_reference (location_t loc, tree ident, tree prototype)
{
tree *chain = &sel_ref_chain;
tree expr;
*chain = tree_cons (prototype, ident, NULL_TREE);
return_at_index:
- expr = build_unary_op (input_location, ADDR_EXPR,
- build_array_ref (UOBJC_SELECTOR_TABLE_decl,
- build_int_cst (NULL_TREE, index),
- input_location),
+ expr = build_unary_op (loc, ADDR_EXPR,
+ build_array_ref (loc, UOBJC_SELECTOR_TABLE_decl,
+ build_int_cst (NULL_TREE, index)),
1);
return convert (objc_selector_type, expr);
}
static tree
-build_selector_reference (tree ident)
+build_selector_reference (location_t loc, tree ident)
{
tree *chain = &sel_ref_chain;
tree expr;
if (TREE_VALUE (*chain) == ident)
return (flag_next_runtime
? TREE_PURPOSE (*chain)
- : build_array_ref (UOBJC_SELECTOR_TABLE_decl,
- build_int_cst (NULL_TREE, index),
- input_location));
+ : build_array_ref (loc, UOBJC_SELECTOR_TABLE_decl,
+ build_int_cst (NULL_TREE, index)));
index++;
chain = &TREE_CHAIN (*chain);
return (flag_next_runtime
? expr
- : build_array_ref (UOBJC_SELECTOR_TABLE_decl,
- build_int_cst (NULL_TREE, index),
- input_location));
+ : build_array_ref (loc, UOBJC_SELECTOR_TABLE_decl,
+ build_int_cst (NULL_TREE, index)));
}
static GTY(()) int class_reference_idx;
IDENTIFIER_POINTER (ident)));
assemble_external (objc_get_class_decl);
- return build_function_call (objc_get_class_decl, params);
+ return build_function_call (input_location, objc_get_class_decl, params);
}
}
ident = get_identifier (buf);
- decl = build_decl (VAR_DECL, ident, build_array_type (char_type_node, 0));
+ decl = build_decl (input_location,
+ VAR_DECL, ident, build_array_type (char_type_node, 0));
DECL_EXTERNAL (decl) = 1;
TREE_PUBLIC (decl) = 0;
TREE_USED (decl) = 1;
push_lang_context (lang_name_c); /* extern "C" */
#endif
lang_hooks.decls.pushdecl (build_decl
- (TYPE_DECL,
+ (input_location,
+ TYPE_DECL,
alias_ident,
xref_tag (RECORD_TYPE, underlying_class)));
#ifdef OBJCPLUS
newexpr),
DECL_NAME (TREE_OPERAND (expr, 1)));
case ARRAY_REF:
- return build_array_ref (objc_substitute_decl (TREE_OPERAND (expr, 0),
+ return build_array_ref (input_location,
+ objc_substitute_decl (TREE_OPERAND (expr, 0),
oldexpr,
newexpr),
- TREE_OPERAND (expr, 1),
- input_location);
+ TREE_OPERAND (expr, 1));
case INDIRECT_REF:
return build_indirect_ref (input_location,
objc_substitute_decl (TREE_OPERAND (expr, 0),
NULL_TREE)));
assemble_external (func);
- return build_function_call (func, func_params);
+ return build_function_call (input_location, func, func_params);
}
static tree
NULL_TREE));
assemble_external (objc_assign_global_decl);
- return build_function_call (objc_assign_global_decl, func_params);
+ return build_function_call (input_location,
+ objc_assign_global_decl, func_params);
}
static tree
NULL_TREE));
assemble_external (objc_assign_strong_cast_decl);
- return build_function_call (objc_assign_strong_cast_decl, func_params);
+ return build_function_call (input_location,
+ objc_assign_strong_cast_decl, func_params);
}
static int
{
tree decl;
- decl = build_decl (VAR_DECL, NULL_TREE, type);
+ decl = build_decl (input_location,
+ VAR_DECL, NULL_TREE, type);
TREE_USED (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
tree t;
t = build_fold_addr_expr (cur_try_context->stack_decl);
t = tree_cons (NULL, t, NULL);
- t = build_function_call (objc_exception_try_exit_decl, t);
+ t = build_function_call (input_location,
+ objc_exception_try_exit_decl, t);
return t;
}
t = build_fold_addr_expr (cur_try_context->stack_decl);
t = tree_cons (NULL, t, NULL);
- enter = build_function_call (objc_exception_try_enter_decl, t);
+ enter = build_function_call (input_location,
+ objc_exception_try_enter_decl, t);
t = objc_build_component_ref (cur_try_context->stack_decl,
get_identifier ("buf"));
t = convert (ptr_type_node, t);
#endif
t = tree_cons (NULL, t, NULL);
- sj = build_function_call (objc_setjmp_decl, t);
+ sj = build_function_call (input_location,
+ objc_setjmp_decl, t);
cond = build2 (COMPOUND_EXPR, TREE_TYPE (sj), enter, sj);
cond = c_common_truthvalue_conversion (input_location, cond);
t = build_fold_addr_expr (cur_try_context->stack_decl);
t = tree_cons (NULL, t, NULL);
- t = build_function_call (objc_exception_extract_decl, t);
+ t = build_function_call (input_location,
+ objc_exception_extract_decl, t);
t = convert (TREE_TYPE (decl), t);
t = build2 (MODIFY_EXPR, void_type_node, decl, t);
args = tree_cons (NULL, cur_try_context->caught_decl, NULL);
t = objc_get_class_reference (OBJC_TYPE_NAME (TREE_TYPE (type)));
args = tree_cons (NULL, t, args);
- t = build_function_call (objc_exception_match_decl, args);
+ t = build_function_call (input_location,
+ objc_exception_match_decl, args);
cond = c_common_truthvalue_conversion (input_location, t);
}
t = build3 (COND_EXPR, void_type_node, cond, body, NULL);
if (cur_try_context->catch_list)
{
tree caught_decl = objc_build_exc_ptr ();
- catch_seq = build_stmt (BIND_EXPR, caught_decl, NULL, NULL);
+ catch_seq = build_stmt (input_location, BIND_EXPR, caught_decl, NULL, NULL);
TREE_SIDE_EFFECTS (catch_seq) = 1;
t = next_sjlj_build_exc_extract (caught_decl);
/* Build the complete FINALLY statement list. */
t = next_sjlj_build_try_exit ();
- t = build_stmt (COND_EXPR,
+ t = build_stmt (input_location, COND_EXPR,
c_common_truthvalue_conversion
(input_location, rethrow_decl),
NULL, t);
&TREE_OPERAND (try_fin, 1));
t = tree_cons (NULL, rethrow_decl, NULL);
- t = build_function_call (objc_exception_throw_decl, t);
- t = build_stmt (COND_EXPR,
+ t = build_function_call (input_location,
+ objc_exception_throw_decl, t);
+ t = build_stmt (input_location, COND_EXPR,
c_common_truthvalue_conversion (input_location,
rethrow_decl),
t, NULL);
compound = c_begin_compound_stmt (true);
/* The parser passed in a PARM_DECL, but what we really want is a VAR_DECL. */
- decl = build_decl (VAR_DECL, DECL_NAME (decl), TREE_TYPE (decl));
+ decl = build_decl (input_location,
+ VAR_DECL, DECL_NAME (decl), TREE_TYPE (decl));
lang_hooks.decls.pushdecl (decl);
/* Since a decl is required here by syntax, don't warn if its unused. */
/* Record the data for the catch in the try context so that we can
finalize it later. */
- t = build_stmt (CATCH_EXPR, type, compound);
+ t = build_stmt (input_location, CATCH_EXPR, type, compound);
cur_try_context->current_catch = t;
/* Initialize the decl from the EXC_PTR_EXPR we get from the runtime. */
cur_try_context->current_catch = NULL;
cur_try_context->end_catch_locus = input_location;
- CATCH_BODY (c) = c_end_compound_stmt (CATCH_BODY (c), 1);
+ CATCH_BODY (c) = c_end_compound_stmt (input_location, CATCH_BODY (c), 1);
append_to_statement_list (c, &cur_try_context->catch_list);
}
stmt = c->try_body;
if (c->catch_list)
{
- stmt = build_stmt (TRY_CATCH_EXPR, stmt, c->catch_list);
+ stmt = build_stmt (input_location, TRY_CATCH_EXPR, stmt, c->catch_list);
SET_EXPR_LOCATION (stmt, cur_try_context->try_locus);
}
if (c->finally_body)
{
- stmt = build_stmt (TRY_FINALLY_EXPR, stmt, c->finally_body);
+ stmt = build_stmt (input_location, TRY_FINALLY_EXPR, stmt, c->finally_body);
SET_EXPR_LOCATION (stmt, cur_try_context->try_locus);
}
}
}
tree
-objc_build_throw_stmt (tree throw_expr)
+objc_build_throw_stmt (location_t loc, tree throw_expr)
{
tree args;
if (cur_try_context == NULL
|| cur_try_context->current_catch == NULL)
{
- error ("%<@throw%> (rethrow) used outside of a @catch block");
+ error_at (loc, "%<@throw%> (rethrow) used outside of a @catch block");
return NULL_TREE;
}
/* A throw is just a call to the runtime throw function with the
object as a parameter. */
args = tree_cons (NULL, throw_expr, NULL);
- return add_stmt (build_function_call (objc_exception_throw_decl, args));
+ return add_stmt (build_function_call (loc,
+ objc_exception_throw_decl, args));
}
tree
/* First lock the mutex. */
mutex = save_expr (mutex);
args = tree_cons (NULL, mutex, NULL);
- call = build_function_call (objc_sync_enter_decl, args);
+ call = build_function_call (input_location,
+ objc_sync_enter_decl, args);
SET_EXPR_LOCATION (call, start_locus);
add_stmt (call);
/* Build the mutex unlock. */
args = tree_cons (NULL, mutex, NULL);
- call = build_function_call (objc_sync_exit_decl, args);
+ call = build_function_call (input_location,
+ objc_sync_exit_decl, args);
SET_EXPR_LOCATION (call, input_location);
/* Put the that and the body in a TRY_FINALLY. */
if (my_super_id)
{
super_expr = add_objc_string (my_super_id, class_names);
- super_expr = build_c_cast (cast_type, super_expr); /* cast! */
+ super_expr = build_c_cast (input_location,
+ cast_type, super_expr); /* cast! */
}
else
super_expr = build_int_cst (NULL_TREE, 0);
root_expr = add_objc_string (my_root_id, class_names);
- root_expr = build_c_cast (cast_type, root_expr); /* cast! */
+ root_expr = build_c_cast (input_location, cast_type, root_expr); /* cast! */
if (CLASS_PROTOCOL_LIST (implementation_template))
{
objc_build_message_expr (tree mess)
{
tree receiver = TREE_PURPOSE (mess);
+ location_t loc;
tree sel_name;
#ifdef OBJCPLUS
tree args = TREE_PURPOSE (TREE_VALUE (mess));
if (TREE_CODE (receiver) == ERROR_MARK)
return error_mark_node;
+ if (CAN_HAVE_LOCATION_P (receiver))
+ loc = EXPR_LOCATION (receiver);
+ else
+ loc = input_location;
+
/* Obtain the full selector name. */
if (TREE_CODE (args) == IDENTIFIER_NODE)
/* A unary selector. */
if (!warn_missing_methods)
{
- warning (0, "(Messages without a matching method signature");
- warning (0, "will be assumed to return %<id%> and accept");
- warning (0, "%<...%> as arguments.)");
+ warning_at (input_location,
+ 0, "(Messages without a matching method signature");
+ warning_at (input_location,
+ 0, "will be assumed to return %<id%> and accept");
+ warning_at (input_location,
+ 0, "%<...%> as arguments.)");
warn_missing_methods = true;
}
}
These are the object itself and the selector. */
if (flag_typed_selectors)
- selector = build_typed_selector_reference (sel_name, method_prototype);
+ selector = build_typed_selector_reference (input_location,
+ sel_name, method_prototype);
else
- selector = build_selector_reference (sel_name);
+ selector = build_selector_reference (input_location, sel_name);
- retval = build_objc_method_call (super, method_prototype,
+ retval = build_objc_method_call (input_location, super, method_prototype,
receiver,
selector, method_params);
looking up the method on object LOOKUP_OBJECT (often same as OBJECT),
assuming the method has prototype METHOD_PROTOTYPE.
(That is an INSTANCE_METHOD_DECL or CLASS_METHOD_DECL.)
+ LOC is the location of the expression to build.
Use METHOD_PARAMS as list of args to pass to the method.
If SUPER_FLAG is nonzero, we look up the superclass's method. */
static tree
-build_objc_method_call (int super_flag, tree method_prototype,
+build_objc_method_call (location_t loc, int super_flag, tree method_prototype,
tree lookup_object, tree selector,
tree method_params)
{
(method_prototype, METHOD_REF, super_flag)));
tree method, t;
- lookup_object = build_c_cast (rcv_p, lookup_object);
+ lookup_object = build_c_cast (loc, rcv_p, lookup_object);
/* Use SAVE_EXPR to avoid evaluating the receiver twice. */
lookup_object = save_expr (lookup_object);
t = tree_cons (NULL_TREE, selector, NULL_TREE);
t = tree_cons (NULL_TREE, lookup_object, t);
- method = build_function_call (sender, t);
+ method = build_function_call (loc,
+ sender, t);
/* Pass the object to the method. */
method_params = tree_cons (NULL_TREE, object,
/* ??? Selector is not at this point something we can use inside
the compiler itself. Set it to garbage for the nonce. */
t = build3 (OBJ_TYPE_REF, sender_cast, method, lookup_object, size_zero_node);
- return build_function_call (t, method_params);
+ return build_function_call (loc,
+ t, method_params);
}
\f
static void
/* This function is called by the parser when a @selector() expression
is found, in order to compile it. It is only called by the parser
- and only to compile a @selector(). */
+ and only to compile a @selector(). LOC is the location of the
+ @selector. */
tree
-objc_build_selector_expr (tree selnamelist)
+objc_build_selector_expr (location_t loc, tree selnamelist)
{
tree selname;
if (flag_typed_selectors)
- return build_typed_selector_reference (selname, 0);
+ return build_typed_selector_reference (loc, selname, 0);
else
- return build_selector_reference (selname);
+ return build_selector_reference (loc, selname);
}
tree
TREE_CHAIN (parm_info) = NULL_TREE;
parm_info = pushdecl (parm_info);
- finish_decl (parm_info, NULL_TREE, NULL_TREE, NULL_TREE);
+ finish_decl (parm_info, input_location, NULL_TREE, NULL_TREE, NULL_TREE);
parm_info = next;
}
arg_info = get_parm_info (have_ellipsis);
self_type = objc_object_type;
/* id self; */
- objc_push_parm (build_decl (PARM_DECL, self_id, self_type));
+ objc_push_parm (build_decl (input_location,
+ PARM_DECL, self_id, self_type));
/* SEL _cmd; */
- objc_push_parm (build_decl (PARM_DECL, ucmd_id, objc_selector_type));
+ objc_push_parm (build_decl (input_location,
+ PARM_DECL, ucmd_id, objc_selector_type));
}
/* Transform an Objective-C method definition into a static C function
{
tree type = TREE_VALUE (TREE_TYPE (parmlist)), parm;
- parm = build_decl (PARM_DECL, KEYWORD_ARG_NAME (parmlist), type);
+ parm = build_decl (input_location,
+ PARM_DECL, KEYWORD_ARG_NAME (parmlist), type);
objc_push_parm (parm);
parmlist = TREE_CHAIN (parmlist);
}
#endif
)
{
- tree fndecl = build_decl (FUNCTION_DECL, name, type);
+ tree fndecl = build_decl (input_location,
+ FUNCTION_DECL, name, type);
#ifdef OBJCPLUS
DECL_ARGUMENTS (fndecl) = params;
push_scope ();
declare_parm_level ();
DECL_RESULT (current_function_decl)
- = build_decl (RESULT_DECL, NULL_TREE,
+ = build_decl (input_location,
+ RESULT_DECL, NULL_TREE,
TREE_TYPE (TREE_TYPE (current_function_decl)));
DECL_ARTIFICIAL (DECL_RESULT (current_function_decl)) = 1;
DECL_IGNORED_P (DECL_RESULT (current_function_decl)) = 1;
if (!UOBJC_SUPER_decl)
{
- UOBJC_SUPER_decl = build_decl (VAR_DECL, get_identifier (TAG_SUPER),
+ UOBJC_SUPER_decl = build_decl (input_location,
+ VAR_DECL, get_identifier (TAG_SUPER),
objc_super_template);
/* This prevents `unused variable' warnings when compiling with -Wall. */
TREE_USED (UOBJC_SUPER_decl) = 1;
lang_hooks.decls.pushdecl (UOBJC_SUPER_decl);
- finish_decl (UOBJC_SUPER_decl, NULL_TREE, NULL_TREE, NULL_TREE);
+ finish_decl (UOBJC_SUPER_decl, input_location, NULL_TREE, NULL_TREE,
+ NULL_TREE);
UOBJC_SUPER_scope = objc_get_current_scope ();
}
/* Set receiver to self. */
super_expr = objc_build_component_ref (UOBJC_SUPER_decl, self_id);
super_expr = build_modify_expr (input_location, super_expr, NULL_TREE,
- NOP_EXPR, self_decl, NULL_TREE);
+ NOP_EXPR, input_location, self_decl,
+ NULL_TREE);
super_expr_list = super_expr;
/* Set class to begin searching. */
super_expr = build_modify_expr (input_location, super_expr,
NULL_TREE, NOP_EXPR,
+ input_location,
((TREE_CODE (objc_method_context)
== INSTANCE_METHOD_DECL)
? ucls_super_ref
super_class
= build_indirect_ref
(input_location,
- build_c_cast (build_pointer_type (objc_class_type),
+ build_c_cast (input_location,
+ build_pointer_type (objc_class_type),
super_class), "unary *");
}
else
assemble_external (super_class);
super_class
= build_function_call
- (super_class,
+ (input_location,
+ super_class,
build_tree_list
(NULL_TREE,
my_build_string_pointer
super_expr
= build_modify_expr (input_location, super_expr, NULL_TREE,
NOP_EXPR,
- build_c_cast (TREE_TYPE (super_expr),
+ input_location,
+ build_c_cast (input_location,
+ TREE_TYPE (super_expr),
super_class),
NULL_TREE);
}
- super_expr_list = build_compound_expr (super_expr_list, super_expr);
+ super_expr_list = build_compound_expr (input_location,
+ super_expr_list, super_expr);
super_expr = build_unary_op (input_location,
ADDR_EXPR, UOBJC_SUPER_decl, 0);
- super_expr_list = build_compound_expr (super_expr_list, super_expr);
+ super_expr_list = build_compound_expr (input_location,
+ super_expr_list, super_expr);
return super_expr_list;
}
#endif
/* Make a decl for this name, so we can use its address in a tree. */
- decl = build_decl (VAR_DECL, get_identifier (string), char_type_node);
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (string), char_type_node);
DECL_EXTERNAL (decl) = 1;
TREE_PUBLIC (decl) = 1;
sprintf (string, "%sobjc_class_ref_%s",
(flag_next_runtime ? "." : "__"), name);
exp = build1 (ADDR_EXPR, string_type_node, decl);
- decl = build_decl (VAR_DECL, get_identifier (string), string_type_node);
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (string), string_type_node);
DECL_INITIAL (decl) = exp;
TREE_STATIC (decl) = 1;
TREE_USED (decl) = 1;
tree decl, init;
init = build_int_cst (c_common_type_for_size (BITS_PER_WORD, 1), 0);
- decl = build_decl (VAR_DECL, get_identifier (string), TREE_TYPE (init));
+ decl = build_decl (input_location,
+ VAR_DECL, get_identifier (string), TREE_TYPE (init));
TREE_PUBLIC (decl) = 1;
TREE_READONLY (decl) = 1;
TREE_USED (decl) = 1;
+2009-06-12 Aldy Hernandez <aldyh@redhat.com>
+
+ * objcp-decl.h (c_end_compound_stmt): New argument.
+ * objcp-decl.c (objcp_start_struct): Add argument.
+ (objcp_finish_struct): Same.
+
2009-06-03 Ian Lance Taylor <iant@google.com>
* Make-lang.in (cc1objplus-checksum.o): Depend upon $(CONFIG_H)
/* Hacks to simulate start_struct() and finish_struct(). */
tree
-objcp_start_struct (enum tree_code code ATTRIBUTE_UNUSED, tree name)
+objcp_start_struct (location_t loc ATTRIBUTE_UNUSED,
+ enum tree_code code ATTRIBUTE_UNUSED, tree name)
{
tree s;
/* The idea here is to mimic the actions that the C++ parser takes when
}
tree
-objcp_finish_struct (tree t, tree fieldlist, tree attributes)
+objcp_finish_struct (location_t loc ATTRIBUTE_UNUSED,
+ tree t, tree fieldlist, tree attributes)
{
tree field, next_field;
#ifndef GCC_OBJCP_DECL_H
#define GCC_OBJCP_DECL_H
-extern tree objcp_start_struct (enum tree_code, tree);
-extern tree objcp_finish_struct (tree, tree, tree);
+extern tree objcp_start_struct (location_t, enum tree_code, tree);
+extern tree objcp_finish_struct (location_t, tree, tree, tree);
extern void objcp_finish_function (void);
extern tree objcp_build_function_call (tree, tree);
extern tree objcp_xref_tag (enum tree_code, tree);
objcp_comptypes (type1, type2)
#define c_begin_compound_stmt(flags) \
objcp_begin_compound_stmt (flags)
-#define c_end_compound_stmt(stmt, flags) \
+#define c_end_compound_stmt(loc, stmt, flags) \
objcp_end_compound_stmt (stmt, flags)
#undef OBJC_TYPE_NAME
tree
copy_var_decl (tree var, tree name, tree type)
{
- tree copy = build_decl (VAR_DECL, name, type);
+ tree copy = build_decl (DECL_SOURCE_LOCATION (var), VAR_DECL, name, type);
TREE_ADDRESSABLE (copy) = TREE_ADDRESSABLE (var);
TREE_THIS_VOLATILE (copy) = TREE_THIS_VOLATILE (var);
DECL_ARTIFICIAL (copy) = DECL_ARTIFICIAL (var);
DECL_IGNORED_P (copy) = DECL_IGNORED_P (var);
DECL_CONTEXT (copy) = DECL_CONTEXT (var);
- DECL_SOURCE_LOCATION (copy) = DECL_SOURCE_LOCATION (var);
TREE_USED (copy) = 1;
DECL_SEEN_IN_BIND_EXPR_P (copy) = 1;
else if ((mask & 3) == 1 && is_reference (var))
type = TREE_TYPE (type);
- field = build_decl (FIELD_DECL, DECL_NAME (var), type);
+ field = build_decl (DECL_SOURCE_LOCATION (var),
+ FIELD_DECL, DECL_NAME (var), type);
/* Remember what variable this field was created for. This does have a
side effect of making dwarf2out ignore this member, so for helpful
insert_field_into_struct (ctx->record_type, field);
if (ctx->srecord_type)
{
- sfield = build_decl (FIELD_DECL, DECL_NAME (var), type);
+ sfield = build_decl (DECL_SOURCE_LOCATION (var),
+ FIELD_DECL, DECL_NAME (var), type);
DECL_ABSTRACT_ORIGIN (sfield) = var;
DECL_ALIGN (sfield) = DECL_ALIGN (field);
DECL_USER_ALIGN (sfield) = DECL_USER_ALIGN (field);
ctx->sfield_map = splay_tree_new (splay_tree_compare_pointers, 0, 0);
for (t = TYPE_FIELDS (ctx->record_type); t ; t = TREE_CHAIN (t))
{
- sfield = build_decl (FIELD_DECL, DECL_NAME (t), TREE_TYPE (t));
+ sfield = build_decl (DECL_SOURCE_LOCATION (var),
+ FIELD_DECL, DECL_NAME (t), TREE_TYPE (t));
DECL_ABSTRACT_ORIGIN (sfield) = DECL_ABSTRACT_ORIGIN (t);
insert_field_into_struct (ctx->srecord_type, sfield);
splay_tree_insert (ctx->sfield_map,
if (TREE_CODE (var) == LABEL_DECL)
{
- new_var = create_artificial_label ();
+ new_var = create_artificial_label (DECL_SOURCE_LOCATION (var));
DECL_CONTEXT (new_var) = current_function_decl;
insert_decl_map (&ctx->cb, var, new_var);
return new_var;
type = lang_hooks.types.make_type (RECORD_TYPE);
name = DECL_NAME (TYPE_NAME (ctx->record_type));
- name = build_decl (TYPE_DECL, name, type);
+ name = build_decl (DECL_SOURCE_LOCATION (ctx->receiver_decl),
+ TYPE_DECL, name, type);
TYPE_NAME (type) = name;
for (f = TYPE_FIELDS (ctx->record_type); f ; f = TREE_CHAIN (f))
else
type = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE);
- decl = build_decl (FUNCTION_DECL, name, type);
+ decl = build_decl (gimple_location (ctx->stmt),
+ FUNCTION_DECL, name, type);
decl = lang_hooks.decls.pushdecl (decl);
if (!task_copy)
DECL_CONTEXT (decl) = NULL_TREE;
DECL_INITIAL (decl) = make_node (BLOCK);
- t = build_decl (RESULT_DECL, NULL_TREE, void_type_node);
+ t = build_decl (DECL_SOURCE_LOCATION (decl),
+ RESULT_DECL, NULL_TREE, void_type_node);
DECL_ARTIFICIAL (t) = 1;
DECL_IGNORED_P (t) = 1;
DECL_CONTEXT (t) = decl;
DECL_RESULT (decl) = t;
- t = build_decl (PARM_DECL, get_identifier (".omp_data_i"), ptr_type_node);
+ t = build_decl (DECL_SOURCE_LOCATION (decl),
+ PARM_DECL, get_identifier (".omp_data_i"), ptr_type_node);
DECL_ARTIFICIAL (t) = 1;
DECL_ARG_TYPE (t) = ptr_type_node;
DECL_CONTEXT (t) = current_function_decl;
ctx->receiver_decl = t;
else
{
- t = build_decl (PARM_DECL, get_identifier (".omp_data_o"),
+ t = build_decl (DECL_SOURCE_LOCATION (decl),
+ PARM_DECL, get_identifier (".omp_data_o"),
ptr_type_node);
DECL_ARTIFICIAL (t) = 1;
DECL_ARG_TYPE (t) = ptr_type_node;
allocate_struct_function clobbers CFUN, so we need to restore
it afterward. */
push_struct_function (decl);
- DECL_SOURCE_LOCATION (decl) = gimple_location (ctx->stmt);
cfun->function_end_locus = gimple_location (ctx->stmt);
pop_cfun ();
}
ctx->default_kind = OMP_CLAUSE_DEFAULT_SHARED;
ctx->record_type = lang_hooks.types.make_type (RECORD_TYPE);
name = create_tmp_var_name (".omp_data_s");
- name = build_decl (TYPE_DECL, name, ctx->record_type);
+ name = build_decl (gimple_location (stmt),
+ TYPE_DECL, name, ctx->record_type);
TYPE_NAME (ctx->record_type) = name;
create_omp_child_function (ctx, false);
gimple_omp_parallel_set_child_fn (stmt, ctx->cb.dst_fn);
ctx->default_kind = OMP_CLAUSE_DEFAULT_SHARED;
ctx->record_type = lang_hooks.types.make_type (RECORD_TYPE);
name = create_tmp_var_name (".omp_data_s");
- name = build_decl (TYPE_DECL, name, ctx->record_type);
+ name = build_decl (gimple_location (stmt),
+ TYPE_DECL, name, ctx->record_type);
TYPE_NAME (ctx->record_type) = name;
create_omp_child_function (ctx, false);
gimple_omp_task_set_child_fn (stmt, ctx->cb.dst_fn);
if (ctx->srecord_type)
{
name = create_tmp_var_name (".omp_data_a");
- name = build_decl (TYPE_DECL, name, ctx->srecord_type);
+ name = build_decl (gimple_location (stmt),
+ TYPE_DECL, name, ctx->srecord_type);
TYPE_NAME (ctx->srecord_type) = name;
create_omp_child_function (ctx, true);
}
ctx->field_map = splay_tree_new (splay_tree_compare_pointers, 0, 0);
ctx->record_type = lang_hooks.types.make_type (RECORD_TYPE);
name = create_tmp_var_name (".omp_copy_s");
- name = build_decl (TYPE_DECL, name, ctx->record_type);
+ name = build_decl (gimple_location (stmt),
+ TYPE_DECL, name, ctx->record_type);
TYPE_NAME (ctx->record_type) = name;
scan_sharing_clauses (gimple_omp_single_clauses (stmt), ctx);
gimple stmt;
tree label_true, arm1, arm2;
- label = create_artificial_label ();
- label_true = create_artificial_label ();
+ label = create_artificial_label (UNKNOWN_LOCATION);
+ label_true = create_artificial_label (UNKNOWN_LOCATION);
arm1 = TREE_OPERAND (predicate, 0);
arm2 = TREE_OPERAND (predicate, 1);
gimplify_expr (&arm1, stmt_list, NULL, is_gimple_val, fb_rvalue);
static void
lower_omp_single_simple (gimple single_stmt, gimple_seq *pre_p)
{
- tree tlabel = create_artificial_label ();
- tree flabel = create_artificial_label ();
+ location_t loc = gimple_location (single_stmt);
+ tree tlabel = create_artificial_label (loc);
+ tree flabel = create_artificial_label (loc);
gimple call, cond;
tree lhs, decl;
{
tree ptr_type, t, l0, l1, l2;
gimple_seq copyin_seq;
+ location_t loc = gimple_location (single_stmt);
ctx->sender_decl = create_tmp_var (ctx->record_type, ".omp_copy_o");
ptr_type = build_pointer_type (ctx->record_type);
ctx->receiver_decl = create_tmp_var (ptr_type, ".omp_copy_i");
- l0 = create_artificial_label ();
- l1 = create_artificial_label ();
- l2 = create_artificial_label ();
+ l0 = create_artificial_label (loc);
+ l1 = create_artificial_label (loc);
+ l2 = create_artificial_label (loc);
t = build_call_expr (built_in_decls[BUILT_IN_GOMP_SINGLE_COPY_START], 0);
t = fold_convert (ptr_type, t);
type = lang_hooks.types.make_type (RECORD_TYPE);
name = DECL_NAME (TYPE_NAME (orig_type));
- name = build_decl (TYPE_DECL, name, type);
+ name = build_decl (gimple_location (tcctx->ctx->stmt),
+ TYPE_DECL, name, type);
TYPE_NAME (type) = name;
for (f = TYPE_FIELDS (orig_type); f ; f = TREE_CHAIN (f))
targetm.encode_section_info. */
/* ??? We don't have any type information except for this is
a function. Pretend this is "int foo()". */
- decl = build_decl (FUNCTION_DECL, get_identifier (name),
+ decl = build_decl (UNKNOWN_LOCATION,
+ FUNCTION_DECL, get_identifier (name),
build_function_type (integer_type_node, NULL_TREE));
DECL_ARTIFICIAL (decl) = 1;
DECL_EXTERNAL (decl) = 1;
#define BLOCK_FOR_INSN(INSN) XBBDEF (INSN, 3)
#define INSN_LOCATOR(INSN) XINT (INSN, 4)
+/* LOCATION of an RTX if relevant. */
+#define RTL_LOCATION(X) (INSN_P (X) ? \
+ locator_location (INSN_LOCATOR (x)) \
+ : UNKNOWN_LOCATION)
+/* LOCATION of current INSN. */
+#define CURR_INSN_LOCATION (locator_location (curr_insn_locator ()))
/* The body of an insn. */
#define PATTERN(INSN) XEXP (INSN, 5)
/* Neither node is bounded. First distinguish the two sides;
then emit the code for one side at a time. */
- tree test_label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
+ tree test_label
+ = build_decl (CURR_INSN_LOCATION,
+ LABEL_DECL, NULL_TREE, NULL_TREE);
/* See if the value is on the right. */
emit_cmp_and_jump_insns (index,
/* Right hand node requires testing.
Branch to a label where we will handle it later. */
- test_label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
+ test_label = build_decl (CURR_INSN_LOCATION,
+ LABEL_DECL, NULL_TREE, NULL_TREE);
emit_cmp_and_jump_insns (index,
convert_modes
(mode, imode,
#if 0 /* not yet, should get fixed properly later */
TYPE_NAME (type) = make_type_decl (get_identifier (name), type);
#else
- TYPE_NAME (type) = build_decl (TYPE_DECL, get_identifier (name), type);
+ TYPE_NAME (type) = build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, get_identifier (name), type);
#endif
TYPE_STUB_DECL (type) = TYPE_NAME (type);
layout_decl (TYPE_NAME (type), 0);
}
tree
-objc_build_selector_expr (tree ARG_UNUSED (expr))
+objc_build_selector_expr (location_t ARG_UNUSED (loc), tree ARG_UNUSED (expr))
{
return 0;
}
}
tree
-objc_build_throw_stmt (tree ARG_UNUSED (expr))
+objc_build_throw_stmt (location_t ARG_UNUSED (loc), tree ARG_UNUSED (expr))
{
return 0;
}
complete expression that implements the operation. PARAMS really
has type VEC(tree,gc)*, but we don't want to include tree.h
here. */
- tree (*resolve_overloaded_builtin) (tree decl, void *params);
+ tree (*resolve_overloaded_builtin) (unsigned int /*location_t*/,
+ tree decl, void *params);
/* Fold a target-specific builtin. */
tree (* fold_builtin) (tree fndecl, tree arglist, bool ignore);
if (t == NULL)
{
- t = build_decl (VAR_DECL, get_identifier ("__stack_chk_guard"),
+ t = build_decl (UNKNOWN_LOCATION,
+ VAR_DECL, get_identifier ("__stack_chk_guard"),
ptr_type_node);
TREE_STATIC (t) = 1;
TREE_PUBLIC (t) = 1;
if (t == NULL_TREE)
{
t = build_function_type_list (void_type_node, NULL_TREE);
- t = build_decl (FUNCTION_DECL, get_identifier ("__stack_chk_fail"), t);
+ t = build_decl (UNKNOWN_LOCATION,
+ FUNCTION_DECL, get_identifier ("__stack_chk_fail"), t);
TREE_STATIC (t) = 1;
TREE_PUBLIC (t) = 1;
DECL_EXTERNAL (t) = 1;
if (t == NULL_TREE)
{
t = build_function_type_list (void_type_node, NULL_TREE);
- t = build_decl (FUNCTION_DECL,
+ t = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL,
get_identifier ("__stack_chk_fail_local"), t);
TREE_STATIC (t) = 1;
TREE_PUBLIC (t) = 1;
+2009-06-12 Aldy Hernandez <aldyh@redhat.com>
+
+ * gcc.dg/old-style-prom-3.c: Add column info.
+ * gcc.dg/overflow-warn-1.c
+ * gcc.dg/gomp/pr27415.c
+ * gcc.dg/gomp/for-1.c: Same.
+ * gcc.dg/enum-compat-1.c: Same.
+ * gcc.dg/c99-tag-3.c: Same.
+ * gcc.dg/Wredundant-decls-2.c: Same.
+ * gcc.dg/func-ptr-conv-1.c: Same.
+ * gcc.dg/asm-wide-1.c: Same.
+ * gcc.dg/nofixed-point-2.c: Same.
+ * gcc.dg/cpp/line3.c: Same.
+ * gcc.dg/array-10.c: Same.
+ * gcc.dg/c99-vla-jump-1.c: Same.
+ * gcc.dg/pr20368-1.c: Same.
+ * gcc.dg/Wshadow-3.c: Same.
+ * gcc.dg/c90-const-expr-8.c: Same.
+ * gcc.dg/label-decl-2.c: Same.
+ * gcc.dg/dremf-type-compat-2.c: Same.
+ * gcc.dg/c90-const-expr-5.c: Same.
+ * gcc.dg/builtins-30.c: Same.
+ * gcc.dg/Warray-bounds.c: Same.
+ * gcc.dg/Wcxx-compat-2.c: Same.
+ * gcc.dg/tree-ssa/col-1.c: Same.
+ * gcc.dg/old-style-prom-2.c: Same.
+ * gcc.dg/cast-function-1.c: Same.
+ * gcc.dg/pr15698-1.c: Same.
+ * gcc.dg/dremf-type-compat-3.c: Same.
+ * gcc.dg/vla-8.c: Same.
+ * gcc.dg/gomp/pr27415.c: Move firstprivate diagnostics to correct
+ line.
+ * gcc.dg/label-decl-2.c: Move label diagnostic to correct line.
+ * gcc.dg/old-style-prom-3.c: Check for error on the correct line.
+ * gcc.dg/enum-compat-1.c: Same.
+ * gcc.dg/dremf-type-compat-2.c: Same.
+ * gcc.dg/old-style-prom-2.c: Same.
+ * gcc.dg/pr15698-1.c: Same.
+ * gcc.dg/pr20368-1.c: Same.
+ * gcc.dg/dremf-type-compat-3.c: Same.
+ * gcc.dg/builtins-30.c: Same. Test for columns.
+
2009-06-12 Janus Weil <janus@gcc.gnu.org>
PR fortran/40176
int c[10];
} c;
- a[-1] = 0; /* { dg-warning "array subscript" } */
+ a[-1] = 0; /* { dg-warning "6:array subscript" } */
a[ 0] = 0;
a[ 1] = 0;
a[ 9] = 0;
- a[10] = 0; /* { dg-warning "array subscript" } */
- a[11] = 0; /* { dg-warning "array subscript" } */
- a[2 * n() - 11] = 1; /* { dg-warning "array subscript" } */
+ a[10] = 0; /* { dg-warning "6:array subscript" } */
+ a[11] = 0; /* { dg-warning "6:array subscript" } */
+ a[2 * n() - 11] = 1; /* { dg-warning "6:array subscript" } */
a[2 * n() - 10] = 1;
a[2 * n() - 1] = 1;
- a[2 * n() - 0] = 1; /* { dg-warning "array subscript" } */
+ a[2 * n() - 0] = 1; /* { dg-warning "6:array subscript" } */
- b[-1] = 0; /* { dg-warning "array subscript" } */
+ b[-1] = 0; /* { dg-warning "6:array subscript" } */
b[ 0] = 0;
b[ 1] = 0;
b[ 9] = 0;
- b[10] = 0; /* { dg-warning "array subscript" } */
- b[11] = 0; /* { dg-warning "array subscript" } */
- b[2 * n() - 11] = 1; /* { dg-warning "array subscript" } */
+ b[10] = 0; /* { dg-warning "6:array subscript" } */
+ b[11] = 0; /* { dg-warning "6:array subscript" } */
+ b[2 * n() - 11] = 1; /* { dg-warning "6:array subscript" } */
b[2 * n() - 10] = 1;
b[2 * n() - 1] = 1;
b[2 * n() - 0] = 1; /* { dg-warning "array subscript" } */
- c.c[-1] = 0; /* { dg-warning "array subscript" } */
+ c.c[-1] = 0; /* { dg-warning "8:array subscript" } */
c.c[ 0] = 0;
c.c[ 1] = 0;
c.c[ 9] = 0;
- c.c[10] = 0; /* { dg-warning "array subscript" } */
- c.c[11] = 0; /* { dg-warning "array subscript" } */
- c.c[2 * n() - 11] = 1; /* { dg-warning "array subscript" } */
+ c.c[10] = 0; /* { dg-warning "8:array subscript" } */
+ c.c[11] = 0; /* { dg-warning "8:array subscript" } */
+ c.c[2 * n() - 11] = 1; /* { dg-warning "8:array subscript" } */
c.c[2 * n() - 10] = 1;
c.c[2 * n() - 1] = 1;
- c.c[2 * n() - 0] = 1; /* { dg-warning "array subscript" } */
+ c.c[2 * n() - 0] = 1; /* { dg-warning "8:array subscript" } */
g(&a[8]);
g(&a[9]);
c.c[-1] = 0;
for (i = 20; i < 30; ++i)
- a[i] = 1; /* { dg-warning "array subscript" } */
+ a[i] = 1; /* { dg-warning "15:array subscript" } */
return a;
}
/* { dg-options "-Wc++-compat" } */
_Bool foo; /* This is okay. */
-int bool; /* { dg-warning "keyword" } */
-int catch; /* { dg-warning "keyword" } */
-int char16_t; /* { dg-warning "keyword" } */
-int char32_t; /* { dg-warning "keyword" } */
-int class; /* { dg-warning "keyword" } */
-int const_cast; /* { dg-warning "keyword" } */
-int decltype; /* { dg-warning "keyword" } */
-int delete; /* { dg-warning "keyword" } */
-int dynamic_cast; /* { dg-warning "keyword" } */
-int explicit; /* { dg-warning "keyword" } */
-int export; /* { dg-warning "keyword" } */
-int false; /* { dg-warning "keyword" } */
-int friend; /* { dg-warning "keyword" } */
-int mutable; /* { dg-warning "keyword" } */
-int namespace; /* { dg-warning "keyword" } */
-int new; /* { dg-warning "keyword" } */
-int operator; /* { dg-warning "keyword" } */
-int private; /* { dg-warning "keyword" } */
-int protected; /* { dg-warning "keyword" } */
-int public; /* { dg-warning "keyword" } */
-int reinterpret_cast; /* { dg-warning "keyword" } */
-int static_assert; /* { dg-warning "keyword" } */
-int static_cast; /* { dg-warning "keyword" } */
-int template; /* { dg-warning "keyword" } */
-int this; /* { dg-warning "keyword" } */
-int throw; /* { dg-warning "keyword" } */
-int true; /* { dg-warning "keyword" } */
-int try; /* { dg-warning "keyword" } */
-int typename; /* { dg-warning "keyword" } */
-int typeid; /* { dg-warning "keyword" } */
-int using; /* { dg-warning "keyword" } */
-int virtual; /* { dg-warning "keyword" } */
+int bool; /* { dg-warning "5:keyword" } */
+int catch; /* { dg-warning "5:keyword" } */
+int char16_t; /* { dg-warning "5:keyword" } */
+int char32_t; /* { dg-warning "5:keyword" } */
+int class; /* { dg-warning "5:keyword" } */
+int const_cast; /* { dg-warning "5:keyword" } */
+int decltype; /* { dg-warning "5:keyword" } */
+int delete; /* { dg-warning "5:keyword" } */
+int dynamic_cast; /* { dg-warning "5:keyword" } */
+int explicit; /* { dg-warning "5:keyword" } */
+int export; /* { dg-warning "5:keyword" } */
+int false; /* { dg-warning "5:keyword" } */
+int friend; /* { dg-warning "5:keyword" } */
+int mutable; /* { dg-warning "5:keyword" } */
+int namespace; /* { dg-warning "5:keyword" } */
+int new; /* { dg-warning "5:keyword" } */
+int operator; /* { dg-warning "5:keyword" } */
+int private; /* { dg-warning "5:keyword" } */
+int protected; /* { dg-warning "5:keyword" } */
+int public; /* { dg-warning "5:keyword" } */
+int reinterpret_cast; /* { dg-warning "5:keyword" } */
+int static_assert; /* { dg-warning "5:keyword" } */
+int static_cast; /* { dg-warning "5:keyword" } */
+int template; /* { dg-warning "5:keyword" } */
+int this; /* { dg-warning "5:keyword" } */
+int throw; /* { dg-warning "5:keyword" } */
+int true; /* { dg-warning "5:keyword" } */
+int try; /* { dg-warning "5:keyword" } */
+int typename; /* { dg-warning "5:keyword" } */
+int typeid; /* { dg-warning "5:keyword" } */
+int using; /* { dg-warning "5:keyword" } */
+int virtual; /* { dg-warning "5:keyword" } */
int wchar_t;
/* { dg-do compile } */
/* { dg-options "-Wredundant-decls" } */
-int j = 5; /* { dg-message "note: previous" } */
-int j; /* { dg-warning "redundant" } */
+int j = 5; /* { dg-message "5:note: previous" } */
+int j; /* { dg-warning "5:redundant" } */
static int k;
-static int k = 5; /* { dg-message "note: previous" } */
-static int k; /* { dg-warning "redundant" } */
+static int k = 5; /* { dg-message "12:note: previous" } */
+static int k; /* { dg-warning "12:redundant" } */
-static int l = 5; /* { dg-message "note: previous" } */
-static int l; /* { dg-warning "redundant" } */
+static int l = 5; /* { dg-message "12:note: previous" } */
+static int l; /* { dg-warning "12:redundant" } */
-static int m; /* { dg-message "note: previous" } */
-static int m; /* { dg-warning "redundant" } */
+static int m; /* { dg-message "12:note: previous" } */
+static int m; /* { dg-warning "12:redundant" } */
static int m = 5;
-int n; /* { dg-message "note: previous" } */
-int n; /* { dg-warning "redundant" } */
+int n; /* { dg-message "5:note: previous" } */
+int n; /* { dg-warning "5:redundant" } */
int n = 5;
static int o;
-/* Test warnings for shadowing in function prototype scope: generally
- useless but of use if the parameter is used within the scope. Bug
- 529. */
-/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* PR middle-end/36902 Array bound warning with dead code after optimization */
/* { dg-do compile } */
-/* { dg-options "-std=gnu89 -Wshadow" } */
-
-int v; /* { dg-warning "shadowed declaration" } */
-int f1(int v);
-int f2(int v, int x[v]); /* { dg-warning "declaration of 'v' shadows a global declaration" } */
-int f3(int v, int y[sizeof(v)]); /* { dg-warning "declaration of 'v' shadows a global declaration" } */
-int f4(int v) { return 0; } /* { dg-warning "declaration of 'v' shadows a global declaration" } */
-int f5(int v, int x[v]) { return 0; } /* { dg-warning "declaration of 'v' shadows a global declaration" } */
-int f6(int x) { return 0; }
-int f7(v) int v; { return 0; } /* { dg-warning "declaration of 'v' shadows a global declaration" } */
-int f8(v, w) int v; int w[v]; { return 0; } /* { dg-warning "declaration of 'v' shadows a global declaration" } */
-int f9(x) int x; { return 0; }
-int f10(v) { return 0; } /* { dg-warning "declaration of 'v' shadows a global declaration" } */
-int f11(int a, int b(int a));
-int f12(int a, int b(int a, int x[a])); /* { dg-warning "declaration of 'a' shadows a parameter" } */
-/* { dg-warning "shadowed declaration" "outer parm" { target *-*-* } 20 } */
+/* { dg-options "-O2 -Warray-bounds -Wall -Wextra" } */
+typedef unsigned char __u8;
+typedef unsigned short __u16;
+
+static inline unsigned char *
+foo(unsigned char * to, const unsigned char * from, int n)
+{
+ switch ( n )
+ {
+ case 3:
+ *to = *from;
+ break;
+ case 5:
+ to[4] = from [4];
+ break;
+ }
+ return to;
+}
+
+struct {
+ int size_of_select;
+ unsigned char pcr_select[4];
+} sel;
+
+int bar(void)
+{
+ static unsigned char buf[64];
+
+ sel.size_of_select = 3;
+ foo(buf, sel.pcr_select, sel.size_of_select);
+
+ return 1;
+}
+
+
+static inline unsigned char *
+foo2(unsigned char * to, const unsigned char * from, int n)
+{
+ switch ( n )
+ {
+ case 3:
+ *to = *from;
+ break;
+ case 5:
+ to[63] = from [111]; /* { dg-warning "array subscript is above array bounds" } */
+ break;
+ }
+ return to;
+}
+
+int baz(void)
+{
+ static unsigned char buf[64];
+
+ sel.size_of_select = 5;
+ foo2(buf, sel.pcr_select, sel.size_of_select);
+
+ return 1;
+}
int a;
-int b0[a]; /* { dg-error "at file scope" } */
-int (*b1)[a]; /* { dg-error "at file scope" } */
+int b0[a]; /* { dg-error "5:at file scope" } */
+int (*b1)[a]; /* { dg-error "7:at file scope" } */
int (*b2())[a]; /* { dg-error "at file scope" } */
-struct b3 { int x[a]; }; /* { dg-error "at file scope" } */
-struct b4 { int (*x)[a]; }; /* { dg-error "at file scope" } */
+struct b3 { int x[a]; }; /* { dg-error "17:at file scope" } */
+struct b4 { int (*x)[a]; }; /* { dg-error "19:at file scope" } */
typeof (int [a]) b5; /* { dg-error "at file scope|outside of any function" } */
-int c0[(__SIZE_TYPE__)&a]; /* { dg-error "at file scope" } */
-int (*c1)[(__SIZE_TYPE__)&a]; /* { dg-error "at file scope" } */
-int (*c2())[(__SIZE_TYPE__)&a]; /* { dg-error "at file scope" } */
-struct c3 { int x[(__SIZE_TYPE__)&a]; }; /* { dg-error "at file scope" } */
-struct c4 { int (*x)[(__SIZE_TYPE__)&a]; }; /* { dg-error "at file scope" } */
-typeof (int [(__SIZE_TYPE__)&a]) c5; /* { dg-error "at file scope" } */
+int c0[(__SIZE_TYPE__)&a]; /* { dg-error "5:at file scope" } */
+int (*c1)[(__SIZE_TYPE__)&a]; /* { dg-error "7:at file scope" } */
+int (*c2())[(__SIZE_TYPE__)&a]; /* { dg-error "7:at file scope" } */
+struct c3 { int x[(__SIZE_TYPE__)&a]; }; /* { dg-error "17:at file scope" } */
+struct c4 { int (*x)[(__SIZE_TYPE__)&a]; }; /* { dg-error "19:at file scope" } */
+typeof (int [(__SIZE_TYPE__)&a]) c5; /* { dg-error "34:at file scope" } */
-int d0[1/0]; /* { dg-error "at file scope" } */
-/* { dg-warning "division by zero" "" { target *-*-* } 23 } */
-int (*d1)[1/0]; /* { dg-error "at file scope" } */
-/* { dg-warning "division by zero" "" { target *-*-* } 25 } */
-int (*d2())[1/0]; /* { dg-error "at file scope" } */
-/* { dg-warning "division by zero" "" { target *-*-* } 27 } */
-struct d3 { int x[1/0]; }; /* { dg-error "at file scope" } */
-/* { dg-warning "division by zero" "" { target *-*-* } 29 } */
-struct d4 { int (*x)[1/0]; }; /* { dg-error "at file scope" } */
-/* { dg-warning "division by zero" "" { target *-*-* } 31 } */
-typeof (int [1/0]) d5; /* { dg-error "at file scope" } */
+int d0[1/0]; /* { dg-error "5:at file scope" } */
+/* { dg-warning "9:division by zero" "" { target *-*-* } 23 } */
+int (*d1)[1/0]; /* { dg-error "7:at file scope" } */
+/* { dg-warning "12:division by zero" "" { target *-*-* } 25 } */
+int (*d2())[1/0]; /* { dg-error "7:at file scope" } */
+/* { dg-warning "14:division by zero" "" { target *-*-* } 27 } */
+struct d3 { int x[1/0]; }; /* { dg-error "17:at file scope" } */
+/* { dg-warning "20:division by zero" "" { target *-*-* } 29 } */
+struct d4 { int (*x)[1/0]; }; /* { dg-error "19:at file scope" } */
+/* { dg-warning "23:division by zero" "" { target *-*-* } 31 } */
+typeof (int [1/0]) d5; /* { dg-error "20:at file scope" } */
/* { dg-do compile } */
/* { dg-options "" } */
-int foo asm (L"bar"); /* { dg-error "wide string literal in 'asm'" } */
+int foo asm (L"bar"); /* { dg-error "14:wide string literal in 'asm'" } */
-asm (L"foo"); /* { dg-error "wide string literal in 'asm'" } */
+asm (L"foo"); /* { dg-error "6:wide string literal in 'asm'" } */
void
f (void)
{
int x = 1;
- asm (L"foo"); /* { dg-error "wide string literal in 'asm'" } */
+ asm (L"foo"); /* { dg-error "8:wide string literal in 'asm'" } */
asm ("foo" :
- L"=g" (x)); /* { dg-error "wide string literal in 'asm'" } */
+ L"=g" (x)); /* { dg-error "8:wide string literal in 'asm'" } */
asm ("foo" : [x]
- L"=g" (x)); /* { dg-error "wide string literal in 'asm'" } */
+ L"=g" (x)); /* { dg-error "8:wide string literal in 'asm'" } */
asm ("foo" : [x] "=g" (x),
- L"=g" (x)); /* { dg-error "wide string literal in 'asm'" } */
+ L"=g" (x)); /* { dg-error "8:wide string literal in 'asm'" } */
asm ("foo" : :
- L"g" (x)); /* { dg-error "wide string literal in 'asm'" } */
+ L"g" (x)); /* { dg-error "8:wide string literal in 'asm'" } */
asm ("foo" : : :
- L"memory"); /* { dg-error "wide string literal in 'asm'" } */
+ L"memory"); /* { dg-error "8:wide string literal in 'asm'" } */
asm ("foo" : : : "memory",
- L"memory"); /* { dg-error "wide string literal in 'asm'" } */
+ L"memory"); /* { dg-error "8:wide string literal in 'asm'" } */
}
/* Extra errors from the substitution of "" for wide strings: */
/* { dg-do compile } */
-/* { dg-options "-Wall -Wshadow" } */
+/* { dg-options "-Wall -Wshadow -fshow-column" } */
extern double strtod (const char *, char **);
#define UNUSED __attribute__ ((unused))
/* A built-in function may be overridden by an old-style definition
specifying too few arguments... */
-double cos () /* { dg-warning "shadows a built-in" } */
+double cos () /* { dg-warning "shadows a built-in|number of arguments" } */
{
- /* { dg-warning "number of arguments doesn't match built-in prototype" "built-in" { target *-*-* } 10 } */
return strtod ("nan", 0);
}
/* the right number, but the wrong type, arguments... */
-double sin (foo) /* { dg-warning "shadows a built-in" } */
- int foo UNUSED;
-{ /* { dg-warning "argument 'foo' doesn't match built-in prototype" } */
+double sin (foo) /* { dg-warning "8:shadows a built-in" } */
+ int foo UNUSED; /* { dg-warning "10:argument 'foo' doesn't match built-in prototype" } */
+{
return strtod ("nan", 0);
}
/* or too many arguments. */
-long double cosl (foo, bar) /* { dg-warning "shadows a built-in" } */
- const char *foo UNUSED;
+long double cosl (foo, bar) /* { dg-warning "shadows a built-in|number of arguments" } */
+ const char *foo UNUSED; /* { dg-warning "18:argument 'foo' doesn't match" } */
int bar UNUSED;
-{ /* { dg-warning "number of arguments doesn't match built-in prototype" } */
- /* { dg-warning "argument 'foo' doesn't match built-in prototype" "foo" { target *-*-* } 26 } */
+{
return strtod ("nan", 0);
}
qualified void. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
-/* { dg-options "-std=iso9899:1990 -pedantic-errors -fshow-column" } */
+/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */
typedef void V;
int *p;
{
/* (V *)0 is a null pointer constant, so the assignment should be
diagnosed. */
- q = (j ? p : (V *)0); /* { dg-error "3:assignment from incompatible pointer type" } */
- q = (j ? p : (void *)0); /* { dg-error "3:assignment from incompatible pointer type" } */
+ q = (j ? p : (V *)0); /* { dg-error "5:assignment from incompatible pointer type" } */
+ q = (j ? p : (void *)0); /* { dg-error "5:assignment from incompatible pointer type" } */
/* And this conversion should be valid. */
(void (*)(void))(V *)0;
(void (*)(void))(void *)0;
/* Pointers to qualified void are not valid null pointer
constants. */
- fp = (const void *)0; /* { dg-error "3:ISO C forbids assignment between function pointer and 'void \\*'" } */
+ fp = (const void *)0; /* { dg-error "6:ISO C forbids assignment between function pointer and 'void \\*'" } */
fp = (void *)0;
fp = (V *)0;
fp = 0;
#include <limits.h>
enum e {
- E0 = 0 * (INT_MAX + 1), /* { dg-warning "integer overflow in expression" } */
- /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 12 } */
- E1 = 0 * (INT_MIN / -1), /* { dg-warning "integer overflow in expression" } */
- /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 14 } */
- E2 = 0 * (INT_MAX * INT_MAX), /* { dg-warning "integer overflow in expression" } */
- /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 16 } */
- E3 = 0 * (INT_MIN - 1), /* { dg-warning "integer overflow in expression" } */
- /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 18 } */
- E4 = 0 * (unsigned)(INT_MIN - 1), /* { dg-warning "integer overflow in expression" } */
- /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 20 } */
- E5 = 0 * -INT_MIN, /* { dg-warning "integer overflow in expression" } */
- /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 22 } */
- E6 = 0 * !-INT_MIN, /* { dg-warning "integer overflow in expression" } */
- /* { dg-error "not an integer constant" "constant" { target *-*-* } 24 } */
+ E0 = 0 * (INT_MAX + 1), /* { dg-warning "21:integer overflow in expression" } */
+ /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } 12 } */
+ E1 = 0 * (INT_MIN / -1), /* { dg-warning "21:integer overflow in expression" } */
+ /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } 14 } */
+ E2 = 0 * (INT_MAX * INT_MAX), /* { dg-warning "21:integer overflow in expression" } */
+ /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } 16 } */
+ E3 = 0 * (INT_MIN - 1), /* { dg-warning "21:integer overflow in expression" } */
+ /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } 18 } */
+ E4 = 0 * (unsigned)(INT_MIN - 1), /* { dg-warning "31:integer overflow in expression" } */
+ /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } 20 } */
+ E5 = 0 * -INT_MIN, /* { dg-warning "12:integer overflow in expression" } */
+ /* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } 22 } */
+ E6 = 0 * !-INT_MIN, /* { dg-warning "13:integer overflow in expression" } */
+ /* { dg-error "3:not an integer constant" "constant" { target *-*-* } 24 } */
E7 = INT_MIN % -1 /* Not an overflow. */
};
/* A declaration with a qualifier or storage class specifier declares
the tag if no other declaration of it is visible. */
-const union u0; /* { dg-warning "useless type qualifier in empty declaration" } */
+const union u0; /* { dg-warning "13:useless type qualifier in empty declaration" } */
union u0 { long b; };
-extern struct s1; /* { dg-warning "useless storage class specifier in empty declaration" } */
+extern struct s1; /* { dg-warning "15:useless storage class specifier in empty declaration" } */
/* But if a declaration of the tag is visible, whether at the same
scope or an outer scope, the declaration specifies the same type as
the members of an enumeration, it is a constraint violation. */
struct s2 { char x; };
-const struct s2; /* { dg-error "empty declaration with type qualifier does not redeclare tag" } */
+const struct s2; /* { dg-error "14:empty declaration with type qualifier does not redeclare tag" } */
union u1;
-extern union u1; /* { dg-error "empty declaration with storage class specifier does not redeclare tag" } */
+extern union u1; /* { dg-error "14:empty declaration with storage class specifier does not redeclare tag" } */
union u2 { long b; };
-void g(void) { const union u2; } /* { dg-error "empty declaration with type qualifier does not redeclare tag" } */
+void g(void) { const union u2; } /* { dg-error "28:empty declaration with type qualifier does not redeclare tag" } */
/* And it does not redeclare the tag either if the outer tag is the
wrong kind of tag. This also yields an error for the reference to
declaration. */
union u3 { float v; };
-void h(void) { const struct u3; } /* { dg-error "'u3' defined as wrong kind of tag" } */
-/* { dg-error "empty declaration with type qualifier does not redeclare tag" "wrong tag empty" { target *-*-* } 42 } */
+void h(void) { const struct u3; } /* { dg-error "29:'u3' defined as wrong kind of tag" } */
+/* { dg-error "29:empty declaration with type qualifier does not redeclare tag" "wrong tag empty" { target *-*-* } 42 } */
/* However, such useless specifiers are OK if the contents of the tag
are being defined, or shadowed in an inner scope with the contents
included in the shadowing. */
struct s3;
-const struct s3 { int a; }; /* { dg-warning "useless type qualifier in empty declaration" } */
+const struct s3 { int a; }; /* { dg-warning "14:useless type qualifier in empty declaration" } */
union u4;
-extern union u4 { int z; }; /* { dg-warning "useless storage class specifier in empty declaration" } */
+extern union u4 { int z; }; /* { dg-warning "14:useless storage class specifier in empty declaration" } */
enum e0 { E0 };
-void i(void) { const enum e0 { E1 }; } /* { dg-warning "useless type qualifier in empty declaration" } */
+void i(void) { const enum e0 { E1 }; } /* { dg-warning "32:useless type qualifier in empty declaration" } */
union u5 { int p; };
-void j(void) { extern struct u5 { int q; }; } /* { dg-warning "useless storage class specifier in empty declaration" } */
+void j(void) { extern struct u5 { int q; }; } /* { dg-warning "30:useless storage class specifier in empty declaration" } */
/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
void fa0 (int n) { goto a; a:{ int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; }
-void fa1 (int n) { goto a; { int b[n]; a:{ int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */
-void fa2 (int n) { goto a; { int b[n]; { int c[n]; a:0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */
-void fa3 (int n) { goto a; { int b[n]; { int c[n]; 0;} a:{ int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */
-void fa4 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; a:0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */
-void fa5 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} a:; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */
+void fa1 (int n) { goto a; { int b[n]; a:{ int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "41:jump into scope of identifier with variably modified type" } */
+void fa2 (int n) { goto a; { int b[n]; { int c[n]; a:0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "53:jump into scope of identifier with variably modified type" } */
+void fa3 (int n) { goto a; { int b[n]; { int c[n]; 0;} a:{ int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "57:jump into scope of identifier with variably modified type" } */
+void fa4 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; a:0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "69:jump into scope of identifier with variably modified type" } */
+void fa5 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} a:; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "73:jump into scope of identifier with variably modified type" } */
void fa6 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; a:0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */
void fa7 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; a:{ int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; }
void fa8 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; a:{ int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */
int i;
str_t s;
- d = ((double (*) (int)) foo1) (i); /* { dg-warning "non-compatible|abort" } */
- i = ((int (*) (double)) foo1) (d); /* { dg-warning "non-compatible|abort" } */
- s = ((str_t (*) (int)) foo1) (i); /* { dg-warning "non-compatible|abort" } */
+ d = ((double (*) (int)) foo1) (i); /* { dg-warning "33:non-compatible|abort" } */
+ i = ((int (*) (double)) foo1) (d); /* { dg-warning "33:non-compatible|abort" } */
+ s = ((str_t (*) (int)) foo1) (i); /* { dg-warning "32:non-compatible|abort" } */
((void (*) (int)) foo1) (d); /* { dg-warning "non-compatible|abort" } */
i = ((int (*) (int)) foo1) (i); /* { dg-bogus "non-compatible|abort" } */
(void) foo1 (i); /* { dg-bogus "non-compatible|abort" } */
- d = ((double (*) (int)) foo2) (i); /* { dg-warning "non-compatible|abort" } */
+ d = ((double (*) (int)) foo2) (i); /* { dg-warning "33:non-compatible|abort" } */
i = ((int (*) (double)) foo2) (d); /* { dg-bogus "non-compatible|abort" } */
s = ((str_t (*) (int)) foo2) (i); /* { dg-warning "non-compatible|abort" } */
((void (*) (int)) foo2) (d); /* { dg-warning "non-compatible|abort" } */
char *A;
A = "text"; /* { dg-warning "discards qualifiers" "case zero" } */
- A = one("text"
+ A = one("text" /* { dg-warning "discards qualifiers" "case one" } */
"text")
- ; /* { dg-warning "discards qualifiers" "case one" } */
- A = two("text"
+ ;
+ A = two("text" /* { dg-warning "discards qualifiers" "case two" } */
"text")
- ; /* { dg-warning "discards qualifiers" "case two" } */
- A = four("text"
+ ;
+ A = four("text" /* { dg-warning "discards qualifiers" "case four" } */
"text")
- ; /* { dg-warning "discards qualifiers" "case four" } */
+ ;
return 0;
}
float
dremf (x, y)
- float x;
- float y;
-{ /* { dg-warning "promoted argument '.' doesn't match prototype" } */
+ float x; /* { dg-warning "promoted argument 'x' doesn't match prototype" } */
+ float y; /* { dg-warning "promoted argument 'y' doesn't match prototype" } */
+{
return x + y;
}
float
dremf (x, y)
- float x;
- float y;
-{ /* { dg-error "promoted argument '.' doesn't match prototype" } */
+ float x; /* { dg-error "promoted argument 'x' doesn't match prototype" } */
+ float y; /* { dg-error "promoted argument 'y' doesn't match prototype" } */
+{
return x + y;
}
void f(enum e1); /* { dg-error "prototype" "error at decl" } */
void f(x)
- enum e2 x;
-{ /* { dg-error "doesn't match prototype" "error at defn" } */
+ enum e2 x; /* { dg-error "doesn't match prototype" } */
+{
return;
}
void f(void);
-void *v1 = f; /* { dg-warning "pointer" "bad conversion" } */
-void *v2 = &f; /* { dg-warning "pointer" "bad conversion" } */
-void *v3 = (void *)f; /* { dg-warning "pointer" "bad conversion" } */
-void *v4 = (void *)&f; /* { dg-warning "pointer" "bad conversion" } */
+void *v1 = f; /* { dg-warning "12:pointer" "bad conversion" } */
+void *v2 = &f; /* { dg-warning "12:pointer" "bad conversion" } */
+void *v3 = (void *)f; /* { dg-warning "12:pointer" "bad conversion" } */
+void *v4 = (void *)&f; /* { dg-warning "12:pointer" "bad conversion" } */
void *v5;
-char *c1 = f; /* { dg-warning "pointer" "bad conversion" } */
-char *c2 = &f; /* { dg-warning "pointer" "bad conversion" } */
-char *c3 = (char *)f; /* { dg-warning "pointer" "bad conversion" } */
-char *c4 = (char *)&f; /* { dg-warning "pointer" "bad conversion" } */
+char *c1 = f; /* { dg-warning "12:pointer" "bad conversion" } */
+char *c2 = &f; /* { dg-warning "12:pointer" "bad conversion" } */
+char *c3 = (char *)f; /* { dg-warning "12:pointer" "bad conversion" } */
+char *c4 = (char *)&f; /* { dg-warning "12:pointer" "bad conversion" } */
char *c5;
void (*fp)(void);
int a;
void
g(void)
{
- v5 = f; /* { dg-warning "pointer" "bad conversion" } */
- v5 = &f; /* { dg-warning "pointer" "bad conversion" } */
- v5 = (void *)f; /* { dg-warning "pointer" "bad conversion" } */
- v5 = (void *)&f; /* { dg-warning "pointer" "bad conversion" } */
- c5 = f; /* { dg-warning "pointer" "bad conversion" } */
- c5 = &f; /* { dg-warning "pointer" "bad conversion" } */
- c5 = (char *)f; /* { dg-warning "pointer" "bad conversion" } */
- c5 = (char *)&f; /* { dg-warning "pointer" "bad conversion" } */
- fp = v5; /* { dg-warning "pointer" "bad conversion" } */
- fp = c5; /* { dg-warning "pointer" "bad conversion" } */
- fp = (void (*)(void))v5; /* { dg-warning "pointer" "bad conversion" } */
- fp = (void (*)(void))c5; /* { dg-warning "pointer" "bad conversion" } */
- (a ? f : v3); /* { dg-warning "pointer" "bad conversion" } */
- (a ? v2 : fp); /* { dg-warning "pointer" "bad conversion" } */
+ v5 = f; /* { dg-warning "6:pointer" "bad conversion" } */
+ v5 = &f; /* { dg-warning "6:pointer" "bad conversion" } */
+ v5 = (void *)f; /* { dg-warning "8:pointer" "bad conversion" } */
+ v5 = (void *)&f; /* { dg-warning "8:pointer" "bad conversion" } */
+ c5 = f; /* { dg-warning "6:pointer" "bad conversion" } */
+ c5 = &f; /* { dg-warning "6:pointer" "bad conversion" } */
+ c5 = (char *)f; /* { dg-warning "8:pointer" "bad conversion" } */
+ c5 = (char *)&f; /* { dg-warning "8:pointer" "bad conversion" } */
+ fp = v5; /* { dg-warning "6:pointer" "bad conversion" } */
+ fp = c5; /* { dg-warning "6:pointer" "bad conversion" } */
+ fp = (void (*)(void))v5; /* { dg-warning "8:pointer" "bad conversion" } */
+ fp = (void (*)(void))c5; /* { dg-warning "8:pointer" "bad conversion" } */
+ (a ? f : v3); /* { dg-warning "6:pointer" "bad conversion" } */
+ (a ? v2 : fp); /* { dg-warning "6:pointer" "bad conversion" } */
/* The following are OK. */
fp = 0;
fp = (void *)0;
baz (i);
#pragma omp for
- for (i = 0; i < 10; i-=3, j+=2) /* { dg-error "23:invalid increment expression" } */
+ for (i = 0; i < 10; i-=3, j+=2) /* { dg-error "27:invalid increment expression" } */
baz (i);
}
test2 (void)
{
int i = 0;
-#pragma omp parallel for firstprivate (i)
- for (i = 0; i < 10; i++) /* { dg-error "should not be firstprivate" } */
+#pragma omp parallel for firstprivate (i) /* { dg-error "should not be firstprivate" } */
+ for (i = 0; i < 10; i++)
;
}
test4 (void)
{
int i = 0;
-#pragma omp parallel for reduction (*:i)
- for (i = 0; i < 10; i++) /* { dg-error "should not be reduction" } */
+#pragma omp parallel for reduction (*:i) /* { dg-error "should not be reduction" } */
+ for (i = 0; i < 10; i++)
;
}
void
f (void)
{
- __label__ a, b, c, d;
+ __label__ a, b, c, d; /* { dg-warning "ISO C forbids label declarations" "label decls" { target *-*-* } 11 } */
__extension__ (void)&&d; /* { dg-error "label 'd' used but not defined" } */
- /* { dg-warning "ISO C forbids label declarations" "label decls" { target *-*-* } 11 } */
goto c; /* { dg-error "label 'c' used but not defined" } */
a: (void)0;
b: (void)0;
}
__typeof (0r) /* { dg-error "not supported" "reject fixed-point" } */
-b2 (void)
+b2 (void) /* { dg-warning "defaults to" } */
{
return 0r; /* { dg-error "not supported" "reject fixed-point" } */
}
return 0k; /* { dg-error "not supported" "reject fixed-point" } */
}
-/* { dg-warning "defaults to" "" { target *-*-* } 13 } */
/* { dg-error "is used without" "" { target *-*-* } 24 } */
float
f (x, y)
- float x;
- float y;
-{ /* { dg-warning "promoted argument '.' doesn't match prototype" } */
+ float x; /* { dg-warning "promoted argument 'x' doesn't match prototype" } */
+ float y; /* { dg-warning "promoted argument 'y' doesn't match prototype" } */
+{
return x + y;
}
float
f (x, y)
- float x;
- float y;
-{ /* { dg-error "promoted argument '.' doesn't match prototype" } */
+ float x; /* { dg-error "promoted argument 'x' doesn't match prototype" } */
+ float y; /* { dg-error "promoted argument 'y' doesn't match prototype" } */
+{
return x + y;
}
/* Overflow in an unevaluated part of an expression is OK (example
in the standard). */
E2 = 2 || 1 / 0,
- E3 = 1 / 0, /* { dg-warning "division by zero" } */
- /* { dg-error "enumerator value for 'E3' is not an integer constant" "enum error" { target *-*-* } 15 } */
+ E3 = 1 / 0, /* { dg-warning "10:division by zero" } */
+ /* { dg-error "3:enumerator value for 'E3' is not an integer constant" "enum error" { target *-*-* } 15 } */
/* But as in DR#031, the 1/0 in an evaluated subexpression means the
whole expression violates the constraints. */
- E4 = 0 * (1 / 0), /* { dg-warning "division by zero" } */
+ E4 = 0 * (1 / 0), /* { dg-warning "15:division by zero" } */
/* { dg-error "enumerator value for 'E4' is not an integer constant" "enum error" { target *-*-* } 19 } */
- E5 = INT_MAX + 1, /* { dg-warning "integer overflow in expression" } */
+ E5 = INT_MAX + 1, /* { dg-warning "16:integer overflow in expression" } */
/* Again, overflow in evaluated subexpression. */
- E6 = 0 * (INT_MAX + 1), /* { dg-warning "integer overflow in expression" } */
+ E6 = 0 * (INT_MAX + 1), /* { dg-warning "21:integer overflow in expression" } */
/* A cast does not constitute overflow in conversion. */
E7 = (char) INT_MAX
};
struct s {
int a;
- int : 0 * (1 / 0); /* { dg-warning "division by zero" } */
- /* { dg-error "not an integer constant" "integer constant" { target *-*-* } 30 } */
+ int : 0 * (1 / 0); /* { dg-warning "16:division by zero" } */
+ /* { dg-error "not an integer constant" "22:integer constant" { target *-*-* } 30 } */
int : 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */
};
{
/* This expression is not required to be a constant expression, so
it should just involve undefined behavior at runtime. */
- int c = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */
+ int c = INT_MAX + 1; /* { dg-warning "19:integer overflow in expression" } */
}
/* But this expression does need to be constant. */
-static int sc = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */
+static int sc = INT_MAX + 1; /* { dg-warning "25:integer overflow in expression" } */
/* The first two of these involve overflow, so are not null pointer
constants. The third has the overflow in an unevaluated
}
char *rindex(a, b)
- register char *a, b;
-{ /* { dg-warning "argument 'a' doesn't match built-in prototype" } */
+ register char *a, b; /* { dg-warning "argument 'a' doesn't match built-in prototype" } */
+{
return 0;
}
extern __typeof (f) g; /* { dg-error "'f' undeclared here \\(not in a function\\)" } */
int
-f (x)
- float x; /* { dg-warning "function declaration isn't a prototype" } */
+f (x) /* { dg-warning "function declaration isn't a prototype" } */
+ float x;
{
}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-gimple-details-lineno" } */
+
+void foo (int, int);
+
+int
+m(int x)
+{
+ int c, a;
+ a = (c = 5) + 16 + x * 2 ;
+ foo (c, a);
+}
+
+/* { dg-final { scan-tree-dump-times "10:9.*c = 5" 1 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "10:14.*c . 16" 1 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "10:4.*a =" 1 "gimple" } } */
+/* { dg-final { cleanup-tree-dump "gimple" } } */
}
void foo2(int n) {
- goto A; /* { dg-error "jump into scope of identifier with variably modified type" } */
+ goto A;
int (*(*bar2)(void))[n];
- A:
+ A: /* { dg-error "jump into scope of identifier with variably modified type" } */
;
}
gcc_assert (cond_expr && gimple_code (cond_expr) == GIMPLE_COND);
/* Now the label. */
- bi_call_label_decl = create_artificial_label ();
+ bi_call_label_decl = create_artificial_label (gimple_location (bi_call));
bi_call_label = gimple_build_label (bi_call_label_decl);
gsi_insert_before (&bi_call_bsi, bi_call_label, GSI_SAME_STMT);
/* Build a label for the new block which will contain the
factored computed goto. */
- factored_label_decl = create_artificial_label ();
+ factored_label_decl = create_artificial_label (UNKNOWN_LOCATION);
factored_computed_goto_label
= gimple_build_label (factored_label_decl);
gsi_insert_after (&new_gsi, factored_computed_goto_label,
if (addr)
{
debug_generic_expr (addr);
- inform (input_location, "in statement");
+ inform (gimple_location (gsi_stmt (*gsi)), "in statement");
debug_gimple_stmt (stmt);
return true;
}
}
}
- label = create_artificial_label ();
+ label = create_artificial_label (UNKNOWN_LOCATION);
stmt = gimple_build_label (label);
gsi_insert_before (&s, stmt, GSI_NEW_STMT);
return label;
m = XNEW (struct tree_map);
m->hash = DECL_UID (decl);
m->base.from = decl;
- m->to = create_artificial_label ();
+ m->to = create_artificial_label (UNKNOWN_LOCATION);
LABEL_DECL_UID (m->to) = LABEL_DECL_UID (decl);
if (LABEL_DECL_UID (m->to) >= cfun->cfg->last_label_uid)
cfun->cfg->last_label_uid = LABEL_DECL_UID (m->to) + 1;
tree label;
gimple_seq new_seq;
treemple temp;
+ location_t loc = gimple_location (gsi_stmt (*gsi));
temp.tp = tp;
new_seq = find_goto_replacement (tf, temp);
return;
}
- label = create_artificial_label ();
+ label = create_artificial_label (loc);
/* Set the new label for the GIMPLE_COND */
*tp = label;
{
gimple x;
gimple_seq cleanup, result;
+ location_t loc = gimple_location (tp);
cleanup = gimple_try_cleanup (tp);
result = gimple_try_eval (tp);
if (gimple_seq_may_fallthru (result))
{
if (!over)
- over = create_artificial_label ();
+ over = create_artificial_label (loc);
x = gimple_build_goto (over);
gimple_seq_add_stmt (&result, x);
}
if (!label)
{
- label = create_artificial_label ();
+ label = create_artificial_label (gimple_location (tf->try_finally_expr));
tf->fallthru_label = label;
if (tf->outer->tf)
{
if (tf->may_throw)
lab = tf->eh_label;
else
- lab = create_artificial_label ();
+ lab = create_artificial_label (gimple_location (tf->try_finally_expr));
/* We expect that tf->top_p is a GIMPLE_TRY. */
finally = gimple_try_cleanup (tf->top_p);
gimple x;
gimple_seq finally;
tree finally_label;
+ location_t loc = gimple_location (tf->try_finally_expr);
finally = gimple_try_cleanup (tf->top_p);
tf->top_p_seq = gimple_try_eval (tf->top_p);
return;
}
- finally_label = create_artificial_label ();
+ finally_label = create_artificial_label (loc);
x = gimple_build_label (finally_label);
gimple_seq_add_stmt (&tf->top_p_seq, x);
gimple_seq seq;
gimple x;
tree tmp;
+ location_t tf_loc = gimple_location (tf->try_finally_expr);
finally = gimple_try_cleanup (tf->top_p);
tf->top_p_seq = gimple_try_eval (tf->top_p);
if (! q)
continue;
- lab = labels[index].label = create_artificial_label ();
+ lab = labels[index].label
+ = create_artificial_label (tf_loc);
if (index == return_index)
do_return_redirection (q, lab, NULL, &return_val);
gimple switch_stmt;
gimple_seq finally;
struct pointer_map_t *cont_map = NULL;
+ /* The location of the TRY_FINALLY stmt. */
+ location_t tf_loc;
+ /* The location of the finally block. */
+ location_t finally_loc;
switch_body = gimple_seq_alloc ();
finally = gimple_try_cleanup (tf->top_p);
tf->top_p_seq = gimple_try_eval (tf->top_p);
+ /* The location of the finally is either the last stmt in the finally
+ block or the location of the TRY_FINALLY itself. */
+ finally_loc = gimple_seq_last_stmt (tf->top_p_seq) != NULL ?
+ gimple_location (gimple_seq_last_stmt (tf->top_p_seq))
+ : tf_loc;
+
/* Lower the finally block itself. */
lower_eh_constructs_1 (state, finally);
ndests = fallthru_index + tf->may_fallthru;
finally_tmp = create_tmp_var (integer_type_node, "finally_tmp");
- finally_label = create_artificial_label ();
+ finally_label = create_artificial_label (finally_loc);
/* We use VEC_quick_push on case_label_vec throughout this function,
since we know the size in advance and allocate precisely as muce
last_case = build3 (CASE_LABEL_EXPR, void_type_node,
build_int_cst (NULL_TREE, fallthru_index), NULL,
- create_artificial_label ());
+ create_artificial_label (tf_loc));
VEC_quick_push (tree, case_label_vec, last_case);
last_case_index++;
last_case = build3 (CASE_LABEL_EXPR, void_type_node,
build_int_cst (NULL_TREE, eh_index), NULL,
- create_artificial_label ());
+ create_artificial_label (tf_loc));
VEC_quick_push (tree, case_label_vec, last_case);
last_case_index++;
gcc_assert (slot);
cont_stmt = *(gimple *) slot;
- label = create_artificial_label ();
+ label = create_artificial_label (tf_loc);
CASE_LABEL (last_case) = label;
x = gimple_build_label (label);
label. */
switch_stmt = gimple_build_switch_vec (finally_tmp, last_case,
case_label_vec);
+ gimple_set_location (switch_stmt, finally_loc);
/* Need to link SWITCH_STMT after running replace_goto_queue
due to not wanting to process the same goto stmts twice. */
struct leh_tf_state this_tf;
struct leh_state this_state;
int ndests;
+ location_t tf_loc = gimple_location (tp);
/* Process the try block. */
this_tf.may_throw = get_eh_region_may_contain_throw (this_tf.region);
if (this_tf.may_throw)
{
- this_tf.eh_label = create_artificial_label ();
+ this_tf.eh_label = create_artificial_label (tf_loc);
set_eh_region_tree_label (this_tf.region, this_tf.eh_label);
honor_protect_cleanup_actions (state, &this_state, &this_tf);
}
struct leh_state this_state;
gimple_stmt_iterator gsi;
tree out_label;
+ location_t try_catch_loc = gimple_location (tp);
try_region = gen_eh_region_try (state->cur_region);
this_state.cur_region = try_region;
this_state.cur_region = catch_region;
lower_eh_constructs_1 (&this_state, gimple_catch_handler (gcatch));
- eh_label = create_artificial_label ();
+ eh_label = create_artificial_label (try_catch_loc);
set_eh_region_tree_label (catch_region, eh_label);
x = gimple_build_label (eh_label);
if (gimple_seq_may_fallthru (gimple_catch_handler (gcatch)))
{
if (!out_label)
- out_label = create_artificial_label ();
+ out_label = create_artificial_label (try_catch_loc);
x = gimple_build_goto (out_label);
gimple_seq_add_stmt (gimple_catch_handler_ptr (gcatch), x);
lower_eh_constructs_1 (state, gimple_eh_filter_failure (inner));
gimple_try_set_cleanup (tp, gimple_eh_filter_failure (inner));
- eh_label = create_artificial_label ();
+ eh_label = create_artificial_label (gimple_location (inner));
set_eh_region_tree_label (this_region, eh_label);
return frob_into_branch_around (tp, eh_label, NULL);
/* Build enough of a try-finally state so that we can reuse
honor_protect_cleanup_actions. */
memset (&fake_tf, 0, sizeof (fake_tf));
- fake_tf.top_p = tp;
+ fake_tf.top_p = fake_tf.try_finally_expr = tp;
fake_tf.outer = state;
fake_tf.region = this_region;
fake_tf.may_fallthru = gimple_seq_may_fallthru (gimple_try_eval (tp));
fake_tf.may_throw = true;
- fake_tf.eh_label = create_artificial_label ();
+ fake_tf.eh_label = create_artificial_label (gimple_location (tp));
set_eh_region_tree_label (this_region, fake_tf.eh_label);
honor_protect_cleanup_actions (state, NULL, &fake_tf);
STRIP_TYPE_NOPS (value);
if (TREE_CONSTANT (value) || TREE_READONLY (value))
{
- *tp = build_empty_stmt ();
+ *tp = build_empty_stmt (EXPR_LOCATION (*tp));
return copy_tree_body_r (tp, walk_subtrees, data);
}
}
static bool
inline_forbidden_p (tree fndecl)
{
- location_t saved_loc = input_location;
struct function *fun = DECL_STRUCT_FUNCTION (fndecl);
tree step;
struct walk_stmt_info wi;
egress:
pointer_set_destroy (visited_nodes);
- input_location = saved_loc;
return forbidden_p;
}
type = TREE_TYPE (decl);
- copy = build_decl (VAR_DECL, DECL_NAME (decl), type);
+ copy = build_decl (DECL_SOURCE_LOCATION (id->dst_fn),
+ VAR_DECL, DECL_NAME (decl), type);
TREE_ADDRESSABLE (copy) = TREE_ADDRESSABLE (decl);
TREE_READONLY (copy) = TREE_READONLY (decl);
TREE_THIS_VOLATILE (copy) = TREE_THIS_VOLATILE (decl);
if (DECL_BY_REFERENCE (decl))
type = TREE_TYPE (type);
- copy = build_decl (VAR_DECL, DECL_NAME (decl), type);
+ copy = build_decl (DECL_SOURCE_LOCATION (id->dst_fn),
+ VAR_DECL, DECL_NAME (decl), type);
TREE_READONLY (copy) = TREE_READONLY (decl);
TREE_THIS_VOLATILE (copy) = TREE_THIS_VOLATILE (decl);
if (!DECL_BY_REFERENCE (decl))
static inline tree
mf_make_builtin (enum tree_code category, const char *name, tree type)
{
- tree decl = mf_mark (build_decl (category, get_identifier (name), type));
+ tree decl = mf_mark (build_decl (UNKNOWN_LOCATION,
+ category, get_identifier (name), type));
TREE_PUBLIC (decl) = 1;
DECL_EXTERNAL (decl) = 1;
lang_hooks.decls.pushdecl (decl);
/* There is, abominably, no language-independent way to construct a
RECORD_TYPE. So we have to call the basic type construction
primitives by hand. */
- tree fieldlo = build_decl (FIELD_DECL, get_identifier ("low"), field_type);
- tree fieldhi = build_decl (FIELD_DECL, get_identifier ("high"), field_type);
+ tree fieldlo = build_decl (UNKNOWN_LOCATION,
+ FIELD_DECL, get_identifier ("low"), field_type);
+ tree fieldhi = build_decl (UNKNOWN_LOCATION,
+ FIELD_DECL, get_identifier ("high"), field_type);
tree struct_type = make_node (RECORD_TYPE);
DECL_CONTEXT (fieldlo) = struct_type;
Note also that it's represented as a parameter. This is more
close to the truth, since the initial value does come from
the caller. */
- decl = build_decl (PARM_DECL, create_tmp_var_name ("CHAIN"), type);
+ decl = build_decl (DECL_SOURCE_LOCATION (info->context),
+ PARM_DECL, create_tmp_var_name ("CHAIN"), type);
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
TREE_USED (decl) = 1;
static GTY(()) tree trampoline_type;
static tree
-get_trampoline_type (void)
+get_trampoline_type (struct nesting_info *info)
{
unsigned align, size;
tree t;
t = build_index_type (build_int_cst (NULL_TREE, size - 1));
t = build_array_type (char_type_node, t);
- t = build_decl (FIELD_DECL, get_identifier ("__data"), t);
+ t = build_decl (DECL_SOURCE_LOCATION (info->context),
+ FIELD_DECL, get_identifier ("__data"), t);
DECL_ALIGN (t) = align;
DECL_USER_ALIGN (t) = 1;
{
tree field = make_node (FIELD_DECL);
DECL_NAME (field) = DECL_NAME (decl);
- TREE_TYPE (field) = get_trampoline_type ();
+ TREE_TYPE (field) = get_trampoline_type (info);
TREE_ADDRESSABLE (field) = 1;
insert_field_into_struct (get_frame_type (info), field);
x = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (x)), x);
/* ??? We should be remapping types as well, surely. */
- new_decl = build_decl (VAR_DECL, DECL_NAME (decl), TREE_TYPE (decl));
+ new_decl = build_decl (DECL_SOURCE_LOCATION (decl),
+ VAR_DECL, DECL_NAME (decl), TREE_TYPE (decl));
DECL_CONTEXT (new_decl) = info->context;
- DECL_SOURCE_LOCATION (new_decl) = DECL_SOURCE_LOCATION (decl);
DECL_ARTIFICIAL (new_decl) = DECL_ARTIFICIAL (decl);
DECL_IGNORED_P (new_decl) = DECL_IGNORED_P (decl);
TREE_THIS_VOLATILE (new_decl) = TREE_THIS_VOLATILE (decl);
{
tree c, decl;
decl = get_chain_decl (info);
- c = build_omp_clause (OMP_CLAUSE_FIRSTPRIVATE);
+ c = build_omp_clause (gimple_location (stmt),
+ OMP_CLAUSE_FIRSTPRIVATE);
OMP_CLAUSE_DECL (c) = decl;
OMP_CLAUSE_CHAIN (c) = gimple_omp_taskreg_clauses (stmt);
gimple_omp_taskreg_set_clauses (stmt, c);
x = info->frame_decl;
x = build3 (COMPONENT_REF, TREE_TYPE (field), x, field, NULL_TREE);
- new_decl = build_decl (VAR_DECL, DECL_NAME (decl), TREE_TYPE (decl));
+ new_decl = build_decl (DECL_SOURCE_LOCATION (decl),
+ VAR_DECL, DECL_NAME (decl), TREE_TYPE (decl));
DECL_CONTEXT (new_decl) = info->context;
- DECL_SOURCE_LOCATION (new_decl) = DECL_SOURCE_LOCATION (decl);
DECL_ARTIFICIAL (new_decl) = DECL_ARTIFICIAL (decl);
DECL_IGNORED_P (new_decl) = DECL_IGNORED_P (decl);
TREE_THIS_VOLATILE (new_decl) = TREE_THIS_VOLATILE (decl);
{
tree c;
(void) get_frame_type (info);
- c = build_omp_clause (OMP_CLAUSE_SHARED);
+ c = build_omp_clause (gimple_location (stmt),
+ OMP_CLAUSE_SHARED);
OMP_CLAUSE_DECL (c) = info->frame_decl;
OMP_CLAUSE_CHAIN (c) = gimple_omp_taskreg_clauses (stmt);
gimple_omp_taskreg_set_clauses (stmt, c);
slot = pointer_map_insert (i->var_map, label);
if (*slot == NULL)
{
- new_label = create_artificial_label ();
+ new_label = create_artificial_label (UNKNOWN_LOCATION);
DECL_NONLOCAL (new_label) = 1;
*slot = new_label;
}
break;
if (c == NULL)
{
- c = build_omp_clause (i ? OMP_CLAUSE_FIRSTPRIVATE
- : OMP_CLAUSE_SHARED);
+ c = build_omp_clause (gimple_location (stmt),
+ i ? OMP_CLAUSE_FIRSTPRIVATE
+ : OMP_CLAUSE_SHARED);
OMP_CLAUSE_DECL (c) = decl;
OMP_CLAUSE_CHAIN (c) = gimple_omp_taskreg_clauses (stmt);
gimple_omp_taskreg_set_clauses (stmt, c);
bvar = create_tmp_var (type, "reduction");
add_referenced_var (bvar);
- c = build_omp_clause (OMP_CLAUSE_REDUCTION);
+ c = build_omp_clause (gimple_location (reduc->reduc_stmt),
+ OMP_CLAUSE_REDUCTION);
OMP_CLAUSE_REDUCTION_CODE (c) = reduc->reduction_code;
OMP_CLAUSE_DECL (c) = SSA_NAME_VAR (gimple_assign_lhs (reduc->reduc_stmt));
struct reduction_info *const red = (struct reduction_info *) *slot;
tree const type = (tree) data;
tree var = SSA_NAME_VAR (gimple_assign_lhs (red->reduc_stmt));
- tree field = build_decl (FIELD_DECL, DECL_NAME (var), TREE_TYPE (var));
+ tree field = build_decl (gimple_location (red->reduc_stmt),
+ FIELD_DECL, DECL_NAME (var), TREE_TYPE (var));
insert_field_into_struct (type, field);
tree type = (tree) data;
tree name = ssa_name (elt->version);
tree var = SSA_NAME_VAR (name);
- tree field = build_decl (FIELD_DECL, DECL_NAME (var), TREE_TYPE (var));
+ tree field = build_decl (DECL_SOURCE_LOCATION (var),
+ FIELD_DECL, DECL_NAME (var), TREE_TYPE (var));
insert_field_into_struct (type, field);
elt->field = field;
{
/* Create the type for the structure to store the ssa names to. */
type = lang_hooks.types.make_type (RECORD_TYPE);
- type_name = build_decl (TYPE_DECL, create_tmp_var_name (".paral_data"),
+ type_name = build_decl (BUILTINS_LOCATION,
+ TYPE_DECL, create_tmp_var_name (".paral_data"),
type);
TYPE_NAME (type) = type_name;
name = get_identifier (tname);
type = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE);
- decl = build_decl (FUNCTION_DECL, name, type);
+ decl = build_decl (BUILTINS_LOCATION,
+ FUNCTION_DECL, name, type);
if (!parallelized_functions)
parallelized_functions = BITMAP_GGC_ALLOC ();
bitmap_set_bit (parallelized_functions, DECL_UID (decl));
DECL_CONTEXT (decl) = NULL_TREE;
DECL_INITIAL (decl) = make_node (BLOCK);
- t = build_decl (RESULT_DECL, NULL_TREE, void_type_node);
+ t = build_decl (BUILTINS_LOCATION,
+ RESULT_DECL, NULL_TREE, void_type_node);
DECL_ARTIFICIAL (t) = 1;
DECL_IGNORED_P (t) = 1;
DECL_RESULT (decl) = t;
- t = build_decl (PARM_DECL, get_identifier (".paral_data_param"),
+ t = build_decl (BUILTINS_LOCATION,
+ PARM_DECL, get_identifier (".paral_data_param"),
ptr_type_node);
DECL_ARTIFICIAL (t) = 1;
DECL_ARG_TYPE (t) = ptr_type_node;
paral_bb = single_pred (bb);
gsi = gsi_last_bb (paral_bb);
- t = build_omp_clause (OMP_CLAUSE_NUM_THREADS);
+ t = build_omp_clause (BUILTINS_LOCATION, OMP_CLAUSE_NUM_THREADS);
OMP_CLAUSE_NUM_THREADS_EXPR (t)
= build_int_cst (integer_type_node, n_threads);
stmt = gimple_build_omp_parallel (NULL, t, loop_fn, data);
/* Emit GIMPLE_OMP_FOR. */
gimple_cond_set_lhs (cond_stmt, cvar_base);
type = TREE_TYPE (cvar);
- t = build_omp_clause (OMP_CLAUSE_SCHEDULE);
+ t = build_omp_clause (BUILTINS_LOCATION, OMP_CLAUSE_SCHEDULE);
OMP_CLAUSE_SCHEDULE_KIND (t) = OMP_CLAUSE_SCHEDULE_STATIC;
for_stmt = gimple_build_omp_for (NULL, t, 1, NULL);
ptr_void = build_pointer_type (void_type_node);
ic_void_ptr_var
- = build_decl (VAR_DECL,
+ = build_decl (UNKNOWN_LOCATION, VAR_DECL,
get_identifier ("__gcov_indirect_call_callee"),
ptr_void);
TREE_STATIC (ic_void_ptr_var) = 1;
gcov_type_ptr = build_pointer_type (get_gcov_type ());
ic_gcov_type_ptr_var
- = build_decl (VAR_DECL,
+ = build_decl (UNKNOWN_LOCATION, VAR_DECL,
get_identifier ("__gcov_indirect_call_counters"),
gcov_type_ptr);
TREE_STATIC (ic_gcov_type_ptr_var) = 1;
if (!useless_type_conversion_p (TREE_TYPE (lhs),
TREE_TYPE (op0))
&& ((tem = maybe_fold_offset_to_address
- (op0, integer_zero_node, TREE_TYPE (lhs)))
+ (gimple_location (stmt),
+ op0, integer_zero_node, TREE_TYPE (lhs)))
!= NULL_TREE))
return tem;
return op0;
&& TREE_CODE (op1) == INTEGER_CST)
{
tree lhs = gimple_assign_lhs (stmt);
- tree tem = maybe_fold_offset_to_address (op0, op1,
- TREE_TYPE (lhs));
+ tree tem = maybe_fold_offset_to_address
+ (gimple_location (stmt), op0, op1, TREE_TYPE (lhs));
if (tem != NULL_TREE)
return tem;
}
/* A subroutine of fold_stmt. Attempts to fold *(A+O) to A[X].
BASE is an array type. OFFSET is a byte displacement. ORIG_TYPE
- is the desired result type. */
+ is the desired result type.
+
+ LOC is the location of the original expression. */
static tree
-maybe_fold_offset_to_array_ref (tree base, tree offset, tree orig_type,
+maybe_fold_offset_to_array_ref (location_t loc, tree base, tree offset,
+ tree orig_type,
bool allow_negative_idx)
{
tree min_idx, idx, idx_type, elt_offset = integer_zero_node;
&& compare_tree_int (idx, 0) < 0)
return NULL_TREE;
- return build4 (ARRAY_REF, elt_type, base, idx, NULL_TREE, NULL_TREE);
+ {
+ tree t = build4 (ARRAY_REF, elt_type, base, idx, NULL_TREE, NULL_TREE);
+ SET_EXPR_LOCATION (t, loc);
+ return t;
+ }
}
/* Attempt to fold *(S+O) to S.X.
BASE is a record type. OFFSET is a byte displacement. ORIG_TYPE
- is the desired result type. */
+ is the desired result type.
+
+ LOC is the location of the original expression. */
static tree
-maybe_fold_offset_to_component_ref (tree record_type, tree base, tree offset,
+maybe_fold_offset_to_component_ref (location_t loc, tree record_type,
+ tree base, tree offset,
tree orig_type, bool base_is_ptr)
{
tree f, t, field_type, tail_array_field, field_offset;
new_base = build1 (INDIRECT_REF, record_type, base);
else
new_base = base;
+ protected_set_expr_location (new_base, loc);
new_base = build3 (COMPONENT_REF, field_type, new_base, f, NULL_TREE);
+ protected_set_expr_location (new_base, loc);
/* Recurse to possibly find the match. */
- ret = maybe_fold_offset_to_array_ref (new_base, t, orig_type,
+ ret = maybe_fold_offset_to_array_ref (loc, new_base, t, orig_type,
f == TYPE_FIELDS (record_type));
if (ret)
return ret;
- ret = maybe_fold_offset_to_component_ref (field_type, new_base, t,
+ ret = maybe_fold_offset_to_component_ref (loc, field_type, new_base, t,
orig_type, false);
if (ret)
return ret;
/* If we get here, we've got an aggregate field, and a possibly
nonzero offset into them. Recurse and hope for a valid match. */
if (base_is_ptr)
- base = build1 (INDIRECT_REF, record_type, base);
+ {
+ base = build1 (INDIRECT_REF, record_type, base);
+ SET_EXPR_LOCATION (base, loc);
+ }
base = build3 (COMPONENT_REF, field_type, base, f, NULL_TREE);
+ SET_EXPR_LOCATION (base, loc);
- t = maybe_fold_offset_to_array_ref (base, offset, orig_type,
+ t = maybe_fold_offset_to_array_ref (loc, base, offset, orig_type,
f == TYPE_FIELDS (record_type));
if (t)
return t;
- return maybe_fold_offset_to_component_ref (field_type, base, offset,
+ return maybe_fold_offset_to_component_ref (loc, field_type, base, offset,
orig_type, false);
}
/* Attempt to express (ORIG_TYPE)BASE+OFFSET as BASE->field_of_orig_type
- or BASE[index] or by combination of those.
+ or BASE[index] or by combination of those.
+
+ LOC is the location of original expression.
Before attempting the conversion strip off existing ADDR_EXPRs and
handled component refs. */
tree
-maybe_fold_offset_to_reference (tree base, tree offset, tree orig_type)
+maybe_fold_offset_to_reference (location_t loc, tree base, tree offset,
+ tree orig_type)
{
tree ret;
tree type;
return NULL_TREE;
type = TREE_TYPE (TREE_TYPE (base));
}
- ret = maybe_fold_offset_to_component_ref (type, base, offset,
+ ret = maybe_fold_offset_to_component_ref (loc, type, base, offset,
orig_type, base_is_ptr);
if (!ret)
{
if (base_is_ptr)
- base = build1 (INDIRECT_REF, type, base);
- ret = maybe_fold_offset_to_array_ref (base, offset, orig_type, true);
+ {
+ base = build1 (INDIRECT_REF, type, base);
+ SET_EXPR_LOCATION (base, loc);
+ }
+ ret = maybe_fold_offset_to_array_ref (loc,
+ base, offset, orig_type, true);
}
return ret;
}
/* Attempt to express (ORIG_TYPE)&BASE+OFFSET as &BASE->field_of_orig_type
or &BASE[index] or by combination of those.
+ LOC is the location of the original expression.
+
Before attempting the conversion strip off existing component refs. */
tree
-maybe_fold_offset_to_address (tree addr, tree offset, tree orig_type)
+maybe_fold_offset_to_address (location_t loc, tree addr, tree offset,
+ tree orig_type)
{
tree t;
gcc_assert (POINTER_TYPE_P (TREE_TYPE (addr))
&& POINTER_TYPE_P (orig_type));
- t = maybe_fold_offset_to_reference (addr, offset, TREE_TYPE (orig_type));
+ t = maybe_fold_offset_to_reference (loc, addr, offset,
+ TREE_TYPE (orig_type));
if (t != NULL_TREE)
{
tree orig = addr;
ptr_type = build_pointer_type (TREE_TYPE (t));
if (!useless_type_conversion_p (orig_type, ptr_type))
return NULL_TREE;
- return build_fold_addr_expr_with_type (t, ptr_type);
+ t = build_fold_addr_expr_with_type (t, ptr_type);
+ protected_set_expr_location (t, loc);
+ return t;
}
return NULL_TREE;
{
tree t;
bool volatile_p = TREE_THIS_VOLATILE (expr);
+ location_t loc = EXPR_LOCATION (expr);
/* We may well have constructed a double-nested PLUS_EXPR via multiple
substitutions. Fold that down to one. Remove NON_LVALUE_EXPRs that
return DECL_INITIAL (base);
/* Try folding *(&B+O) to B.X. */
- t = maybe_fold_offset_to_reference (base_addr, offset,
+ t = maybe_fold_offset_to_reference (loc, base_addr, offset,
TREE_TYPE (expr));
if (t)
{
/* Try folding *(B+O) to B->X. Still an improvement. */
if (POINTER_TYPE_P (TREE_TYPE (base)))
{
- t = maybe_fold_offset_to_reference (base, offset,
+ t = maybe_fold_offset_to_reference (loc, base, offset,
TREE_TYPE (expr));
if (t)
return t;
which may be able to propagate further. */
tree
-maybe_fold_stmt_addition (tree res_type, tree op0, tree op1)
+maybe_fold_stmt_addition (location_t loc, tree res_type, tree op0, tree op1)
{
tree ptd_type;
tree t;
ptd_type = TREE_TYPE (TREE_TYPE (op0));
/* At which point we can try some of the same things as for indirects. */
- t = maybe_fold_offset_to_array_ref (op0, op1, ptd_type, true);
+ t = maybe_fold_offset_to_array_ref (loc, op0, op1, ptd_type, true);
if (!t)
- t = maybe_fold_offset_to_component_ref (TREE_TYPE (op0), op0, op1,
+ t = maybe_fold_offset_to_component_ref (loc, TREE_TYPE (op0), op0, op1,
ptd_type, false);
if (t)
- t = build1 (ADDR_EXPR, res_type, t);
+ {
+ t = build1 (ADDR_EXPR, res_type, t);
+ SET_EXPR_LOCATION (t, loc);
+ }
return t;
}
&& POINTER_TYPE_P (TREE_TYPE (gimple_assign_rhs1 (stmt))))
{
tree type = gimple_expr_type (stmt);
- tree t = maybe_fold_offset_to_address (gimple_assign_rhs1 (stmt),
+ tree t = maybe_fold_offset_to_address (gimple_location (stmt),
+ gimple_assign_rhs1 (stmt),
integer_zero_node, type);
if (t)
return t;
(TREE_TYPE (gimple_assign_lhs (stmt)), type))
type = TREE_TYPE (gimple_assign_rhs1 (stmt));
}
- result = maybe_fold_stmt_addition (type,
+ result = maybe_fold_stmt_addition (gimple_location (stmt),
+ type,
gimple_assign_rhs1 (stmt),
gimple_assign_rhs2 (stmt));
}
of the elements in X into &x[C1 + C2/element size]. */
if (TREE_CODE (rhs2) == INTEGER_CST)
{
- tree new_rhs = maybe_fold_stmt_addition (TREE_TYPE (def_rhs),
+ tree new_rhs = maybe_fold_stmt_addition (gimple_location (use_stmt),
+ TREE_TYPE (def_rhs),
def_rhs, rhs2);
if (new_rhs)
{
gcc_assert (cfun->gimple_df->vop == NULL_TREE);
- global_var = build_decl (VAR_DECL, get_identifier (".MEM"),
+ global_var = build_decl (BUILTINS_LOCATION, VAR_DECL,
+ get_identifier (".MEM"),
void_type_node);
DECL_ARTIFICIAL (global_var) = 1;
TREE_READONLY (global_var) = 0;
if (xloc.file != floc.file
|| xloc.line < floc.line
|| xloc.line > LOCATION_LINE (cfun->function_end_locus))
- inform (input_location, "%J%qD was declared here", var, var);
+ inform (location, "%J%qD was declared here", var, var);
}
}
tree name, cst;
gimple load;
gimple_stmt_iterator gsi = gsi_for_stmt (swtch);
+ location_t loc = gimple_location (swtch);
gcc_assert (info.default_values[num]);
ctor = build_constructor (array_type, info.constructors[num]);
TREE_CONSTANT (ctor) = true;
- decl = build_decl (VAR_DECL, NULL_TREE, array_type);
+ decl = build_decl (loc, VAR_DECL, NULL_TREE, array_type);
TREE_STATIC (decl) = 1;
DECL_INITIAL (decl) = ctor;
static void
gen_inbound_check (gimple swtch)
{
- tree label_decl1 = create_artificial_label ();
- tree label_decl2 = create_artificial_label ();
- tree label_decl3 = create_artificial_label ();
+ tree label_decl1 = create_artificial_label (UNKNOWN_LOCATION);
+ tree label_decl2 = create_artificial_label (UNKNOWN_LOCATION);
+ tree label_decl3 = create_artificial_label (UNKNOWN_LOCATION);
gimple label1, label2, label3;
tree utype;
IGNORE_OFF_BY_ONE is true if the ARRAY_REF is inside a ADDR_EXPR. */
static void
-check_array_ref (tree ref, location_t location, bool ignore_off_by_one)
+check_array_ref (location_t location, tree ref, bool ignore_off_by_one)
{
value_range_t* vr = NULL;
tree low_sub, up_sub;
do
{
if (TREE_CODE (t) == ARRAY_REF)
- check_array_ref (t, location, true /*ignore_off_by_one*/);
+ check_array_ref (location, t, true /*ignore_off_by_one*/);
t = TREE_OPERAND (t, 0);
}
{
tree t = *tp;
struct walk_stmt_info *wi = (struct walk_stmt_info *) data;
- const location_t *location = (const location_t *) wi->info;
+ location_t location;
+
+ if (EXPR_HAS_LOCATION (t))
+ location = EXPR_LOCATION (t);
+ else
+ {
+ location_t *locp = (location_t *) wi->info;
+ location = *locp;
+ }
*walk_subtree = TRUE;
if (TREE_CODE (t) == ARRAY_REF)
- check_array_ref (t, *location, false /*ignore_off_by_one*/);
+ check_array_ref (location, t, false /*ignore_off_by_one*/);
if (TREE_CODE (t) == INDIRECT_REF
|| (TREE_CODE (t) == RETURN_EXPR && TREE_OPERAND (t, 0)))
- search_for_addr_array (TREE_OPERAND (t, 0), *location);
+ search_for_addr_array (TREE_OPERAND (t, 0), location);
if (TREE_CODE (t) == ADDR_EXPR)
*walk_subtree = FALSE;
return t;
t = build1 (SAVE_EXPR, TREE_TYPE (expr), t);
+ SET_EXPR_LOCATION (t, EXPR_LOCATION (expr));
/* This expression might be placed ahead of a jump to ensure that the
value was computed on both sides of the jump. So make sure it isn't
/* Create a DECL_... node of code CODE, name NAME and data type TYPE.
We do NOT enter this node in any sort of symbol table.
+ LOC is the location of the decl.
+
layout_decl is used to set up the decl's storage layout.
Other slots are initialized to 0 or null pointers. */
tree
-build_decl_stat (enum tree_code code, tree name, tree type MEM_STAT_DECL)
+build_decl_stat (location_t loc, enum tree_code code, tree name,
+ tree type MEM_STAT_DECL)
{
tree t;
t = make_node_stat (code PASS_MEM_STAT);
+ DECL_SOURCE_LOCATION (t) = loc;
/* if (type == error_mark_node)
type = integer_type_node; */
build_fn_decl (const char *name, tree type)
{
tree id = get_identifier (name);
- tree decl = build_decl (FUNCTION_DECL, id, type);
+ tree decl = build_decl (input_location, FUNCTION_DECL, id, type);
DECL_EXTERNAL (decl) = 1;
TREE_PUBLIC (decl) = 1;
name = 0;
if (name != 0)
- TYPE_NAME (t) = build_decl (TYPE_DECL, get_identifier (name), t);
+ TYPE_NAME (t) = build_decl (UNKNOWN_LOCATION, TYPE_DECL,
+ get_identifier (name), t);
}
return build_qualified_type (t, TYPE_QUALS (component_type));
build_index_type (index));
tree rt = make_node (RECORD_TYPE);
- TYPE_FIELDS (rt) = build_decl (FIELD_DECL, get_identifier ("f"), array);
+ TYPE_FIELDS (rt) = build_decl (UNKNOWN_LOCATION, FIELD_DECL,
+ get_identifier ("f"), array);
DECL_CONTEXT (TYPE_FIELDS (rt)) = rt;
layout_type (rt);
TYPE_DEBUG_REPRESENTATION_TYPE (t) = rt;
}
}
-/* Build an empty statement. */
+/* Build an empty statement at location LOC. */
tree
-build_empty_stmt (void)
+build_empty_stmt (location_t loc)
{
- return build1 (NOP_EXPR, void_type_node, size_zero_node);
+ tree t = build1 (NOP_EXPR, void_type_node, size_zero_node);
+ SET_EXPR_LOCATION (t, loc);
+ return t;
}
-/* Build an OpenMP clause with code CODE. */
+/* Build an OpenMP clause with code CODE. LOC is the location of the
+ clause. */
tree
-build_omp_clause (enum omp_clause_code code)
+build_omp_clause (location_t loc, enum omp_clause_code code)
{
tree t;
int size, length;
memset (t, 0, size);
TREE_SET_CODE (t, OMP_CLAUSE);
OMP_CLAUSE_SET_CODE (t, code);
+ OMP_CLAUSE_LOCATION (t) = loc;
#ifdef GATHER_STATISTICS
tree_node_counts[(int) omp_clause_kind]++;
}
-/* Create a nameless artificial label and put it in the current function
- context. Returns the newly created label. */
+/* Create a nameless artificial label and put it in the current
+ function context. The label has a location of LOC. Returns the
+ newly created label. */
tree
-create_artificial_label (void)
+create_artificial_label (location_t loc)
{
- tree lab = build_decl (LABEL_DECL, NULL_TREE, void_type_node);
+ tree lab = build_decl (loc,
+ LABEL_DECL, NULL_TREE, void_type_node);
DECL_ARTIFICIAL (lab) = 1;
DECL_IGNORED_P (lab) = 1;
/* True if a tree is an expression or statement that can have a
location. */
-#define CAN_HAVE_LOCATION_P(NODE) (EXPR_P (NODE))
+#define CAN_HAVE_LOCATION_P(NODE) ((NODE) && EXPR_P (NODE))
extern void protected_set_expr_location (tree, location_t);
OMP_CLAUSE_OPERAND (OMP_CLAUSE_RANGE_CHECK (OMP_CLAUSE_CHECK (NODE), \
OMP_CLAUSE_PRIVATE, \
OMP_CLAUSE_COPYPRIVATE), 0)
+#define OMP_CLAUSE_HAS_LOCATION(NODE) \
+ ((OMP_CLAUSE_CHECK (NODE))->omp_clause.locus != UNKNOWN_LOCATION)
+#define OMP_CLAUSE_LOCATION(NODE) (OMP_CLAUSE_CHECK (NODE))->omp_clause.locus
/* True on an OMP_SECTION statement that was the last lexical member.
This status is meaningful in the implementation of lastprivate. */
struct GTY(()) tree_omp_clause {
struct tree_common common;
+ location_t locus;
enum omp_clause_code code;
union omp_clause_subcode {
enum omp_clause_default_kind default_kind;
#define build_tree_list(t,q) build_tree_list_stat(t,q MEM_STAT_INFO)
extern tree build_tree_list_vec_stat (const VEC(tree,gc) * MEM_STAT_DECL);
#define build_tree_list_vec(v) build_tree_list_vec_stat (v MEM_STAT_INFO)
-extern tree build_decl_stat (enum tree_code, tree, tree MEM_STAT_DECL);
+extern tree build_decl_stat (location_t, enum tree_code,
+ tree, tree MEM_STAT_DECL);
extern tree build_fn_decl (const char *, tree);
-#define build_decl(c,t,q) build_decl_stat (c,t,q MEM_STAT_INFO)
+#define build_decl(l,c,t,q) build_decl_stat (l,c,t,q MEM_STAT_INFO)
extern tree build_block (tree, tree, tree, tree);
-extern tree build_empty_stmt (void);
-extern tree build_omp_clause (enum omp_clause_code);
+extern tree build_empty_stmt (location_t);
+extern tree build_omp_clause (location_t, enum omp_clause_code);
extern tree build_vl_exp_stat (enum tree_code, int MEM_STAT_DECL);
#define build_vl_exp(c,n) build_vl_exp_stat (c,n MEM_STAT_INFO)
extern tree call_expr_arg (tree, int);
extern tree *call_expr_argp (tree, int);
extern tree call_expr_arglist (tree);
-extern tree create_artificial_label (void);
+extern tree create_artificial_label (location_t);
extern const char *get_name (tree);
extern bool stdarg_p (tree);
extern bool prototype_p (tree);
#define tree_priority_map_marked_p tree_map_base_marked_p
/* In tree-ssa-ccp.c */
-extern tree maybe_fold_offset_to_reference (tree, tree, tree);
-extern tree maybe_fold_offset_to_address (tree, tree, tree);
-extern tree maybe_fold_stmt_addition (tree, tree, tree);
+extern tree maybe_fold_offset_to_reference (location_t, tree, tree, tree);
+extern tree maybe_fold_offset_to_address (location_t, tree, tree, tree);
+extern tree maybe_fold_stmt_addition (location_t, tree, tree, tree);
/* In tree-ssa-address.c. */
extern tree tree_mem_ref_addr (tree, tree);
{
tree word_type_node, field, next_field;
- field = build_decl (FIELD_DECL, get_identifier ("__templ"), ptr_type_node);
+ field = build_decl (UNKNOWN_LOCATION,
+ FIELD_DECL, get_identifier ("__templ"), ptr_type_node);
DECL_CONTEXT (field) = type;
next_field = field;
- field = build_decl (FIELD_DECL, get_identifier ("__offset"),
+ field = build_decl (UNKNOWN_LOCATION,
+ FIELD_DECL, get_identifier ("__offset"),
ptr_type_node);
DECL_CONTEXT (field) = type;
TREE_CHAIN (field) = next_field;
next_field = field;
word_type_node = lang_hooks.types.type_for_mode (word_mode, 1);
- field = build_decl (FIELD_DECL, get_identifier ("__align"),
+ field = build_decl (UNKNOWN_LOCATION,
+ FIELD_DECL, get_identifier ("__align"),
word_type_node);
DECL_CONTEXT (field) = type;
TREE_CHAIN (field) = next_field;
next_field = field;
- field = build_decl (FIELD_DECL, get_identifier ("__size"), word_type_node);
+ field = build_decl (UNKNOWN_LOCATION,
+ FIELD_DECL, get_identifier ("__size"), word_type_node);
DECL_CONTEXT (field) = type;
TREE_CHAIN (field) = next_field;
field = targetm.emutls.var_fields (type, &type_name);
if (!type_name)
type_name = get_identifier ("__emutls_object");
- type_name = build_decl (TYPE_DECL, type_name, type);
+ type_name = build_decl (UNKNOWN_LOCATION,
+ TYPE_DECL, type_name, type);
TYPE_NAME (type) = type_name;
TYPE_FIELDS (type) = field;
layout_type (type);
name = prefix_name (prefix, name);
}
- to = build_decl (VAR_DECL, name, TREE_TYPE (decl));
+ to = build_decl (DECL_SOURCE_LOCATION (decl),
+ VAR_DECL, name, TREE_TYPE (decl));
SET_DECL_ASSEMBLER_NAME (to, DECL_NAME (to));
DECL_TLS_MODEL (to) = TLS_MODEL_EMULATED;
DECL_ARTIFICIAL (to) = 1;
to = h->to;
else
{
- to = build_decl (VAR_DECL, get_emutls_object_name (name),
+ to = build_decl (DECL_SOURCE_LOCATION (decl),
+ VAR_DECL, get_emutls_object_name (name),
get_emutls_object_type ());
h = GGC_NEW (struct tree_map);
if (! decl)
{
- decl = build_decl (TREE_CODE (alias_decl), target,
+ decl = build_decl (DECL_SOURCE_LOCATION (alias_decl),
+ TREE_CODE (alias_decl), target,
TREE_TYPE (alias_decl));
DECL_EXTERNAL (decl) = 1;