r191182 - PR16529: Don't forget to add the CXXFunctionalCastExpr type sugar to an
Richard Smith
richard-llvm at metafoo.co.uk
Sun Sep 22 19:20:01 PDT 2013
Author: rsmith
Date: Sun Sep 22 21:20:00 2013
New Revision: 191182
URL: http://llvm.org/viewvc/llvm-project?rev=191182&view=rev
Log:
PR16529: Don't forget to add the CXXFunctionalCastExpr type sugar to an
InitListExpr for a C++11-style T{...} construction, if initialization
registered a destructor for it.
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/SemaCXX/decltype.cpp
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=191182&r1=191181&r2=191182&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Sun Sep 22 21:20:00 2013
@@ -903,18 +903,21 @@ Sema::BuildCXXTypeConstructExpr(TypeSour
InitializationSequence InitSeq(*this, Entity, Kind, Exprs);
ExprResult Result = InitSeq.Perform(*this, Entity, Kind, Exprs);
- if (!Result.isInvalid() && ListInitialization &&
- isa<InitListExpr>(Result.get())) {
+ if (Result.isInvalid() || !ListInitialization)
+ return Result;
+
+ Expr *Inner = Result.get();
+ if (CXXBindTemporaryExpr *BTE = dyn_cast_or_null<CXXBindTemporaryExpr>(Inner))
+ Inner = BTE->getSubExpr();
+ if (isa<InitListExpr>(Inner)) {
// If the list-initialization doesn't involve a constructor call, we'll get
// the initializer-list (with corrected type) back, but that's not what we
// want, since it will be treated as an initializer list in further
// processing. Explicitly insert a cast here.
- InitListExpr *List = cast<InitListExpr>(Result.take());
- Result = Owned(CXXFunctionalCastExpr::Create(Context, List->getType(),
- Expr::getValueKindForType(TInfo->getType()),
- TInfo, CK_NoOp, List,
- /*Path=*/0,
- LParenLoc, RParenLoc));
+ QualType ResultType = Result.get()->getType();
+ Result = Owned(CXXFunctionalCastExpr::Create(
+ Context, ResultType, Expr::getValueKindForType(TInfo->getType()), TInfo,
+ CK_NoOp, Result.take(), /*Path=*/ 0, LParenLoc, RParenLoc));
}
// FIXME: Improve AST representation?
Modified: cfe/trunk/test/SemaCXX/decltype.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/decltype.cpp?rev=191182&r1=191181&r2=191182&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/decltype.cpp (original)
+++ cfe/trunk/test/SemaCXX/decltype.cpp Sun Sep 22 21:20:00 2013
@@ -37,6 +37,14 @@ struct C {
// expected-error {{expected ')'}} expected-note {{to match this '('}}
};
+namespace PR16529 {
+ struct U {};
+ template <typename T> struct S {
+ static decltype(T{}, U{}) &f();
+ };
+ U &r = S<int>::f();
+}
+
template<typename>
class conditional {
};
More information about the cfe-commits
mailing list