Skip to content

Commit 37eb30a

Browse files
[clang] [Sema] Preserve nested name specifier prefix in MemberPointerType
1 parent d77cab8 commit 37eb30a

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,13 @@ sizeof...($TemplateParameter[[Elements]]);
10921092
$Field_dependentName[[waldo]];
10931093
}
10941094
};
1095+
)cpp",
1096+
// Pointer-to-member with nested-name-specifiers
1097+
R"cpp(
1098+
struct $Class_def[[Outer]] {
1099+
struct $Class_def[[Inner]] {};
1100+
};
1101+
using $Typedef_decl[[Alias]] = void ($Class[[Outer]]::$Class[[Inner]]:: *)();
10951102
)cpp"};
10961103
for (const auto &TestCase : TestCases)
10971104
// Mask off scope modifiers to keep the tests manageable.

clang/lib/Sema/SemaType.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5347,13 +5347,16 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
53475347

53485348
case NestedNameSpecifier::TypeSpec:
53495349
case NestedNameSpecifier::TypeSpecWithTemplate:
5350-
ClsType = QualType(NNS->getAsType(), 0);
5350+
const Type *NNSType = NNS->getAsType();
5351+
ClsType = QualType(NNSType, 0);
53515352
// Note: if the NNS has a prefix and ClsType is a nondependent
5352-
// TemplateSpecializationType, then the NNS prefix is NOT included
5353-
// in ClsType; hence we wrap ClsType into an ElaboratedType.
5354-
// NOTE: in particular, no wrap occurs if ClsType already is an
5355-
// Elaborated, DependentName, or DependentTemplateSpecialization.
5356-
if (isa<TemplateSpecializationType>(NNS->getAsType()))
5353+
// TemplateSpecializationType or a RecordType, then the NNS prefix is
5354+
// NOT included in ClsType; hence we wrap ClsType into an
5355+
// ElaboratedType. NOTE: in particular, no wrap occurs if ClsType
5356+
// already is an Elaborated, DependentName, or
5357+
// DependentTemplateSpecialization.
5358+
if (isa<TemplateSpecializationType>(NNSType) ||
5359+
(NNSPrefix && isa<RecordType>(NNSType)))
53575360
ClsType = Context.getElaboratedType(ElaboratedTypeKeyword::None,
53585361
NNSPrefix, ClsType);
53595362
break;

0 commit comments

Comments
 (0)