<p dir="ltr">On Jul 27, 2015 4:22 PM, "Argyrios Kyrtzidis" <<a href="mailto:akyrtzi@gmail.com">akyrtzi@gmail.com</a>> wrote:<br>
><br>
> Author: akirtzidis<br>
> Date: Mon Jul 27 18:16:53 2015<br>
> New Revision: 243343<br>
><br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D243343-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=r51TahMwkIkp8nIAToFOgCoXgSuju5DIJdNqKorI9iQ&s=feCYXL8AB-evWCHYjpt8XTIC3ivRNaFsD3eykW3_HIQ&e=">http://llvm.org/viewvc/llvm-project?rev=243343&view=rev</a><br>
> Log:<br>
> [sema] Fix infinite loop when using a boolean value as designated initializer.<br>
><br>
> For designated indices use the max array size type bitwidth, not the bitwidth of the index value itself.<br>
> rdar://21942503<br>
><br>
> Added:<br>
>     cfe/trunk/test/CodeGenObjCXX/<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__designated-2Dinitializers.mm&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=r51TahMwkIkp8nIAToFOgCoXgSuju5DIJdNqKorI9iQ&s=Mu-On_svsGylBBJKETq0DpcDpcMttObPgIg_ZjU0pbU&e=">designated-initializers.mm</a><br>
> Modified:<br>
>     cfe/trunk/lib/Sema/SemaInit.cpp<br>
><br>
> Modified: cfe/trunk/lib/Sema/SemaInit.cpp<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_Sema_SemaInit.cpp-3Frev-3D243343-26r1-3D243342-26r2-3D243343-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=r51TahMwkIkp8nIAToFOgCoXgSuju5DIJdNqKorI9iQ&s=Hkda3VQfxbIhUHp1JyT3DvY7zdkKSbel8yN73ZO4_1g&e=">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=243343&r1=243342&r2=243343&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Sema/SemaInit.cpp (original)<br>
> +++ cfe/trunk/lib/Sema/SemaInit.cpp Mon Jul 27 18:16:53 2015<br>
> @@ -2372,14 +2372,12 @@ InitListChecker::CheckDesignatedInitiali<br>
>        return true;<br>
>      }<br>
>    } else {<br>
> -    // Make sure the bit-widths and signedness match.<br>
> -    if (DesignatedStartIndex.getBitWidth() > DesignatedEndIndex.getBitWidth())<br>
> -      DesignatedEndIndex<br>
> -        = DesignatedEndIndex.extend(DesignatedStartIndex.getBitWidth());<br>
> -    else if (DesignatedStartIndex.getBitWidth() <<br>
> -             DesignatedEndIndex.getBitWidth())<br>
> -      DesignatedStartIndex<br>
> -        = DesignatedStartIndex.extend(DesignatedEndIndex.getBitWidth());<br>
> +    unsigned DesignatedIndexBitWidth =<br>
> +      ConstantArrayType::getMaxSizeBits(SemaRef.Context);<br>
> +    DesignatedStartIndex =<br>
> +      DesignatedStartIndex.extOrTrunc(DesignatedIndexBitWidth);<br>
> +    DesignatedEndIndex =<br>
> +      DesignatedEndIndex.extOrTrunc(DesignatedIndexBitWidth);</p>
<p dir="ltr">Do we produce any kind of diagnostic in the case where this truncation is lossy?</p>
<p dir="ltr">>      DesignatedStartIndex.setIsUnsigned(true);<br>
>      DesignatedEndIndex.setIsUnsigned(true);<br>
>    }<br>
><br>
> Added: cfe/trunk/test/CodeGenObjCXX/<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__designated-2Dinitializers.mm&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=r51TahMwkIkp8nIAToFOgCoXgSuju5DIJdNqKorI9iQ&s=Mu-On_svsGylBBJKETq0DpcDpcMttObPgIg_ZjU0pbU&e=">designated-initializers.mm</a><br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_test_CodeGenObjCXX_designated-2Dinitializers.mm-3Frev-3D243343-26view-3Dauto&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=r51TahMwkIkp8nIAToFOgCoXgSuju5DIJdNqKorI9iQ&s=fiiLwHBC5dMaY1MfAUh_VZkhel1p-_k_wbncqycbORE&e=">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/designated-initializers.mm?rev=243343&view=auto</a><br>
> ==============================================================================<br>
> --- cfe/trunk/test/CodeGenObjCXX/<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__designated-2Dinitializers.mm&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=r51TahMwkIkp8nIAToFOgCoXgSuju5DIJdNqKorI9iQ&s=Mu-On_svsGylBBJKETq0DpcDpcMttObPgIg_ZjU0pbU&e=">designated-initializers.mm</a> (added)<br>
> +++ cfe/trunk/test/CodeGenObjCXX/<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__designated-2Dinitializers.mm&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=r51TahMwkIkp8nIAToFOgCoXgSuju5DIJdNqKorI9iQ&s=Mu-On_svsGylBBJKETq0DpcDpcMttObPgIg_ZjU0pbU&e=">designated-initializers.mm</a> Mon Jul 27 18:16:53 2015<br>
> @@ -0,0 +1,36 @@<br>
> +// RUN: %clang_cc1 -triple arm64 %s -verify -emit-llvm -o - | FileCheck %s<br>
> +// expected-no-diagnostics<br>
> +<br>
> +// Make sure we don't enter an infinite loop (rdar://21942503)<br>
> +<br>
> +int vals1[] = {<br>
> +  [__objc_yes] = 1,<br>
> +  [__objc_no] = 2<br>
> +};<br>
> +// CHECK: @vals1 = global [2 x i32] [i32 2, i32 1]<br>
> +<br>
> +int vals2[] = {<br>
> +  [true] = 3,<br>
> +  [false] = 4<br>
> +};<br>
> +// CHECK: @vals2 = global [2 x i32] [i32 4, i32 3]<br>
> +<br>
> +int vals3[] = {<br>
> +  [false] = 1,<br>
> +  [true] = 2,<br>
> +  5<br>
> +};<br>
> +// CHECK: @vals3 = global [3 x i32] [i32 1, i32 2, i32 5]<br>
> +<br>
> +int vals4[2] = {<br>
> +  [true] = 5,<br>
> +  [false] = 6<br>
> +};<br>
> +// CHECK: @vals4 = global [2 x i32] [i32 6, i32 5]<br>
> +<br>
> +int vals5[3] = {<br>
> +  [false] = 1,<br>
> +  [true] = 2,<br>
> +  6<br>
> +};<br>
> +// CHECK: @vals5 = global [3 x i32] [i32 1, i32 2, i32 6]<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</p>