зеркало из https://github.com/microsoft/clang-1.git
PR12012: Fix a regression in r150419 where we would try (and fail) to
zero-initialize class types with virtual bases when constant-evaluating an initializer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150770 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
df79567796
Коммит
ce582fe2a7
|
@ -3387,6 +3387,11 @@ bool RecordExprEvaluator::ZeroInitialization(const Expr *E) {
|
||||||
return EvaluateInPlace(Result.getUnionValue(), Info, Subobject, &VIE);
|
return EvaluateInPlace(Result.getUnionValue(), Info, Subobject, &VIE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isa<CXXRecordDecl>(RD) && cast<CXXRecordDecl>(RD)->getNumVBases()) {
|
||||||
|
Info.Diag(E->getExprLoc(), diag::note_constexpr_virtual_base) << RD;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return HandleClassZeroInitialization(Info, E, RD, This, Result);
|
return HandleClassZeroInitialization(Info, E, RD, This, Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -279,3 +279,17 @@ namespace CrossFuncLabelDiff {
|
||||||
// CHECK: sub nsw i64 ptrtoint (i8* blockaddress(@_ZN18CrossFuncLabelDiff4testEv, {{.*}}) to i64),
|
// CHECK: sub nsw i64 ptrtoint (i8* blockaddress(@_ZN18CrossFuncLabelDiff4testEv, {{.*}}) to i64),
|
||||||
// CHECK: store i64 {{.*}}, i64* @_ZZN18CrossFuncLabelDiff4testEvE1b, align 8
|
// CHECK: store i64 {{.*}}, i64* @_ZZN18CrossFuncLabelDiff4testEvE1b, align 8
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PR12012
|
||||||
|
namespace VirtualBase {
|
||||||
|
struct B {};
|
||||||
|
struct D : virtual B {};
|
||||||
|
D d;
|
||||||
|
// CHECK: call {{.*}}@_ZN11VirtualBase1DC1Ev
|
||||||
|
|
||||||
|
template<typename T> struct X : T {
|
||||||
|
constexpr X() : T() {}
|
||||||
|
};
|
||||||
|
X<D> x;
|
||||||
|
// CHECK: call {{.*}}@_ZN11VirtualBase1XINS_1DEEC1Ev
|
||||||
|
}
|
||||||
|
|
|
@ -29,3 +29,9 @@ constexpr D d1; // expected-error {{requires a user-provided default constructor
|
||||||
constexpr D d2 = D(); // ok with DR1452
|
constexpr D d2 = D(); // ok with DR1452
|
||||||
static_assert(D().c == 0, "");
|
static_assert(D().c == 0, "");
|
||||||
static_assert(D().d == 0, "");
|
static_assert(D().d == 0, "");
|
||||||
|
|
||||||
|
struct V : virtual C {};
|
||||||
|
template<typename T> struct Z : T {
|
||||||
|
constexpr Z() : V() {}
|
||||||
|
};
|
||||||
|
constexpr int n = Z<V>().c; // expected-error {{constant expression}} expected-note {{virtual base class}}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче