]> gcc.gnu.org Git - gcc.git/commitdiff
re PR middle-end/41837 (Using '-O -fipa-struct-reorg -fwhole-program -fprofile-genera...
authorJakub Jelinek <jakub@redhat.com>
Wed, 28 Oct 2009 14:45:03 +0000 (15:45 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 28 Oct 2009 14:45:03 +0000 (15:45 +0100)
PR middle-end/41837
* ipa-struct-reorg.c (find_field_in_struct_1): Return NULL if
fields don't have DECL_NAME.

* gcc.dg/pr41837.c: New test.

From-SVN: r153670

gcc/ChangeLog
gcc/ipa-struct-reorg.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr41837.c [new file with mode: 0644]

index dccf36fe96fc27b2282e1396ec4a739eeae3ca3d..e43a0774893c3968859c2cc98423a16c28a92391 100644 (file)
@@ -4,6 +4,10 @@
        vt_expand_loc unnecessarily when location is not a register nor
        memory.
 
+       PR middle-end/41837
+       * ipa-struct-reorg.c (find_field_in_struct_1): Return NULL if
+       fields don't have DECL_NAME.
+
        PR debug/41801
        * builtins.c (get_builtin_sync_mem): Expand loc in ptr_mode,
        call convert_memory_address on addr.
index bc84eee372b483fce4e0bd3670d78517c525f051..7b05bf64c0d7f14be814e76c33a42e70bbffa44e 100644 (file)
@@ -258,15 +258,21 @@ find_field_in_struct_1 (tree str_type, tree field)
 {
   tree str_field;
 
+  if (!DECL_NAME (field))
+    return NULL;
+
   for (str_field = TYPE_FIELDS (str_type); str_field; 
        str_field = TREE_CHAIN (str_field))
     {
-      const char * str_field_name;
-      const char * field_name;
+      const char *str_field_name;
+      const char *field_name;
+
+      if (!DECL_NAME (str_field))
+       continue;
 
       str_field_name = IDENTIFIER_POINTER (DECL_NAME (str_field));
       field_name = IDENTIFIER_POINTER (DECL_NAME (field));
-      
+
       gcc_assert (str_field_name);
       gcc_assert (field_name);
 
@@ -274,7 +280,7 @@ find_field_in_struct_1 (tree str_type, tree field)
        {
          /* Check field types.  */       
          if (is_equal_types (TREE_TYPE (str_field), TREE_TYPE (field)))
-             return str_field;
+           return str_field;
        }
     }
 
index 747c81b7d8f2a2751e1164e5e5653d39877439f2..9f06387b1fbd9a9c76c16e6c08217bfbe0068d95 100644 (file)
@@ -1,5 +1,8 @@
 2009-10-28  Jakub Jelinek  <jakub@redhat.com>
 
+       PR middle-end/41837
+       * gcc.dg/pr41837.c: New test.
+
        PR debug/41801
        * g++.dg/ext/sync-3.C: New test.
 
diff --git a/gcc/testsuite/gcc.dg/pr41837.c b/gcc/testsuite/gcc.dg/pr41837.c
new file mode 100644 (file)
index 0000000..f96c347
--- /dev/null
@@ -0,0 +1,38 @@
+/* PR middle-end/41837 */
+/* { dg-do compile } */
+/* { dg-options "-fipa-struct-reorg -O -fwhole-program -fprofile-generate" } */
+
+typedef struct { int a, b; } T1;
+typedef struct S1 *T2;
+typedef struct S2 *T3;
+typedef struct S3 *T4;
+typedef struct S4 *T5;
+struct S4 { union { int c; } d; };
+struct S2 { int e; T2 f; int g; };
+typedef struct { T3 h; } T6;
+typedef struct { int i; } *T7;
+struct S3 { T6 j; T7 k; };
+
+void
+f1 (T4 x)
+{
+  if (!x->j.h->e)
+    f5 (x);
+}
+
+void
+f2 (void)
+{
+  f6 (f1);
+}
+
+void
+f3 (T5 x, T1 *y)
+{
+}
+
+void
+f4 (void)
+{
+  f7 (f3);
+}
This page took 0.138708 seconds and 5 git commands to generate.