forked from OSchip/llvm-project
PR18044: Reject declarations of enumtype::X early to avoid an assertion in
downstream code. llvm-svn: 195687
This commit is contained in:
parent
82a0005b21
commit
8ac1c92df9
|
@ -4224,7 +4224,7 @@ NamedDecl *Sema::HandleDeclarator(Scope *S, Declarator &D,
|
|||
|
||||
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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue