https://bugs.llvm.org/show_bug.cgi?id=46747

            Bug ID: 46747
           Summary: Lower limit of availability attribute isn't enforced
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C
          Assignee: unassignedclangb...@nondot.org
          Reporter: malcolm_fergu...@yahoo.com
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk

The following does not produce an error.  I expect it should:
$ cat << EOF | ./clang -x c - -mmacosx-version-min=10.9
__attribute__((availability(macosx,introduced=10.10,deprecated=10.11,obsoleted=10.12)))
int fn(void) { return 1; }
int main() { return fn(); }
EOF

If I set -mmacosx-version-min=10.11, clang issues a warning.  If I set it to
10.12, clang issues an error.  It handles the upper limit of the availibity
attribute, but not the lower limit.

This was a problem for us compiling Python3 to run on macOS 10.9 using a modern
version of Xcode.  The fdopendir() function was added to dirent.h in
MacOSX10.10.sdk and is available on systems running macOS 10.10 or later.  The
autoconf script for Python detects that fdopendir is available and uses this
instead of opendir(), but it wouldn't do this if clang issued an error.  This
led to runtime fails on the min. supported system.  We build all of our
products this way, which means we run the risk of accidentally using functions
that aren't available.

Apple's dirent.h declares:
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0)
DIR *fdopendir(int) __DARWIN_ALIAS_I(fdopendir);

Which preprocesses to:
# 128
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/dirent.h"
3 4
__attribute__((availability(macosx,introduced=10.10)))
DIR *fdopendir(int) __asm("_" "fdopendir" "$INODE64" );

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to