[flang-commits] [flang] [Flang] Add fallthrough annotations in visit.h (PR #90014)

Alexander Shaposhnikov via flang-commits flang-commits at lists.llvm.org
Wed Apr 24 20:51:07 PDT 2024


https://github.com/alexander-shaposhnikov created https://github.com/llvm/llvm-project/pull/90014

Add fallthrough annotations to avoid warnings if -Wimplicit-fallthrough is enabled.
Note, LLVM_FALLTHROUGH can't be  included into VISIT_CASE_N - it would cause a compile error for the last case.

Test plan: ninja check-all

>From 50f5ae0a5313ca2761325e52fb02914b80de4048 Mon Sep 17 00:00:00 2001
From: Alexander Shaposhnikov <ashaposhnikov at google.com>
Date: Thu, 25 Apr 2024 03:43:33 +0000
Subject: [PATCH] [Flang] Add fallthrough annotations in visit.h

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

diff --git a/flang/include/flang/Common/visit.h b/flang/include/flang/Common/visit.h
index 4d0897301e01db..7fe9ff839917c9 100644
--- a/flang/include/flang/Common/visit.h
+++ b/flang/include/flang/Common/visit.h
@@ -23,6 +23,7 @@
 
 #include "variant.h"
 #include "flang/Common/api-attrs.h"
+#include "llvm/Support/Compiler.h"
 #include <type_traits>
 
 namespace Fortran::common {
@@ -40,11 +41,17 @@ inline RT_API_ATTRS RESULT Log2VisitHelper(
       return visitor(std::get<(LOW + N)>(std::forward<VARIANT>(u))...); \
     }
       VISIT_CASE_N(1)
+      LLVM_FALLTHROUGH;
       VISIT_CASE_N(2)
+      LLVM_FALLTHROUGH;
       VISIT_CASE_N(3)
+      LLVM_FALLTHROUGH;
       VISIT_CASE_N(4)
+      LLVM_FALLTHROUGH;
       VISIT_CASE_N(5)
+      LLVM_FALLTHROUGH;
       VISIT_CASE_N(6)
+      LLVM_FALLTHROUGH;
       VISIT_CASE_N(7)
 #undef VISIT_CASE_N
     }



More information about the flang-commits mailing list