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 7a087c5..69aa170 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 6551de6..de981bc 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 05beba0..6612d86 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());
+}