llvm-project/clang/test/ParserHLSL/hlsl_groupshared.cpp
Chris B d462621694
[HLSL] Parameter modifier parsing and AST (#72139)
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
2023-11-28 15:03:10 -06:00

13 lines
494 B
C++

// RUN: %clang_cc1 %s -verify
extern groupshared float f; // expected-error{{unknown type name 'groupshared'}}
extern float groupshared f2; // expected-error{{expected ';' after top level declarator}}
namespace {
float groupshared [[]] f3 = 12; // expected-error{{expected ';' after top level declarator}}
}
// expected-error@#fgc{{expected ';' after top level declarator}}
// expected-error@#fgc{{a type specifier is required for all declarations}}
float groupshared const f4 = 12; // #fgc