[flang-commits] [flang] d502c68 - [flang][common] return ENUM_CLASS names definition to original state (#143553)

via flang-commits flang-commits at lists.llvm.org
Tue Jun 10 09:21:23 PDT 2025


Author: Andre Kuhlenschmidt
Date: 2025-06-10T09:21:20-07:00
New Revision: d502c68dcb63fbb8aa0b9989838dbaa32988453a

URL: https://github.com/llvm/llvm-project/commit/d502c68dcb63fbb8aa0b9989838dbaa32988453a
DIFF: https://github.com/llvm/llvm-project/commit/d502c68dcb63fbb8aa0b9989838dbaa32988453a.diff

LOG: [flang][common] return ENUM_CLASS names definition to original state (#143553)

This PR simply reverts a few lines in
bf60aa1c551ef5de62fd1d1cdcbff58cba55cacd to their state in
bcba39a56fd4e1debe3854d564c3e03bf0a50ee6 so that they are constant for
some of the build tests that require it. This should fix the breakage
caused by #142022.

Added: 
    

Modified: 
    flang/include/flang/Common/enum-class.h

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Common/enum-class.h b/flang/include/flang/Common/enum-class.h
index 0635a0c85be05..9f9134ee3ff7a 100644
--- a/flang/include/flang/Common/enum-class.h
+++ b/flang/include/flang/Common/enum-class.h
@@ -62,14 +62,13 @@ constexpr std::array<std::string_view, ITEMS> EnumNames(const char *p) {
   enum class NAME { __VA_ARGS__ }; \
   [[maybe_unused]] static constexpr std::size_t NAME##_enumSize{ \
       ::Fortran::common::CountEnumNames(#__VA_ARGS__)}; \
-  [[maybe_unused]] static constexpr std::array<std::string_view, \
-      NAME##_enumSize> NAME##_names{ \
-      ::Fortran::common::EnumNames<NAME##_enumSize>(#__VA_ARGS__)}; \
   [[maybe_unused]] static inline std::size_t EnumToInt(NAME e) { \
     return static_cast<std::size_t>(e); \
   } \
   [[maybe_unused]] static inline std::string_view EnumToString(NAME e) { \
-    return NAME##_names[static_cast<std::size_t>(e)]; \
+    static const constexpr auto names{ \
+        ::Fortran::common::EnumNames<NAME##_enumSize>(#__VA_ARGS__)}; \
+    return names[static_cast<std::size_t>(e)]; \
   } \
   [[maybe_unused]] inline void ForEach##NAME(std::function<void(NAME)> f) { \
     for (std::size_t i{0}; i < NAME##_enumSize; ++i) { \


        


More information about the flang-commits mailing list