[cfe-commits] r71961 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaCXX/member-expr-static.cpp
Anders Carlsson
andersca at mac.com
Sat May 16 14:43:43 PDT 2009
Author: andersca
Date: Sat May 16 16:43:42 2009
New Revision: 71961
URL: http://llvm.org/viewvc/llvm-project?rev=71961&view=rev
Log:
Don't return member pointer types for static member functions. Fixes 6879261.
Added:
cfe/trunk/test/SemaCXX/member-expr-static.cpp
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=71961&r1=71960&r2=71961&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sat May 16 16:43:42 2009
@@ -4471,17 +4471,13 @@
return Context.getMemberPointerType(op->getType(),
Context.getTypeDeclType(cast<RecordDecl>(Ctx)).getTypePtr());
}
- } else if (isa<FunctionDecl>(dcl)) {
+ } else if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(dcl)) {
// Okay: we can take the address of a function.
// As above.
- if (isa<QualifiedDeclRefExpr>(op)) {
- DeclContext *Ctx = dcl->getDeclContext();
- if (Ctx && Ctx->isRecord())
- return Context.getMemberPointerType(op->getType(),
- Context.getTypeDeclType(cast<RecordDecl>(Ctx)).getTypePtr());
- }
- }
- else
+ if (isa<QualifiedDeclRefExpr>(op) && MD->isInstance())
+ return Context.getMemberPointerType(op->getType(),
+ Context.getTypeDeclType(MD->getParent()).getTypePtr());
+ } else if (!isa<FunctionDecl>(dcl))
assert(0 && "Unknown/unexpected decl type");
}
Added: cfe/trunk/test/SemaCXX/member-expr-static.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/member-expr-static.cpp?rev=71961&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/member-expr-static.cpp (added)
+++ cfe/trunk/test/SemaCXX/member-expr-static.cpp Sat May 16 16:43:42 2009
@@ -0,0 +1,21 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+typedef void (*thread_continue_t)();
+
+extern "C" {
+extern void kernel_thread_start(thread_continue_t continuation);
+extern void pure_c(void);
+}
+
+class _IOConfigThread
+{
+public:
+ static void main( void );
+};
+
+
+void foo( void )
+{
+ kernel_thread_start(&_IOConfigThread::main);
+ kernel_thread_start((thread_continue_t)&_IOConfigThread::main);
+ kernel_thread_start(&pure_c);
+}
More information about the cfe-commits
mailing list