[PATCH] make isScopedEnumerationType look through typedefs
Stephan Bergmann
sbergman at redhat.com
Fri Dec 19 03:25:52 PST 2014
On 12/19/2014 06:05 AM, Richard Smith wrote:
> LGTM, do you need someone to commit this for you?
yes, please; I don't have commit rights
> On Thu, Dec 18, 2014 at 12:28 AM, Stephan Bergmann <sbergman at redhat.com
> <mailto:sbergman at redhat.com>> wrote:
>
> On 12/17/2014 08:40 PM, Richard Smith wrote:
>
> The right way to write this is:
>
> - if (const EnumType *ET = dyn_cast<EnumType>(T))
> + if (const EnumType *ET = T->getAs<EnumType>())
>
>
> updated patch attached
>
> On Tue, Dec 16, 2014 at 5:51 AM, Rafael EspĂndola
> <rafael.espindola at gmail.com <mailto:rafael.espindola at gmail.com>
> <mailto:rafael.espindola at __gmail.com
> <mailto:rafael.espindola at gmail.com>>> wrote:
>
> LGTM.
>
> Clang is not my expertise, but the patch looks clearly
> correct, fixes
> a bug and has a testcase.
>
>
> On 16 December 2014 at 04:49, Stephan Bergmann
> <sbergman at redhat.com <mailto:sbergman at redhat.com>
> <mailto:sbergman at redhat.com <mailto:sbergman at redhat.com>>>
> wrote:
> > ping
> >
> >
> > On 11/25/2014 03:04 PM, Rafael EspĂndola wrote:
> >>
> >> ccing Richard.
> >> On 25 November 2014 at 03:38, Stephan Bergmann
> <sbergman at redhat.com <mailto:sbergman at redhat.com>
> <mailto:sbergman at redhat.com <mailto:sbergman at redhat.com>>>
> >> wrote:
> >>>
> >>> ping
> >>>
> >>>
> >>> On 11/10/2014 06:18 PM, Stephan Bergmann wrote:
> >>>>
> >>>>
> >>>> On 10/23/2014 10:41 AM, David Majnemer wrote:
> >>>>>
> >>>>>
> >>>>> Per the developer policy [1], please add a test case to
> accompany your
> >>>>> change.
> >>>>>
> >>>>> [1]
> http://llvm.org/docs/__DeveloperPolicy.html#test-__cases
> <http://llvm.org/docs/DeveloperPolicy.html#test-cases>
> >>>>>
> >>>>> Looks good otherwise.
> >>>>
> >>>>
> >>>>
> >>>> Attached updated patch including test case.
> >>>>
> >>>>> On Thu, Oct 23, 2014 at 12:43 AM, Stephan Bergmann
> <sbergman at redhat.com <mailto:sbergman at redhat.com>
> <mailto:sbergman at redhat.com <mailto:sbergman at redhat.com>>
> >>>>> <mailto:sbergman at redhat.com
> <mailto:sbergman at redhat.com> <mailto:sbergman at redhat.com
> <mailto:sbergman at redhat.com>>>> wrote:
> >>>>>
> >>>>> [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.
>
>
More information about the cfe-commits
mailing list