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]

Patch for bug 22308


This patch fixes bug 22308, a regression from 2.95.x where
C_TYPE_FIELDS_READONLY was not being updated for variants of a
structure type being completed.  The same issue appears to be present
in principle with C_TYPE_FIELDS_VOLATILE and C_TYPE_VARIABLE_SIZE
although I did not find a testcase where this causes a bug.

Bootstrapped with no regressions on x86_64-unknown-linux-gnu.  Applied
to mainline.  I'm testing for 3.4 and 4.0 branches, and subject to
testing passing there will apply the patch or a suitable variant
thereof to 3.4 branch and queue it for 4.0.2.  (In general many
c-decl.c bugs aren't suitable for fixing on 3.4 branch, but this is
one which is suitable for fixing there.)

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    joseph@codesourcery.com (CodeSourcery mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)

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.

testsuite:
2005-07-05  Joseph S. Myers  <joseph@codesourcery.com>

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

diff -rupN GCC.orig/gcc/c-decl.c GCC/gcc/c-decl.c
--- GCC.orig/gcc/c-decl.c	2005-07-03 20:58:28.000000000 +0000
+++ GCC/gcc/c-decl.c	2005-07-05 13:50:44.000000000 +0000
@@ -5420,6 +5420,9 @@ finish_struct (tree t, tree fieldlist, t
       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
diff -rupN GCC.orig/gcc/testsuite/gcc.dg/pr22308-1.c GCC/gcc/testsuite/gcc.dg/pr22308-1.c
--- GCC.orig/gcc/testsuite/gcc.dg/pr22308-1.c	1970-01-01 00:00:00.000000000 +0000
+++ GCC/gcc/testsuite/gcc.dg/pr22308-1.c	2005-07-05 13:35:08.000000000 +0000
@@ -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'" } */
+}


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