Skip to content

Comments

[Clang][Sema] Fix crash when nested-name-specifier prefix points to non-dependent context#5

Open
sdkrystian wants to merge 1 commit intocppalliance:mainfrom
sdkrystian:fix-178324
Open

[Clang][Sema] Fix crash when nested-name-specifier prefix points to non-dependent context#5
sdkrystian wants to merge 1 commit intocppalliance:mainfrom
sdkrystian:fix-178324

Conversation

@sdkrystian
Copy link
Member

After 154507c, a NestedNameSpecifier of Type kind can have a prefix pointing to a non-dependent type even when the NNS itself is dependent. This occurs when the Type has a prefix in its own qualified-id that refers to a non-dependent record.

The getCurrentInstantiationOf() function in SemaCXXScopeSpec.cpp would call isCurrentInstantiation() on such non-dependent records, triggering an assertion failure since isCurrentInstantiation() requires the record to be a dependent context.

This patch adds a guard to check isDependentContext() before calling isCurrentInstantiation(), matching the pattern used in all other call sites of isCurrentInstantiation() throughout the codebase.

Fixes 178324 in upstream.

@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd just add -fms-extensions to the current test invocation, since it only enables extensions but doesn't change how existing code behaves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants