diff --git a/flang/include/flang/Common/idioms.h b/flang/include/flang/Common/idioms.h --- a/flang/include/flang/Common/idioms.h +++ b/flang/include/flang/Common/idioms.h @@ -24,7 +24,6 @@ #endif #include "visit.h" -#include "llvm/Support/Compiler.h" #include #include #include @@ -34,6 +33,16 @@ #include #include +#ifndef __has_attribute +#define __has_attribute(x) 0 +#endif + +#if __has_attribute(unused) +#define FLANG_ATTRIBUTE_UNUSED __attribute__((__unused__)) +#else +#define FLANG_ATTRIBUTE_UNUSED +#endif + #if __GNUC__ == 7 // Avoid a deduction bug in GNU 7.x headers by forcing the answer. namespace std { @@ -125,11 +134,11 @@ #define ENUM_CLASS(NAME, ...) \ enum class NAME { __VA_ARGS__ }; \ - LLVM_ATTRIBUTE_UNUSED static constexpr std::size_t NAME##_enumSize{[] { \ + FLANG_ATTRIBUTE_UNUSED static constexpr std::size_t NAME##_enumSize{[] { \ enum { __VA_ARGS__ }; \ return Fortran::common::ListItemCount{__VA_ARGS__}.value; \ }()}; \ - LLVM_ATTRIBUTE_UNUSED static inline std::string EnumToString(NAME e) { \ + FLANG_ATTRIBUTE_UNUSED static inline std::string EnumToString(NAME e) { \ return Fortran::common::EnumIndexToString( \ static_cast(e), #__VA_ARGS__); \ }