Patchwork [C++] Fix ENUM_FIXED_UNDERLYING_TYPE_P (PR c++/47704)

login
register
mail settings
Submitter Jakub Jelinek
Date Feb. 15, 2011, 10:07 p.m.
Message ID <20110215220717.GU30899@tyan-ft48-01.lab.bos.redhat.com>
Download mbox | patch
Permalink /patch/83304/
State New
Headers show

Comments

Jakub Jelinek - Feb. 15, 2011, 10:07 p.m.
Hi!

ENUM_FIXED_UNDERLYING_TYPE_P currently uses the same bit as TYPE_FOR_JAVA,
and in several places TYPE_FOR_JAVA isn't guarded just for class types.
The following patch instead uses TYPE_LANG_FLAG_5 bit instead, which is used
just by
#define SET_CLASS_TYPE_P(T, VAL) \
  (TYPE_LANG_FLAG_5 (T) = (VAL))
#define CLASS_TYPE_P(T) \
  (RECORD_OR_UNION_CODE_P (TREE_CODE (T)) && TYPE_LANG_FLAG_5 (T))
and SET_CLASS_TYPE_P only applies to the records/unions.  Additionally it
copies over the bit in pt.c.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2011-02-15  Jakub Jelinek  <jakub@redhat.com>

	PR c++/47704
	* cp-tree.h (ENUM_FIXED_UNDERLYING_TYPE_P): Use TYPE_LANG_FLAG_5
	instead of TYPE_LANG_FLAG_3.
	* pt.c (lookup_template_class): Copy over
	ENUM_FIXED_UNDERLYING_TYPE_P.

	* g++.dg/cpp0x/enum8.C: New test.


	Jakub
Jason Merrill - Feb. 16, 2011, 12:02 a.m.
OK.

Jason

Patch

--- gcc/cp/cp-tree.h.jj	2011-01-31 14:11:25.000000000 +0100
+++ gcc/cp/cp-tree.h	2011-02-15 17:10:56.000000000 +0100
@@ -115,6 +115,7 @@  c-common.h, not after.
    3: TYPE_FOR_JAVA.
    4: TYPE_HAS_NONTRIVIAL_DESTRUCTOR
    5: CLASS_TYPE_P (in RECORD_TYPE and UNION_TYPE)
+      ENUM_FIXED_UNDERLYING_TYPE_P (in ENUMERAL_TYPE)
    6: TYPE_DEPENDENT_P_VALID
 
    Usage of DECL_LANG_FLAG_?:
@@ -3098,7 +3099,7 @@  more_aggr_init_expr_args_p (const aggr_i
 
 /* Determines whether an ENUMERAL_TYPE has an explicit
    underlying type.  */
-#define ENUM_FIXED_UNDERLYING_TYPE_P(NODE) (TYPE_LANG_FLAG_3 (NODE))
+#define ENUM_FIXED_UNDERLYING_TYPE_P(NODE) (TYPE_LANG_FLAG_5 (NODE))
 
 /* Returns the underlying type of the given enumeration type. The
    underlying type is determined in different ways, depending on the
--- gcc/cp/pt.c.jj	2011-02-15 15:42:18.000000000 +0100
+++ gcc/cp/pt.c	2011-02-15 20:48:29.000000000 +0100
@@ -6993,6 +6993,8 @@  lookup_template_class (tree d1,
               SET_SCOPED_ENUM_P (t, SCOPED_ENUM_P (template_type));
             }
           SET_OPAQUE_ENUM_P (t, OPAQUE_ENUM_P (template_type));
+	  ENUM_FIXED_UNDERLYING_TYPE_P (t)
+	    = ENUM_FIXED_UNDERLYING_TYPE_P (template_type);
 	}
       else
 	{
--- gcc/testsuite/g++.dg/cpp0x/enum8.C.jj	2011-02-15 17:00:24.000000000 +0100
+++ gcc/testsuite/g++.dg/cpp0x/enum8.C	2011-02-15 16:59:56.000000000 +0100
@@ -0,0 +1,10 @@ 
+// PR c++/47704
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+void
+foo ()
+{
+  enum class E { A, B };
+  new E;
+}