Skip to content

Conversation

mizvekov
Copy link
Contributor

@mizvekov mizvekov commented Aug 25, 2025

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

…ameSpecifier

Through alias templates, followed by canonicalization, any canonical
dependent type can appear in a NestedNameSpecifier.
Remove the list as it's not feasible to maintain it.

This fixes a regression reported here: #147835 (comment)

Since the regression was never released, there are no release notes.
@mizvekov mizvekov self-assigned this Aug 25, 2025
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Aug 25, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 25, 2025

@llvm/pr-subscribers-clang

Author: Matheus Izvekov (mizvekov)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/155272.diff

2 Files Affected:

  • (modified) clang/lib/Sema/TreeTransform.h (+3-14)
  • (modified) clang/test/SemaTemplate/nested-name-spec-template.cpp (+13-8)
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 1d14ead778446..87550614f645b 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -5539,21 +5539,10 @@ QualType TreeTransform<Derived>::TransformTypeInObjectScope(
         TLB, TL.castAs<DependentNameTypeLoc>(), /*DeducedTSTContext=*/false,
         ObjectType, UnqualLookup);
   }
-  case TypeLoc::Typedef:
-  case TypeLoc::TemplateSpecialization:
-  case TypeLoc::SubstTemplateTypeParm:
-  case TypeLoc::SubstTemplateTypeParmPack:
-  case TypeLoc::PackIndexing:
-  case TypeLoc::Enum:
-  case TypeLoc::Record:
-  case TypeLoc::InjectedClassName:
-  case TypeLoc::TemplateTypeParm:
-  case TypeLoc::Decltype:
-  case TypeLoc::UnresolvedUsing:
-  case TypeLoc::Using:
-    return getDerived().TransformType(TLB, TL);
   default:
-    llvm_unreachable("unexpected type class");
+    // Any dependent canonical type can appear here, through type alias
+    // templates.
+    return getDerived().TransformType(TLB, TL);
   }
 }
 
diff --git a/clang/test/SemaTemplate/nested-name-spec-template.cpp b/clang/test/SemaTemplate/nested-name-spec-template.cpp
index 153f4e2555e3a..0f51a14af9e52 100644
--- a/clang/test/SemaTemplate/nested-name-spec-template.cpp
+++ b/clang/test/SemaTemplate/nested-name-spec-template.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-c++20-extensions
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++11-extensions -std=c++98 %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 namespace N {
@@ -24,14 +24,7 @@ namespace N {
 
   M::Promote<int>::type *ret_intptr3(int* ip) { return ip; }
   M::template Promote<int>::type *ret_intptr4(int* ip) { return ip; }
-#if __cplusplus <= 199711L
-  // expected-warning@-2 {{'template' keyword outside of a template}}
-#endif
-
   M::template Promote<int> pi;
-#if __cplusplus <= 199711L
-  // expected-warning@-2 {{'template' keyword outside of a template}}
-#endif
 }
 
 N::M::Promote<int>::type *ret_intptr5(int* ip) { return ip; }
@@ -181,3 +174,15 @@ namespace SubstTemplateTypeParmPackType {
   template void f<B>();
 } // namespace SubstTemplateTypeParmPackType
 #endif
+
+namespace DependentUnaryTransform {
+  template <class T> using decay_t = __decay(T);
+  template <class, class> struct A;
+  template <class T> struct A<T, typename decay_t<T>::X>;
+} // namespace DependentUnaryTransform
+
+namespace DependentSizedArray {
+  template <int V> using Z = int[V];
+  template <class, class> struct A;
+  template <class T> struct A<T, typename Z<T(0)>::X>;
+} // namespace DependentUnaryTransform

@mizvekov mizvekov merged commit f941769 into main Aug 25, 2025
12 checks passed
@mizvekov mizvekov deleted the users/mizvekov/GH147835-regression-3 branch August 25, 2025 17:45
@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 25, 2025

LLVM Buildbot has detected a new failure on builder clangd-ubuntu-tsan running on clangd-ubuntu-clang while building clang at step 6 "test-build-clangd-clangd-index-server-clangd-in...".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/134/builds/25080

Here is the relevant piece of the build log for the reference
Step 6 (test-build-clangd-clangd-index-server-clangd-in...) failure: test (failure)
******************** TEST 'Clangd :: inlayHints.test' FAILED ********************
Exit Code: 66

Command Output (stderr):
--
clangd -lit-test < /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/clang-tools-extra/clangd/test/inlayHints.test | /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/bin/FileCheck /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/clang-tools-extra/clangd/test/inlayHints.test # RUN: at line 1
+ clangd -lit-test
+ /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/bin/FileCheck /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/clang-tools-extra/clangd/test/inlayHints.test
WARNING: ThreadSanitizer: unexpected memory mapping 0x79ffffc72000-0x7a0000100000
FATAL: ThreadSanitizer: unexpectedly found incompatible memory layout.
FATAL: Please file a bug.
I[18:43:29.460] clangd version 22.0.0git (https://github.com/llvm/llvm-project.git f941769a8af61159e27f5598f1dffaab6f7b0fbb)
I[18:43:29.461] Features: linux+debug+tsan+grpc
I[18:43:29.461] PID: 16345
I[18:43:29.461] Working directory: /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/tools/clang/tools/extra/clangd/test
I[18:43:29.461] argv[0]: clangd
I[18:43:29.461] argv[1]: -lit-test
I[18:43:29.461] Starting LSP over stdin/stdout
V[18:43:29.461] <<< {
  "id": 0,
  "jsonrpc": "2.0",
  "method": "initialize",
  "params": {}
}

I[18:43:29.461] <-- initialize(0)
I[18:43:29.462] --> reply:initialize(0) 1 ms

--

********************


@zwuis zwuis added the skip-precommit-approval PR for CI feedback, not intended for review label Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category skip-precommit-approval PR for CI feedback, not intended for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[clang/TemplateInstantiator] crash (segfault) in TransformDependentTemplateSpecializationType
4 participants