From ed837e205f3e67c4ae112f544cfe486ca3cc8455 Mon Sep 17 00:00:00 2001 From: Mukund Keshava Date: Thu, 15 May 2025 14:45:43 +0530 Subject: Rename 'main' on some backends (#7105) * Rename 'main' on some backednds Fixes #5542 Some backends like cuda, metal, cpu do not allow 'main' as the entry point. This commit adds a new warning that is emitted when a program uses main as the entry point. In addition to emitting the warning, it internally renames the entry point to "main_". It also adds a test to check these for the three backends. * format code * move test to diagnostics * rename test to diagnostic * generate unique name --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --- tests/diagnostics/entry-point-main-warning.slang | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/diagnostics/entry-point-main-warning.slang (limited to 'tests') diff --git a/tests/diagnostics/entry-point-main-warning.slang b/tests/diagnostics/entry-point-main-warning.slang new file mode 100644 index 000000000..9d880dbb1 --- /dev/null +++ b/tests/diagnostics/entry-point-main-warning.slang @@ -0,0 +1,14 @@ +// Test to check if we emit a warning and rename main to main_ on CUDA, CPU, metal backends + +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -entry main -target cuda +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -entry main -target metal +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -entry main -target cpp +[shader("compute")] +[numthreads(1,1,1)] +void main(RWBuffer output) +{ + output[0] = 1.0f; +} + +// CHECK: warning 40100: entry point 'main' is not allowed, and has been renamed to 'main_0' +// CHECK: void main_ \ No newline at end of file -- cgit v1.2.3