r292561 - PR31701: Fix crash on invalid caused by parsing a dependent initializer when we

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 26 15:56:24 PST 2017


A candidate for clang 4?

On Thu, Jan 19, 2017 at 5:19 PM, Richard Smith via cfe-commits
<cfe-commits at lists.llvm.org> wrote:
> 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 at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


More information about the cfe-commits mailing list