r225889 - Look through sugar when determining whether a type is a scoped enumeration
Richard Smith
richard-llvm at metafoo.co.uk
Tue Jan 13 16:33:11 PST 2015
Author: rsmith
Date: Tue Jan 13 18:33:10 2015
New Revision: 225889
URL: http://llvm.org/viewvc/llvm-project?rev=225889&view=rev
Log:
Look through sugar when determining whether a type is a scoped enumeration
type. Patch by Stephan Bergmann!
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/enum-scoped.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=225889&r1=225888&r2=225889&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Jan 13 18:33:10 2015
@@ -7546,7 +7546,7 @@ QualType Sema::CheckSubtractionOperands(
}
static bool isScopedEnumerationType(QualType T) {
- if (const EnumType *ET = dyn_cast<EnumType>(T))
+ if (const EnumType *ET = T->getAs<EnumType>())
return ET->getDecl()->isScoped();
return false;
}
Modified: cfe/trunk/test/SemaCXX/enum-scoped.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/enum-scoped.cpp?rev=225889&r1=225888&r2=225889&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/enum-scoped.cpp (original)
+++ cfe/trunk/test/SemaCXX/enum-scoped.cpp Tue Jan 13 18:33:10 2015
@@ -301,3 +301,11 @@ namespace PR18044 {
using E::a; // ok!
E b = a;
}
+
+namespace test11 {
+ enum class E { a };
+ typedef E E2;
+ E2 f1() { return E::a; }
+
+ bool f() { return !f1(); } // expected-error {{invalid argument type 'E2' (aka 'test11::E') to unary expression}}
+}
More information about the cfe-commits
mailing list