r216254 - Fix PR20705, crash on invalid.
Richard Trieu
rtrieu at google.com
Thu Aug 21 18:16:44 PDT 2014
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();
+ // expected-error at -1 4{{}}
+};
More information about the cfe-commits
mailing list