]> granicus.if.org Git - clang/commitdiff
Fix a case where we'd return "is not a constant expr" without
authorChris Lattner <sabre@nondot.org>
Tue, 11 Dec 2007 23:11:17 +0000 (23:11 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 11 Dec 2007 23:11:17 +0000 (23:11 +0000)
return a location.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44889 91177308-0d34-0410-b5e6-96231b3b80d8

AST/Expr.cpp

index 545ebd8e182538cf25158be60c9d237ac638e8e7..c6a6ab360142d86b5128b4296017f431e064b013 100644 (file)
@@ -443,8 +443,13 @@ bool Expr::isConstantExpr(ASTContext &Ctx, SourceLocation *Loc) const {
     const UnaryOperator *Exp = cast<UnaryOperator>(this);
     
     // C99 6.6p9
-    if (Exp->getOpcode() == UnaryOperator::AddrOf)
-      return Exp->getSubExpr()->hasStaticStorage();
+    if (Exp->getOpcode() == UnaryOperator::AddrOf) {
+      if (!Exp->getSubExpr()->hasStaticStorage()) {
+        if (Loc) *Loc = getLocStart();
+        return false;
+      }
+      return true;
+    }
 
     // Get the operand value.  If this is sizeof/alignof, do not evalute the
     // operand.  This affects C99 6.6p3.