r230381 - PR22673: Don't forget to check a constructor for deletedness when we use it to
Richard Smith
richard-llvm at metafoo.co.uk
Tue Feb 24 13:16:19 PST 2015
Author: rsmith
Date: Tue Feb 24 15:16:19 2015
New Revision: 230381
URL: http://llvm.org/viewvc/llvm-project?rev=230381&view=rev
Log:
PR22673: Don't forget to check a constructor for deletedness when we use it to
implicitly construct a temporary in a reference binding.
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/SemaCXX/deleted-function.cpp
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=230381&r1=230380&r2=230381&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Feb 24 15:16:19 2015
@@ -2591,6 +2591,8 @@ static ExprResult BuildCXXCastArgument(S
S.CheckConstructorAccess(CastLoc, Constructor,
InitializedEntity::InitializeTemporary(Ty),
Constructor->getAccess());
+ if (S.DiagnoseUseOfDecl(FoundDecl, CastLoc))
+ return ExprError();
ExprResult Result = S.BuildCXXConstructExpr(
CastLoc, Ty, cast<CXXConstructorDecl>(Method),
@@ -2606,6 +2608,10 @@ static ExprResult BuildCXXCastArgument(S
case CK_UserDefinedConversion: {
assert(!From->getType()->isPointerType() && "Arg can't have pointer type!");
+ S.CheckMemberOperatorAccess(CastLoc, From, /*arg*/ nullptr, FoundDecl);
+ if (S.DiagnoseUseOfDecl(FoundDecl, CastLoc))
+ return ExprError();
+
// Create an implicit call expr that calls it.
CXXConversionDecl *Conv = cast<CXXConversionDecl>(Method);
ExprResult Result = S.BuildCXXMemberCallExpr(From, FoundDecl, Conv,
@@ -2617,8 +2623,6 @@ static ExprResult BuildCXXCastArgument(S
CK_UserDefinedConversion, Result.get(),
nullptr, Result.get()->getValueKind());
- S.CheckMemberOperatorAccess(CastLoc, From, /*arg*/ nullptr, FoundDecl);
-
return S.MaybeBindToTemporary(Result.get());
}
}
@@ -2649,7 +2653,7 @@ Sema::PerformImplicitConversion(Expr *Fr
FunctionDecl *FD = ICS.UserDefined.ConversionFunction;
CastKind CastKind;
QualType BeforeToType;
- assert(FD && "FIXME: aggregate initialization from init list");
+ assert(FD && "no conversion function for user-defined conversion seq");
if (const CXXConversionDecl *Conv = dyn_cast<CXXConversionDecl>(FD)) {
CastKind = CK_UserDefinedConversion;
Modified: cfe/trunk/test/SemaCXX/deleted-function.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/deleted-function.cpp?rev=230381&r1=230380&r2=230381&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/deleted-function.cpp (original)
+++ cfe/trunk/test/SemaCXX/deleted-function.cpp Tue Feb 24 15:16:19 2015
@@ -67,7 +67,7 @@ void test4() {} // expected-note {{previ
void test4() = delete; // expected-error {{redefinition of 'test4'}}
struct DelCtor { // expected-note 4{{implicit}}
- DelCtor(int) = delete; // expected-note 13{{deleted}}
+ DelCtor(int) = delete; // expected-note 14{{deleted}}
// ensure the class is not an aggregate
DelCtor(int, int, int, int);
};
@@ -85,5 +85,5 @@ int use_dc(DelCtor); // expected-note 2{
int dc11 = use_dc(0); // expected-error {{deleted}}
int dc12 = use_dc({0}); // expected-error {{deleted}}
int use_dcr(const DelCtor &); // expected-note {{here}}
-int dc13 = use_dcr(0); // FIXME PR22673: should reject this
+int dc13 = use_dcr(0); // expected-error {{deleted}}
int dc14 = use_dcr({0}); // expected-error {{deleted}}
More information about the cfe-commits
mailing list