]> granicus.if.org Git - clang/commitdiff
Revert r163829. The world (or libstdc++, at least) is not ready.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 13 Sep 2012 22:00:12 +0000 (22:00 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 13 Sep 2012 22:00:12 +0000 (22:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163846 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOverload.cpp
test/CXX/expr/expr.const/p3-0x.cpp
test/CodeGenCXX/mangle.cpp

index 4d8795ea962f3cd1dcb08a189adf0b27e41b58cd..14f8db6db5e8a090f2e549438ed4293ee8ff8c17 100644 (file)
@@ -4818,6 +4818,12 @@ static bool CheckConvertedConstantConversions(Sema &S,
     return true;
 
   case ICK_Boolean_Conversion:
+    // Conversion from an integral or unscoped enumeration type to bool is
+    // classified as ICK_Boolean_Conversion, but it's also an integral
+    // conversion, so it's permitted in a converted constant expression.
+    return SCS.getFromType()->isIntegralOrUnscopedEnumerationType() &&
+           SCS.getToType(2)->isBooleanType();
+
   case ICK_Floating_Integral:
   case ICK_Complex_Real:
     return false;
index dca20c90c2e6a6e06365c800d8d425428e76b6e2..6ddd11bcee268024efb2eeacf28eba6fef466554 100644 (file)
@@ -73,13 +73,12 @@ using Int = A<1000>; // expected-error {{template argument evaluates to 1000, wh
 using Int = A<-3>; // expected-error {{template argument evaluates to -3, which cannot be narrowed to type 'unsigned char'}}
 
 // Note, conversions from integral or unscoped enumeration types to bool are
-// boolean conversions, not integral conversions, so are not permitted. See
-// core issue 1407.
+// integral conversions as well as boolean conversions.
 template<typename T, T v> struct Val { static constexpr T value = v; };
-static_assert(Val<bool, E1>::value == 1, ""); // expected-error {{conversion from 'E' to 'bool' is not allowed in a converted constant expression}}
-static_assert(Val<bool, '\0'>::value == 0, ""); // expected-error {{conversion from 'char' to 'bool' is not allowed in a converted constant expression}}
-static_assert(Val<bool, U'\1'>::value == 1, ""); // expected-error {{conversion from 'char32_t' to 'bool' is not allowed in a converted constant expression}}
-static_assert(Val<bool, E5>::value == 1, ""); // expected-error {{conversion from 'E' to 'bool' is not allowed in a converted constant expression}}
+static_assert(Val<bool, E1>::value == 1, ""); // ok
+static_assert(Val<bool, '\0'>::value == 0, ""); // ok
+static_assert(Val<bool, U'\1'>::value == 1, ""); // ok
+static_assert(Val<bool, E5>::value == 1, ""); // expected-error {{5, which cannot be narrowed to type 'bool'}}
 
 // (no other conversions are permitted)
 using Int = A<1.0>; // expected-error {{conversion from 'double' to 'unsigned char' is not allowed in a converted constant expression}}
index b384d2ea13f611a5f5fed600e73abc18c7f92cbc..ba1b3bf5acd267b69d8d09b78cfe1b3e59cfa020 100644 (file)
@@ -181,7 +181,7 @@ template <typename T> typename T::U ft6(const T&) { return 0; }
 template int ft6<S>(const S&);
 
 template<typename> struct __is_scalar_type {
-  static const bool __value = true;
+  enum { __value = 1 };
 };
 
 template<bool, typename> struct __enable_if { };
@@ -231,7 +231,7 @@ template void ft8<void*>();
 // PR5796
 namespace PR5796 {
 template<typename> struct __is_scalar_type {
-  static const bool __value = false;
+  enum { __value = 0 };
 };
 
 template<bool, typename> struct __enable_if {};