re PR c++/14329 ([4.1 only] badly formatted warnings for SRA replacements used uninit...
authorRichard Henderson <rth@redhat.com>
Thu, 27 Jan 2005 09:28:45 +0000 (01:28 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Thu, 27 Jan 2005 09:28:45 +0000 (01:28 -0800)
        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

gcc/ChangeLog
gcc/c-objc-common.c
gcc/dwarf2out.c
gcc/testsuite/gcc.dg/uninit-I.c [new file with mode: 0644]
gcc/toplev.c
gcc/tree-outof-ssa.c
gcc/tree-sra.c
gcc/tree.h
gcc/var-tracking.c

index e7cfcd234e42cfaf21c9320c2223ae98d43e163b..6999c439dc2c5bed376edda709452f076befc5b9 100644 (file)
@@ -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,
index 35bcf9e327559430e1b9474c1b8b24acfe12b3b2..50bb0fc0da29298d586967007bbc0804b050d3f2 100644 (file)
@@ -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);
index 6336cf69dba8b283d842e8f333af738ea4912f34..49bca54c9516aaf143048802e87db62a37a4caf3 100644 (file)
@@ -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 (file)
index 0000000..bd7c13a
--- /dev/null
@@ -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;
+}
index af57e570f78ccffe0b29d8213b5af2dfe7160888..2659997a9418078ef2d2bfe332fd54288df135d4 100644 (file)
@@ -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
index 430e8cae58a6e2b28afe2498b52497efee0f1b4b..65c74d310a4fe18b3eb546194b570b61f578cade 100644 (file)
@@ -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);
index 1ac0ec0a0aeb4fe967f7a53c93789352ee655996..01bf53c0af9274d7e39925807732dbfc659f0061 100644 (file)
@@ -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 *);
 \f
 /* 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)
index b393cab2c4073dbeae0e5f5be047f6713d08b3ae..a4c590b476abcb464c5a026b08eadfceb581aa80 100644 (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
index 14a1dc263f6fc2863c8ddce4d4d24a317b504bfc..7621313fa1392bfdd0076aab9eaa7bf28ada2064 100644 (file)
@@ -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.  */