Skip to content

Commit 8d3ff0e

Browse files
committed
fixup! make dedicated unit-test
1 parent 9fba42d commit 8d3ff0e

File tree

2 files changed

+46
-6
lines changed

2 files changed

+46
-6
lines changed

clang/test/CXX/drs/cwg6xx.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,12 +1257,6 @@ namespace cwg686 { // cwg686: 3.0
12571257
// cxx98-14-error@-1 {{'Q' cannot be defined in a type specifier}}
12581258
#endif
12591259
}
1260-
int f2(int, double) {
1261-
struct N {
1262-
operator struct O{}(){};
1263-
// expected-error@-1 {{'cwg686::f2(int, double)::N::O' cannot be defined in a type specifier}}
1264-
};
1265-
}
12661260
template<struct R *> struct X;
12671261
template<struct R {} *> struct Y;
12681262
// expected-error@-1 {{'cwg686::R' cannot be defined in a type specifier}}

clang/unittests/AST/TypePrinterTest.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,3 +295,49 @@ TEST(TypePrinter, TemplateArgumentsSubstitution_Expressions) {
295295
Ctx, Arg, Param, ArgList.asArray(), Params->getDepth()));
296296
}
297297
}
298+
299+
TEST(TypePrinter, NestedNameSpecifiers) {
300+
constexpr char Code[] = R"cpp(
301+
void level1() {
302+
struct Inner {
303+
Inner(int) {
304+
struct {
305+
union {} u;
306+
} imem;
307+
}
308+
};
309+
}
310+
)cpp";
311+
312+
// Types scoped immediately inside a function don't print the function name in
313+
// their scope.
314+
ASSERT_TRUE(PrintedTypeMatches(
315+
Code, {}, varDecl(hasName("imem"), hasType(qualType().bind("id"))),
316+
"struct (unnamed)", [](PrintingPolicy &Policy) {
317+
Policy.FullyQualifiedName = true;
318+
Policy.AnonymousTagLocations = false;
319+
}));
320+
321+
ASSERT_TRUE(PrintedTypeMatches(
322+
Code, {}, varDecl(hasName("imem"), hasType(qualType().bind("id"))),
323+
"struct (unnamed)", [](PrintingPolicy &Policy) {
324+
Policy.FullyQualifiedName = false;
325+
Policy.AnonymousTagLocations = false;
326+
}));
327+
328+
// Further levels of nesting print the entire scope.
329+
ASSERT_TRUE(PrintedTypeMatches(
330+
Code, {}, fieldDecl(hasName("u"), hasType(qualType().bind("id"))),
331+
"union level1()::Inner::Inner(int)::(anonymous struct)::(unnamed)",
332+
[](PrintingPolicy &Policy) {
333+
Policy.FullyQualifiedName = true;
334+
Policy.AnonymousTagLocations = false;
335+
}));
336+
337+
ASSERT_TRUE(PrintedTypeMatches(
338+
Code, {}, fieldDecl(hasName("u"), hasType(qualType().bind("id"))),
339+
"union (unnamed)", [](PrintingPolicy &Policy) {
340+
Policy.FullyQualifiedName = false;
341+
Policy.AnonymousTagLocations = false;
342+
}));
343+
}

0 commit comments

Comments
 (0)