Skip to content

Commit f941769

Browse files
authored
[clang] fix runtime check listing types which can appear in a NestedNameSpecifier (#155272)
Through alias templates, followed by canonicalization, any canonical dependent type can appear in a NestedNameSpecifier. Remove the list as a practical matter. This fixes a regression reported here: #147835 (comment) Since the regression was never released, there are no release notes. Fixes #155260
1 parent 6072fc1 commit f941769

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

clang/lib/Sema/TreeTransform.h

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5539,21 +5539,10 @@ QualType TreeTransform<Derived>::TransformTypeInObjectScope(
55395539
TLB, TL.castAs<DependentNameTypeLoc>(), /*DeducedTSTContext=*/false,
55405540
ObjectType, UnqualLookup);
55415541
}
5542-
case TypeLoc::Typedef:
5543-
case TypeLoc::TemplateSpecialization:
5544-
case TypeLoc::SubstTemplateTypeParm:
5545-
case TypeLoc::SubstTemplateTypeParmPack:
5546-
case TypeLoc::PackIndexing:
5547-
case TypeLoc::Enum:
5548-
case TypeLoc::Record:
5549-
case TypeLoc::InjectedClassName:
5550-
case TypeLoc::TemplateTypeParm:
5551-
case TypeLoc::Decltype:
5552-
case TypeLoc::UnresolvedUsing:
5553-
case TypeLoc::Using:
5554-
return getDerived().TransformType(TLB, TL);
55555542
default:
5556-
llvm_unreachable("unexpected type class");
5543+
// Any dependent canonical type can appear here, through type alias
5544+
// templates.
5545+
return getDerived().TransformType(TLB, TL);
55575546
}
55585547
}
55595548

clang/test/SemaTemplate/nested-name-spec-template.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-c++20-extensions
2-
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
2+
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++11-extensions -std=c++98 %s
33
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
44

55
namespace N {
@@ -24,14 +24,7 @@ namespace N {
2424

2525
M::Promote<int>::type *ret_intptr3(int* ip) { return ip; }
2626
M::template Promote<int>::type *ret_intptr4(int* ip) { return ip; }
27-
#if __cplusplus <= 199711L
28-
// expected-warning@-2 {{'template' keyword outside of a template}}
29-
#endif
30-
3127
M::template Promote<int> pi;
32-
#if __cplusplus <= 199711L
33-
// expected-warning@-2 {{'template' keyword outside of a template}}
34-
#endif
3528
}
3629

3730
N::M::Promote<int>::type *ret_intptr5(int* ip) { return ip; }
@@ -181,3 +174,15 @@ namespace SubstTemplateTypeParmPackType {
181174
template void f<B>();
182175
} // namespace SubstTemplateTypeParmPackType
183176
#endif
177+
178+
namespace DependentUnaryTransform {
179+
template <class T> using decay_t = __decay(T);
180+
template <class, class> struct A;
181+
template <class T> struct A<T, typename decay_t<T>::X>;
182+
} // namespace DependentUnaryTransform
183+
184+
namespace DependentSizedArray {
185+
template <int V> using Z = int[V];
186+
template <class, class> struct A;
187+
template <class T> struct A<T, typename Z<T(0)>::X>;
188+
} // namespace DependentUnaryTransform

0 commit comments

Comments
 (0)