llvm-project/clang/test/SemaHLSL/GlobalConstructors.hlsl
Chris Bieneman d3c54a172d [HLSL] Call global constructors inside entry
HLSL doesn't have a runtime loader model that supports global
construction by a loader or runtime initializer. To allow us to leverage
global constructors with minimal code generation impact we put calls to
the global constructors inside the generated entry function.

Differential Revision: https://reviews.llvm.org/D132977
2022-09-09 09:01:28 -05:00

19 lines
397 B
HLSL

// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -fsyntax-only %s -verify
int i;
struct Pup {
Pup() {
i++;
}
};
// expected-error@+1 {{initializer priorities are not supported in HLSL}}
Pup __attribute__((init_priority(1))) Fido;
// expected-error@+1 {{initializer priorities are not supported in HLSL}}
__attribute__((constructor(1))) void call_me_first(void) {
i = 12;
}