[cfe-commits] r55614 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/array-init.c

Eli Friedman eli.friedman at gmail.com
Mon Sep 1 15:08:18 PDT 2008


Author: efriedma
Date: Mon Sep  1 17:08:17 2008
New Revision: 55614

URL: http://llvm.org/viewvc/llvm-project?rev=55614&view=rev
Log:
Backing out r55607 due to logic errors and test regression.

I'll try to come up with a correct fix for the testcase sometime soon.


Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/Sema/array-init.c

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=55614&r1=55613&r2=55614&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Sep  1 17:08:17 2008
@@ -1076,13 +1076,6 @@
     const Decl *D = cast<DeclRefExpr>(Init)->getDecl();
     if (isa<EnumConstantDecl>(D))
       return false;
-
-    if (const ValueDecl *VD = dyn_cast<ValueDecl>(D)) {
-      QualType Ty = VD->getType();
-      if (Ty->isPointerLikeType() || Ty->isArrayType())
-        return false;
-    }
-
     Diag(Init->getExprLoc(),
          diag::err_init_element_not_constant, Init->getSourceRange());
     return true;
@@ -1105,8 +1098,6 @@
       Diag(Init->getExprLoc(),
            diag::err_init_element_not_constant, Init->getSourceRange());
       return true;
-    case UnaryOperator::AddrOf:
-      return false;
     case UnaryOperator::SizeOf:
     case UnaryOperator::AlignOf:
     case UnaryOperator::OffsetOf:
@@ -1169,7 +1160,12 @@
   case Expr::ImplicitCastExprClass:
   case Expr::ExplicitCastExprClass: {
     const Expr *SubExpr = cast<CastExpr>(Init)->getSubExpr();
-    return CheckArithmeticConstantExpression(SubExpr);
+    if (SubExpr->getType()->isArithmeticType())
+      return CheckArithmeticConstantExpression(SubExpr);
+
+    Diag(Init->getExprLoc(),
+         diag::err_init_element_not_constant, Init->getSourceRange());
+    return true;
   }
   case Expr::ConditionalOperatorClass: {
     const ConditionalOperator *Exp = cast<ConditionalOperator>(Init);

Modified: cfe/trunk/test/Sema/array-init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/array-init.c?rev=55614&r1=55613&r2=55614&view=diff

==============================================================================
--- cfe/trunk/test/Sema/array-init.c (original)
+++ cfe/trunk/test/Sema/array-init.c Mon Sep  1 17:08:17 2008
@@ -222,19 +222,5 @@
 struct {int a; int:5;} noNamedImplicit[] = {1,2,3};
 int noNamedImplicitCheck[sizeof(noNamedImplicit) == 3 * sizeof(*noNamedImplicit) ? 1 : -1];
 
-
-// ptrs are constant
-struct soft_segment_descriptor {
-	int ssd_base;
-};
-static int dblfault_tss;
-
-union uniao { int ola; } xpto[1];
-
-struct soft_segment_descriptor gdt_segs[] = {
-	{(int) &dblfault_tss},
-	{ (int)xpto},
-};
-
 static void sppp_ipv6cp_up();
 const struct {} ipcp = { sppp_ipv6cp_up }; //expected-warning{{empty struct extension}} expected-warning{{excess elements in array initializer}}





More information about the cfe-commits mailing list