diff options
author | Richard Henderson <rth@redhat.com> | 2005-01-27 01:28:45 -0800 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2005-01-27 01:28:45 -0800 |
commit | dad2a933ba0fe99918377dc328ce87325365fb91 (patch) | |
tree | b06cc8f8944057cfd57dcd5faf93040dd75dae74 /gcc | |
parent | 17c21957198083a5787308566dff7526d1307bc5 (diff) | |
download | gcc-dad2a933ba0fe99918377dc328ce87325365fb91.zip gcc-dad2a933ba0fe99918377dc328ce87325365fb91.tar.gz gcc-dad2a933ba0fe99918377dc328ce87325365fb91.tar.bz2 |
re PR c++/14329 ([4.1 only] badly formatted warnings for SRA replacements used uninitialized)
PR tree-opt/14329
* tree.h (struct tree_decl): Add debug_expr_is_from.
(DECL_DEBUG_EXPR_IS_FROM): New.
(DECL_DEBUG_EXPR): Rename from DECL_DEBUG_ALIAS_OF.
* dwarf2out.c (dwarf2out_var_location): Update to match.
* tree-outof-ssa.c (create_temp): Likewise.
* var-tracking.c (track_expr_p): Likewise.
* tree-sra.c (instantiate_element): Set DECL_DEBUG_EXPR.
* c-objc-common.c (c_tree_printer) <'D'>: Handle DECL_DEBUG_EXPR.
* toplev.c (default_tree_printer): Likewise.
From-SVN: r94317
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 13 | ||||
-rw-r--r-- | gcc/c-objc-common.c | 11 | ||||
-rw-r--r-- | gcc/dwarf2out.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/uninit-I.c | 8 | ||||
-rw-r--r-- | gcc/toplev.c | 29 | ||||
-rw-r--r-- | gcc/tree-outof-ssa.c | 12 | ||||
-rw-r--r-- | gcc/tree-sra.c | 18 | ||||
-rw-r--r-- | gcc/tree.h | 13 | ||||
-rw-r--r-- | gcc/var-tracking.c | 11 |
9 files changed, 98 insertions, 22 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e7cfcd2..6999c43 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2005-01-27 Richard Henderson <rth@redhat.com> + + PR tree-opt/14329 + * tree.h (struct tree_decl): Add debug_expr_is_from. + (DECL_DEBUG_EXPR_IS_FROM): New. + (DECL_DEBUG_EXPR): Rename from DECL_DEBUG_ALIAS_OF. + * dwarf2out.c (dwarf2out_var_location): Update to match. + * tree-outof-ssa.c (create_temp): Likewise. + * var-tracking.c (track_expr_p): Likewise. + * tree-sra.c (instantiate_element): Set DECL_DEBUG_EXPR. + * c-objc-common.c (c_tree_printer) <'D'>: Handle DECL_DEBUG_EXPR. + * toplev.c (default_tree_printer): Likewise. + 2005-01-27 Alexandre Oliva <aoliva@redhat.com> * config/frv/frv.c (frv_class_likely_spilled_p): Add GR8_REGS, diff --git a/gcc/c-objc-common.c b/gcc/c-objc-common.c index 35bcf9e..50bb0fc 100644 --- a/gcc/c-objc-common.c +++ b/gcc/c-objc-common.c @@ -177,6 +177,17 @@ c_tree_printer (pretty_printer *pp, text_info *text) switch (*text->format_spec) { case 'D': + if (DECL_DEBUG_EXPR (t) && DECL_DEBUG_EXPR_IS_FROM (t)) + { + t = DECL_DEBUG_EXPR (t); + if (!DECL_P (t)) + { + pp_c_expression (cpp, t); + return true; + } + } + /* FALLTHRU */ + case 'F': if (DECL_NAME (t)) n = lang_hooks.decl_printable_name (t, 2); diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 6336cf6..49bca54 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -13131,8 +13131,9 @@ dwarf2out_var_location (rtx loc_note) last_insn = loc_note; last_label = newloc->label; decl = NOTE_VAR_LOCATION_DECL (loc_note); - if (DECL_DEBUG_ALIAS_OF (decl)) - decl = DECL_DEBUG_ALIAS_OF (decl); + if (DECL_DEBUG_EXPR (decl) && DECL_DEBUG_EXPR_IS_FROM (decl) + && DECL_P (DECL_DEBUG_EXPR (decl))) + decl = DECL_DEBUG_EXPR (decl); add_var_loc_to_decl (decl, newloc); } diff --git a/gcc/testsuite/gcc.dg/uninit-I.c b/gcc/testsuite/gcc.dg/uninit-I.c new file mode 100644 index 0000000..bd7c13a --- /dev/null +++ b/gcc/testsuite/gcc.dg/uninit-I.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options -O2 -Wuninitialized } */ + +int sys_msgctl (void) +{ + struct { int mode; } setbuf; /* { dg-warning "'setbuf[.]mode' is used" } */ + return setbuf.mode; +} diff --git a/gcc/toplev.c b/gcc/toplev.c index af57e57..2659997 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1554,23 +1554,36 @@ default_pch_valid_p (const void *data_p, size_t len) static bool default_tree_printer (pretty_printer * pp, text_info *text) { + tree t; + switch (*text->format_spec) { case 'D': + t = va_arg (*text->args_ptr, tree); + if (DECL_DEBUG_EXPR (t) && DECL_DEBUG_EXPR_IS_FROM (t)) + t = DECL_DEBUG_EXPR (t); + break; + case 'F': case 'T': - { - tree t = va_arg (*text->args_ptr, tree); - const char *n = DECL_NAME (t) - ? lang_hooks.decl_printable_name (t, 2) - : "<anonymous>"; - pp_string (pp, n); - } - return true; + t = va_arg (*text->args_ptr, tree); + break; default: return false; } + + if (DECL_P (t)) + { + const char *n = DECL_NAME (t) + ? lang_hooks.decl_printable_name (t, 2) + : "<anonymous>"; + pp_string (pp, n); + } + else + dump_generic_node (pp, t, 0, 0, 0); + + return true; } /* Initialization of the front end environment, before command line diff --git a/gcc/tree-outof-ssa.c b/gcc/tree-outof-ssa.c index 430e8ca..65c74d3 100644 --- a/gcc/tree-outof-ssa.c +++ b/gcc/tree-outof-ssa.c @@ -157,10 +157,16 @@ create_temp (tree t) name = "temp"; tmp = create_tmp_var (type, name); - if (DECL_DEBUG_ALIAS_OF (t)) - DECL_DEBUG_ALIAS_OF (tmp) = DECL_DEBUG_ALIAS_OF (t); + if (DECL_DEBUG_EXPR (t) && DECL_DEBUG_EXPR_IS_FROM (t)) + { + DECL_DEBUG_EXPR (tmp) = DECL_DEBUG_EXPR (t); + DECL_DEBUG_EXPR_IS_FROM (tmp) = 1; + } else if (!DECL_IGNORED_P (t)) - DECL_DEBUG_ALIAS_OF (tmp) = t; + { + DECL_DEBUG_EXPR (tmp) = t; + DECL_DEBUG_EXPR_IS_FROM (tmp) = 1; + } DECL_ARTIFICIAL (tmp) = DECL_ARTIFICIAL (t); DECL_IGNORED_P (tmp) = DECL_IGNORED_P (t); add_referenced_tmp_var (tmp); diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index 1ac0ec0..01bf53c 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -144,6 +144,8 @@ static struct obstack sra_obstack; static void dump_sra_elt_name (FILE *, struct sra_elt *); extern void debug_sra_elt_name (struct sra_elt *); +/* Forward declarations. */ +static tree generate_element_ref (struct sra_elt *); /* Return true if DECL is an SRA candidate. */ @@ -1112,15 +1114,25 @@ instantiate_element (struct sra_elt *elt) elt->replacement = var = make_rename_temp (elt->type, "SR"); DECL_SOURCE_LOCATION (var) = DECL_SOURCE_LOCATION (base); - TREE_NO_WARNING (var) = TREE_NO_WARNING (base); - DECL_ARTIFICIAL (var) = DECL_ARTIFICIAL (base); - DECL_IGNORED_P (var) = DECL_IGNORED_P (base); + DECL_ARTIFICIAL (var) = 1; if (DECL_NAME (base) && !DECL_IGNORED_P (base)) { char *pretty_name = build_element_name (elt); DECL_NAME (var) = get_identifier (pretty_name); obstack_free (&sra_obstack, pretty_name); + + DECL_DEBUG_EXPR (var) = generate_element_ref (elt); + DECL_DEBUG_EXPR_IS_FROM (var) = 1; + + DECL_IGNORED_P (var) = 0; + TREE_NO_WARNING (var) = TREE_NO_WARNING (base); + } + else + { + DECL_IGNORED_P (var) = 1; + /* ??? We can't generate any warning that would be meaningful. */ + TREE_NO_WARNING (var) = 1; } if (dump_file) @@ -2018,9 +2018,13 @@ struct tree_binfo GTY (()) writing debugging information about vfield and vbase decls for C++. */ #define DECL_FCONTEXT(NODE) (FIELD_DECL_CHECK (NODE)->decl.vindex) -/* For VAR_DECL, this is set to the variable we were split from, due to - optimization. */ -#define DECL_DEBUG_ALIAS_OF(NODE) (DECL_CHECK (NODE)->decl.vindex) +/* For VAR_DECL, this is set to either an expression that it was split + from (if DECL_DEBUG_EXPR_IS_FROM is true), otherwise a tree_list of + subexpressions that it was split into. */ +#define DECL_DEBUG_EXPR(NODE) (DECL_CHECK (NODE)->decl.vindex) + +#define DECL_DEBUG_EXPR_IS_FROM(NODE) \ + (DECL_CHECK (NODE)->decl.debug_expr_is_from) /* Every ..._DECL node gets a unique number. */ #define DECL_UID(NODE) (DECL_CHECK (NODE)->decl.uid) @@ -2361,7 +2365,8 @@ struct tree_decl GTY(()) unsigned possibly_inlined : 1; unsigned preserve_flag: 1; unsigned gimple_formal_temp : 1; - /* 13 unused bits. */ + unsigned debug_expr_is_from : 1; + /* 12 unused bits. */ union tree_decl_u1 { /* In a FUNCTION_DECL for which DECL_BUILT_IN holds, this is diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c index 14a1dc2..7621313 100644 --- a/gcc/var-tracking.c +++ b/gcc/var-tracking.c @@ -1460,8 +1460,15 @@ track_expr_p (tree expr) don't need to track this expression if the ultimate declaration is ignored. */ realdecl = expr; - if (DECL_DEBUG_ALIAS_OF (realdecl)) - realdecl = DECL_DEBUG_ALIAS_OF (realdecl); + if (DECL_DEBUG_EXPR (realdecl) + && DECL_DEBUG_EXPR_IS_FROM (realdecl)) + { + realdecl = DECL_DEBUG_EXPR (realdecl); + /* ??? We don't yet know how to emit DW_OP_piece for variable + that has been SRA'ed. */ + if (!DECL_P (realdecl)) + return 0; + } /* Do not track EXPR if REALDECL it should be ignored for debugging purposes. */ |