Fix the perentheses location when the constructor is called on a class that has a destructor

llvm-svn: 246844
This commit is contained in:
Olivier Goffart 2015-09-04 10:17:10 +00:00
parent a04668ff34
commit 1ba7dc38d0
2 changed files with 19 additions and 3 deletions

View File

@ -2483,8 +2483,11 @@ ExprResult Sema::BuildCXXFunctionalCastExpr(TypeSourceInfo *CastTypeInfo,
Op.CheckCXXCStyleCast(/*FunctionalStyle=*/true, /*ListInit=*/false);
if (Op.SrcExpr.isInvalid())
return ExprError();
if (CXXConstructExpr *ConstructExpr = dyn_cast<CXXConstructExpr>(Op.SrcExpr.get()))
auto *SubExpr = Op.SrcExpr.get();
if (auto *BindExpr = dyn_cast<CXXBindTemporaryExpr>(SubExpr))
SubExpr = BindExpr->getSubExpr();
if (auto *ConstructExpr = dyn_cast<CXXConstructExpr>(SubExpr))
ConstructExpr->setParenOrBraceRange(SourceRange(LPLoc, RPLoc));
return Op.complete(CXXFunctionalCastExpr::Create(Context, Op.ResultType,

View File

@ -7,7 +7,7 @@ class P {
};
namespace foo {
class A { public: A() {} };
class A { public: A(int = 0) {} };
enum B {};
typedef int C;
}
@ -37,3 +37,16 @@ void destruct(foo::A *a1, foo::A *a2, P<int> *p1) {
// CHECK: MemberExpr {{0x[0-9a-fA-F]+}} <col:3, col:13> '<bound member function type>' ->~P
p1->~P<int>();
}
struct D {
D(int);
~D();
};
void construct() {
using namespace foo;
A a = A(12);
// CHECK: CXXConstructExpr {{0x[0-9a-fA-F]+}} <col:9, col:13> 'class foo::A' 'void (int)'
D d = D(12);
// CHECK: CXXConstructExpr {{0x[0-9a-fA-F]+}} <col:9, col:13> 'struct D' 'void (int)'
}