diff options
author | Hans Wennborg <hans@hanshq.net> | 2017-01-27 16:26:10 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2017-01-27 16:26:10 +0000 |
commit | faf6e6df56928fe2ea5b9fba2c03ccdbf94e218b (patch) | |
tree | 083eabb785e085afc220a8c6cb87537acb5316d5 | |
parent | cadf1a490f9ae802ad340da5d9e2a272c81efa87 (diff) |
Merging r292561:
------------------------------------------------------------------------
r292561 | rsmith | 2017-01-19 17:19:46 -0800 (Thu, 19 Jan 2017) | 3 lines
PR31701: Fix crash on invalid caused by parsing a dependent initializer when we
don't know we're in a dependent context.
------------------------------------------------------------------------
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_40@293297 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/ASTContext.cpp | 3 | ||||
-rw-r--r-- | test/SemaCXX/constant-expression.cpp | 11 |
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index d03c22af5b..b531a66dba 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -9025,7 +9025,8 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) { // Variables that have initialization with side-effects are required. if (VD->getInit() && VD->getInit()->HasSideEffects(*this) && - !VD->evaluateValue()) + // We can get a value-dependent initializer during error recovery. + (VD->getInit()->isValueDependent() || !VD->evaluateValue())) return true; // Likewise, variables with tuple-like bindings are required if their diff --git a/test/SemaCXX/constant-expression.cpp b/test/SemaCXX/constant-expression.cpp index f82a692093..69e846bf0e 100644 --- a/test/SemaCXX/constant-expression.cpp +++ b/test/SemaCXX/constant-expression.cpp @@ -143,3 +143,14 @@ namespace rdar16064952 { } char PR17381_ice = 1000000 * 1000000; // expected-warning {{overflow}} expected-warning {{changes value}} + +namespace PR31701 { + struct C { + template<int i> static int n; // expected-warning {{extension}} + }; + template <int M> class D; + template <int M> + template<int i> void D<M>::set() { // expected-error {{from class 'D<M>' without definition}} + const C c = C::n<i>; + } +} |