Files
clang-p2996/clang/test/ParserHLSL/cb_error.hlsl
Justin Bogner d35bf17e8a [HLSL] Add a warning for implicit bindings (#135909)
Implicit bindings will cause very confusing crashes in the backend at
present, so this is intended at least partially as a stop gap until we
get them implemented (see #110722).

However, I do think that this is useful in the longer term as well as an
off-by-default warning, as it is quite easy to miss a binding or two
when using explicit bindings and the results of that can be surprisingly
hard to debug. I've filed #135907 to track turning this into an
off-by-default warning or removing it eventually as we see fit.
2025-04-16 15:45:18 -07:00

75 lines
1.5 KiB
HLSL

// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify
// expected-error@+2 {{expected identifier}}
// expected-error@+1 {{expected unqualified-id}}
cbuffer { ... };
// expected-error@+1 {{expected '{'}}
cbuffer missing_definition;
// expected-error@+1 {{expected unqualified-id}}
int cbuffer;
// expected-error@+1 {{expected identifier}}
cbuffer;
// expected-error@+2 {{expected identifier}}
// expected-error@+1 {{expected unqualified-id}}
tbuffer { ... };
// expected-error@+1 {{expected '{'}}
tbuffer missing_definition;
// expected-error@+1 {{expected unqualified-id}}
int tbuffer;
// expected-error@+1 {{expected identifier}}
tbuffer;
// expected-error@+1 {{expected unqualified-id}}
cbuffer A {}, B{}
// cbuffer inside namespace is supported.
namespace N {
cbuffer A {
float g;
}
}
cbuffer A {
// expected-error@+1 {{invalid declaration inside cbuffer}}
namespace N {
}
}
cbuffer A {
// expected-error@+1 {{invalid declaration inside cbuffer}}
cbuffer Nested {
}
}
struct S {
// expected-error@+1 {{expected member name or ';' after declaration specifiers}}
cbuffer what {
int y;
}
};
void func() {
// expected-error@+1 {{expected expression}}
tbuffer derp {
int z;
}
decltype(derp) another {
int a;
}
}
// struct decl inside cb is supported.
cbuffer A {
struct S2 {
float s;
};
S2 s;
}
// function decl inside cb is supported.
cbuffer A {
float foo_inside_cb() { return 1.2;}
}