[clang] [SemaHLSL] Add missing validations of existing semantics (PR #224139)

Deric C. via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 25 11:57:57 PDT 2026


================
@@ -1106,13 +1106,8 @@ void SemaHLSL::checkSemanticAnnotation(
     return;
   }
 
-  // SV_-prefixed names can have arbitrary interpretations, e.g. SV_Position
-  // on a vertex input. Do not apply system-value constraints to them.
-  if (Interpretation == llvm::hlsl::SemanticInterpretation::Arbitrary)
-    return;
-
   diagnoseSemanticIndex(SemanticAttr, Kind, ElementCount);
-  diagnoseSystemSemanticType(Param, SemanticAttr, Kind);
+  diagnoseSemanticType(Param, SemanticAttr, Kind);
----------------
Icohedron wrote:

This change makes `int4` `SV_Position` invalid.
```hlsl
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -finclude-default-header -x hlsl -fsyntax-only -verify %s
// expected-no-diagnostics

// SV_Position is arbitrary on vertex inputs, so it need not be a float type.
// The same semantic on the vertex output is a system value and is float4.
[shader("vertex")]
float4 main(int4 P : SV_Position) : SV_Position { return (float4)P; }
```

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


More information about the cfe-commits mailing list