diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-01-14 00:33:10 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-01-14 00:33:10 +0000 |
| commit | 43d3f55072759739cbee96647c5732bd16cab854 (patch) | |
| tree | a3b57d03826eee6bfa7576c1d9b73cf80d05b481 | |
| parent | a3b04cea0458481ccdd29573e52931ad70fd3a63 (diff) | |
| download | bcm5719-llvm-43d3f55072759739cbee96647c5732bd16cab854.tar.gz bcm5719-llvm-43d3f55072759739cbee96647c5732bd16cab854.zip | |
Look through sugar when determining whether a type is a scoped enumeration
type. Patch by Stephan Bergmann!
llvm-svn: 225889
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 2 | ||||
| -rw-r--r-- | clang/test/SemaCXX/enum-scoped.cpp | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 59efbc1bb6a..fba7a2d23ff 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -7546,7 +7546,7 @@ QualType Sema::CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS, } 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; } diff --git a/clang/test/SemaCXX/enum-scoped.cpp b/clang/test/SemaCXX/enum-scoped.cpp index 1eed2281e93..909802335e4 100644 --- a/clang/test/SemaCXX/enum-scoped.cpp +++ b/clang/test/SemaCXX/enum-scoped.cpp @@ -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}} +} |

