As @david2050 commented, changes introduced by https://reviews.llvm.org/D56397 break builds for older compilers
which don't support __has(_cpp)_attribute. This is a fix for the break.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
@kkwli0 Thanks for letting me know! But wouldn't https://reviews.llvm.org/D57848 always fall to "else" case added if the compiler is not GCC?
I agree, Clang defines __GNUC__ to value 4 for compatibility reasons. Likewise, this change doesn't handle compilers other than GCC that don't support __has_cpp_attribute (yet).
I'd propose to take the solution that libcxx, LLVMSupport, and LLVMDemangle use:
#ifndef __has_cpp_attribute #define __has_cpp_attribute(__x) 0 #endif
Also Kelvin is right that _GNUC_VER is not defined here (it's from libcxx). Maybe we should take the macros from LLVM (except the non-C++ case)? That would also give us a correct checking for gnu::fallthrough, but remove __attribute__((__fallthrough__)) completely.
I close https://reviews.llvm.org/D57848 and consolidate the review and patch in this one.