]> granicus.if.org Git - clang/commitdiff
PR1963: Address of function is a constant expression
authorSeo Sanghyeon <sanxiyn@gmail.com>
Fri, 4 Apr 2008 09:45:30 +0000 (09:45 +0000)
committerSeo Sanghyeon <sanxiyn@gmail.com>
Fri, 4 Apr 2008 09:45:30 +0000 (09:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49212 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Expr.cpp
test/Sema/address-constant.c

index 11fcc419a5141a049371ca9d08d647607991fee3..5205702f29730c74362a1f2d00a303e784b602c2 100644 (file)
@@ -453,6 +453,8 @@ bool Expr::hasGlobalStorage() const {
     const Decl *D = cast<DeclRefExpr>(this)->getDecl();
     if (const VarDecl *VD = dyn_cast<VarDecl>(D))
       return VD->hasGlobalStorage();
+    if (isa<FunctionDecl>(D))
+      return true;
     return false;
   }
   case MemberExprClass: {
index 0b451cc39c0ceeb6567a441a26f909d0f65d5d88..e1704b8b0e66752897ecadd1f17a59edd69f5336 100644 (file)
@@ -5,3 +5,6 @@ int a[] = {0};
 struct { int i; } s;
 
 int *array[] = {&i, a, &s.i};
+
+extern void f(void);
+void (*f_addr)(void) = &f;