[cfe-commits] r70483 - in /cfe/trunk: lib/CodeGen/CGExprConstant.cpp test/CodeGen/const-init.c

Eli Friedman eli.friedman at gmail.com
Thu Apr 30 00:03:23 PDT 2009


Author: efriedma
Date: Thu Apr 30 02:03:22 2009
New Revision: 70483

URL: http://llvm.org/viewvc/llvm-project?rev=70483&view=rev
Log:
Fix for PR4108: be a bit looser with the casts that we accept in 
constant initializers.


Modified:
    cfe/trunk/lib/CodeGen/CGExprConstant.cpp
    cfe/trunk/test/CodeGen/const-init.c

Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=70483&r1=70482&r2=70483&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Thu Apr 30 02:03:22 2009
@@ -59,8 +59,9 @@
       return EmitUnion(CGM.EmitConstantExpr(SubExpr, SubExpr->getType(), CGF), 
                        Ty);
     }
-    if (CGM.getContext().getCanonicalType(E->getSubExpr()->getType()) ==
-        CGM.getContext().getCanonicalType(E->getType())) {
+    // Explicit and implicit no-op casts
+    QualType Ty = E->getType(), SubTy = E->getSubExpr()->getType();
+    if (CGM.getContext().hasSameUnqualifiedType(Ty, SubTy)) {
       return Visit(E->getSubExpr());
     }
     return 0;

Modified: cfe/trunk/test/CodeGen/const-init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/const-init.c?rev=70483&r1=70482&r2=70483&view=diff

==============================================================================
--- cfe/trunk/test/CodeGen/const-init.c (original)
+++ cfe/trunk/test/CodeGen/const-init.c Thu Apr 30 02:03:22 2009
@@ -96,4 +96,9 @@
   return l0.f1;
 }
 
+// PR4108
+struct g21 {int g21;};
+const struct g21 g21 = (struct g21){1};
+
 // RUN: true
+





More information about the cfe-commits mailing list