[clang] [HLSL][RootSignature] Implement diagnostic for missed comma (PR #147350)

Finn Plummer via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 10 09:46:51 PDT 2025


================
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -fsyntax-only %s -verify
+
+// expected-no-diagnostics
+
+// Test that we have consistent behaviour for comma parsing. Namely:
+// - a single trailing comma is allowed after any parameter
+// - a trailing comma is not required
+
+[RootSignature("CBV(b0, flags = DATA_VOLATILE,), DescriptorTable(Sampler(s0,),),")]
----------------
inbelic wrote:

The intended behaviour is to reject multiple commas. It was just quite hard to decouple from the implementation of a new diag done [here](https://github.com/llvm/llvm-project/pull/147800). And we will get the multiple error warning for free because of this change there:

https://github.com/llvm/llvm-project/blob/70448a3e3daae9ebac71df5b995bc93025b7a644/clang/lib/Parse/ParseHLSLRootSignature.cpp#L62-L67

and will be tested here:

https://github.com/llvm/llvm-project/blob/7ec7e32d2ac4945a489d5463b9fb700b0cceff9d/clang/test/SemaHLSL/RootSignature-err.hlsl#L117

For context, the original draft of this pr, had both an improvement of diagnostic but I wanted to trim it down as much as possible to just be a fix, so that we could get it in before the other pr.

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


More information about the cfe-commits mailing list