[clang] [ParserHLSL] Attempt to parse HLSL annotations on Field Decls. (PR #96346)
Joshua Batista via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 26 12:46:19 PDT 2024
================
@@ -1,11 +1,24 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -o - %s -verify
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -ast-dump -x hlsl -o - %s | Filecheck %s
-// expected-no-diagnostics
struct MyBitFields {
- unsigned int field1 : 3; // 3 bits for field1
- unsigned int field2 : 4; // 4 bits for field2
- int field3 : 5; // 5 bits for field3 (signed)
+ // CHECK: FieldDecl 0x{{[0-9a-f]+}} <line:9:3, col:25> col:16 referenced field1 'unsigned int'
+ // CHECK:-ConstantExpr 0x{{[0-9a-f]+}} <col:25> 'int'
+ // CHECK:-value: Int 3
+ // CHECK:-IntegerLiteral 0x{{[0-9a-f]+}} <col:25> 'int' 3
+ unsigned int field1 : 3; // 3 bits for field1
+
+ // CHECK:FieldDecl 0x{{[0-9a-f]+}} <line:15:3, col:25> col:16 referenced field2 'unsigned int'
+ // CHECK:-ConstantExpr 0x{{[0-9a-f]+}} <col:25> 'int'
+ // CHECK:-value: Int 4
+ // CHECK:-IntegerLiteral 0x{{[0-9a-f]+}} <col:25> 'int' 4
+ unsigned int field2 : 4; // 4 bits for field2
+
+ // CHECK:FieldDecl 0x{{[0-9a-f]+}} <line:21:3, col:16> col:7 field3 'int'
+ // CHECK:-ConstantExpr 0x{{[0-9a-f]+}} <col:16> 'int'
+ // CHECK:-value: Int 5
+ // CHECK:-IntegerLiteral 0x{{[0-9a-f]+}} <col:16> 'int' 5
+ int field3 : 5; // 5 bits for field3 (signed)
----------------
bob80905 wrote:
DXC does, as you pointed out here:
https://godbolt.org/z/8f3xxodEj
There are currently no diagnostics defined for this case in DiagnosticSemaKinds.td, this error was emitted in HLSignatureLower.cpp in DXC. I believe we would want to report an error if that struct is used as a parameter for an entry point to keep HLSL consistent, but I don't think this behavior should be implemented in this PR.
https://github.com/llvm/llvm-project/pull/96346
More information about the cfe-commits
mailing list