aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 };
+