[flang-commits] [flang] fix: split ifndef for CHECK and CHECK_MSG (PR #114707)

Ivan Aksamentov via flang-commits flang-commits at lists.llvm.org
Sun Nov 3 06:04:17 PST 2024


https://github.com/ivan-aksamentov created https://github.com/llvm/llvm-project/pull/114707

Resolves https://github.com/llvm/llvm-project/issues/114703

I think it's the best practice that each macro has it's own `ifndef` check and it resolved the build issue for me.

I also find the names of these macro a bit too generic - an easy recipe for conflicts. In my case, the error was likely caused by something else defining `CHECK` but not `CHECK_MSG`, so likely these `CHECK` and `CHECK_MSG` weren't actually working at all because the result of `ifndef` is always false. AS a definitive fix, perhaps it makes sense to rename them to something more specific, e.g. `FLANG_CHECK` and `FLANG_CHECK_MSG`.


>From 6b13be8bd7c5bbd04220da90304d48a0a3d8dcb1 Mon Sep 17 00:00:00 2001
From: ivan-aksamentov <ivan.aksamentov at gmail.com>
Date: Sun, 3 Nov 2024 14:57:50 +0100
Subject: [PATCH] fix: split ifndef for CHECK and CHECK_MSG

---
 flang/include/flang/Common/idioms.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/flang/include/flang/Common/idioms.h b/flang/include/flang/Common/idioms.h
index 99f383ec75b999..06631bcf2e4450 100644
--- a/flang/include/flang/Common/idioms.h
+++ b/flang/include/flang/Common/idioms.h
@@ -87,7 +87,10 @@ template <typename... LAMBDAS> visitors(LAMBDAS... x) -> visitors<LAMBDAS...>;
 // To disable, compile with '-DCHECK=(void)'
 #ifndef CHECK
 #define CHECK(x) ((x) || (DIE("CHECK(" #x ") failed"), false))
+#endif
+
 // Same as above, but with a custom error message.
+#ifndef CHECK_MSG
 #define CHECK_MSG(x, y) ((x) || (DIE("CHECK(" #x ") failed: " #y), false))
 #endif
 



More information about the flang-commits mailing list