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

            Bug ID: 40769
           Summary: stdatomic.h not C11 compliant with Objective C
                    framework
           Product: clang
           Version: trunk
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Headers
          Assignee: unassignedclangb...@nondot.org
          Reporter: theboywonder2...@yahoo.co.jp
                CC: craig.top...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk

On Mac OSX 10.4 (Mojave) with Apple LLVM Version 10.0.0 (clang-1000.11.45.5)

I have written my own <stdatomic.h> for multiple platforms that don't support
it. It is designed to work under all C11-compliant compilers. My own
<stdatomic.h> has a gate that says:

#ifndef __STDC_NO_ATOMICS__
#  error ... error text goes here ...
#endif

As my entire source repository is a shared repository, this file is visible
during compilation on all platforms. I use "-idirafter" to make sure that any 
file provided by the hosted environment gets picked up before my file.

If clang on Mac OSX is invoked on a file with ".c" extension then the hosted
environment doesn't supply <stdatomic.h>. In this case __STDC_NO_ATOMICS__ is
defined, my custom file is called, and it compiles cleanly.

However, for the Objective C framework, LLVM headers provide a <stdatomic.h>.
Inside this file is the following:

#if __STDC_HOSTED__ && __has_include_next(<stdatomic.h>)
#  include_next <statomic.h>
#endif

The extension "include_next" searches "-idirafter" and sees my <stdatomic.h>
and includes it, but it does *not* define __STDC_NO_ATOMICS__ so the gate
within my custom <stdatomic.h> is entered and the build always fails. This
appears to be a violation of C2011.

-- 
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