Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/lib/Sema/SemaCXXScopeSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,8 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,

if (!Found.empty()) {
const auto *ND = Found.getAsSingle<NamedDecl>();
if(!ND)
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::)); // expected-error {{expected unqualified-id}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like we aren't actually diagnosing the error? I'd expect something like error: 'c' is not a class, namespace, or enumeration, which is what we generate in the non-template case.

What happens if you instead write the following?

  ((::c::x));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like we aren't actually diagnosing the error? I'd expect something like error: 'c' is not a class, namespace, or enumeration, which is what we generate in the non-template case.

Yeah, that was something I wasn't sure about.

What happens if you instead write the following?

  ((::c::x));

Looks like we report nothing, the way I've structured it. That version still causes the crash w/o the nullptr check, so let me update the check to make sure it works in the expected way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've updated the early exit by duplicating the diagnostic. I didn't see an obvious way to avoid doing that. Happy to amend if this still isn't quite right.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@efriedma-quic does the new version work the way you'd expect it to? I'd like to get this merged if it does.

}
}
Loading