re PR tree-optimization/36879 (undefined reference to a variable)
authorAndrew Pinski <andrew_pinski@playstation.sony.com>
Sun, 20 Jul 2008 17:51:48 +0000 (17:51 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Sun, 20 Jul 2008 17:51:48 +0000 (10:51 -0700)
2008-07-20  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR tree-opt/36879
        * tree-switch-conversion.c (build_one_array): Call
        varpool_mark_needed_node and varpool_finalize_decl
        instead of assemble_variable.

2008-07-20  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR tree-opt/36879
        * gcc.c-torture/execute/20080719-1.c: New testcase.

From-SVN: r138012

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20080719-1.c [new file with mode: 0644]
gcc/tree-switch-conversion.c

index 63fff767c202658383b7ebd65a43d6dec0868128..494e252fa78d95082778f382c3c370b1ac0c4071 100644 (file)
@@ -1,3 +1,10 @@
+2008-07-20  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+       PR tree-opt/36879
+       * tree-switch-conversion.c (build_one_array): Call
+       varpool_mark_needed_node and varpool_finalize_decl 
+       instead of assemble_variable.
+
 2008-07-19  Jan Hubicka  <jh@suse.cz>
 
        * cgraph.c (cgraph_add_new_function): Do early local passes.
index 6de072e05e8f8ff2ccea4f55580aff23bff1bea7..8eea44725d937aeb370a01e0875d65c7d1cd63f6 100644 (file)
@@ -1,3 +1,8 @@
+2008-07-20  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+       PR tree-opt/36879
+       * gcc.c-torture/execute/20080719-1.c: New testcase.
+
 2008-07-20  Hans-Peter Nilsson  <hp@axis.com>
 
        * gcc.dg/tree-ssa/data-dep-1.c: XFAIL.
diff --git a/gcc/testsuite/gcc.c-torture/execute/20080719-1.c b/gcc/testsuite/gcc.c-torture/execute/20080719-1.c
new file mode 100644 (file)
index 0000000..694abcb
--- /dev/null
@@ -0,0 +1,65 @@
+typedef unsigned int u32;
+
+static const u32 deadfish = 0xdeadf155;
+
+static const u32 cfb_tab8_be[] = {
+    0x00000000,0x000000ff,0x0000ff00,0x0000ffff,
+    0x00ff0000,0x00ff00ff,0x00ffff00,0x00ffffff,
+    0xff000000,0xff0000ff,0xff00ff00,0xff00ffff,
+    0xffff0000,0xffff00ff,0xffffff00,0xffffffff
+};
+
+static const u32 cfb_tab8_le[] = {
+    0x00000000,0xff000000,0x00ff0000,0xffff0000,
+    0x0000ff00,0xff00ff00,0x00ffff00,0xffffff00,
+    0x000000ff,0xff0000ff,0x00ff00ff,0xffff00ff,
+    0x0000ffff,0xff00ffff,0x00ffffff,0xffffffff
+};
+
+static const u32 cfb_tab16_be[] = {
+    0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff
+};
+
+static const u32 cfb_tab16_le[] = {
+    0x00000000, 0xffff0000, 0x0000ffff, 0xffffffff
+};
+
+static const u32 cfb_tab32[] = {
+ 0x00000000, 0xffffffff
+};
+
+
+
+
+
+
+const u32 *xxx(int bpp)
+{
+ const u32 *tab;
+
+if (0) return &deadfish;
+
+ switch (bpp) {
+ case 8:
+  tab = cfb_tab8_be;
+  break;
+ case 16:
+  tab = cfb_tab16_be;
+  break;
+ case 32:
+ default:
+  tab = cfb_tab32;
+  break;
+ }
+
+ return tab;
+}
+
+int main(void)
+{
+  const u32 *a = xxx(8);
+  int b = a[0];
+  if (b != cfb_tab8_be[0])
+    __builtin_abort ();
+  return 0;
+}
index 36c87f9bd5184932c1a4ad3260b523bb75b0d999..2205c1a8b7172567fac047d2049e3133e228df8c 100644 (file)
@@ -474,7 +474,8 @@ build_one_array (tree swtch, int num, tree arr_index_type, tree phi, tree tidx)
   DECL_ARTIFICIAL (decl) = 1;
   TREE_CONSTANT (decl) = 1;
   add_referenced_var (decl);
-  assemble_variable (decl, 0, 0, 0);
+  varpool_mark_needed_node (varpool_node (decl));
+  varpool_finalize_decl (decl);
   mark_sym_for_renaming (decl);
 
   name = make_ssa_name (SSA_NAME_VAR (PHI_RESULT (phi)), NULL_TREE);