mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-05-14 01:46:41 +00:00

This change implements parsing for HLSL's parameter modifier keywords `in`, `out` and `inout`. Because HLSL doesn't support references or pointers, these keywords are used to allow parameters to be passed in and out of functions. This change only implements the parsing and AST support. In the HLSL ASTs we represent `out` and `inout` parameters as references, and we implement the semantics of by-value passing during IR generation. In HLSL parameters marked `out` and `inout` are ambiguous in function declarations, and `in`, `out` and `inout` may be ambiguous at call sites. This means a function may be defined as `fn(in T)` and `fn(inout T)` or `fn(out T)`, but not `fn(inout T)` and `fn(out T)`. If a funciton `fn` is declared with `in` and `inout` or `out` arguments, the call will be ambiguous the same as a C++ call would be ambiguous given declarations `fn(T)` and `fn(T&)`. Fixes #59849
51 lines
1.6 KiB
C++
51 lines
1.6 KiB
C++
// RUN: %clang_cc1 %s -verify
|
|
|
|
// expected-error@#fn{{unknown type name 'in'}}
|
|
// expected-error@#fn{{expected ')'}}
|
|
// expected-note@#fn{{to match this '('}}
|
|
void fn(in out float f); // #fn
|
|
|
|
// expected-error@#fn2{{unknown type name 'in'}}
|
|
// expected-error@#fn2{{expected ')'}}
|
|
// expected-note@#fn2{{to match this '('}}
|
|
void fn2(in in float f); // #fn2
|
|
|
|
// expected-error@#fn3{{unknown type name 'out'}}
|
|
// expected-error@#fn3{{expected ')'}}
|
|
// expected-note@#fn3{{to match this '('}}
|
|
void fn3(out out float f); // #fn3
|
|
|
|
// expected-error@#fn4{{unknown type name 'inout'}}
|
|
// expected-error@#fn4{{expected ')'}}
|
|
// expected-note@#fn4{{to match this '('}}
|
|
void fn4(inout in out float f); // #fn4
|
|
|
|
// expected-error@#fn5{{unknown type name 'inout'}}
|
|
// expected-error@#fn5{{expected ')'}}
|
|
// expected-note@#fn5{{to match this '('}}
|
|
void fn5(inout in float f); // #fn5
|
|
|
|
// expected-error@#fn6{{unknown type name 'inout'}}
|
|
// expected-error@#fn6{{expected ')'}}
|
|
// expected-note@#fn6{{to match this '('}}
|
|
void fn6(inout out float f); // #fn6
|
|
|
|
void implicitFn(float f);
|
|
|
|
// expected-error@#inFn{{unknown type name 'in'}}
|
|
void inFn(in float f); // #inFn
|
|
|
|
// expected-error@#inoutFn{{unknown type name 'inout'}}
|
|
void inoutFn(inout float f); // #inoutFn
|
|
|
|
// expected-error@#outFn{{unknown type name 'out'}}
|
|
void outFn(out float f); // #outFn
|
|
|
|
// expected-error@#fn7{{unknown type name 'inout'}}
|
|
// expected-error@#fn7{{declaration of 'T' shadows template parameter}}
|
|
// expected-error@#fn7{{expected ')'}}
|
|
// expected-note@#fn7{{to match this '('}}
|
|
template <typename T> // expected-note{{template parameter is declared here}}
|
|
void fn7(inout T f); // #fn7
|
|
|