Files
clang-p2996/clang/test/ParserHLSL/invalid_inside_cb.hlsl
Xiang Li 782ac2182c [HLSL] Support cbuffer/tbuffer for hlsl.
This is first part for support cbuffer/tbuffer.

The format for cbuffer/tbuffer is
BufferType [Name] [: register(b#)] { VariableDeclaration [: packoffset(c#.xyzw)]; ... };

More details at https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-constants

New keyword 'cbuffer' and 'tbuffer' are added.
New AST node HLSLBufferDecl is added.
Build AST for simple cbuffer/tbuffer without attribute support.

The special thing is variables declared inside cbuffer is exposed into global scope.
So isTransparentContext should return true for HLSLBuffer.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D129883
2022-09-21 10:07:43 -07:00

22 lines
613 B
HLSL

// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify
// template not allowed inside cbuffer.
cbuffer A {
// expected-error@+2 {{invalid declaration inside cbuffer}}
template<typename T>
T foo(T t) { return t;}
}
cbuffer A {
// expected-error@+2 {{invalid declaration inside cbuffer}}
template<typename T>
struct S { float s;};
}
// typealias not allowed inside cbuffer.
cbuffer A {
// expected-error@+2 {{invalid declaration inside cbuffer}}
// expected-warning@+1 {{alias declarations are a C++11 extension}}
using F32 = float;
}