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

Xiang Li via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 26 12:06:58 PDT 2024


================
@@ -1,10 +1,13 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -o - %s -verify
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -o - %s | FileCheck %s
 
-// TODO: update once we handle annotations on struct fields
+// tests that hlsl annotations are properly parsed when applied on field decls,
+// and that the annotation gets properly placed on the AST.
 
 struct Eg9{
-// expected-error at +1{{attribute 'SV_DispatchThreadID' only applies to parameter}}
-  int a : SV_DispatchThreadID;
+  // CHECK: CXXRecordDecl 0x{{[0-9a-f]+}} <col:1, col:8> col:8 implicit struct Eg9
+  // CHECK: FieldDecl 0x{{[0-9a-f]+}} <line:10:3, col:16> col:16 referenced a 'unsigned int'
+  // CHECK: -HLSLSV_DispatchThreadIDAttr 0x{{[0-9a-f]+}} <col:20>
+  unsigned int a : SV_DispatchThreadID;
----------------
python3kgae wrote:

Do we support semantics other than SV_DispatchThreadID to test currently?
Something like struct A {
uint a : SV_DispatchThreadID;
uint b: SV_GroupID;
};

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


More information about the cfe-commits mailing list