mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-29 23:06:05 +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);
|
||||
if (!Constructor)
|
||||
RealDecl->setInvalidDecl();
|
||||
else
|
||||
Exprs.release();
|
||||
|
||||
else {
|
||||
// Let clients know that initialization was done with a direct
|
||||
// initializer.
|
||||
VDecl->setCXXDirectInitializer(true);
|
||||
|
||||
// FIXME: Add ExprTys and Constructor to the RealDecl as part of
|
||||
// the initializer.
|
||||
Expr *Temp =
|
||||
new (Context) CXXTemporaryObjectExpr(Constructor, DeclInitType,
|
||||
SourceLocation(),
|
||||
(Expr**)Exprs.release(),
|
||||
NumExprs,
|
||||
SourceLocation());
|
||||
AddInitializerToDecl(Dcl, ExprArg(*this, Temp), /*DirectInit=*/true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user