aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-11-01 02:45:17 +0000
committerChris Lattner <sabre@nondot.org>2007-11-01 02:45:17 +0000
commit4ef8dd6e8736097bf9e3c387139c668565d89dca (patch)
tree6012cb2e76d1c3f67c2d02560ab522f7760a5e3b
parent0c67829763b98bc670062b553897a851fab17401 (diff)
Implement test/Sema/init.c by treating functions as constants.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43599 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--AST/Expr.cpp7
-rw-r--r--test/Sema/init.c6
2 files changed, 11 insertions, 2 deletions
diff --git a/AST/Expr.cpp b/AST/Expr.cpp
index b21aad20ce..14ef48c7de 100644
--- a/AST/Expr.cpp
+++ b/AST/Expr.cpp
@@ -382,11 +382,14 @@ bool Expr::isConstantExpr(ASTContext &Ctx, SourceLocation *Loc) const {
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);
diff --git a/test/Sema/init.c b/test/Sema/init.c
new file mode 100644
index 0000000000..71b1d63d61
--- /dev/null
+++ b/test/Sema/init.c
@@ -0,0 +1,6 @@
+// RUN: clang %s -verify -fsyntax-only
+
+typedef void (* fp)(void);
+void foo(void);
+fp a[1] = { foo };
+