r195687 - PR18044: Reject declarations of enumtype::X early to avoid an assertion in
Richard Smith
richard-llvm at metafoo.co.uk
Mon Nov 25 13:30:29 PST 2013
Author: rsmith
Date: Mon Nov 25 15:30:29 2013
New Revision: 195687
URL: http://llvm.org/viewvc/llvm-project?rev=195687&view=rev
Log:
PR18044: Reject declarations of enumtype::X early to avoid an assertion in
downstream code.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/enum-scoped.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=195687&r1=195686&r2=195687&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Nov 25 15:30:29 2013
@@ -4224,7 +4224,7 @@ NamedDecl *Sema::HandleDeclarator(Scope
bool EnteringContext = !D.getDeclSpec().isFriendSpecified();
DC = computeDeclContext(D.getCXXScopeSpec(), EnteringContext);
- if (!DC) {
+ if (!DC || isa<EnumDecl>(DC)) {
// If we could not compute the declaration context, it's because the
// declaration context is dependent but does not refer to a class,
// class template, or class template partial specialization. Complain
Modified: cfe/trunk/test/SemaCXX/enum-scoped.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/enum-scoped.cpp?rev=195687&r1=195686&r2=195687&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/enum-scoped.cpp (original)
+++ cfe/trunk/test/SemaCXX/enum-scoped.cpp Mon Nov 25 15:30:29 2013
@@ -282,3 +282,17 @@ namespace rdar15124329 {
static_assert(T2 == B::T, "");
}
+namespace PR18044 {
+ enum class E { a };
+
+ int E::e = 0; // expected-error {{does not refer into a class}}
+ void E::f() {} // expected-error {{does not refer into a class}}
+ struct E::S {}; // expected-error {{no struct named 'S'}}
+ struct T : E::S {}; // expected-error {{expected class name}}
+ enum E::E {}; // expected-error {{no enum named 'E'}}
+ int E::*p; // expected-error {{does not point into a class}}
+ using E::f; // expected-error {{no member named 'f'}}
+
+ using E::a; // ok!
+ E b = a;
+}
More information about the cfe-commits
mailing list