Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 251acc0

Browse files
committed
Merge pull request numpy#4842 from cournape/fix_intrinsics_detection
fix unknown attribute warnings under clang
2 parents dc98a3d + d0689a3 commit 251acc0

3 files changed

Lines changed: 46 additions & 4 deletions

File tree

numpy/core/setup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,11 @@ def check_funcs(funcs_name):
176176
moredefs.append((fname2def(f), 1))
177177

178178
for dec, fn in OPTIONAL_FUNCTION_ATTRIBUTES:
179-
if config.check_func(fn, decl='int %s %s(void *);' % (dec, fn),
180-
call=False):
179+
if config.check_gcc_function_attribute(dec, fn):
181180
moredefs.append((fname2def(fn), 1))
182181

183182
for fn in OPTIONAL_VARIABLE_ATTRIBUTES:
184-
if config.check_func(fn, decl='int %s a;' % (fn), call=False):
183+
if config.check_gcc_variable_attribute(fn):
185184
m = fn.replace("(", "_").replace(")", "_")
186185
moredefs.append((fname2def(m), 1))
187186

numpy/distutils/command/autodist.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,37 @@ def check_compiler_gcc4(cmd):
4141
}
4242
"""
4343
return cmd.try_compile(body, None, None)
44+
45+
46+
def check_gcc_function_attribute(cmd, attribute, name):
47+
"""Return True if the given function attribute is supported."""
48+
cmd._check_compiler()
49+
body = """
50+
#pragma GCC diagnostic error "-Wattributes"
51+
#pragma clang diagnostic error "-Wattributes"
52+
53+
int %s %s(void*);
54+
55+
int
56+
main()
57+
{
58+
}
59+
""" % (attribute, name)
60+
return cmd.try_compile(body, None, None) != 0
61+
62+
def check_gcc_variable_attribute(cmd, attribute):
63+
"""Return True if the given variable attribute is supported."""
64+
cmd._check_compiler()
65+
body = """
66+
#pragma GCC diagnostic error "-Wattributes"
67+
#pragma clang diagnostic error "-Wattributes"
68+
69+
int %s foo;
70+
71+
int
72+
main()
73+
{
74+
return 0;
75+
}
76+
""" % (attribute, )
77+
return cmd.try_compile(body, None, None) != 0

numpy/distutils/command/config.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
import distutils
1717
from numpy.distutils.exec_command import exec_command
1818
from numpy.distutils.mingw32ccompiler import generate_manifest
19-
from numpy.distutils.command.autodist import check_inline, check_compiler_gcc4
19+
from numpy.distutils.command.autodist import (check_gcc_function_attribute,
20+
check_gcc_variable_attribute,
21+
check_inline,
22+
check_compiler_gcc4)
2023
from numpy.distutils.compat import get_exception
2124

2225
LANG_EXT['f77'] = '.f'
@@ -402,6 +405,12 @@ def check_compiler_gcc4(self):
402405
"""Return True if the C compiler is gcc >= 4."""
403406
return check_compiler_gcc4(self)
404407

408+
def check_gcc_function_attribute(self, attribute, name):
409+
return check_gcc_function_attribute(self, attribute, name)
410+
411+
def check_gcc_variable_attribute(self, attribute):
412+
return check_gcc_variable_attribute(self, attribute)
413+
405414
def get_output(self, body, headers=None, include_dirs=None,
406415
libraries=None, library_dirs=None,
407416
lang="c", use_tee=None):

0 commit comments

Comments
 (0)