[clang] [HLSL] Add a warning for implicit bindings (PR #135909)

Justin Bogner via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 16 13:26:09 PDT 2025


================
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -Wno-error=hlsl-implicit-binding -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify
+
+// expected-warning at +1 {{resource has implicit register binding}}
+cbuffer cb0 {
+  int a;
+}
+
+// No warning - this is an element of the $Globals buffer not it's own binding.
+float b;
+
+// expected-warning at +1 {{resource has implicit register binding}}
+RWBuffer<int> c;
+
+// No warning - explicit binding.
+RWBuffer<float> d : register(u0);
+
----------------
bogner wrote:

This can't be tested util #135287 goes in, but it should warn. I added a commented out test and a `TODO` comment.

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


More information about the cfe-commits mailing list