[cfe-commits] r61111 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaCXX/address-of.cpp
Nuno Lopes
nunoplopes at sapo.pt
Tue Dec 16 14:58:28 PST 2008
Author: nlopes
Date: Tue Dec 16 16:58:26 2008
New Revision: 61111
URL: http://llvm.org/viewvc/llvm-project?rev=61111&view=rev
Log:
fix PR 3222: allow one to get the address of a global function in C++
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/address-of.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=61111&r1=61110&r2=61111&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Dec 16 16:58:26 2008
@@ -2889,7 +2889,7 @@
}
NamedDecl *dcl = getPrimaryDecl(op);
Expr::isLvalueResult lval = op->isLvalue(Context);
-
+ printf("oleee\n");
if (lval != Expr::LV_Valid) { // C99 6.5.3.2p1
if (!dcl || !isa<FunctionDecl>(dcl)) {// allow function designators
// FIXME: emit more specific diag...
@@ -2922,8 +2922,10 @@
return Context.OverloadTy;
} else if (isa<FieldDecl>(dcl)) {
// Okay: we can take the address of a field.
+ } else if (isa<FunctionDecl>(dcl)) {
+ // Okay: we can take the address of a function.
}
- else
+ else
assert(0 && "Unknown/unexpected decl type");
}
Modified: cfe/trunk/test/SemaCXX/address-of.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/address-of.cpp?rev=61111&r1=61110&r2=61111&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/address-of.cpp (original)
+++ cfe/trunk/test/SemaCXX/address-of.cpp Tue Dec 16 16:58:26 2008
@@ -1,4 +1,4 @@
-// RUN: clang -fsyntax-only -verify %S
+// RUN: clang -fsyntax-only -verify %s
// PR clang/3175
void bar(int*);
@@ -29,3 +29,7 @@
void test2() {
(void)&N; // expected-error{{address expression must be an lvalue or a function designator}}
}
+
+// PR clang/3222
+void xpto();
+void (*xyz)(void) = &xpto;
More information about the cfe-commits
mailing list