forked from OSchip/llvm-project
[C++20] [Modules] Handle reachability for enum class
In previous reachability patch, we missed the case for enum class. Trying to handle it in this patch and add the corresponding tests.
This commit is contained in:
parent
f75ccadcdd
commit
2f1555fb11
|
@ -8669,12 +8669,13 @@ bool Sema::hasAcceptableDefinition(NamedDecl *D, NamedDecl **Suggested,
|
|||
// of it will do.
|
||||
*Suggested = nullptr;
|
||||
for (auto *Redecl : ED->redecls()) {
|
||||
if (isVisible(Redecl))
|
||||
if (isAcceptable(Redecl, Kind))
|
||||
return true;
|
||||
if (Redecl->isThisDeclarationADefinition() ||
|
||||
(Redecl->isCanonicalDecl() && !*Suggested))
|
||||
*Suggested = Redecl;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
D = ED->getDefinition();
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
// Checks for reachability for C++11 enum class properly
|
||||
//
|
||||
// RUN: rm -rf %t
|
||||
// RUN: mkdir -p %t
|
||||
// RUN: split-file %s %t
|
||||
//
|
||||
// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-module-interface -o %t/A.pcm
|
||||
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -verify -fsyntax-only
|
||||
|
||||
//--- foo.h
|
||||
enum class foo {
|
||||
a, b, c
|
||||
};
|
||||
|
||||
//--- A.cppm
|
||||
module;
|
||||
#include "foo.h"
|
||||
export module A;
|
||||
export foo func();
|
||||
|
||||
//--- Use.cpp
|
||||
// expected-no-diagnostics
|
||||
import A;
|
||||
void bar() {
|
||||
auto f = func();
|
||||
}
|
Loading…
Reference in New Issue