Skip to content
5 changes: 5 additions & 0 deletions clang/lib/Sema/SemaCXXScopeSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,11 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,

if (!Found.empty()) {
const auto *ND = Found.getAsSingle<NamedDecl>();
if (!ND) {
Diag(IdInfo.IdentifierLoc, diag::err_expected_class_or_namespace)
<< IdInfo.Identifier << getLangOpts().CPlusPlus;
return true;
}
if (::ExtendNestedNameSpecifier(*this, SS, ND, IdInfo.IdentifierLoc,
IdInfo.CCLoc)) {
const Type *T = SS.getScopeRep().getAsType();
Expand Down
7 changes: 7 additions & 0 deletions clang/test/Sema/PR166843.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only %s -verify
namespace a {
template <class b>
void c() {
((::c::x)); // expected-error {{'c' is not a class, namespace, or enumeration}}
}
}