r202467 - Fix crash with enable_if on constructors.
Nick Lewycky
nicholas at mxc.ca
Thu Feb 27 21:26:13 PST 2014
Author: nicholas
Date: Thu Feb 27 23:26:13 2014
New Revision: 202467
URL: http://llvm.org/viewvc/llvm-project?rev=202467&view=rev
Log:
Fix crash with enable_if on constructors.
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCXX/enable_if.cpp
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=202467&r1=202466&r2=202467&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Feb 27 23:26:13 2014
@@ -5646,7 +5646,8 @@ EnableIfAttr *Sema::CheckEnableIf(Functi
bool InitializationFailed = false;
for (unsigned i = 0, e = Args.size(); i != e; ++i) {
if (i == 0 && !MissingImplicitThis && isa<CXXMethodDecl>(Function) &&
- !cast<CXXMethodDecl>(Function)->isStatic()) {
+ !cast<CXXMethodDecl>(Function)->isStatic() &&
+ !isa<CXXConstructorDecl>(Function)) {
CXXMethodDecl *Method = cast<CXXMethodDecl>(Function);
ExprResult R =
PerformObjectArgumentInitialization(Args[0], /*Qualifier=*/0,
Modified: cfe/trunk/test/SemaCXX/enable_if.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/enable_if.cpp?rev=202467&r1=202466&r2=202467&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/enable_if.cpp (original)
+++ cfe/trunk/test/SemaCXX/enable_if.cpp Thu Feb 27 23:26:13 2014
@@ -4,6 +4,10 @@ typedef int (*fp)(int);
int surrogate(int);
struct X {
+ X() = default; // expected-note{{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
+ X(const X&) = default; // expected-note{{candidate constructor not viable: no known conversion from 'bool' to 'const X' for 1st argument}}
+ X(bool b) __attribute__((enable_if(b, "chosen when 'b' is true"))); // expected-note{{candidate disabled: chosen when 'b' is true}}
+
void f(int n) __attribute__((enable_if(n == 0, "chosen when 'n' is zero")));
void f(int n) __attribute__((enable_if(n == 1, "chosen when 'n' is one"))); // expected-note{{member declaration nearly matches}} expected-note{{candidate disabled: chosen when 'n' is one}}
@@ -26,6 +30,9 @@ void X::f(int n) __attribute__((enable_i
{
}
+X x1(true);
+X x2(false); // expected-error{{no matching constructor for initialization of 'X'}}
+
__attribute__((deprecated)) constexpr int old() { return 0; } // expected-note2{{'old' has been explicitly marked deprecated here}}
void deprec1(int i) __attribute__((enable_if(old() == 0, "chosen when old() is zero"))); // expected-warning{{'old' is deprecated}}
void deprec2(int i) __attribute__((enable_if(old() == 0, "chosen when old() is zero"))); // expected-warning{{'old' is deprecated}}
More information about the cfe-commits
mailing list