[llvm-bugs] [Bug 50273] New: No `-std=c2x` identification-macros at compile-time.

via llvm-bugs llvm-bugs at lists.llvm.org
Sat May 8 04:08:34 PDT 2021


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

            Bug ID: 50273
           Summary: No `-std=c2x` identification-macros at compile-time.
           Product: clang
           Version: 12.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C2x
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ipaldesse at gmail.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Created attachment 24842
  --> https://bugs.llvm.org/attachment.cgi?id=24842&action=edit
no_c2x_identify_code_example

Looks like `clang-12` has no macros at compile-time for `-std=c2x`
identification, or at least for it's features. Here's an example of what I
mean:


> cat cxx.c
#if __has_extension(cxx_attributes) || __has_feature(cxx_attributes)
#  define is_cpp_attr 1
#else
#  define is_cpp_attr 0
#endif

#if defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L
#  define is_c2x_support 1
#else
#  define is_c2x_support 0
#endif

int main(void) {
#if is_cpp_attr || is_c2x_support
  "c2x works";
#else
  "has no c2x definition support";
#endif
}

> clang-12 -std=c2x -dM -E cxx.c | grep "is_c" 
#define is_c2x_support 0
#define is_cpp_attr 0

> cp cxx.c cxx.cpp
> clang++-12 -dM -E cxx.cpp | grep "is_c"
#define is_c2x_support 0
#define is_cpp_attr 1



Because of this bug the next C-code, compiled with `clang -std=c2x`, will not
never work with C++11-style attributes:

#if __is_cpp_attr__
#  define libsalloc_attr_transparent [[gnu::transparent_union]] // -std=c2x
will not change anything
#else
#  if __has_attribute(transparent_union)
#    define libsalloc_attr_transparent __attribute__((transparent_union))
#  else
#    define libsalloc_attr_transparent
#  endif
#endif


Thanks.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210508/e7b6f383/attachment.html>


More information about the llvm-bugs mailing list