[cfe-commits] r43599 - in /cfe/trunk: AST/Expr.cpp test/Sema/init.c

Chris Lattner sabre at nondot.org
Wed Oct 31 19:45:17 PDT 2007


Author: lattner
Date: Wed Oct 31 21:45:17 2007
New Revision: 43599

URL: http://llvm.org/viewvc/llvm-project?rev=43599&view=rev
Log:
Implement test/Sema/init.c by treating functions as constants.

Added:
    cfe/trunk/test/Sema/init.c
Modified:
    cfe/trunk/AST/Expr.cpp

Modified: cfe/trunk/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Expr.cpp?rev=43599&r1=43598&r2=43599&view=diff

==============================================================================
--- cfe/trunk/AST/Expr.cpp (original)
+++ cfe/trunk/AST/Expr.cpp Wed Oct 31 21:45:17 2007
@@ -382,11 +382,14 @@
     if (Loc) *Loc = getLocStart();
     return false;
   }
-  case DeclRefExprClass:
-    if (isa<EnumConstantDecl>(cast<DeclRefExpr>(this)->getDecl()))
+  case DeclRefExprClass: {
+    const Decl *D = cast<DeclRefExpr>(this)->getDecl();
+    // Accept address of function.
+    if (isa<EnumConstantDecl>(D) || isa<FunctionDecl>(D))
       return true;
     if (Loc) *Loc = getLocStart();
     return false;
+  }
   case UnaryOperatorClass: {
     const UnaryOperator *Exp = cast<UnaryOperator>(this);
     

Added: cfe/trunk/test/Sema/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/init.c?rev=43599&view=auto

==============================================================================
--- cfe/trunk/test/Sema/init.c (added)
+++ cfe/trunk/test/Sema/init.c Wed Oct 31 21:45:17 2007
@@ -0,0 +1,6 @@
+// RUN: clang %s -verify -fsyntax-only
+
+typedef void (* fp)(void);
+void foo(void);
+fp a[1] = { foo };
+





More information about the cfe-commits mailing list