[clang] REAPPLY [clang-repl] Ensure clang-repl accepts all C keywords supported in all language models (PR #181335)
Anutosh Bhat via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 13 00:58:18 PST 2026
https://github.com/anutosh491 created https://github.com/llvm/llvm-project/pull/181335
https://github.com/llvm/llvm-project/pull/142749 was reverted because `_Float16` is only supported on the following targets
(https://clang.llvm.org/docs/LanguageExtensions.html#half-precision-floating-point) & the previous PR wasn't guarding it to expect a failure on some targets.
Hence the CI failed with errors like
```
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/bin/clang -cc1 -internal-isystem /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/lib/clang/21/include -nostdsysteminc -fsyntax-only -verify -fincremental-extensions -std=c++20 /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang/test/Interpreter/disambiguate-decl-stmt.cpp # RUN: at line 1
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/bin/clang -cc1 -internal-isystem /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/lib/clang/21/include -nostdsysteminc -fsyntax-only -verify -fincremental-extensions -std=c++20 /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang/test/Interpreter/disambiguate-decl-stmt.cpp
error: 'expected-error' diagnostics seen but not expected:
File /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang/test/Interpreter/disambiguate-decl-stmt.cpp Line 113: _Float16 is not supported on this target
1 error generated.
```
This should now be fixed as we are expecting an error (or no error) based on the target through the `expected-error 0-1` framework
>From ac14ffa9d7b99a03dc56b1e25f81a92a0c43cf43 Mon Sep 17 00:00:00 2001
From: anutosh491 <andersonbhat491 at gmail.com>
Date: Fri, 13 Feb 2026 14:23:45 +0530
Subject: [PATCH] ReApply [clang-repl] Ensure clang-repl accepts all C keywords
supported in all language models
---
clang/lib/Parse/ParseTentative.cpp | 2 ++
clang/test/Interpreter/disambiguate-decl-stmt.cpp | 13 +++++++++++++
2 files changed, 15 insertions(+)
diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp
index 0047e3ea3749b..c08546816d35a 100644
--- a/clang/lib/Parse/ParseTentative.cpp
+++ b/clang/lib/Parse/ParseTentative.cpp
@@ -1192,6 +1192,7 @@ Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename,
case tok::kw_inline:
case tok::kw_virtual:
case tok::kw_explicit:
+ case tok::kw__Noreturn:
// Modules
case tok::kw___module_private__:
@@ -1246,6 +1247,7 @@ Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename,
// GNU
case tok::kw_restrict:
case tok::kw__Complex:
+ case tok::kw__Imaginary:
case tok::kw___attribute:
case tok::kw___auto_type:
return TPResult::True;
diff --git a/clang/test/Interpreter/disambiguate-decl-stmt.cpp b/clang/test/Interpreter/disambiguate-decl-stmt.cpp
index 24902cee8ed1f..8183c7c18ee2f 100644
--- a/clang/test/Interpreter/disambiguate-decl-stmt.cpp
+++ b/clang/test/Interpreter/disambiguate-decl-stmt.cpp
@@ -101,3 +101,16 @@ __attribute((noreturn)) Attrs2::Attrs2() = default;
// Extra semicolon
namespace N {};
+
+// Test C keywords supported in all language modes.
+// https://clang.llvm.org/docs/LanguageExtensions.html#c-keywords-supported-in-all-language-modes
+
+_Alignas(16) int aligned_var;
+int align = _Alignof(double);
+_Atomic int atomic_var = 0;
+_Complex double complex_val = 1.0 + 2.0i;
+_Float16 f = 1.5; // expected-error 0-1{{_Float16 is not supported on this target}}
+_Thread_local int counter = 0;
+_Static_assert(sizeof(int) == 4, "int must be 4 bytes");
+_Imaginary float i = 2.0f; // expected-error {{imaginary types are not supported}}
+_Noreturn void noreturn_func() { while (true) {} }
\ No newline at end of file
More information about the cfe-commits
mailing list