[clang] [Clang] Fix double revert of a keyword token that was cached before the first fallback (PR #219799)

Shengxin Pei via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 31 01:19:13 PDT 2026


================
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,garbage -DGARBAGE %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// The undeclared template-name 'foo' starts a tentative parse that caches the
+// rest of the file, so the second '__make_unsigned' token keeps its keyword
+// kind after the first one has already been reverted to an identifier.
+#ifdef GARBAGE
+foo < bar()
+// garbage-error at -1 {{no template named 'foo'}}
+// garbage-error at -2 {{use of undeclared identifier 'bar'}}
+// garbage-error at -3 {{expected '>'}}
+// garbage-note at -4 {{to match this '<'}}
+#endif
+
+namespace N { // garbage-error {{expected unqualified-id}}
+template <typename _Tp> struct __make_unsigned { typedef _Tp __type; };
+// expected-warning at -1 {{keyword '__make_unsigned' will be made available as an identifier for the remainder of the translation unit}}
+struct __make_unsigned<char> { typedef char __type; };
+// expected-error at -1 {{template specialization requires 'template<>'}}
+} // namespace N
----------------
TPPPP72 wrote:

Ditto

https://github.com/llvm/llvm-project/pull/219799


More information about the cfe-commits mailing list