From 7e2af53a14ce4710e1dca754acf603db0f9d8802 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Sun, 21 Sep 2003 16:39:40 -0700 Subject: [PATCH] tree.h (TREE_LOCUS): Rename from DECL_SOURCE_LOCATION; make const. * tree.h (TREE_LOCUS): Rename from DECL_SOURCE_LOCATION; make const. (TREE_FILENAME, TREE_LINENO): Likewise. (set_tree_locus, copy_tree_locus, set_tree_file_line): New. (TREE_LOCUS_SET_P): New. * c-aux-info.c, c-decl.c, c-parse.in, coverage.c, dbxout.c, diagnostic.c, dwarf2out.c, dwarfout.c, function.c, integrate.c, print-tree.c, stmt.c, toplev.c, tree-dump.c, tree-inline.c, tree-optimize.c, tree.c, tree.def, xcoffout.c, config/alpha/alpha.c, config/mips/mips.c, doc/c-tree.texi, objc/objc-act.c: Update to match. ada/ * trans.c, utils.c: Update for DECL_SOURCE_LOCATION rename and change to const. cp/ * class.c, cp-tree.h, decl.c, decl2.c, error.c, init.c, method.c, optimize.c, pt.c, semantics.c, tree.c: Update for DECL_SOURCE_LOCATION rename and change to const. f/ * com.c, ste.c: Update for DECL_SOURCE_LOCATION rename and change to const. java/ * class.c, decl.c, jcf-parse.c, jcf-write.c, parse.y, resource.c: Update for DECL_SOURCE_LOCATION rename and change to const. treelang/ * treetree.c: Update for DECL_SOURCE_LOCATION rename and change to const. From-SVN: r71636 --- gcc/ChangeLog | 12 ++++++++++++ gcc/ada/ChangeLog | 5 +++++ gcc/ada/trans.c | 4 ++-- gcc/ada/utils.c | 6 +++--- gcc/c-aux-info.c | 4 ++-- gcc/c-decl.c | 24 ++++++++++-------------- gcc/c-parse.in | 10 +++++----- gcc/config/alpha/alpha.c | 6 ++---- gcc/config/mips/mips.c | 4 ++-- gcc/coverage.c | 8 ++++---- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/class.c | 2 +- gcc/cp/cp-tree.h | 2 +- gcc/cp/decl.c | 21 ++++++++++----------- gcc/cp/decl2.c | 2 +- gcc/cp/error.c | 2 +- gcc/cp/init.c | 2 +- gcc/cp/method.c | 2 +- gcc/cp/optimize.c | 4 ++-- gcc/cp/pt.c | 32 ++++++++++++++------------------ gcc/cp/semantics.c | 2 +- gcc/cp/tree.c | 2 +- gcc/dbxout.c | 4 ++-- gcc/diagnostic.c | 2 +- gcc/doc/c-tree.texi | 4 ++-- gcc/dwarf2out.c | 20 ++++++++++---------- gcc/dwarfout.c | 6 +++--- gcc/f/ChangeLog | 5 +++++ gcc/f/com.c | 7 +++---- gcc/f/ste.c | 4 ++-- gcc/function.c | 4 ++-- gcc/integrate.c | 4 ++-- gcc/java/ChangeLog | 5 +++++ gcc/java/class.c | 11 +++++------ gcc/java/decl.c | 5 ++--- gcc/java/jcf-parse.c | 10 ++++++---- gcc/java/jcf-write.c | 4 ++-- gcc/java/parse.y | 31 +++++++++++++++---------------- gcc/java/resource.c | 3 +-- gcc/objc/objc-act.c | 12 +++++------- gcc/print-tree.c | 2 +- gcc/stmt.c | 2 +- gcc/toplev.c | 6 +++--- gcc/tree-dump.c | 8 ++++---- gcc/tree-inline.c | 4 ++-- gcc/tree-optimize.c | 2 +- gcc/tree.c | 2 +- gcc/tree.def | 2 +- gcc/tree.h | 30 +++++++++++++++++++++++------- gcc/treelang/ChangeLog | 5 +++++ gcc/treelang/treetree.c | 13 +++++++------ gcc/xcoffout.c | 2 +- 52 files changed, 210 insertions(+), 171 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c14137bb437..a288901d290 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2003-09-21 Richard Henderson + + * tree.h (TREE_LOCUS): Rename from DECL_SOURCE_LOCATION; make const. + (TREE_FILENAME, TREE_LINENO): Likewise. + (set_tree_locus, copy_tree_locus, set_tree_file_line): New. + (TREE_LOCUS_SET_P): New. + * c-aux-info.c, c-decl.c, c-parse.in, coverage.c, dbxout.c, + diagnostic.c, dwarf2out.c, dwarfout.c, function.c, integrate.c, + print-tree.c, stmt.c, toplev.c, tree-dump.c, tree-inline.c, + tree-optimize.c, tree.c, tree.def, xcoffout.c, config/alpha/alpha.c, + config/mips/mips.c, doc/c-tree.texi, objc/objc-act.c: Update to match. + 2003-09-21 Nathanael Nerode * config/vax/vax-protos.h: Convert to ISO C90. diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 2dfbc3717b9..51ba6b4783d 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2003-09-21 Richard Henderson + + * trans.c, utils.c: Update for DECL_SOURCE_LOCATION rename and + change to const. + 2003-09-04 Michael Matz * misc.c: Include "target.h". diff --git a/gcc/ada/trans.c b/gcc/ada/trans.c index 8e6f9ac4e49..889b267cd17 100644 --- a/gcc/ada/trans.c +++ b/gcc/ada/trans.c @@ -2611,7 +2611,7 @@ tree_transform (gnat_node) the body so that the line number notes are written correctly. */ set_lineno (gnat_node, 0); - DECL_SOURCE_LOCATION (gnu_subprog_decl) = input_location; + set_tree_locus (gnu_subprog_decl, input_location); begin_subprog_body (gnu_subprog_decl); set_lineno (gnat_node, 1); @@ -5333,7 +5333,7 @@ build_unit_elab (gnat_unit, body_p, gnu_elab_list) { tree lhs = TREE_PURPOSE (gnu_elab_list); - input_location = DECL_SOURCE_LOCATION (lhs); + input_location = TREE_LOCUS (lhs); /* If LHS has a padded type, convert it to the unpadded type so the assignment is done properly. */ diff --git a/gcc/ada/utils.c b/gcc/ada/utils.c index 186b0fdb175..eddfb320011 100644 --- a/gcc/ada/utils.c +++ b/gcc/ada/utils.c @@ -1655,9 +1655,9 @@ create_label_decl (label_name) { tree label_decl = build_decl (LABEL_DECL, label_name, void_type_node); - DECL_CONTEXT (label_decl) = current_function_decl; - DECL_MODE (label_decl) = VOIDmode; - DECL_SOURCE_LOCATION (label_decl) = input_location; + DECL_CONTEXT (label_decl) = current_function_decl; + DECL_MODE (label_decl) = VOIDmode; + set_tree_locus (label_decl, input_location); return label_decl; } diff --git a/gcc/c-aux-info.c b/gcc/c-aux-info.c index e785ade2239..0a14839a357 100644 --- a/gcc/c-aux-info.c +++ b/gcc/c-aux-info.c @@ -569,8 +569,8 @@ gen_aux_info_record (tree fndecl, int is_definition, int is_implicit, /* Write the actual line of auxiliary info. */ fprintf (aux_info_file, "/* %s:%d:%c%c */ %s;", - DECL_SOURCE_FILE (fndecl), - DECL_SOURCE_LINE (fndecl), + TREE_FILENAME (fndecl), + TREE_LINENO (fndecl), (is_implicit) ? 'I' : (is_prototyped) ? 'N' : 'O', (is_definition) ? 'F' : 'C', gen_decl (fndecl, is_definition, ansi)); diff --git a/gcc/c-decl.c b/gcc/c-decl.c index db35f9a9ea9..f58f5601d9e 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -905,8 +905,7 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, return 0; } } - else if (TREE_CODE (olddecl) == FUNCTION_DECL - && DECL_SOURCE_LINE (olddecl) == 0) + else if (TREE_CODE (olddecl) == FUNCTION_DECL && !TREE_LOCUS_SET_P (olddecl)) { /* A function declaration for a predeclared function that isn't actually built in. */ @@ -1175,7 +1174,7 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, } /* Optionally warn about more than one declaration for the same name. */ - if (errmsg == 0 && warn_redundant_decls && DECL_SOURCE_LINE (olddecl) != 0 + if (errmsg == 0 && warn_redundant_decls && TREE_LOCUS_SET_P (olddecl) /* Don't warn about a function declaration followed by a definition. */ && !(TREE_CODE (newdecl) == FUNCTION_DECL && DECL_INITIAL (newdecl) != 0 @@ -1272,10 +1271,7 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, information so that meaningful diagnostics can be given. */ if (DECL_INITIAL (newdecl) == 0 && DECL_INITIAL (olddecl) != 0 && ! different_binding_level) - { - DECL_SOURCE_LINE (newdecl) = DECL_SOURCE_LINE (olddecl); - DECL_SOURCE_FILE (newdecl) = DECL_SOURCE_FILE (olddecl); - } + copy_tree_locus (newdecl, olddecl); /* Merge the unused-warning information. */ if (DECL_IN_SYSTEM_HEADER (olddecl)) @@ -1525,7 +1521,7 @@ warn_if_shadowing (tree x, tree old) /* Shadow warnings not wanted? */ || !warn_shadow /* No shadow warnings for internally generated vars. */ - || DECL_SOURCE_LINE (x) == 0 + || !TREE_LOCUS_SET_P (x) /* No shadow warnings for vars made for inlining. */ || DECL_FROM_INLINE (x) /* Don't warn about the parm names in function declarator @@ -1593,7 +1589,7 @@ warn_if_shadowing (tree x, tree old) static void clone_underlying_type (tree x) { - if (DECL_SOURCE_LINE (x) == 0) + if (!TREE_LOCUS_SET_P (x)) { if (TYPE_NAME (TREE_TYPE (x)) == 0) TYPE_NAME (TREE_TYPE (x)) = x; @@ -1948,7 +1944,7 @@ make_label (tree name, location_t location) DECL_CONTEXT (label) = current_function_decl; DECL_MODE (label) = VOIDmode; - DECL_SOURCE_LOCATION (label) = location; + set_tree_locus (label, location); return label; } @@ -1995,7 +1991,7 @@ lookup_label (tree name) location to point here, for better diagnostics if it turns out not to have been defined. */ if (!TREE_USED (label)) - DECL_SOURCE_LOCATION (label) = input_location; + set_tree_locus (label, input_location); return label; } @@ -2074,7 +2070,7 @@ define_label (location_t location, tree name) /* The label has been used or declared already in this function, but not defined. Update its location to point to this definition. */ - DECL_SOURCE_LOCATION (label) = location; + set_tree_locus (label, location); } else { @@ -5462,7 +5458,7 @@ start_function (tree declspecs, tree declarator, tree attributes) && TYPE_ARG_TYPES (TREE_TYPE (decl1)) == 0) { TREE_TYPE (decl1) = TREE_TYPE (old_decl); - current_function_prototype_locus = DECL_SOURCE_LOCATION (old_decl); + current_function_prototype_locus = TREE_LOCUS (old_decl); } /* Optionally warn of old-fashioned def with no previous prototype. */ @@ -5755,7 +5751,7 @@ store_parm_decls_oldstyle (void) { decl = build_decl (PARM_DECL, TREE_VALUE (parm), integer_type_node); DECL_ARG_TYPE (decl) = TREE_TYPE (decl); - DECL_SOURCE_LOCATION (decl) = DECL_SOURCE_LOCATION (fndecl); + copy_tree_locus (decl, fndecl); pushdecl (decl); if (flag_isoc99) diff --git a/gcc/c-parse.in b/gcc/c-parse.in index bb9cc1a7703..35825461b33 100644 --- a/gcc/c-parse.in +++ b/gcc/c-parse.in @@ -414,7 +414,7 @@ fndef: YYERROR1; } old_style_parm_decls save_location - { DECL_SOURCE_LOCATION (current_function_decl) = $6; + { set_tree_locus (current_function_decl, $6); store_parm_decls (); } compstmt_or_error { finish_function (); @@ -427,7 +427,7 @@ fndef: YYERROR1; } old_style_parm_decls save_location - { DECL_SOURCE_LOCATION (current_function_decl) = $6; + { set_tree_locus (current_function_decl, $6); store_parm_decls (); } compstmt_or_error { finish_function (); @@ -440,7 +440,7 @@ fndef: YYERROR1; } old_style_parm_decls save_location - { DECL_SOURCE_LOCATION (current_function_decl) = $5; + { set_tree_locus (current_function_decl, $5); store_parm_decls (); } compstmt_or_error { finish_function (); @@ -1563,7 +1563,7 @@ nested_function: } old_style_parm_decls save_location { tree decl = current_function_decl; - DECL_SOURCE_LOCATION (decl) = $4; + set_tree_locus (decl, $4); store_parm_decls (); } /* This used to use compstmt_or_error. That caused a bug with input `f(g) int g {}', @@ -1594,7 +1594,7 @@ notype_nested_function: } old_style_parm_decls save_location { tree decl = current_function_decl; - DECL_SOURCE_LOCATION (decl) = $4; + set_tree_locus (decl, $4); store_parm_decls (); } /* This used to use compstmt_or_error. That caused a bug with input `f(g) int g {}', diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index 72d01af2f15..4b32ca0a907 100644 --- a/gcc/config/alpha/alpha.c +++ b/gcc/config/alpha/alpha.c @@ -7349,13 +7349,11 @@ alpha_start_function (FILE *file, const char *fnname, if (write_symbols == SDB_DEBUG) { #ifdef ASM_OUTPUT_SOURCE_FILENAME - ASM_OUTPUT_SOURCE_FILENAME (file, - DECL_SOURCE_FILE (current_function_decl)); + ASM_OUTPUT_SOURCE_FILENAME (file, TREE_FILENAME (current_function_decl)); #endif #ifdef ASM_OUTPUT_SOURCE_LINE if (debug_info_level != DINFO_LEVEL_TERSE) - ASM_OUTPUT_SOURCE_LINE (file, - DECL_SOURCE_LINE (current_function_decl), 0); + ASM_OUTPUT_SOURCE_LINE (file, TREE_LINENO (current_function_decl), 0); #endif } diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index 8bd2139d9ef..307027ed56f 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -6507,11 +6507,11 @@ mips_output_function_prologue (FILE *file, HOST_WIDE_INT size ATTRIBUTE_UNUSED) need the source filename more than once in the file, beyond what is emitted by the debug information. */ if (!TARGET_GAS) - ASM_OUTPUT_SOURCE_FILENAME (file, DECL_SOURCE_FILE (current_function_decl)); + ASM_OUTPUT_SOURCE_FILENAME (file, TREE_FILENAME (current_function_decl)); #ifdef SDB_DEBUGGING_INFO if (debug_info_level != DINFO_LEVEL_TERSE && write_symbols == SDB_DEBUG) - ASM_OUTPUT_SOURCE_LINE (file, DECL_SOURCE_LINE (current_function_decl), 0); + ASM_OUTPUT_SOURCE_LINE (file, TREE_LINENO (current_function_decl), 0); #endif /* In mips16 mode, we may need to generate a 32 bit to handle diff --git a/gcc/coverage.c b/gcc/coverage.c index e6f4129dd79..dc10206cef8 100644 --- a/gcc/coverage.c +++ b/gcc/coverage.c @@ -410,9 +410,9 @@ checksum_string (unsigned chksum, const char *string) static unsigned compute_checksum (void) { - unsigned chksum = DECL_SOURCE_LINE (current_function_decl); + unsigned chksum = TREE_LINENO (current_function_decl); - chksum = checksum_string (chksum, DECL_SOURCE_FILE (current_function_decl)); + chksum = checksum_string (chksum, TREE_FILENAME (current_function_decl)); chksum = checksum_string (chksum, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl))); @@ -432,8 +432,8 @@ coverage_begin_output (void) if (!bbg_function_announced) { - const char *file = DECL_SOURCE_FILE (current_function_decl); - unsigned line = DECL_SOURCE_LINE (current_function_decl); + const char *file = TREE_FILENAME (current_function_decl); + unsigned line = TREE_LINENO (current_function_decl); unsigned long offset; if (!bbg_file_opened) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2734bf6f4d4..19c3c481343 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-09-21 Richard Henderson + + * class.c, cp-tree.h, decl.c, decl2.c, error.c, init.c, + method.c, optimize.c, pt.c, semantics.c, tree.c: Update for + DECL_SOURCE_LOCATION rename and change to const. + 2003-09-20 Richard Henderson * decl.c, decl2.c, pt.c: Use %J in diagnostics. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 17ff0e49674..ebcad8041a5 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5212,7 +5212,7 @@ finish_struct (tree t, tree attributes) /* Nadger the current location so that diagnostics point to the start of the struct, not the end. */ - input_location = DECL_SOURCE_LOCATION (TYPE_NAME (t)); + input_location = TREE_LOCUS (TYPE_NAME (t)); if (processing_template_decl) { diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index ef38d5565d8..8f931aa05b1 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -390,7 +390,7 @@ typedef enum cp_id_kind /* The IDENTIFIER_VALUE is the value of the IDENTIFIER_BINDING, or NULL_TREE if there is no binding. */ #define IDENTIFIER_VALUE(NODE) \ - (IDENTIFIER_BINDING (NODE) ? IDENTIFIER_BINDING (NODE)->value : NULL) + (IDENTIFIER_BINDING (NODE) ? IDENTIFIER_BINDING (NODE)->value : NULL_TREE) /* If IDENTIFIER_CLASS_VALUE is set, then NODE is bound in the current class, and IDENTIFIER_CLASS_VALUE is the value binding. This is diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 892affacc82..376d8de10de 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1787,7 +1787,7 @@ print_binding_level (struct cp_binding_level* lvl) continue; if (no_print_builtins && (TREE_CODE (t) == TYPE_DECL) - && (!strcmp (DECL_SOURCE_FILE (t),""))) + && (!strcmp (TREE_FILENAME (t), ""))) continue; /* Function decls tend to have longer names. */ @@ -3153,9 +3153,8 @@ duplicate_decls (tree newdecl, tree olddecl) if (DECL_INITIAL (DECL_TEMPLATE_RESULT (olddecl)) == NULL_TREE && DECL_INITIAL (DECL_TEMPLATE_RESULT (newdecl)) != NULL_TREE) { - DECL_SOURCE_LOCATION (olddecl) - = DECL_SOURCE_LOCATION (DECL_TEMPLATE_RESULT (olddecl)) - = DECL_SOURCE_LOCATION (newdecl); + copy_tree_locus (olddecl, newdecl); + copy_tree_locus (DECL_TEMPLATE_RESULT (olddecl), newdecl); } return 1; @@ -3195,13 +3194,13 @@ duplicate_decls (tree newdecl, tree olddecl) TYPE_RAISES_EXCEPTIONS (oldtype)); if ((pedantic || ! DECL_IN_SYSTEM_HEADER (olddecl)) - && DECL_SOURCE_LINE (olddecl) != 0 + && TREE_LOCUS_SET_P (olddecl) && flag_exceptions && !comp_except_specs (TYPE_RAISES_EXCEPTIONS (TREE_TYPE (newdecl)), TYPE_RAISES_EXCEPTIONS (TREE_TYPE (olddecl)), 1)) { error ("declaration of `%F' throws different exceptions", - newdecl); + newdecl); cp_error_at ("than previous declaration `%F'", olddecl); } } @@ -3232,7 +3231,7 @@ duplicate_decls (tree newdecl, tree olddecl) && DECL_INITIAL (olddecl) != NULL_TREE) { DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl); - DECL_SOURCE_LOCATION (newdecl) = DECL_SOURCE_LOCATION (olddecl); + copy_tree_locus (newdecl, olddecl); if (CAN_HAVE_FULL_LANG_DECL_P (newdecl) && DECL_LANG_SPECIFIC (newdecl) && DECL_LANG_SPECIFIC (olddecl)) @@ -3701,7 +3700,7 @@ pushdecl (tree x) if (TREE_CODE (x) == TYPE_DECL) { tree type = TREE_TYPE (x); - if (DECL_SOURCE_LINE (x) == 0) + if (!TREE_LOCUS_SET_P (x)) { if (TYPE_NAME (type) == 0) TYPE_NAME (type) = x; @@ -4075,7 +4074,7 @@ pushdecl_class_level (tree x) for (f = TYPE_FIELDS (TREE_TYPE (x)); f; f = TREE_CHAIN (f)) { location_t save_location = input_location; - input_location = DECL_SOURCE_LOCATION (f); + input_location = TREE_LOCUS (f); if (!pushdecl_class_level (f)) is_valid = false; input_location = save_location; @@ -4520,7 +4519,7 @@ make_label_decl (tree id, int local_p) /* Say where one reference is to the label, for the sake of the error if it is not defined. */ - DECL_SOURCE_LOCATION (decl) = input_location; + set_tree_locus (decl, input_location); /* Record the fact that this identifier is bound to this label. */ SET_IDENTIFIER_LABEL_VALUE (id, decl); @@ -4831,7 +4830,7 @@ define_label (location_t location, tree name) /* Mark label as having been defined. */ DECL_INITIAL (decl) = error_mark_node; /* Say where in the source. */ - DECL_SOURCE_LOCATION (decl) = location; + set_tree_locus (decl, location); if (ent) { ent->names_in_scope = current_binding_level->names; diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index b1ee970464e..084cc9b1021 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -2240,7 +2240,7 @@ start_static_initialization_or_destruction (tree decl, int initp) where DECL was declared so that error-messages make sense, and so that the debugger will show somewhat sensible file and line information. */ - input_location = DECL_SOURCE_LOCATION (decl); + input_location = TREE_LOCUS (decl); /* Because of: diff --git a/gcc/cp/error.c b/gcc/cp/error.c index a10dcf6a876..74d1218af1e 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1959,7 +1959,7 @@ location_of (tree t) else if (TREE_CODE (t) == OVERLOAD) t = OVL_FUNCTION (t); - return DECL_SOURCE_LOCATION (t); + return TREE_LOCUS (t); } /* Now the interfaces from error et al to dump_type et al. Each takes an diff --git a/gcc/cp/init.c b/gcc/cp/init.c index ace82cdc39f..4427754ea40 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -2414,9 +2414,9 @@ create_temporary_var (tree type) decl = build_decl (VAR_DECL, NULL_TREE, type); TREE_USED (decl) = 1; DECL_ARTIFICIAL (decl) = 1; - DECL_SOURCE_LOCATION (decl) = input_location; DECL_IGNORED_P (decl) = 1; DECL_CONTEXT (decl) = current_function_decl; + set_tree_locus (decl, input_location); return decl; } diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 52770042bee..b5d5e327770 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -719,7 +719,7 @@ synthesize_method (tree fndecl) where the attempt to generate the function occurs, giving the user a hint as to why we are attempting to generate the function. */ - DECL_SOURCE_LOCATION (fndecl) = input_location; + set_tree_locus (fndecl, input_location); interface_unknown = 1; start_function (NULL_TREE, fndecl, NULL_TREE, SF_DEFAULT | SF_PRE_PARSED); diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index 2b7df6c5244..a817084bb82 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -109,7 +109,7 @@ update_cloned_parm (tree parm, tree cloned_parm) /* The name may have changed from the declaration. */ DECL_NAME (cloned_parm) = DECL_NAME (parm); - DECL_SOURCE_LOCATION (cloned_parm) = DECL_SOURCE_LOCATION (parm); + copy_tree_locus (cloned_parm, parm); } /* FN is a function that has a complete body. Clone the body as @@ -146,7 +146,7 @@ maybe_clone_body (tree fn) splay_tree decl_map; /* Update CLONE's source position information to match FN's. */ - DECL_SOURCE_LOCATION (clone) = DECL_SOURCE_LOCATION (fn); + copy_tree_locus (clone, fn); DECL_INLINE (clone) = DECL_INLINE (fn); DECL_DECLARED_INLINE_P (clone) = DECL_DECLARED_INLINE_P (fn); DECL_COMDAT (clone) = DECL_COMDAT (fn); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 12baea14a33..c1d49e7b056 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -966,10 +966,9 @@ register_specialization (tree spec, tree tmpl, tree args) else if (DECL_TEMPLATE_SPECIALIZATION (fn)) { if (!duplicate_decls (spec, fn) && DECL_INITIAL (spec)) - /* Dup decl failed, but this is a new - definition. Set the line number so any errors - match this new definition. */ - DECL_SOURCE_LOCATION (fn) = DECL_SOURCE_LOCATION (spec); + /* Dup decl failed, but this is a new definition. Set the + line number so any errors match this new definition. */ + copy_tree_locus (fn, spec); return fn; } @@ -1783,9 +1782,8 @@ check_explicit_specialization (tree declarator, DECL_INITIAL (DECL_TEMPLATE_RESULT (tmpl)) = NULL_TREE; if (have_def) { - DECL_SOURCE_LOCATION (tmpl) = DECL_SOURCE_LOCATION (decl); - DECL_SOURCE_LOCATION (DECL_TEMPLATE_RESULT (tmpl)) - = DECL_SOURCE_LOCATION (decl); + copy_tree_locus (tmpl, decl); + copy_tree_locus (DECL_TEMPLATE_RESULT (tmpl), decl); } return tmpl; } @@ -4255,8 +4253,7 @@ lookup_template_class (tree d1, type_decl = create_implicit_typedef (DECL_NAME (template), t); DECL_CONTEXT (type_decl) = TYPE_CONTEXT (t); TYPE_STUB_DECL (t) = type_decl; - DECL_SOURCE_LOCATION (type_decl) - = DECL_SOURCE_LOCATION (TYPE_STUB_DECL (template_type)); + copy_tree_locus (type_decl, TYPE_STUB_DECL (template_type)); } else type_decl = TYPE_NAME (t); @@ -4712,7 +4709,7 @@ tsubst_friend_function (tree decl, tree args) tree new_friend; location_t saved_loc = input_location; - input_location = DECL_SOURCE_LOCATION (decl); + input_location = TREE_LOCUS (decl); if (TREE_CODE (decl) == FUNCTION_DECL && DECL_TEMPLATE_INSTANTIATION (decl) @@ -5153,7 +5150,7 @@ instantiate_class_template (tree type) /* Set the input location to the template definition. This is needed if tsubsting causes an error. */ - input_location = DECL_SOURCE_LOCATION (TYPE_NAME (pattern)); + input_location = TREE_LOCUS (TYPE_NAME (pattern)); TYPE_HAS_CONSTRUCTOR (type) = TYPE_HAS_CONSTRUCTOR (pattern); TYPE_HAS_DESTRUCTOR (type) = TYPE_HAS_DESTRUCTOR (pattern); @@ -5302,7 +5299,7 @@ instantiate_class_template (tree type) assist in error message reporting. Since we called push_tinst_level above, we don't need to restore these. */ - input_location = DECL_SOURCE_LOCATION (t); + input_location = TREE_LOCUS (t); if (TREE_CODE (t) == TEMPLATE_DECL) processing_template_decl++; @@ -5411,7 +5408,7 @@ instantiate_class_template (tree type) implicit functions at a predictable point, and the same point that would be used for non-template classes. */ typedecl = TYPE_MAIN_DECL (type); - input_location = DECL_SOURCE_LOCATION (typedecl); + input_location = TREE_LOCUS (typedecl); unreverse_member_declarations (type); finish_struct_1 (type); @@ -5708,7 +5705,7 @@ tsubst_decl (tree t, tree args, tree type, tsubst_flags_t complain) /* Set the filename and linenumber to improve error-reporting. */ saved_loc = input_location; - input_location = DECL_SOURCE_LOCATION (t); + input_location = TREE_LOCUS (t); switch (TREE_CODE (t)) { @@ -10774,7 +10771,7 @@ instantiate_decl (tree d, int defer_ok) else pattern_defined = ! DECL_IN_AGGR_P (code_pattern); - input_location = DECL_SOURCE_LOCATION (d); + input_location = TREE_LOCUS (d); if (pattern_defined) { @@ -10890,7 +10887,7 @@ instantiate_decl (tree d, int defer_ok) /* We already set the file and line above. Reset them now in case they changed as a result of calling regenerate_decl_from_template. */ - input_location = DECL_SOURCE_LOCATION (d); + input_location = TREE_LOCUS (d); if (TREE_CODE (d) == VAR_DECL) { @@ -11178,8 +11175,7 @@ tsubst_enum (tree tag, tree newtag, tree args) } finish_enum (newtag); - DECL_SOURCE_LOCATION (TYPE_NAME (newtag)) - = DECL_SOURCE_LOCATION (TYPE_NAME (tag)); + copy_tree_locus (TYPE_NAME (newtag), TYPE_NAME (tag)); } /* DECL is a FUNCTION_DECL that is a template specialization. Return diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index ef42579f349..ca04ddf26b6 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2030,7 +2030,7 @@ begin_class_definition (tree t) } /* Update the location of the decl. */ - DECL_SOURCE_LOCATION (TYPE_NAME (t)) = input_location; + set_tree_locus (TYPE_NAME (t), input_location); if (TYPE_BEING_DEFINED (t)) { diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 0c729d6118c..6dce605dbd1 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2153,7 +2153,7 @@ cp_copy_res_decl_for_inlining (tree result, && DECL_NAME (var) == NULL_TREE) { DECL_NAME (var) = DECL_NAME (nrv); - DECL_SOURCE_LOCATION (var) = DECL_SOURCE_LOCATION (nrv); + copy_tree_locus (var, nrv); DECL_ABSTRACT_ORIGIN (var) = DECL_ORIGIN (nrv); /* Don't lose initialization info. */ DECL_INITIAL (var) = DECL_INITIAL (nrv); diff --git a/gcc/dbxout.c b/gcc/dbxout.c index e4c797894c0..3f457b594b6 100644 --- a/gcc/dbxout.c +++ b/gcc/dbxout.c @@ -2689,7 +2689,7 @@ static void dbxout_prepare_symbol (tree decl ATTRIBUTE_UNUSED) { #ifdef WINNING_GDB - const char *filename = DECL_SOURCE_FILE (decl); + const char *filename = TREE_FILENAME (decl); dbxout_source_file (asmfile, filename); #endif @@ -2703,7 +2703,7 @@ dbxout_finish_symbol (tree sym) #else int line = 0; if (use_gnu_debug_info_extensions && sym != 0) - line = DECL_SOURCE_LINE (sym); + line = TREE_LINENO (sym); fprintf (asmfile, "\",%d,0,%d,", current_sym_code, line); if (current_sym_addr) diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index c29867a60b3..953733995b2 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -139,7 +139,7 @@ text_specifies_location (text_info *text, location_t *locus) else if (p[0] == '%' && p[1] == 'J') { tree t = va_arg (*text->args_ptr, tree); - *locus = DECL_SOURCE_LOCATION (t); + *locus = TREE_LOCUS (t); text->format_spec = p + 2; return true; } diff --git a/gcc/doc/c-tree.texi b/gcc/doc/c-tree.texi index 29ccaec317d..7f125ee58d6 100644 --- a/gcc/doc/c-tree.texi +++ b/gcc/doc/c-tree.texi @@ -856,13 +856,13 @@ entity. @item TREE_TYPE This macro returns the type of the entity declared. -@item DECL_SOURCE_FILE +@item TREE_FILENAME This macro returns the name of the file in which the entity was declared, as a @code{char*}. For an entity declared implicitly by the compiler (like @code{__builtin_memcpy}), this will be the string @code{""}. -@item DECL_SOURCE_LINE +@item TREE_LINENO This macro returns the line number at which the entity was declared, as an @code{int}. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 5fa730e1b55..dc28f11c142 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -9907,10 +9907,10 @@ add_pure_or_virtual_attribute (dw_die_ref die, tree func_decl) static void add_src_coords_attributes (dw_die_ref die, tree decl) { - unsigned file_index = lookup_filename (DECL_SOURCE_FILE (decl)); + unsigned file_index = lookup_filename (TREE_FILENAME (decl)); add_AT_unsigned (die, DW_AT_decl_file, file_index); - add_AT_unsigned (die, DW_AT_decl_line, DECL_SOURCE_LINE (decl)); + add_AT_unsigned (die, DW_AT_decl_line, TREE_LINENO (decl)); } /* Add a DW_AT_name attribute and source coordinate attribute for the @@ -10596,7 +10596,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) } else if (old_die) { - unsigned file_index = lookup_filename (DECL_SOURCE_FILE (decl)); + unsigned file_index = lookup_filename (TREE_FILENAME (decl)); if (!get_AT_flag (old_die, DW_AT_declaration) /* We can have a normal definition following an inline one in the @@ -10625,7 +10625,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) && (DECL_ARTIFICIAL (decl) || (get_AT_unsigned (old_die, DW_AT_decl_file) == file_index && (get_AT_unsigned (old_die, DW_AT_decl_line) - == (unsigned) DECL_SOURCE_LINE (decl))))) + == (unsigned) TREE_LINENO (decl))))) { subr_die = old_die; @@ -10640,9 +10640,9 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) if (get_AT_unsigned (old_die, DW_AT_decl_file) != file_index) add_AT_unsigned (subr_die, DW_AT_decl_file, file_index); if (get_AT_unsigned (old_die, DW_AT_decl_line) - != (unsigned) DECL_SOURCE_LINE (decl)) + != (unsigned) TREE_LINENO (decl)) add_AT_unsigned - (subr_die, DW_AT_decl_line, DECL_SOURCE_LINE (decl)); + (subr_die, DW_AT_decl_line, TREE_LINENO (decl)); } } else @@ -10859,16 +10859,16 @@ gen_variable_die (tree decl, dw_die_ref context_die) add_AT_die_ref (var_die, DW_AT_specification, old_die); if (DECL_NAME (decl)) { - unsigned file_index = lookup_filename (DECL_SOURCE_FILE (decl)); + unsigned file_index = lookup_filename (TREE_FILENAME (decl)); if (get_AT_unsigned (old_die, DW_AT_decl_file) != file_index) add_AT_unsigned (var_die, DW_AT_decl_file, file_index); if (get_AT_unsigned (old_die, DW_AT_decl_line) - != (unsigned) DECL_SOURCE_LINE (decl)) + != (unsigned) TREE_LINENO (decl)) add_AT_unsigned (var_die, DW_AT_decl_line, - DECL_SOURCE_LINE (decl)); + TREE_LINENO (decl)); } } else @@ -12036,7 +12036,7 @@ dwarf2out_decl (tree decl) /* Don't bother trying to generate any DIEs to represent any of the normal built-in types for the language we are compiling. */ - if (DECL_SOURCE_LINE (decl) == 0) + if (!TREE_LOCUS_SET_P (decl)) { /* OK, we need to generate one for `bool' so GDB knows what type comparisons have. */ diff --git a/gcc/dwarfout.c b/gcc/dwarfout.c index dfd1f0b57e1..0ad9d0fcf1f 100644 --- a/gcc/dwarfout.c +++ b/gcc/dwarfout.c @@ -3411,10 +3411,10 @@ name_and_src_coords_attributes (tree decl) Fred Fish sez that m68k/svr4 assemblers botch those. */ ASM_OUTPUT_POP_SECTION (asm_out_file); - file_index = lookup_filename (DECL_SOURCE_FILE (decl)); + file_index = lookup_filename (TREE_FILENAME (decl)); ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION); - src_coords_attribute (file_index, DECL_SOURCE_LINE (decl)); + src_coords_attribute (file_index, TREE_LINENO (decl)); } #endif /* defined(DWARF_DECL_COORDINATES) */ } @@ -5618,7 +5618,7 @@ dwarfout_file_scope_decl (tree decl, int set_finalizing) /* ??? This code is different than the equivalent code in dwarf2out.c. The dwarf2out.c code is probably more correct. */ - if (DECL_SOURCE_LINE (decl) == 0 + if (!TREE_LOCUS_SET_P (decl) && (type_is_fundamental (TREE_TYPE (decl)) || TREE_CODE (TREE_TYPE (decl)) == LANG_TYPE)) return; diff --git a/gcc/f/ChangeLog b/gcc/f/ChangeLog index e98507002f3..5d588e974d8 100644 --- a/gcc/f/ChangeLog +++ b/gcc/f/ChangeLog @@ -1,3 +1,8 @@ +2003-09-21 Richard Henderson + + * com.c, ste.c: Update for DECL_SOURCE_LOCATION rename and + change to const. + 2003-09-21 Toon Moene * news.texi: Update with fixed PR's. diff --git a/gcc/f/com.c b/gcc/f/com.c index a5100d9bfa9..9658a544bad 100644 --- a/gcc/f/com.c +++ b/gcc/f/com.c @@ -13227,7 +13227,7 @@ duplicate_decls (tree newdecl, tree olddecl) return 0; } else if (TREE_CODE (olddecl) == FUNCTION_DECL - && DECL_SOURCE_LINE (olddecl) == 0) + && !TREE_LOCUS_SET_P (olddecl)) { /* A function declaration for a predeclared function that isn't actually built in. */ @@ -13297,8 +13297,7 @@ duplicate_decls (tree newdecl, tree olddecl) if ((DECL_INITIAL (newdecl) == 0 && DECL_INITIAL (olddecl) != 0) || (DECL_CONTEXT (newdecl) != 0 && DECL_CONTEXT (olddecl) == 0)) { - DECL_SOURCE_LINE (newdecl) = DECL_SOURCE_LINE (olddecl); - DECL_SOURCE_FILE (newdecl) = DECL_SOURCE_FILE (olddecl); + copy_tree_locus (newdecl, olddecl); if (DECL_CONTEXT (olddecl) == 0 && TREE_CODE (newdecl) != FUNCTION_DECL) @@ -14535,7 +14534,7 @@ pushdecl (tree x) if (TREE_CODE (x) == TYPE_DECL) { - if (DECL_SOURCE_LINE (x) == 0) + if (!TREE_LOCUS_SET_P (x)) { if (TYPE_NAME (TREE_TYPE (x)) == 0) TYPE_NAME (TREE_TYPE (x)) = x; diff --git a/gcc/f/ste.c b/gcc/f/ste.c index 82435bc8dc8..dc0d27e9da1 100644 --- a/gcc/f/ste.c +++ b/gcc/f/ste.c @@ -2392,8 +2392,8 @@ ffeste_labeldef_branch (ffelab label) assert (DECL_INITIAL (glabel) == NULL_TREE); DECL_INITIAL (glabel) = error_mark_node; - DECL_SOURCE_FILE (glabel) = ffelab_definition_filename (label); - DECL_SOURCE_LINE (glabel) = ffelab_definition_filelinenum (label); + set_tree_file_line (glabel, ffelab_definition_filename (label), + ffelab_definition_filelinenum (label)); emit_nop (); diff --git a/gcc/function.c b/gcc/function.c index baec4ab3048..1af4d38ff01 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -6399,8 +6399,8 @@ init_function_start (tree subr) function. Also tell final how to output a linenum before the function prologue. Note linenums could be missing, e.g. when compiling a Java .class file. */ - if (DECL_SOURCE_LINE (subr)) - emit_line_note (DECL_SOURCE_LOCATION (subr)); + if (TREE_LOCUS_SET_P (subr)) + emit_line_note (TREE_LOCUS (subr)); /* Make sure first insn is a note even if we don't want linenums. This makes sure the first insn will never be deleted. diff --git a/gcc/integrate.c b/gcc/integrate.c index 21a738ea237..2c6ff174551 100644 --- a/gcc/integrate.c +++ b/gcc/integrate.c @@ -987,7 +987,7 @@ expand_inline_function (tree fndecl, tree parms, rtx target, int ignore, && ! (GET_CODE (XEXP (loc, 0)) == REG && REGNO (XEXP (loc, 0)) > LAST_VIRTUAL_REGISTER)) { - rtx note = emit_line_note (DECL_SOURCE_LOCATION (formal)); + rtx note = emit_line_note (TREE_LOCUS (formal)); if (note) RTX_INTEGRATED_P (note) = 1; @@ -2985,7 +2985,7 @@ output_inline_function (tree fndecl) /* Make sure warnings emitted by the optimizers (e.g. control reaches end of non-void function) is not wildly incorrect. */ - input_location = DECL_SOURCE_LOCATION (fndecl); + input_location = TREE_LOCUS (fndecl); /* Compile this function all the way down to assembly code. As a side effect this destroys the saved RTL representation, but diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index a14c1db5597..be46849d5fe 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,8 @@ +2003-09-21 Richard Henderson + + * class.c, decl.c, jcf-parse.c, jcf-write.c, parse.y, + resource.c: Update for DECL_SOURCE_LOCATION rename and change to const. + 2003-09-20 Richard Henderson * check-init.c, class.c, decl.c, expr.c: Use %J in diagnostics. diff --git a/gcc/java/class.c b/gcc/java/class.c index e3e6cc36e58..289dbfa2eb8 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -1728,8 +1728,8 @@ maybe_layout_super_class (tree super_class, tree this_class) { tree this_decl = TYPE_NAME (this_class); this_wrap = build_expr_wfl (this_class, - DECL_SOURCE_FILE (this_decl), - DECL_SOURCE_LINE (this_decl), 0); + TREE_FILENAME (this_decl), + TREE_LINENO (this_decl), 0); } super_class = do_resolve_class (NULL_TREE, /* FIXME? */ super_class, NULL_TREE, this_wrap); @@ -1767,8 +1767,8 @@ layout_class (tree this_class) tree decl = TYPE_NAME (TREE_PURPOSE (current)); sprintf (buffer, "\n which inherits from `%s' (%s:%d)", IDENTIFIER_POINTER (DECL_NAME (decl)), - DECL_SOURCE_FILE (decl), - DECL_SOURCE_LINE (decl)); + TREE_FILENAME (decl), + TREE_LINENO (decl)); obstack_grow (&temporary_obstack, buffer, strlen (buffer)); } obstack_1grow (&temporary_obstack, '\0'); @@ -2059,7 +2059,6 @@ emit_register_classes (void) init_decl = build_decl (FUNCTION_DECL, init_name, init_type); SET_DECL_ASSEMBLER_NAME (init_decl, init_name); - DECL_SOURCE_LINE (init_decl) = 0; TREE_STATIC (init_decl) = 1; current_function_decl = init_decl; DECL_RESULT (init_decl) = build_decl (RESULT_DECL, NULL_TREE, @@ -2084,7 +2083,7 @@ emit_register_classes (void) for ( t = registered_class; t; t = TREE_CHAIN (t)) emit_library_call (registerClass_libfunc, 0, VOIDmode, 1, XEXP (DECL_RTL (t), 0), Pmode); - input_location = DECL_SOURCE_LOCATION (init_decl); + input_location = TREE_LOCUS (init_decl); expand_function_end (); poplevel (1, 0, 1); rest_of_compilation (init_decl); diff --git a/gcc/java/decl.c b/gcc/java/decl.c index 7ddf704efad..d92bbdce4ad 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -1070,7 +1070,7 @@ pushdecl (tree x) /* Maybe warn if shadowing something else. */ else if (warn_shadow && !DECL_EXTERNAL (x) /* No shadow warnings for internally generated vars. */ - && DECL_SOURCE_LINE (x) != 0 + && TREE_LOCUS_SET_P (x) /* No shadow warnings for vars made for inlining. */ && ! DECL_FROM_INLINE (x)) { @@ -1817,8 +1817,7 @@ java_expand_body (tree fndecl) int saved_lineno = input_line; current_function_decl = fndecl; - input_filename = DECL_SOURCE_FILE (fndecl); - input_line = DECL_SOURCE_LINE (fndecl); + input_location = TREE_LOCUS (fndecl); timevar_push (TV_EXPAND); diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c index f47dbe0897a..eea2a15ced8 100644 --- a/gcc/java/jcf-parse.c +++ b/gcc/java/jcf-parse.c @@ -145,8 +145,10 @@ set_source_filename (JCF *jcf, int index) return; } input_filename = sfname; - DECL_SOURCE_FILE (TYPE_NAME (current_class)) = sfname; - if (current_class == main_class) main_input_filename = input_filename; + set_tree_file_line (TYPE_NAME (current_class), sfname, + TREE_LINENO (TYPE_NAME (current_class))); + if (current_class == main_class) + main_input_filename = input_filename; } #define HANDLE_SOURCEFILE(INDEX) set_source_filename (jcf, INDEX) @@ -418,7 +420,7 @@ give_name_to_class (JCF *jcf, int i) tree class_name = unmangle_classname (JPOOL_UTF_DATA (jcf, j), JPOOL_UTF_LENGTH (jcf, j)); this_class = lookup_class (class_name); - input_filename = DECL_SOURCE_FILE (TYPE_NAME (this_class)); + input_filename = TREE_FILENAME (TYPE_NAME (this_class)); input_line = 0; if (main_input_filename == NULL && jcf == main_jcf) main_input_filename = input_filename; @@ -708,7 +710,7 @@ parse_class_file (void) java_layout_seen_class_methods (); - input_filename = DECL_SOURCE_FILE (TYPE_NAME (current_class)); + input_filename = TREE_FILENAME (TYPE_NAME (current_class)); input_line = 0; (*debug_hooks->start_source_file) (input_line, input_filename); init_outgoing_cpool (); diff --git a/gcc/java/jcf-write.c b/gcc/java/jcf-write.c index 82c77b1c831..bc76c8888e8 100644 --- a/gcc/java/jcf-write.c +++ b/gcc/java/jcf-write.c @@ -3113,7 +3113,7 @@ generate_classfile (tree clas, struct jcf_partial *state) } ptr = methods_count_ptr; UNSAFE_PUT2 (methods_count); - source_file = DECL_SOURCE_FILE (TYPE_NAME (clas)); + source_file = TREE_FILENAME (TYPE_NAME (clas)); for (s = source_file; ; s++) { char ch = *s; @@ -3299,7 +3299,7 @@ make_class_file_name (tree clas) /* Make sure we put the class file into the .java file's directory, and not into some subdirectory thereof. */ char *t; - dname = DECL_SOURCE_FILE (TYPE_NAME (clas)); + dname = TREE_FILENAME (TYPE_NAME (clas)); slash = strrchr (dname, DIR_SEPARATOR); #ifdef DIR_SEPARATOR_2 if (! slash) diff --git a/gcc/java/parse.y b/gcc/java/parse.y index a5064e18465..de0a7d40fa3 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -3208,7 +3208,7 @@ classitf_redefinition_error (const char *context, tree id, tree decl, tree cl) { parse_error_context (cl, "%s `%s' already defined in %s:%d", context, IDENTIFIER_POINTER (id), - DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl)); + TREE_FILENAME (decl), TREE_LINENO (decl)); /* Here we should point out where its redefined. It's a unicode. FIXME */ } @@ -3716,12 +3716,10 @@ maybe_create_class_interface_decl (tree decl, tree raw_name, decl = push_class (make_class (), qualified_name); /* Take care of the file and line business */ - DECL_SOURCE_FILE (decl) = EXPR_WFL_FILENAME (cl); - /* If we're emiting xrefs, store the line/col number information */ - if (flag_emit_xref) - DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (cl); - else - DECL_SOURCE_LINE (decl) = EXPR_WFL_LINENO (cl); + set_tree_file_line (decl, EXPR_WFL_FILENAME (cl), + (flag_emit_xref + ? EXPR_WFL_LINECOL (cl) : EXPR_WFL_LINENO (cl))); + CLASS_FROM_SOURCE_P (TREE_TYPE (decl)) = 1; CLASS_PARSED_P (TREE_TYPE (decl)) = 1; CLASS_FROM_CURRENTLY_COMPILED_P (TREE_TYPE (decl)) = @@ -4205,7 +4203,7 @@ duplicate_declaration_error_p (tree new_field_name, tree new_type, tree cl) (cl , "Duplicate variable declaration: `%s %s' was `%s %s' (%s:%d)", t1, IDENTIFIER_POINTER (new_field_name), t2, IDENTIFIER_POINTER (DECL_NAME (decl)), - DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl)); + TREE_FILENAME (decl), TREE_LINENO (decl)); free (t1); free (t2); return 1; @@ -4687,7 +4685,7 @@ method_header (int flags, tree type, tree mdecl, tree throws) /* If doing xref, store column and line number information instead of the line number only. */ if (flag_emit_xref) - DECL_SOURCE_LINE (meth) = EXPR_WFL_LINECOL (id); + set_tree_file_line (meth, TREE_FILENAME (meth), EXPR_WFL_LINECOL (id)); return meth; } @@ -6705,8 +6703,8 @@ lookup_cl (tree decl) cl_v = build_expr_wfl (NULL_TREE, NULL, 0, 0); } - EXPR_WFL_FILENAME_NODE (cl_v) = get_identifier (DECL_SOURCE_FILE (decl)); - EXPR_WFL_SET_LINECOL (cl_v, DECL_SOURCE_LINE (decl), -1); + EXPR_WFL_FILENAME_NODE (cl_v) = get_identifier (TREE_FILENAME (decl)); + EXPR_WFL_SET_LINECOL (cl_v, TREE_LINENO (decl), -1); line = java_get_line_col (EXPR_WFL_FILENAME (cl_v), EXPR_WFL_LINENO (cl_v), EXPR_WFL_COLNO (cl_v)); @@ -7286,7 +7284,7 @@ declare_local_variables (int modifier, tree type, tree vlist) if ((other = lookup_name_in_blocks (name))) { variable_redefinition_error (wfl, name, TREE_TYPE (other), - DECL_SOURCE_LINE (other)); + TREE_LINENO (other)); continue; } @@ -7306,7 +7304,8 @@ declare_local_variables (int modifier, tree type, tree vlist) /* If doing xreferencing, replace the line number with the WFL compound value */ if (flag_emit_xref) - DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (wfl); + set_tree_file_line (decl, TREE_FILENAME (decl), + EXPR_WFL_LINECOL (wfl)); /* Don't try to use an INIT statement when an error was found */ if (init && java_error_count) @@ -7414,7 +7413,7 @@ create_artificial_method (tree class, int flags, tree type, static void start_artificial_method_body (tree mdecl) { - DECL_SOURCE_LINE (mdecl) = 1; + set_tree_file_line (mdecl, TREE_FILENAME (mdecl), 1); DECL_FUNCTION_LAST_LINE (mdecl) = 1; source_start_java_method (mdecl); enter_block (); @@ -7980,7 +7979,7 @@ start_complete_expand_method (tree mdecl) TREE_CHAIN (tem) = next; } pushdecl_force_head (DECL_ARGUMENTS (mdecl)); - input_line = DECL_SOURCE_LINE (mdecl); + input_location = TREE_LOCUS (mdecl); build_result_decl (mdecl); } @@ -10145,7 +10144,7 @@ check_deprecation (tree wfl, tree decl) to the record. */ decl = TYPE_NAME (TREE_TYPE (elt)); } - file = DECL_SOURCE_FILE (decl); + file = TREE_FILENAME (decl); /* Complain if the field is deprecated and the file it was defined in isn't compiled at the same time the file which contains its diff --git a/gcc/java/resource.c b/gcc/java/resource.c index b71a6709f5e..25b8a81010d 100644 --- a/gcc/java/resource.c +++ b/gcc/java/resource.c @@ -114,7 +114,6 @@ write_resource_constructor (void) init_type = build_function_type (void_type_node, end_params_node); init_decl = build_decl (FUNCTION_DECL, init_name, init_type); - DECL_SOURCE_LINE (init_decl) = 0; SET_DECL_ASSEMBLER_NAME (init_decl, init_name); TREE_STATIC (init_decl) = 1; current_function_decl = init_decl; @@ -140,7 +139,7 @@ write_resource_constructor (void) Pmode); } - input_location = DECL_SOURCE_LOCATION (init_decl); + input_location = TREE_LOCUS (init_decl); expand_function_end (); poplevel (1, 0, 1); { diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 0c075430502..02678a4fb65 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -1984,13 +1984,12 @@ build_selector_translation_table (void) } if (!found) { - /* Adjust line number for warning message. */ - int save_lineno = input_line; + location_t loc = input_location; if (flag_next_runtime && TREE_PURPOSE (chain)) - input_line = DECL_SOURCE_LINE (TREE_PURPOSE (chain)); - warning ("creating selector for non existant method %s", - IDENTIFIER_POINTER (TREE_VALUE (chain))); - input_line = save_lineno; + loc = TREE_LOCUS (TREE_PURPOSE (chain)); + + warning ("%Hcreating selector for non existant method %s", + &loc, IDENTIFIER_POINTER (TREE_VALUE (chain))); } } @@ -2857,7 +2856,6 @@ build_tmp_function_decl (void) expr_decl = build1 (INDIRECT_REF, NULL_TREE, expr_decl); tmp_decl = define_decl (expr_decl, decl_specs); - DECL_SOURCE_LINE (tmp_decl) = 0; return tmp_decl; } diff --git a/gcc/print-tree.c b/gcc/print-tree.c index 3d6c01e01ee..40495009d9d 100644 --- a/gcc/print-tree.c +++ b/gcc/print-tree.c @@ -368,7 +368,7 @@ print_node (FILE *file, const char *prefix, tree node, int indent) fprintf (file, " %s", GET_MODE_NAME (mode)); fprintf (file, " file %s line %d", - DECL_SOURCE_FILE (node), DECL_SOURCE_LINE (node)); + TREE_FILENAME (node), TREE_LINENO (node)); print_node (file, "size", DECL_SIZE (node), indent + 4); print_node (file, "unit size", DECL_SIZE_UNIT (node), indent + 4); diff --git a/gcc/stmt.c b/gcc/stmt.c index 9d5553f2517..40ad357a334 100644 --- a/gcc/stmt.c +++ b/gcc/stmt.c @@ -3981,7 +3981,7 @@ expand_decl_init (tree decl) } else if (DECL_INITIAL (decl) && TREE_CODE (DECL_INITIAL (decl)) != TREE_LIST) { - emit_line_note (DECL_SOURCE_LOCATION (decl)); + emit_line_note (TREE_LOCUS (decl)); expand_assignment (decl, DECL_INITIAL (decl), 0); emit_queue (); } diff --git a/gcc/toplev.c b/gcc/toplev.c index 03485bc8aed..559e6828990 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1709,7 +1709,7 @@ warn_deprecated_use (tree node) if (DECL_P (node)) warning ("`%s' is deprecated (declared at %s:%d)", IDENTIFIER_POINTER (DECL_NAME (node)), - DECL_SOURCE_FILE (node), DECL_SOURCE_LINE (node)); + TREE_FILENAME (node), TREE_LINENO (node)); else if (TYPE_P (node)) { const char *what = NULL; @@ -1725,13 +1725,13 @@ warn_deprecated_use (tree node) { if (decl) warning ("`%s' is deprecated (declared at %s:%d)", what, - DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl)); + TREE_FILENAME (decl), TREE_LINENO (decl)); else warning ("`%s' is deprecated", what); } else if (decl) warning ("type is deprecated (declared at %s:%d)", - DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl)); + TREE_FILENAME (decl), TREE_LINENO (decl)); else warning ("type is deprecated"); } diff --git a/gcc/tree-dump.c b/gcc/tree-dump.c index c3696336c44..296d19c992e 100644 --- a/gcc/tree-dump.c +++ b/gcc/tree-dump.c @@ -321,18 +321,18 @@ dequeue_and_dump (dump_info_p di) queue_and_dump_type (di, t); dump_child ("scpe", DECL_CONTEXT (t)); /* And a source position. */ - if (DECL_SOURCE_FILE (t)) + if (TREE_FILENAME (t)) { - const char *filename = strrchr (DECL_SOURCE_FILE (t), '/'); + const char *filename = strrchr (TREE_FILENAME (t), '/'); if (!filename) - filename = DECL_SOURCE_FILE (t); + filename = TREE_FILENAME (t); else /* Skip the slash. */ ++filename; dump_maybe_newline (di); fprintf (di->stream, "srcp: %s:%-6d ", filename, - DECL_SOURCE_LINE (t)); + TREE_LINENO (t)); di->column += 6 + strlen (filename) + 8; } /* And any declaration can be compiler-generated. */ diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index e4e24b2b3b2..13cb5bb19c1 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1322,7 +1322,7 @@ expand_call_inline (tree *tp, int *walk_subtrees, void *data) line numbers corresponding to the function we are calling. We wrap the whole inlined body in an EXPR_WITH_FILE_AND_LINE as well because individual statements don't record the filename. */ - push_srcloc (DECL_SOURCE_FILE (fn), DECL_SOURCE_LINE (fn)); + push_srcloc (TREE_FILENAME (fn), TREE_LINENO (fn)); #ifndef INLINER_FOR_JAVA /* Build a statement-expression containing code to initialize the @@ -1522,7 +1522,7 @@ expand_call_inline (tree *tp, int *walk_subtrees, void *data) #ifndef INLINER_FOR_JAVA chain = TREE_CHAIN (*tp); #endif /* INLINER_FOR_JAVA */ - *tp = build_expr_wfl (expr, DECL_SOURCE_FILE (fn), DECL_SOURCE_LINE (fn), + *tp = build_expr_wfl (expr, TREE_FILENAME (fn), TREE_LINENO (fn), /*col=*/0); EXPR_WFL_EMIT_LINE_NOTE (*tp) = 1; #ifndef INLINER_FOR_JAVA diff --git a/gcc/tree-optimize.c b/gcc/tree-optimize.c index e6049cb2b29..ab11f4d2ad3 100644 --- a/gcc/tree-optimize.c +++ b/gcc/tree-optimize.c @@ -105,7 +105,7 @@ tree_rest_of_compilation (tree fndecl, bool nested_p) /* Initialize the RTL code for the function. */ current_function_decl = fndecl; saved_loc = input_location; - input_location = DECL_SOURCE_LOCATION (fndecl); + input_location = TREE_LOCUS (fndecl); init_function_start (fndecl); /* This function is being processed in whole-function mode. */ diff --git a/gcc/tree.c b/gcc/tree.c index b82a6bf6965..ef720aea27b 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -287,7 +287,7 @@ make_node (enum tree_code code) DECL_ALIGN (t) = 1; DECL_USER_ALIGN (t) = 0; DECL_IN_SYSTEM_HEADER (t) = in_system_header; - DECL_SOURCE_LOCATION (t) = input_location; + set_tree_locus (t, input_location); DECL_UID (t) = next_decl_uid++; /* We have not yet computed the alias set for this declaration. */ diff --git a/gcc/tree.def b/gcc/tree.def index 4b6d236dde6..f603f2455c0 100644 --- a/gcc/tree.def +++ b/gcc/tree.def @@ -327,7 +327,7 @@ DEFTREECODE (STRING_CST, "string_cst", 'c', 0) built-in functions. Its value is an enum built_in_function that says which built-in function it is. - DECL_SOURCE_FILE holds a filename string and DECL_SOURCE_LINE + TREE_FILENAME holds a filename string and TREE_LINENO holds a line number. In some cases these can be the location of a reference, if no definition has been seen. diff --git a/gcc/tree.h b/gcc/tree.h index d742bc3d95b..2d879442a42 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -802,6 +802,29 @@ struct tree_vec GTY(()) #define TREE_OPERAND(NODE, I) TREE_OPERAND_CHECK (NODE, I) #define TREE_COMPLEXITY(NODE) (EXPR_CHECK (NODE)->exp.complexity) +/* These macros access the location of a declaration. For 3.4, this is + only defined for DECLs, but for 3.5 it will be valid on EXPRs as well; + thus the name is not decl specific. The values accessed from the + uppercase macros are intentionally read-only. Use the setter functions + to write to this field. */ + +#define TREE_LOCUS(NODE) \ + (*(const location_t *)&DECL_CHECK (NODE)->decl.locus) +#define TREE_FILENAME(NODE) (TREE_LOCUS (NODE).file) +#define TREE_LINENO(NODE) (TREE_LOCUS (NODE).line) +#define TREE_LOCUS_SET_P(NODE) (TREE_LINENO (NODE) != 0) + +#define set_tree_locus(NODE, LOC) \ + ((void)(DECL_CHECK (NODE)->decl.locus = (LOC))) +#define copy_tree_locus(DEST, SRC) \ + ((void)(DECL_CHECK (DEST)->decl.locus = DECL_CHECK (SRC)->decl.locus)) +#define set_tree_file_line(NODE, FILE, LINE) \ + do { \ + location_t *l_ = &DECL_CHECK (NODE)->decl.locus; \ + l_->file = (FILE); \ + l_->line = (LINE); \ + } while (0) + /* In a LABELED_BLOCK_EXPR node. */ #define LABELED_BLOCK_LABEL(NODE) \ TREE_OPERAND_CHECK_CODE (NODE, LABELED_BLOCK_EXPR, 0) @@ -1309,13 +1332,6 @@ struct tree_type GTY(()) /* For a FIELD_DECL in a QUAL_UNION_TYPE, records the expression, which if nonzero, indicates that the field occupies the type. */ #define DECL_QUALIFIER(NODE) (FIELD_DECL_CHECK (NODE)->decl.initial) -/* These two fields describe where in the source code the declaration - was. If the declaration appears in several places (as for a C - function that is declared first and then defined later), this - information should refer to the definition. */ -#define DECL_SOURCE_LOCATION(NODE) (DECL_CHECK (NODE)->decl.locus) -#define DECL_SOURCE_FILE(NODE) (DECL_SOURCE_LOCATION (NODE).file) -#define DECL_SOURCE_LINE(NODE) (DECL_SOURCE_LOCATION (NODE).line) /* Holds the size of the datum, in bits, as a tree expression. Need not be constant. */ #define DECL_SIZE(NODE) (DECL_CHECK (NODE)->decl.size) diff --git a/gcc/treelang/ChangeLog b/gcc/treelang/ChangeLog index 7b8a5a5b8c9..75b9b2fefa2 100644 --- a/gcc/treelang/ChangeLog +++ b/gcc/treelang/ChangeLog @@ -1,3 +1,8 @@ +2003-09-21 Richard Henderson + + * treetree.c: Update for DECL_SOURCE_LOCATION rename and + change to const. + 2003-07-28 Andreas Jaeger * treetree.c: Convert remaining K&R prototypes to ISO C90. diff --git a/gcc/treelang/treetree.c b/gcc/treelang/treetree.c index 7697e3c49e5..da92110b4b7 100644 --- a/gcc/treelang/treetree.c +++ b/gcc/treelang/treetree.c @@ -313,8 +313,9 @@ tree_code_create_function_prototype (unsigned char* chars, id = get_identifier ((const char*)chars); fn_decl = build_decl (FUNCTION_DECL, id, fn_type); - DECL_CONTEXT (fn_decl) = NULL_TREE; /* Nested functions not supported here. */ - DECL_SOURCE_LOCATION (fn_decl) = loc; + /* Nested functions not supported here. */ + DECL_CONTEXT (fn_decl) = NULL_TREE; + set_tree_locus (fn_decl, loc); TREE_USED (fn_decl) = 1; @@ -387,14 +388,14 @@ tree_code_create_function_initial (tree prev_saved, current_function_decl = fn_decl; DECL_INITIAL (fn_decl) = error_mark_node; - DECL_SOURCE_LOCATION (fn_decl) = loc; + set_tree_locus (fn_decl, loc); /* Prepare creation of rtl for a new function. */ resultdecl = DECL_RESULT (fn_decl) = build_decl (RESULT_DECL, NULL_TREE, TREE_TYPE (TREE_TYPE (fn_decl))); DECL_CONTEXT (DECL_RESULT (fn_decl)) = fn_decl; - DECL_SOURCE_LOCATION (resultdecl) = loc; + set_tree_locus (resultdecl, loc); /* Work out the size. ??? is this needed. */ layout_decl (DECL_RESULT (fn_decl), 0); @@ -414,7 +415,7 @@ tree_code_create_function_initial (tree prev_saved, if (!fn_decl) abort (); DECL_CONTEXT (parm_decl) = fn_decl; - DECL_SOURCE_LOCATION (parm_decl) = loc; + set_tree_locus (parm_decl, loc); parm_list = chainon (parm_decl, parm_list); } @@ -582,7 +583,7 @@ tree_code_create_variable (unsigned int storage_class, DECL_CONTEXT (var_decl) = current_function_decl; - DECL_SOURCE_LOCATION (var_decl) = loc; + set_tree_locus (var_decl, loc); /* Set the storage mode and whether only visible in the same file. */ switch (storage_class) diff --git a/gcc/xcoffout.c b/gcc/xcoffout.c index 7c03ca5b096..0999af941f4 100644 --- a/gcc/xcoffout.c +++ b/gcc/xcoffout.c @@ -411,7 +411,7 @@ xcoffout_declare_function (FILE *file, tree decl, const char *name) /* Any pending .bi or .ei must occur before the .function pseudo op. Otherwise debuggers will think that the function is in the previous file and/or at the wrong line number. */ - xcoffout_source_file (file, DECL_SOURCE_FILE (decl), 0); + xcoffout_source_file (file, TREE_FILENAME (decl), 0); dbxout_symbol (decl, 0); /* .function NAME, TOP, MAPPING, TYPE, SIZE