зеркало из https://github.com/microsoft/clang-1.git
Re-bind non-dependent CXXTemporaryObjectExpr nodes as temporaries when
instantiating a template, which ensures the destructor is called. This fixes PR6671. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100029 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
521468391c
Коммит
a3ce8ae361
|
@ -5134,7 +5134,7 @@ TreeTransform<Derived>::TransformCXXTemporaryObjectExpr(
|
|||
!ArgumentChanged) {
|
||||
// FIXME: Instantiation-specific
|
||||
SemaRef.MarkDeclarationReferenced(E->getTypeBeginLoc(), Constructor);
|
||||
return SemaRef.Owned(E->Retain());
|
||||
return SemaRef.MaybeBindToTemporary(E->Retain());
|
||||
}
|
||||
|
||||
// FIXME: Bogus location information
|
||||
|
|
|
@ -43,6 +43,19 @@ struct Temporaries0 {
|
|||
|
||||
template struct Temporaries0<5, 7>;
|
||||
|
||||
// Ensure that both the constructor and the destructor are instantiated by
|
||||
// checking for parse errors from each.
|
||||
template<int N> struct BadX {
|
||||
BadX() { int a[-N]; } // expected-error {{array size is negative}}
|
||||
~BadX() { int a[-N]; } // expected-error {{array size is negative}}
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct PR6671 {
|
||||
void f() { (void)BadX<1>(); } // expected-note 2 {{instantiation}}
|
||||
};
|
||||
template struct PR6671<1>;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// new/delete expressions
|
||||
// ---------------------------------------------------------------------
|
||||
|
|
Загрузка…
Ссылка в новой задаче