]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c/22308
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 5 Jul 2005 17:34:29 +0000 (17:34 +0000)
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 5 Jul 2005 17:34:29 +0000 (17:34 +0000)
* c-decl.c (finish_struct): Also copy C_TYPE_FIELDS_READONLY,
C_TYPE_FIELDS_VOLATILE and C_TYPE_VARIABLE_SIZE to type variants.

testsuite:
* gcc.dg/pr22308-1.c: New test.

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

gcc/ChangeLog
gcc/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr22308-1.c [new file with mode: 0644]

index d680ff852b48b215fcf6ec557a0c70b3d5580c4b..2d3889700da3e9058fd3e1d0f6b02d946af37bec 100644 (file)
@@ -1,3 +1,9 @@
+2005-07-05  Joseph S. Myers  <joseph@codesourcery.com>
+
+       PR c/22308
+       * c-decl.c (finish_struct): Also copy C_TYPE_FIELDS_READONLY,
+       C_TYPE_FIELDS_VOLATILE and C_TYPE_VARIABLE_SIZE to type variants.
+
 2005-07-05  Paolo Bonzini  <bonzini@gnu.org>
 
        * Makefile.in: Adjust dependencies.
index 3c241fe6af943e044ef76eef9d51bddfa1d51dbb..23ff373ed0d6b36818edde2d816e508e8dc8f2c2 100644 (file)
@@ -5420,6 +5420,9 @@ finish_struct (tree t, tree fieldlist, tree attributes)
       TYPE_LANG_SPECIFIC (x) = TYPE_LANG_SPECIFIC (t);
       TYPE_ALIGN (x) = TYPE_ALIGN (t);
       TYPE_USER_ALIGN (x) = TYPE_USER_ALIGN (t);
+      C_TYPE_FIELDS_READONLY (x) = C_TYPE_FIELDS_READONLY (t);
+      C_TYPE_FIELDS_VOLATILE (x) = C_TYPE_FIELDS_VOLATILE (t);
+      C_TYPE_VARIABLE_SIZE (x) = C_TYPE_VARIABLE_SIZE (t);
     }
 
   /* If this was supposed to be a transparent union, but we can't
index 546754f2e7d43da5568c77ca74abd3ece45e705a..7588b6669e72b8023fdafd38e2591648f4f29dde 100644 (file)
@@ -1,3 +1,8 @@
+2005-07-05  Joseph S. Myers  <joseph@codesourcery.com>
+
+       PR c/22308
+       * gcc.dg/pr22308-1.c: New test.
+
 2005-07-05  Kazu Hirata  <kazu@codesourcery.com>
 
        * gcc.dg/compare1.c: Add -fno-short-enums.  Don't skip on any
diff --git a/gcc/testsuite/gcc.dg/pr22308-1.c b/gcc/testsuite/gcc.dg/pr22308-1.c
new file mode 100644 (file)
index 0000000..bcbb294
--- /dev/null
@@ -0,0 +1,13 @@
+/* Bug 22308: C_TYPE_FIELDS_READONLY not updated on type variants.  */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+struct foo s;
+volatile struct foo t;
+struct foo { const int z; };
+
+void
+bar (void)
+{
+  t = s; /* { dg-error "error: assignment of read-only variable 't'" } */
+}