forked from OSchip/llvm-project
Handle destruction of temporaries used in default argument
construction of constructor calls. llvm-svn: 78222
This commit is contained in:
parent
4b5c761af2
commit
d460cb4356
|
@ -2396,6 +2396,7 @@ void Sema::InitializeVarWithConstructor(VarDecl *VD,
|
|||
DeclInitType, Constructor,
|
||||
false, Exprs, NumExprs);
|
||||
MarkDeclarationReferenced(VD->getLocation(), Constructor);
|
||||
Temp = MaybeCreateCXXExprWithTemporaries(Temp, /*DestroyTemps=*/true);
|
||||
VD->setInit(Context, Temp);
|
||||
}
|
||||
|
||||
|
|
|
@ -179,6 +179,7 @@ bool Sema::CheckInitializerTypes(Expr *&Init, QualType &DeclType,
|
|||
|
||||
Init = BuildCXXConstructExpr(Context,
|
||||
DeclType, Constructor, false, &Init, 1);
|
||||
Init = MaybeCreateCXXExprWithTemporaries(Init, /*DestroyTemps=*/true);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,9 +7,19 @@ struct T {
|
|||
|
||||
void f(const T& t = T());
|
||||
|
||||
class X { // ...
|
||||
public:
|
||||
X();
|
||||
X(const X&, const T& t = T());
|
||||
};
|
||||
|
||||
void g() {
|
||||
// RUN: grep "call void @_ZN1TC1Ev" %t | count 2 &&
|
||||
// RUN: grep "call void @_ZN1TD1Ev" %t | count 2
|
||||
// RUN: grep "call void @_ZN1TC1Ev" %t | count 4 &&
|
||||
// RUN: grep "call void @_ZN1TD1Ev" %t | count 4
|
||||
f();
|
||||
f();
|
||||
|
||||
X a;
|
||||
X b(a);
|
||||
X c = a;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue