r224411 - Sema: Don't dyn_cast a null pointer in CheckUsingDeclQualifier
David Majnemer
david.majnemer at gmail.com
Tue Dec 16 18:41:36 PST 2014
Author: majnemer
Date: Tue Dec 16 20:41:36 2014
New Revision: 224411
URL: http://llvm.org/viewvc/llvm-project?rev=224411&view=rev
Log:
Sema: Don't dyn_cast a null pointer in CheckUsingDeclQualifier
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.
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=224411&r1=224410&r2=224411&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Dec 16 20:41:36 2014
@@ -8159,7 +8159,7 @@ bool Sema::CheckUsingDeclQualifier(Sourc
// 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;
Modified: cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp?rev=224411&r1=224410&r2=224411&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp (original)
+++ cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp Tue Dec 16 20:41:36 2014
@@ -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 {};
More information about the cfe-commits
mailing list