]> granicus.if.org Git - clang/commitdiff
Fix for PR4108: be a bit looser with the casts that we accept in
authorEli Friedman <eli.friedman@gmail.com>
Thu, 30 Apr 2009 07:03:22 +0000 (07:03 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Thu, 30 Apr 2009 07:03:22 +0000 (07:03 +0000)
constant initializers.

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

lib/CodeGen/CGExprConstant.cpp
test/CodeGen/const-init.c

index d7c6457ff8fd69e1657abb4bae19ffda04e6e432..e618dab33ebeae655bde49c489aa6c21d1677e83 100644 (file)
@@ -59,8 +59,9 @@ public:
       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;
index a7220e0c29ba6e8733c073d5c62c61b14410c327..1f9d74c7e9fd1d67ad4bd336c0430e35546d732a 100644 (file)
@@ -96,4 +96,9 @@ void *g20(void) {
   return l0.f1;
 }
 
+// PR4108
+struct g21 {int g21;};
+const struct g21 g21 = (struct g21){1};
+
 // RUN: true
+