summaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/c_function_attributes.py
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2023-11-04 13:12:07 +0100
committerEli Schwartz <eschwartz93@gmail.com>2023-11-04 23:36:03 -0400
commit2d538c58cb7626cf3d799761dd9444f1aed9ba40 (patch)
treec2e645ac5f1f4d1435551ab198c2ebe255802d38 /mesonbuild/compilers/c_function_attributes.py
parentfb1c6e32f41277540b8ab51b1b4223ec68d18821 (diff)
downloadmeson-2d538c58cb7626cf3d799761dd9444f1aed9ba40.tar.gz
Fix visibility attribute support check for GCC on Windows
has_function_attribute() depends on -Wattributes being emitted when an attribute is not supported by the compiler. In case of GCC on Window (at least) there is no warning in case the attribute is used on a declaration. Only once there is also a function definition does it emit a warning like: a.c: In function ‘foo’: a.c:8:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes] 8 | } To fix this add a dummy function definition to all visibility compiler checks in meson. The tests in "197 function attributes" only checked for positive return result on on-msvc compilers, except one special case for dllexport/dllimport. Refactor the tests a bit so one can specify also a negative expected result, and add tests for all visibility attribute variants.
Diffstat (limited to 'mesonbuild/compilers/c_function_attributes.py')
-rw-r--r--mesonbuild/compilers/c_function_attributes.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/mesonbuild/compilers/c_function_attributes.py b/mesonbuild/compilers/c_function_attributes.py
index 71ee9b22a..eec872b5f 100644
--- a/mesonbuild/compilers/c_function_attributes.py
+++ b/mesonbuild/compilers/c_function_attributes.py
@@ -103,17 +103,17 @@ C_FUNC_ATTRIBUTES = {
'vector_size':
'__attribute__((vector_size(32))); int foo(void) { return 0; }',
'visibility': '''
- int foo_def(void) __attribute__((visibility("default")));
- int foo_hid(void) __attribute__((visibility("hidden")));
- int foo_int(void) __attribute__((visibility("internal")));''',
+ int foo_def(void) __attribute__((visibility("default"))); int foo_def(void) { return 0; }
+ int foo_hid(void) __attribute__((visibility("hidden"))); int foo_hid(void) { return 0; }
+ int foo_int(void) __attribute__((visibility("internal"))); int foo_int(void) { return 0; }''',
'visibility:default':
- 'int foo(void) __attribute__((visibility("default")));',
+ 'int foo(void) __attribute__((visibility("default"))); int foo(void) { return 0; }',
'visibility:hidden':
- 'int foo(void) __attribute__((visibility("hidden")));',
+ 'int foo(void) __attribute__((visibility("hidden"))); int foo(void) { return 0; }',
'visibility:internal':
- 'int foo(void) __attribute__((visibility("internal")));',
+ 'int foo(void) __attribute__((visibility("internal"))); int foo(void) { return 0; }',
'visibility:protected':
- 'int foo(void) __attribute__((visibility("protected")));',
+ 'int foo(void) __attribute__((visibility("protected"))); int foo(void) { return 0; }',
'warning':
'int foo(void) __attribute__((warning("")));',
'warn_unused_result':