diff options
| -rw-r--r-- | mesonbuild/compilers/c_function_attributes.py | 14 | ||||
| -rw-r--r-- | test cases/common/197 function attributes/meson.build | 43 |
2 files changed, 36 insertions, 21 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': diff --git a/test cases/common/197 function attributes/meson.build b/test cases/common/197 function attributes/meson.build index 0d5c04ed1..8ef6b741d 100644 --- a/test cases/common/197 function attributes/meson.build +++ b/test cases/common/197 function attributes/meson.build @@ -23,7 +23,8 @@ if c.get_id() == 'pgi' error('MESON_SKIP_TEST: PGI supports its own set of features, will need a separate list for PGI to test it.') endif -expected_result = not ['msvc', 'clang-cl', 'intel-cl'].contains(c.get_id()) +expected = {} +expected_default = not ['msvc', 'clang-cl', 'intel-cl'].contains(c.get_id()) # Q: Why is ifunc not in this list or any of the below lists? # A: It's too damn hard to figure out if you actually support it, since it @@ -56,8 +57,24 @@ attributes = [ 'vector_size', 'warn_unused_result', 'weak', + 'dllexport', + 'dllimport', ] +expected += { + 'dllexport': ['windows', 'cygwin'].contains(host_machine.system()), + 'dllimport': ['windows', 'cygwin'].contains(host_machine.system()), +} + +if c.get_id() == 'gcc' and ['windows', 'cygwin'].contains(host_machine.system()) + expected += { + 'visibility': false, + 'visibility:hidden': false, + 'visibility:internal': false, + 'visibility:protected': false, + } +endif + if c.get_id() != 'intel' # not supported by icc as of 19.0.0 attributes += 'weakref' @@ -67,6 +84,10 @@ endif if host_machine.system() != 'darwin' attributes += 'alias' attributes += 'visibility' + attributes += 'visibility:default' + attributes += 'visibility:hidden' + attributes += 'visibility:internal' + attributes += 'visibility:protected' attributes += 'alloc_size' endif @@ -94,24 +115,18 @@ endif if get_option('mode') == 'single' foreach a : attributes x = c.has_function_attribute(a) + expected_result = expected.get(a, expected_default) assert(x == expected_result, '@0@: @1@'.format(c.get_id(), a)) x = cpp.has_function_attribute(a) assert(x == expected_result, '@0@: @1@'.format(cpp.get_id(), a)) endforeach - - win_expect = ['windows', 'cygwin'].contains(host_machine.system()) - foreach a : ['dllexport', 'dllimport'] - assert(c.has_function_attribute(a) == win_expect, - '@0@: @1@'.format(c.get_id(), a)) - assert(cpp.has_function_attribute(a) == win_expect, - '@0@: @1@'.format(cpp.get_id(), a)) - endforeach else - if not ['msvc', 'clang-cl', 'intel-cl'].contains(c.get_id()) - multi_expected = attributes - else - multi_expected = [] - endif + multi_expected = [] + foreach a : attributes + if expected.get(a, expected_default) + multi_expected += a + endif + endforeach multi_check = c.get_supported_function_attributes(attributes) assert(multi_check == multi_expected, 'get_supported_function_arguments works (C)') |
