From: Bill Wendling Date: Tue, 26 Nov 2013 04:09:45 +0000 (+0000) Subject: Merging r195687: X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=13303b992574409370abff941d90ee4bfa5b97e5;p=clang Merging r195687: ------------------------------------------------------------------------ r195687 | rsmith | 2013-11-25 13:30:29 -0800 (Mon, 25 Nov 2013) | 3 lines PR18044: Reject declarations of enumtype::X early to avoid an assertion in downstream code. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_34@195720 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 1892809bce..dc52354d1b 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -4223,7 +4223,7 @@ NamedDecl *Sema::HandleDeclarator(Scope *S, Declarator &D, bool EnteringContext = !D.getDeclSpec().isFriendSpecified(); DC = computeDeclContext(D.getCXXScopeSpec(), EnteringContext); - if (!DC) { + if (!DC || isa(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 diff --git a/test/SemaCXX/enum-scoped.cpp b/test/SemaCXX/enum-scoped.cpp index c6869449ca..b4aad18b17 100644 --- a/test/SemaCXX/enum-scoped.cpp +++ b/test/SemaCXX/enum-scoped.cpp @@ -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; +}