diff options
Diffstat (limited to 'mesonbuild/compilers/mixins')
-rw-r--r-- | mesonbuild/compilers/mixins/clang.py | 5 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/clike.py | 11 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/gnu.py | 5 |
3 files changed, 18 insertions, 3 deletions
diff --git a/mesonbuild/compilers/mixins/clang.py b/mesonbuild/compilers/mixins/clang.py index 92f8c5f..1c0ee45 100644 --- a/mesonbuild/compilers/mixins/clang.py +++ b/mesonbuild/compilers/mixins/clang.py @@ -112,3 +112,8 @@ class ClangCompiler(GnuLikeCompiler): 'Cannot find linker {}.'.format(linker)) return ['-fuse-ld={}'.format(linker)] return super().use_linker_args(linker) + + def get_has_func_attribute_extra_args(self, name): + # Clang only warns about unknown or ignored attributes, so force an + # error. + return ['-Werror=attributes'] diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 41848bc..24f4796 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -1115,6 +1115,12 @@ class CLikeCompiler: m = pattern.match(ret) return ret + def get_has_func_attribute_extra_args(self, name): + # Most compilers (such as GCC and Clang) only warn about unknown or + # ignored attributes, so force an error. Overriden in GCC and Clang + # mixins. + return ['-Werror'] + def has_func_attribute(self, name, env): # Just assume that if we're not on windows that dllimport and dllexport # don't work @@ -1123,6 +1129,5 @@ class CLikeCompiler: if name in ['dllimport', 'dllexport']: return False, False - # Clang and GCC both return warnings if the __attribute__ is undefined, - # so set -Werror - return self.compiles(self.attribute_check_func(name), env, extra_args='-Werror') + return self.compiles(self.attribute_check_func(name), env, + extra_args=self.get_has_func_attribute_extra_args(name)) diff --git a/mesonbuild/compilers/mixins/gnu.py b/mesonbuild/compilers/mixins/gnu.py index 29552f3..3526a91 100644 --- a/mesonbuild/compilers/mixins/gnu.py +++ b/mesonbuild/compilers/mixins/gnu.py @@ -369,3 +369,8 @@ class GnuCompiler(GnuLikeCompiler): if self.language in {'c', 'objc'} and 'is valid for C++/ObjC++' in p.stde: result = False return result, p.cached + + def get_has_func_attribute_extra_args(self, name): + # GCC only warns about unknown or ignored attributes, so force an + # error. + return ['-Werror=attributes'] |