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
// 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;
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 {};