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]

C++ PATCH: PR 30328


This patch fixes PR c++/30328, another bitfield problem.  Here, we
were using the lowered (rather than unlowered) type of the bitfield
when computing a typoef expression.  (This is yet another problem
related to language extensions.)

Tested on x86_64-unknown-linux-gnu, applied to the mainline.  I will
apply to the 4.2 branch once testing completes.

--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

2007-03-11  Mark Mitchell  <mark@codesourcery.com>

	PR c++/30328
	* semantics.c (finish_typeof): Use unlowered_expr_type.
	
2007-03-11  Mark Mitchell  <mark@codesourcery.com>

	PR c++/30328
	* g++.dg/ext/bitfield1.C: New test.

Index: gcc/cp/semantics.c
===================================================================
--- gcc/cp/semantics.c	(revision 122822)
+++ gcc/cp/semantics.c	(working copy)
@@ -2927,7 +2928,7 @@ finish_typeof (tree expr)
       return type;
     }
 
-  type = TREE_TYPE (expr);
+  type = unlowered_expr_type (expr);
 
   if (!type || type == unknown_type_node)
     {
Index: gcc/testsuite/g++.dg/ext/bitfield1.C
===================================================================
--- gcc/testsuite/g++.dg/ext/bitfield1.C	(revision 0)
+++ gcc/testsuite/g++.dg/ext/bitfield1.C	(revision 0)
@@ -0,0 +1,22 @@
+// PR c++/30328
+// { dg-do link }
+// { dg-options "" }
+
+struct S
+{
+  signed int a:17;
+} x;
+
+typedef typeof (x.a) foo;
+
+template <class T>
+T* inc(T* p) { return p+1; }
+
+int main ()
+{
+  foo x[2] = { 1,2 };
+  int y[2] = { 1,2 };
+  *inc(x);
+  *inc(y);
+  return 0;
+}


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