Author: rsmith Date: Thu Jan 19 19:19:46 2017 New Revision: 292561 URL: http://llvm.org/viewvc/llvm-project?rev=292561&view=rev Log: PR31701: Fix crash on invalid caused by parsing a dependent initializer when we don't know we're in a dependent context.
Modified: cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/test/SemaCXX/constant-expression.cpp Modified: cfe/trunk/lib/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=292561&r1=292560&r2=292561&view=diff ============================================================================== --- cfe/trunk/lib/AST/ASTContext.cpp (original) +++ cfe/trunk/lib/AST/ASTContext.cpp Thu Jan 19 19:19:46 2017 @@ -9021,7 +9021,8 @@ bool ASTContext::DeclMustBeEmitted(const // 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 Modified: cfe/trunk/test/SemaCXX/constant-expression.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression.cpp?rev=292561&r1=292560&r2=292561&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/constant-expression.cpp (original) +++ cfe/trunk/test/SemaCXX/constant-expression.cpp Thu Jan 19 19:19:46 2017 @@ -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>; + } +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits