[clang] [ParserHLSL] Attempt to parse HLSL annotations on Field Decls. (PR #96346)
Joshua Batista via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 21 12:45:53 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.
+
+struct Eg9{
+// expected-error at +1{{attribute 'SV_DispatchThreadID' only applies to parameter}}
+ int a : SV_DispatchThreadID;
----------------
bob80905 wrote:
Added.
Are you suggesting I should add your attached code example as a separate test?
https://github.com/llvm/llvm-project/pull/96346
More information about the cfe-commits
mailing list