PR c++/25331
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 13 Dec 2005 07:56:10 +0000 (07:56 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 13 Dec 2005 07:56:10 +0000 (07:56 +0000)
* gcc.dg/compat/struct-layout-1_generate.c (subfield): Don't
put atal* and atpaal* attributes on array elements.
(generate_fields): Revert 2005-10-07 and 2005-10-11 changes.
* g++.dg/compat/struct-layout-1_generate.c (subfield): Don't
put atal* and atpaal* attributes on array elements.
(generate_fields): Don't prevent atal* attribute on ETYPE_ARRAY.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@108460 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/compat/struct-layout-1_generate.c
gcc/testsuite/gcc.dg/compat/struct-layout-1_generate.c

index 2bd0541..e71e05e 100644 (file)
@@ -1,3 +1,13 @@
+2005-12-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/25331
+       * gcc.dg/compat/struct-layout-1_generate.c (subfield): Don't
+       put atal* and atpaal* attributes on array elements.
+       (generate_fields): Revert 2005-10-07 and 2005-10-11 changes.
+       * g++.dg/compat/struct-layout-1_generate.c (subfield): Don't
+       put atal* and atpaal* attributes on array elements.
+       (generate_fields): Don't prevent atal* attribute on ETYPE_ARRAY.
+
 2005-12-13  Carlos O'Donell <carlos@codesourcery.com>
 
        * gcc.dg/single-precision-constant.c: New test.
index 2951638..da915c7 100644 (file)
@@ -609,6 +609,13 @@ subfield (struct entry *e, char *letter)
            snprintf (buf, 20, "%c[]", *letter);
          else
            snprintf (buf, 20, "%c[%d]", *letter, e[0].arr_len);
+         /* If this is an array type, do not put aligned attributes on
+            elements.  Aligning elements to a value greater than their
+            size will result in a compiler error.  */
+         if (type == 1
+             && ((strncmp (e[0].attrib, "atal", 4) == 0)
+                  || strncmp (e[0].attrib, "atpaal", 6) == 0))
+           type = 2;
        }
       else
        {
@@ -665,18 +672,32 @@ subfield (struct entry *e, char *letter)
        }
       ++*letter;
       if (e[0].attrib)
-       switch (generate_random () % 3)
-         {
-         case 0:
-           fprintf (outfile, "%s %s %s;", e[0].attrib, e[0].type->name, buf);
-           break;
-         case 1:
-           fprintf (outfile, "%s %s %s;", e[0].type->name, e[0].attrib, buf);
-           break;
-         case 2:
-           fprintf (outfile, "%s %s %s;", e[0].type->name, buf, e[0].attrib);
-           break;
-         }
+       {
+         /* If this is an array type, do not put aligned attributes on
+            elements.  Aligning elements to a value greater than their
+            size will result in a compiler error.  */
+         if (e[0].etype == ETYPE_ARRAY
+             && ((strncmp (e[0].attrib, "atal", 4) == 0)
+                  || strncmp (e[0].attrib, "atpaal", 6) == 0))
+           type = 2;
+         else
+           type = generate_random () % 3;
+         switch (type)
+           {
+           case 0:
+             fprintf (outfile, "%s %s %s;", e[0].attrib, e[0].type->name,
+                      buf);
+             break;
+           case 1:
+             fprintf (outfile, "%s %s %s;", e[0].type->name, e[0].attrib,
+                      buf);
+             break;
+           case 2:
+             fprintf (outfile, "%s %s %s;", e[0].type->name, buf,
+                      e[0].attrib);
+             break;
+           }
+       }
       else
        fprintf (outfile, "%s %s;", e[0].type->name, buf);
       return 1;
@@ -1297,15 +1318,6 @@ generate_fields (enum FEATURE features, struct entry *e, struct entry *parent,
                  || (e[n].type >= &aligned_bitfld_types[0]
                      && e[n].type < &aligned_bitfld_types[n_aligned_bitfld_types])))
            e[n].attrib = NULL;
-
-         /* If this is an array type, do not put aligned attributes on
-            elements.  Aligning elements to a value greater than their
-            size will result in a compiler error.  */
-
-         if ((e[n].etype == ETYPE_ARRAY)
-             && e[n].attrib != NULL
-             && (strncmp (e[n].attrib, "atal", 4) == 0))
-            e[n].attrib = NULL;
        }
     }
 }
index 2f69575..cca2954 100644 (file)
@@ -789,6 +789,13 @@ subfield (struct entry *e, char *letter)
            snprintf (buf, 20, "%c[]", *letter);
          else
            snprintf (buf, 20, "%c[%d]", *letter, e[0].arr_len);
+         /* If this is an array type, do not put aligned attributes on
+            elements.  Aligning elements to a value greater than their
+            size will result in a compiler error.  */
+         if (type == 1
+             && ((strncmp (e[0].attrib, "atal", 4) == 0)
+                  || strncmp (e[0].attrib, "atpaal", 6) == 0))
+           type = 2;
        }
       else
         {
@@ -845,18 +852,32 @@ subfield (struct entry *e, char *letter)
         }
       ++*letter;
       if (e[0].attrib)
-       switch (generate_random () % 3)
-          {
-          case 0:
-            fprintf (outfile, "%s %s %s;", e[0].attrib, e[0].type->name, buf);
-            break;
-          case 1:
-            fprintf (outfile, "%s %s %s;", e[0].type->name, e[0].attrib, buf);
-            break;
-          case 2:
-            fprintf (outfile, "%s %s %s;", e[0].type->name, buf, e[0].attrib);
-            break;
-          }
+       {
+         /* If this is an array type, do not put aligned attributes on
+            elements.  Aligning elements to a value greater than their
+            size will result in a compiler error.  */
+         if (e[0].etype == ETYPE_ARRAY
+              && ((strncmp (e[0].attrib, "atal", 4) == 0)
+                   || strncmp (e[0].attrib, "atpaal", 6) == 0))
+           type = 2;
+         else
+            type = generate_random () % 3;
+         switch (type)
+           {
+           case 0:
+             fprintf (outfile, "%s %s %s;", e[0].attrib, e[0].type->name,
+                      buf);
+             break;
+           case 1:
+             fprintf (outfile, "%s %s %s;", e[0].type->name, e[0].attrib,
+                      buf);
+             break;
+           case 2:
+             fprintf (outfile, "%s %s %s;", e[0].type->name, buf,
+                      e[0].attrib);
+             break;
+           }
+       }
       else
        fprintf (outfile, "%s %s;", e[0].type->name, buf);
       return 1;
@@ -1746,15 +1767,6 @@ generate_fields (enum FEATURE features, struct entry *e, struct entry *parent,
                  || (e[n].type >= &aligned_bitfld_types[0]
                      && e[n].type < &aligned_bitfld_types[n_aligned_bitfld_types])))
            e[n].attrib = NULL;
-
-         /* If this is an array type, do not put aligned attributes on
-            elements.  Aligning elements to a value greater than their
-            size will result in a compiler error.  */
-
-         if ((e[n].etype == ETYPE_ARRAY)
-             && e[n].attrib != NULL
-             && (strncmp (e[n].attrib, "atal", 4) == 0))
-            e[n].attrib = NULL;
        }
     }
 }