re PR c++/48534 ([C++0x][SFINAE] Compiler break down on explicit scoped enum => bool...
authorJason Merrill <jason@redhat.com>
Mon, 11 Apr 2011 22:00:31 +0000 (18:00 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 11 Apr 2011 22:00:31 +0000 (18:00 -0400)
PR c++/48534
* cvt.c (ocp_convert): Use build_nop to convert to underlying type
of scoped enum.

From-SVN: r172284

gcc/cp/ChangeLog
gcc/cp/cvt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/enum10.C [new file with mode: 0644]

index 7a087c52ddc392cd4decf6e1b672a74791d47f7d..69aa17081eec3ed0502ef68bd2618ccc756642cd 100644 (file)
@@ -1,5 +1,9 @@
 2011-04-11  Jason Merrill  <jason@redhat.com>
 
+       PR c++/48534
+       * cvt.c (ocp_convert): Use build_nop to convert to underlying type
+       of scoped enum.
+
        PR c++/48523
        * tree.c (maybe_dummy_object): Use build_x_indirect_ref rather
        than cp_build_indirect_ref.
index 6551de62ac31c8c88ba75e2427c4cd7147e39e11..de981bc01131b88cf7a735ddafaacd3aeb2057e9 100644 (file)
@@ -731,7 +731,7 @@ ocp_convert (tree type, tree expr, int convtype, int flags)
          /* We can't implicitly convert a scoped enum to bool, so convert
             to the underlying type first.  */
          if (SCOPED_ENUM_P (intype) && (convtype & CONV_STATIC))
-           e = convert (ENUM_UNDERLYING_TYPE (intype), e);
+           e = build_nop (ENUM_UNDERLYING_TYPE (intype), e);
          return cp_truthvalue_conversion (e);
        }
 
index 05beba02a41fc84ec29eb84f702113bd28250c08..6612d864613c4d62b204c8cf3450effc16487edf 100644 (file)
@@ -1,5 +1,7 @@
 2011-04-11  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/cpp0x/enum10.C: New.
+
        * g++.dg/cpp0x/lambda/lambda-this4.C: New.
 
        * g++.dg/cpp0x/rv-func.C: New.
diff --git a/gcc/testsuite/g++.dg/cpp0x/enum10.C b/gcc/testsuite/g++.dg/cpp0x/enum10.C
new file mode 100644 (file)
index 0000000..55a1ab4
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/48534
+// { dg-options -std=c++0x }
+
+enum class OpSE : bool;
+
+int main()
+{
+  return static_cast<bool>(OpSE());
+}