[clang] [llvm] Implement resource binding type prefix mismatch errors (PR #87578)

Joshua Batista via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 29 15:49:02 PDT 2024


================
@@ -44,7 +44,7 @@ void foo2() {
   // expected-warning at +1 {{'register' attribute only applies to cbuffer/tbuffer and external global variables}}
   extern RWBuffer<float> U2 : register(u5);
 }
-// FIXME: expect-error once fix https://github.com/llvm/llvm-project/issues/57886.
+// expected-error at +1 {{invalid register name prefix 'u' for 'float' (expected 't')}}
----------------
bob80905 wrote:

I don't have a prior example to base this off of at hand, but I think I saw some hlsl with a builtin type bound to a register and the valid prefix was 't'.
To answer your question, the assignment is represented as a VarDecl, so the compiler assumes this resource is a Sampler, UAV, or  SRV. Then the resource type is analyzed to see if it's a builtin (float happens to be a builtin).
Then we check the binding prefix to see if it's 't', and if not, emit an error. float is a builtin type, and the prefix isn't t, so that's why this test case expects 't'.
What prefix should it expect, if any?

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


More information about the cfe-commits mailing list