[clang] 90a2e0b - [clang] Silence GCC warnings about control reaching end of non void function

Martin Storsjö via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 13 05:55:59 PDT 2024


Author: Martin Storsjö
Date: 2024-09-13T15:55:03+03:00
New Revision: 90a2e0bb423629b7e70f4b91adb44851199dd5ea

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

LOG: [clang] Silence GCC warnings about control reaching end of non void function

This fixes GCC warnings since
e7f782e7481cea23ef452a75607d3d61f5bd0d22.

Added: 
    

Modified: 
    clang/include/clang/Basic/DiagnosticIDs.h
    clang/lib/Sema/SemaOverload.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/DiagnosticIDs.h b/clang/include/clang/Basic/DiagnosticIDs.h
index 2402996ece5c94..daad66f499538f 100644
--- a/clang/include/clang/Basic/DiagnosticIDs.h
+++ b/clang/include/clang/Basic/DiagnosticIDs.h
@@ -18,6 +18,7 @@
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/ErrorHandling.h"
 #include <optional>
 #include <vector>
 
@@ -310,6 +311,7 @@ class DiagnosticIDs : public RefCountedBase<DiagnosticIDs> {
         return {diag::Severity::Fatal, std::string(Message), CLASS_ERROR,
                 /*ShowInSystemHeader*/ true};
       }
+      llvm_unreachable("Fully covered switch above!");
     }());
   }
 

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index d3e009a658f0e8..382630ed674107 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -7331,6 +7331,7 @@ static bool diagnoseDiagnoseIfAttrsWith(Sema &S, const NamedDecl *ND,
     case DiagnoseIfAttr::DS_error:
       return diag::Severity::Error;
     }
+    llvm_unreachable("Fully covered switch above!");
   };
 
   for (const auto *DIA : llvm::make_range(WarningBegin, Attrs.end()))


        


More information about the cfe-commits mailing list