C++ PATCH: PR 31273

Mark Mitchell mark@codesourcery.com
Fri Mar 23 04:53:00 GMT 2007


This patch fixes fallout from the recent C++ bitfield patches.
standard_conversion keeps a variable "fcode" around, which is supposed
to be the same as "TREE_CODE (from)"; one of my patches caused the two
variables to get out of sync.  This fixes it, and, as penance, cleans
things up a bit by using type_decays_to to handle the decay of array
and function types.

Jim Wilson posted the key part of this patch to bugzilla; I just
tested it and checked it in.  

Tested on x86_64-unknown-linux-gnu, applied to 4.2.  I will apply to
mainline shortly.

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

2007-03-22  Jim Wilson  <wilson@specifix.com>
	    Mark Mitchell  <mark@codesourcery.com>

	PR c++/31273
	* call.c (standard_conversion): Use type_decays_to.  Keep FCODE
	consistent with FROM.

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

	PR c++/31273
	* g++.dg/expr/bitfield7.C: New test.

Index: gcc/cp/call.c
===================================================================
--- gcc/cp/call.c	(revision 123137)
+++ gcc/cp/call.c	(working copy)
@@ -636,15 +636,9 @@ standard_conversion (tree to, tree from,
   tcode = TREE_CODE (to);
 
   conv = build_identity_conv (from, expr);
-  if (fcode == FUNCTION_TYPE)
+  if (fcode == FUNCTION_TYPE || fcode == ARRAY_TYPE)
     {
-      from = build_pointer_type (from);
-      fcode = TREE_CODE (from);
-      conv = build_conv (ck_lvalue, from, conv);
-    }
-  else if (fcode == ARRAY_TYPE)
-    {
-      from = build_pointer_type (TREE_TYPE (from));
+      from = type_decays_to (from);
       fcode = TREE_CODE (from);
       conv = build_conv (ck_lvalue, from, conv);
     }
@@ -655,7 +649,10 @@ standard_conversion (tree to, tree from,
 	  tree bitfield_type;
 	  bitfield_type = is_bitfield_expr_with_lowered_type (expr);
 	  if (bitfield_type)
-	    from = strip_top_quals (bitfield_type);
+	    {
+	      from = strip_top_quals (bitfield_type);
+	      fcode = TREE_CODE (from);
+	    }
 	}
       conv = build_conv (ck_rvalue, from, conv);
     }
Index: gcc/testsuite/g++.dg/expr/bitfield7.C
===================================================================
--- gcc/testsuite/g++.dg/expr/bitfield7.C	(revision 0)
+++ gcc/testsuite/g++.dg/expr/bitfield7.C	(revision 0)
@@ -0,0 +1,8 @@
+// PR c++/31273
+
+enum E { e };
+struct S {
+  E v:5;
+};
+S s;
+int main() { if (!s.v) return 0; }



More information about the Gcc-patches mailing list