Skip to content

Conversation

@sarnex
Copy link
Member

@sarnex sarnex commented Nov 24, 2025

These are C tests, not C++, so no function parameters means unspecified number of parameters, not void.

These compile fine on the current tested offload targets because an error is only thrown if the calling convention doesn't support variadic arguments, which they happen to.

When compiling this test for other targets that do not support variadic arguments, we get an error, which does not seem intentional.

Just add void to the parameter list.

@sarnex sarnex marked this pull request as ready for review November 24, 2025 20:21
@llvmbot
Copy link
Member

llvmbot commented Nov 24, 2025

@llvm/pr-subscribers-offload

Author: Nick Sarnie (sarnex)

Changes

These are C tests, not C++, so no function parameters means unspecified number of parameters, not void.

These compile fine on the current tested offload targets because an error is only thrown if the calling convention doesn't support variadic arguments, which they happen to.

When compiling this test for other targets that do not support variadic arguments, we get an error, which does not seem intentional.

Just add void to the parameter list.


Full diff: https://github.com/llvm/llvm-project/pull/169399.diff

2 Files Affected:

  • (modified) offload/test/offloading/shared_lib_fp_mapping.c (+1-1)
  • (modified) offload/test/offloading/static_linking.c (+1-1)
diff --git a/offload/test/offloading/shared_lib_fp_mapping.c b/offload/test/offloading/shared_lib_fp_mapping.c
index c6203443eee18..0e1fed4d0baf8 100644
--- a/offload/test/offloading/shared_lib_fp_mapping.c
+++ b/offload/test/offloading/shared_lib_fp_mapping.c
@@ -7,7 +7,7 @@
 
 #include <stdio.h>
 
-extern int func(); // Provided in liba.so, returns 42
+extern int func(void); // Provided in liba.so, returns 42
 typedef int (*fp_t)();
 
 int main() {
diff --git a/offload/test/offloading/static_linking.c b/offload/test/offloading/static_linking.c
index 7be95a10ffcd6..273109e10c09e 100644
--- a/offload/test/offloading/static_linking.c
+++ b/offload/test/offloading/static_linking.c
@@ -14,7 +14,7 @@ int foo() {
 }
 #else
 #include <stdio.h>
-int foo();
+int foo(void);
 
 int main() {
   int x = foo();

@sarnex sarnex requested a review from jhuber6 November 24, 2025 20:22

extern int func(); // Provided in liba.so, returns 42
extern int func(void); // Provided in liba.so, returns 42
typedef int (*fp_t)();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for the typedef?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was using SPIR-V to repro the issue and it compiled successfully with just the func change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need the void in the typedef too, otherwise it's a type mismatch. Most compilers will accept it. Clang just reports a warning.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in latest commit, thanks!

Signed-off-by: Nick Sarnie <[email protected]>
Copy link
Contributor

@kevinsala kevinsala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sarnex sarnex merged commit b3b83ac into llvm:main Nov 25, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants