From ceb07622bacde3184b19caf0957f5eeba5cb6784 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 13 Sep 2012 19:55:13 +0000 Subject: [PATCH] Remove speculative fix for C++ core issue 1407, since it was resolved as NAD. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163829 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaOverload.cpp | 6 ------ test/CXX/expr/expr.const/p3-0x.cpp | 11 ++++++----- test/CodeGenCXX/mangle.cpp | 4 ++-- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index ea0f4b6937..ec64665516 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -4798,12 +4798,6 @@ 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; diff --git a/test/CXX/expr/expr.const/p3-0x.cpp b/test/CXX/expr/expr.const/p3-0x.cpp index 6ddd11bcee..dca20c90c2 100644 --- a/test/CXX/expr/expr.const/p3-0x.cpp +++ b/test/CXX/expr/expr.const/p3-0x.cpp @@ -73,12 +73,13 @@ 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 -// integral conversions as well as boolean conversions. +// boolean conversions, not integral conversions, so are not permitted. See +// core issue 1407. template struct Val { static constexpr T value = v; }; -static_assert(Val::value == 1, ""); // ok -static_assert(Val::value == 0, ""); // ok -static_assert(Val::value == 1, ""); // ok -static_assert(Val::value == 1, ""); // expected-error {{5, which cannot be narrowed to type 'bool'}} +static_assert(Val::value == 1, ""); // expected-error {{conversion from 'E' to 'bool' is not allowed in a converted constant expression}} +static_assert(Val::value == 0, ""); // expected-error {{conversion from 'char' to 'bool' is not allowed in a converted constant expression}} +static_assert(Val::value == 1, ""); // expected-error {{conversion from 'char32_t' to 'bool' is not allowed in a converted constant expression}} +static_assert(Val::value == 1, ""); // expected-error {{conversion from 'E' to 'bool' is not allowed in a converted constant expression}} // (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}} diff --git a/test/CodeGenCXX/mangle.cpp b/test/CodeGenCXX/mangle.cpp index ba1b3bf5ac..b384d2ea13 100644 --- a/test/CodeGenCXX/mangle.cpp +++ b/test/CodeGenCXX/mangle.cpp @@ -181,7 +181,7 @@ template typename T::U ft6(const T&) { return 0; } template int ft6(const S&); template struct __is_scalar_type { - enum { __value = 1 }; + static const bool __value = true; }; template struct __enable_if { }; @@ -231,7 +231,7 @@ template void ft8(); // PR5796 namespace PR5796 { template struct __is_scalar_type { - enum { __value = 0 }; + static const bool __value = false; }; template struct __enable_if {}; -- 2.40.0