diff options
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 2 | ||||
-rw-r--r-- | clang/test/SemaCXX/PR20705.cpp | 21 |
2 files changed, 22 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index c8c381518b1..0244d4c4a30 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -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); diff --git a/clang/test/SemaCXX/PR20705.cpp b/clang/test/SemaCXX/PR20705.cpp new file mode 100644 index 00000000000..be2676e5635 --- /dev/null +++ b/clang/test/SemaCXX/PR20705.cpp @@ -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@-1 4{{}} + }; + return 5; +}(); + +template <typename T1, typename T2> +class PC { +}; + +template <typename T> +class P { + static typename PC<T, Invalid>::Type Foo(); + // expected-error@-1 4{{}} +}; |