[clang] [ParserHLSL] Attempt to parse HLSL annotations on Field Decls. (PR #96346)

Justin Bogner via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 21 11:47:29 PDT 2024


================
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -o - %s -verify
+
+// previously, this test would result in an error shown below on the line that 
+// declares variable a in struct Eg9:
+// error: use of undeclared identifier
+//     'SV_DispatchThreadID'
+// This is because the annotation is parsed as if it was a c++ bit field, and an identifier
+// that represents an integer is expected, but not found.
+
+// This test ensures that hlsl annotations are attempted to be parsed when parsing struct decls.
+// Ideally, we'd validate this behavior by ensuring the annotation is parsed and properly
+// attached as an attribute to the member in the struct in the AST. However, in this case
+// this can't happen presently because there are other issues with annotations on field decls.
+// This test just ensures we make progress by moving the validation error from the realm of
+// C++ and expecting bitfields, to HLSL and a specialized error for the recognized annotation.
----------------
bogner wrote:

Similarly, I'm not sure that we need all of these details about why this still fails. I'd probably just put a `TODO: update once we handle annotations on struct fields` next to the expected error diagnostic and leave it at that. 

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


More information about the cfe-commits mailing list