This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tree-ssa] fix 14204


        * tree-ssa.c (warn_uninit): Don't warn for hard register variables.
        * gcc.dg/uninit-H.c: New.

Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa.c,v
retrieving revision 1.1.4.209
diff -u -p -r1.1.4.209 tree-ssa.c
--- tree-ssa.c	11 Mar 2004 05:07:18 -0000	1.1.4.209
+++ tree-ssa.c	12 Mar 2004 01:56:37 -0000
@@ -4090,19 +4090,28 @@ warn_uninit (tree t, const char *msgid, 
   tree var = SSA_NAME_VAR (t);
   tree def = SSA_NAME_DEF_STMT (t);
 
-  /* Default uses (indicated by an empty definition statement), are
-     uninitialized.  Except for PARMs of course, which are always
-     initialized.  TREE_NO_WARNING either means we already warned,
-     or the front end wishes to suppress the warning.  */
-  if (IS_EMPTY_STMT (def)
-      && TREE_CODE (var) != PARM_DECL
-      && !TREE_NO_WARNING (var))
-    {
-      if (!locus)
-	locus = &DECL_SOURCE_LOCATION (var);
-      warning (msgid, locus, var);
-      TREE_NO_WARNING (var) = 1;
-    }
+  /* Default uses (indicated by an empty definition statement),
+     are uninitialized.  */
+  if (!IS_EMPTY_STMT (def))
+    return;
+
+  /* Except for PARMs of course, which are always initialized.  */
+  if (TREE_CODE (var) == PARM_DECL)
+    return;
+
+  /* Hard register variables get their initial value from the ether.  */
+  if (DECL_HARD_REGISTER (var))
+    return;
+
+  /* TREE_NO_WARNING either means we already warned, or the front end
+     wishes to suppress the warning.  */
+  if (TREE_NO_WARNING (var))
+    return;
+
+  if (!locus)
+    locus = &DECL_SOURCE_LOCATION (var);
+  warning (msgid, locus, var);
+  TREE_NO_WARNING (var) = 1;
 }
    
 /* Called via walk_tree, look for SSA_NAMEs that have empty definitions
Index: testsuite/gcc.dg/uninit-H.c
===================================================================
RCS file: testsuite/gcc.dg/uninit-H.c
diff -N testsuite/gcc.dg/uninit-H.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/uninit-H.c	12 Mar 2004 01:56:51 -0000
@@ -0,0 +1,19 @@
+/* PR 14204 */
+/* { dg-do compile } */
+/* { dg-options "-O -Wall -Werror" } */
+
+#if defined __alpha__
+# define ASM __asm__("$30")
+#elif defined __i386__
+# define ASM __asm__("esp")
+#elif defined __powerpc__
+# define ASM __asm__("r1")
+#else
+# define ASM
+#endif
+
+void *load_PCB (void)
+{
+  register void *sp ASM;
+  return sp;			/* { dg-bogus "uninitialized" } */
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]