r216254 - Fix PR20705, crash on invalid.

Richard Smith richard at metafoo.co.uk
Thu Aug 21 19:09:22 PDT 2014


On Thu, Aug 21, 2014 at 6:16 PM, Richard Trieu <rtrieu at google.com> wrote:

> Author: rtrieu
> Date: Thu Aug 21 20:16:44 2014
> New Revision: 216254
>
> URL: http://llvm.org/viewvc/llvm-project?rev=216254&view=rev
> Log:
> Fix PR20705, crash on invalid.
>
> dyn_cast -> dyn_cast_or_null to handle a null pointer.
>
> Added:
>     cfe/trunk/test/SemaCXX/PR20705.cpp
> Modified:
>     cfe/trunk/lib/Sema/SemaDecl.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=216254&r1=216253&r2=216254&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Aug 21 20:16:44 2014
> @@ -9300,7 +9300,7 @@ Sema::FinalizeDeclaration(Decl *ThisDecl
>    // Static locals inherit dll attributes from their function.
>    if (VD->isStaticLocal()) {
>      if (FunctionDecl *FD =
> -            dyn_cast<FunctionDecl>(VD->getParentFunctionOrMethod())) {
> +
> dyn_cast_or_null<FunctionDecl>(VD->getParentFunctionOrMethod())) {
>        if (Attr *A = getDLLAttr(FD)) {
>          auto *NewAttr = cast<InheritableAttr>(A->clone(getASTContext()));
>          NewAttr->setInherited(true);
>
> Added: cfe/trunk/test/SemaCXX/PR20705.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/PR20705.cpp?rev=216254&view=auto
>
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/PR20705.cpp (added)
> +++ cfe/trunk/test/SemaCXX/PR20705.cpp Thu Aug 21 20:16:44 2014
> @@ -0,0 +1,21 @@
> +// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
> +
> +template <typename T>
> +struct X {};
> +auto b = []() {
> +  struct S {
> +    static typename X<decltype(int)>::type Run(){};
> +    // expected-error at -1 4{{}}
> +  };
> +  return 5;
> +}();
> +
> +template <typename T1, typename T2>
> +class PC {
> +};
> +
> +template <typename T>
> +class P {
> +  static typename PC<T, Invalid>::Type Foo();
>

Hmm, why do we end up with a VarDecl that thinks it's a static local
variable here? Is there a more fundamental bug at play?


> +  // expected-error at -1 4{{}}
> +};
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140821/aa9b052e/attachment.html>


More information about the cfe-commits mailing list