[llvm] r304083 - Added braces to address gcc warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]. NFC.

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 19 09:06:22 PDT 2017


On Wed, Jun 14, 2017 at 1:39 PM Galina Kistanova via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Let me summarize what we have.
>
> The old trick with "switch (0) case 0: default:" does not work with
> gcc-7.1 any more. The same is for the one-time-for-loop. And, unless I'm
> missing something, we do not have other ideas which may work.
>
> I have filed an issue https://github.com/google/googletest/issues/1119.
>
> In the mean time, these are the only warnings which block me from having
> the gcc-7.1 bot in the production master and I would like to get this
> resolved as soon as possible.
>
> Unless anyone has a better idea, I'm going to add the explicit braces in
> those 37 places and be done with this.
>

Please disable the warning (for GCC only) instead - Clang's dangling-else
should catch enough cases, hopefully, that this isn't a great loss in
coverage.

- Dave


>
> Thanks
>
> Galina
>
>
> On Sat, Jun 3, 2017 at 10:25 PM, Galina Kistanova <gkistanova at gmail.com>
> wrote:
>
>> Unfortunately, a do { ... } while (0) wrapper wouldn't work either.
>> Because of usages like this:
>>
>> ASSERT_EQ(&TestOption, Retrieved) << "Retrieved wrong option.";
>>
>> Galina
>>
>> On Sun, May 28, 2017 at 2:41 PM, Joerg Sonnenberger via llvm-commits <
>> llvm-commits at lists.llvm.org> wrote:
>>
>>> On Sat, May 27, 2017 at 10:30:54PM -0700, Craig Topper via llvm-commits
>>> wrote:
>>> > EXPECT_STREQ should already be using this as far as I can tell.
>>>
>>> GTEST_ASSERT_ should get a do { ... } while (0) wrapper. That's much
>>> better than the switch statement it is currently trying to use.
>>>
>>> Joerg
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>>
>>
>>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170619/2c3fa1e6/attachment.html>


More information about the llvm-commits mailing list