forked from OSchip/llvm-project
[clang] Fix an assertion crash in delayed access check.
`TD->getTemplatedDecl()` might not be a DeclContext variant, which can trigger an assertion inside `isa<>`. Differential Revision: https://reviews.llvm.org/D91380
This commit is contained in:
parent
105ed27ed8
commit
7ad6c8414c
|
@ -1476,7 +1476,8 @@ void Sema::HandleDelayedAccessCheck(DelayedDiagnostic &DD, Decl *D) {
|
|||
} else if (FunctionDecl *FN = dyn_cast<FunctionDecl>(D)) {
|
||||
DC = FN;
|
||||
} else if (TemplateDecl *TD = dyn_cast<TemplateDecl>(D)) {
|
||||
DC = cast<DeclContext>(TD->getTemplatedDecl());
|
||||
if (isa<DeclContext>(TD->getTemplatedDecl()))
|
||||
DC = cast<DeclContext>(TD->getTemplatedDecl());
|
||||
}
|
||||
|
||||
EffectiveContext EC(DC);
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s
|
||||
|
||||
namespace NoCrashOnDelayedAccessCheck {
|
||||
class Foo {
|
||||
class Private; // expected-note {{declared private here}}
|
||||
};
|
||||
|
||||
struct Bar {};
|
||||
|
||||
template <typename T>
|
||||
Foo::Private Bar::ABC; // expected-error {{no member named 'ABC' in 'NoCrashOnDelayedAccessCheck::Bar'}} \
|
||||
expected-error {{'Private' is a private member of}}
|
||||
}
|
Loading…
Reference in New Issue