[cfe-commits] r72552 - in /cfe/trunk: lib/CodeGen/CGExprAgg.cpp test/CodeGen/2009-05-28-const-typedef.c

Eli Friedman eli.friedman at gmail.com
Thu May 28 16:04:00 PDT 2009


Author: efriedma
Date: Thu May 28 18:04:00 2009
New Revision: 72552

URL: http://llvm.org/viewvc/llvm-project?rev=72552&view=rev
Log:
PR4281: Fix bogus CodeGen assertion.  The issue is that 
getUnqualifiedType() doesn't strip off all qualifiers for non-canonical 
types.


Added:
    cfe/trunk/test/CodeGen/2009-05-28-const-typedef.c
Modified:
    cfe/trunk/lib/CodeGen/CGExprAgg.cpp

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Thu May 28 18:04:00 2009
@@ -178,9 +178,8 @@
 }
 
 void AggExprEmitter::VisitImplicitCastExpr(ImplicitCastExpr *E) {
-  assert(CGF.getContext().typesAreCompatible(
-                          E->getSubExpr()->getType().getUnqualifiedType(),
-                          E->getType().getUnqualifiedType()) &&
+  assert(CGF.getContext().hasSameUnqualifiedType(E->getSubExpr()->getType(),
+                                                 E->getType()) &&
          "Implicit cast types must be compatible");
   Visit(E->getSubExpr());
 }
@@ -226,9 +225,8 @@
 void AggExprEmitter::VisitBinAssign(const BinaryOperator *E) {
   // For an assignment to work, the value on the right has
   // to be compatible with the value on the left.
-  assert(CGF.getContext().typesAreCompatible(
-             E->getLHS()->getType().getUnqualifiedType(),
-             E->getRHS()->getType().getUnqualifiedType())
+  assert(CGF.getContext().hasSameUnqualifiedType(E->getLHS()->getType(),
+                                                 E->getRHS()->getType())
          && "Invalid assignment");
   LValue LHS = CGF.EmitLValue(E->getLHS());
 
@@ -378,8 +376,7 @@
     if (E->getNumInits() > 0) {
       QualType T1 = E->getType();
       QualType T2 = E->getInit(0)->getType();
-      if (CGF.getContext().getCanonicalType(T1).getUnqualifiedType() == 
-          CGF.getContext().getCanonicalType(T2).getUnqualifiedType()) {
+      if (CGF.getContext().hasSameUnqualifiedType(T1, T2)) {
         EmitAggLoadOfLValue(E->getInit(0));
         return;
       }

Added: cfe/trunk/test/CodeGen/2009-05-28-const-typedef.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/2009-05-28-const-typedef.c?rev=72552&view=auto

==============================================================================
--- cfe/trunk/test/CodeGen/2009-05-28-const-typedef.c (added)
+++ cfe/trunk/test/CodeGen/2009-05-28-const-typedef.c Thu May 28 18:04:00 2009
@@ -0,0 +1,17 @@
+// RUN: clang-cc -emit-llvm %s -o -
+// PR4281
+
+typedef struct {
+        int i;
+} something;
+
+typedef const something const_something;
+
+something fail(void);
+
+int
+main(int argc, char *argv[])
+{
+        const_something R = fail();
+}
+





More information about the cfe-commits mailing list