]> granicus.if.org Git - clang/commitdiff
Sema: Don't dyn_cast a null pointer in CheckUsingDeclQualifier
authorDavid Majnemer <david.majnemer@gmail.com>
Wed, 17 Dec 2014 02:41:36 +0000 (02:41 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Wed, 17 Dec 2014 02:41:36 +0000 (02:41 +0000)
This code was written with the intent that a pointer could be null but
we dyn_cast'd it anyway.  Change the dyn_cast to a dyn_cast_or_null.

This fixes PR21933.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224411 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp

index b2a765b53a946d5e578031b68e57db444d7c4f71..96149c5e04701c2749b4ef39fdc5c872fd625b57 100644 (file)
@@ -8159,7 +8159,7 @@ bool Sema::CheckUsingDeclQualifier(SourceLocation UsingLoc,
     // If we weren't able to compute a valid scope, it must be a
     // dependent class scope.
     if (!NamedContext || NamedContext->isRecord()) {
-      auto *RD = dyn_cast<CXXRecordDecl>(NamedContext);
+      auto *RD = dyn_cast_or_null<CXXRecordDecl>(NamedContext);
       if (RD && RequireCompleteDeclContext(const_cast<CXXScopeSpec&>(SS), RD))
         RD = nullptr;
 
index 4f89dcfb3f522bc40f7234299158dc1a9be9f616..ebe5388d65acc1080c44ed98f9f7b5b6446cb0f1 100644 (file)
@@ -17,6 +17,11 @@ void f() {
   using X::s; // expected-error{{using declaration cannot refer to class member}}
 }
 
+template <typename T>
+struct PR21933 : T {
+  static void StaticFun() { using T::member; } // expected-error{{using declaration cannot refer to class member}}
+};
+
 struct S {
   static int n;
   struct Q {};