diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-09-29 20:30:13 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-09-29 20:30:13 +0000 |
| commit | 00966d1791f9150d5b9931bab64341fcf8be5e0d (patch) | |
| tree | 54cd44ab925af4fe8c9ebb86e4af3c07b2a1c71d /clang | |
| parent | 0e3f659137189abac6f732b6a576d5c0e2db8383 (diff) | |
| download | bcm5719-llvm-00966d1791f9150d5b9931bab64341fcf8be5e0d.tar.gz bcm5719-llvm-00966d1791f9150d5b9931bab64341fcf8be5e0d.zip | |
Don't crash if a variable with a constexpr destructor has a
value-dependent initializer.
llvm-svn: 373173
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 3 | ||||
| -rw-r--r-- | clang/test/SemaCXX/constant-expression-cxx2a.cpp | 9 |
2 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index d21d2689123..eaeca7806d4 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -13401,7 +13401,8 @@ void Sema::FinalizeVarWithDestructor(VarDecl *VD, const RecordType *Record) { // If the destructor is constexpr, check whether the variable has constant // destruction now. - if (Destructor->isConstexpr() && VD->evaluateValue()) { + if (Destructor->isConstexpr() && VD->getInit() && + !VD->getInit()->isValueDependent() && VD->evaluateValue()) { SmallVector<PartialDiagnosticAt, 8> Notes; if (!VD->evaluateDestruction(Notes) && VD->isConstexpr()) { Diag(VD->getLocation(), diff --git a/clang/test/SemaCXX/constant-expression-cxx2a.cpp b/clang/test/SemaCXX/constant-expression-cxx2a.cpp index 5e05c292984..0cf41d8f44d 100644 --- a/clang/test/SemaCXX/constant-expression-cxx2a.cpp +++ b/clang/test/SemaCXX/constant-expression-cxx2a.cpp @@ -1269,3 +1269,12 @@ namespace temp_dtor { // FIXME: We could in prinicple accept this. constexpr const A &c = A{false}; // expected-error {{constant}} expected-note {{non-trivial destruction of lifetime-extended temporary}} } + +namespace value_dependent_init { + struct A { + constexpr ~A() {} + }; + template<typename T> void f() { + A a = T(); + } +} |

