[PATCH] make isScopedEnumerationType look through typedefs
Stephan Bergmann
sbergman at redhat.com
Thu Oct 23 00:43:19 PDT 2014
[ping]
On 10/14/2014 04:12 PM, Stephan Bergmann wrote:
>> $ clang++ --version
>> clang version 3.6.0 (trunk 219190)
>> Target: x86_64-unknown-linux-gnu
>> Thread model: posix
>>
>> $ cat test.cc
>> enum class E { e };
>> typedef E E2;
>> E2 f1() { return E::e; }
>> E f2() { return E::e; }
>> bool g1() { return !f1(); }
>> bool g2() { return !f2(); }
>>
>> $ clang++ -std=c++11 -c test.cc
>> test.cc:6:20: error: invalid argument type 'E' to unary expression
>> bool g2() { return !f2(); }
>> ^~~~~
>> 1 error generated.
>
> rightly complains about the invalid contextual conversion to bool in g2
> but erroneously not also about the one in g1.
>
>> Index: lib/Sema/SemaExpr.cpp
>> ===================================================================
>> --- lib/Sema/SemaExpr.cpp (revision 219190)
>> +++ lib/Sema/SemaExpr.cpp (working copy)
>> @@ -7414,7 +7414,7 @@
>> }
>>
>> static bool isScopedEnumerationType(QualType T) {
>> - if (const EnumType *ET = dyn_cast<EnumType>(T))
>> + if (const EnumType *ET = dyn_cast<EnumType>(T.getCanonicalType()))
>> return ET->getDecl()->isScoped();
>> return false;
>> }
>
> would fix that for me.
>
> Stephan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: isScopedEnumerationType.patch
Type: text/x-patch
Size: 440 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141023/1bdd3147/attachment.bin>
More information about the cfe-commits
mailing list