mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-29 13:56:08 +00:00
When declaring a variable that has a constructor and a direct initializer, for example:
struct X { X(int, int); }; X x(10, 10); we model that as X x = X(10, 10); inserting a temporary object expr. llvm-svn: 69227
This commit is contained in:
parent
c7ba533378
commit
332ef55cf2
@ -1796,15 +1796,19 @@ void Sema::AddCXXDirectInitializerToDecl(DeclPtrTy Dcl,
|
|||||||
IK_Direct);
|
IK_Direct);
|
||||||
if (!Constructor)
|
if (!Constructor)
|
||||||
RealDecl->setInvalidDecl();
|
RealDecl->setInvalidDecl();
|
||||||
else
|
else {
|
||||||
Exprs.release();
|
// Let clients know that initialization was done with a direct
|
||||||
|
// initializer.
|
||||||
|
VDecl->setCXXDirectInitializer(true);
|
||||||
|
|
||||||
// Let clients know that initialization was done with a direct
|
Expr *Temp =
|
||||||
// initializer.
|
new (Context) CXXTemporaryObjectExpr(Constructor, DeclInitType,
|
||||||
VDecl->setCXXDirectInitializer(true);
|
SourceLocation(),
|
||||||
|
(Expr**)Exprs.release(),
|
||||||
// FIXME: Add ExprTys and Constructor to the RealDecl as part of
|
NumExprs,
|
||||||
// the initializer.
|
SourceLocation());
|
||||||
|
AddInitializerToDecl(Dcl, ExprArg(*this, Temp), /*DirectInit=*/true);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user