[llvm-branch-commits] [cfe-branch] r243562 - Merging r243343:

Hans Wennborg hans at hanshq.net
Wed Jul 29 12:58:24 PDT 2015


Author: hans
Date: Wed Jul 29 14:58:23 2015
New Revision: 243562

URL: http://llvm.org/viewvc/llvm-project?rev=243562&view=rev
Log:
Merging r243343:
------------------------------------------------------------------------
r243343 | akirtzidis | 2015-07-27 16:16:53 -0700 (Mon, 27 Jul 2015) | 4 lines

[sema] Fix infinite loop when using a boolean value as designated initializer.

For designated indices use the max array size type bitwidth, not the bitwidth of the index value itself.
rdar://21942503
------------------------------------------------------------------------

Added:
    cfe/branches/release_37/test/CodeGenObjCXX/designated-initializers.mm
      - copied unchanged from r243343, cfe/trunk/test/CodeGenObjCXX/designated-initializers.mm
Modified:
    cfe/branches/release_37/   (props changed)
    cfe/branches/release_37/lib/Sema/SemaInit.cpp

Propchange: cfe/branches/release_37/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jul 29 14:58:23 2015
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:242244,242285,242293,242297,242313,242382,242422,242499,242574,242660,242662,242667,242678,242766,242905,242973,243018,243048,243098,243101,243105,243144,243153,243196,243277,243280,243285,243289,243417
+/cfe/trunk:242244,242285,242293,242297,242313,242382,242422,242499,242574,242660,242662,242667,242678,242766,242905,242973,243018,243048,243098,243101,243105,243144,243153,243196,243277,243280,243285,243289,243343,243417
 /cfe/trunk/test:170344
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_37/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_37/lib/Sema/SemaInit.cpp?rev=243562&r1=243561&r2=243562&view=diff
==============================================================================
--- cfe/branches/release_37/lib/Sema/SemaInit.cpp (original)
+++ cfe/branches/release_37/lib/Sema/SemaInit.cpp Wed Jul 29 14:58:23 2015
@@ -2372,14 +2372,12 @@ InitListChecker::CheckDesignatedInitiali
       return true;
     }
   } else {
-    // Make sure the bit-widths and signedness match.
-    if (DesignatedStartIndex.getBitWidth() > DesignatedEndIndex.getBitWidth())
-      DesignatedEndIndex
-        = DesignatedEndIndex.extend(DesignatedStartIndex.getBitWidth());
-    else if (DesignatedStartIndex.getBitWidth() <
-             DesignatedEndIndex.getBitWidth())
-      DesignatedStartIndex
-        = DesignatedStartIndex.extend(DesignatedEndIndex.getBitWidth());
+    unsigned DesignatedIndexBitWidth =
+      ConstantArrayType::getMaxSizeBits(SemaRef.Context);
+    DesignatedStartIndex =
+      DesignatedStartIndex.extOrTrunc(DesignatedIndexBitWidth);
+    DesignatedEndIndex =
+      DesignatedEndIndex.extOrTrunc(DesignatedIndexBitWidth);
     DesignatedStartIndex.setIsUnsigned(true);
     DesignatedEndIndex.setIsUnsigned(true);
   }





More information about the llvm-branch-commits mailing list