[llvm] 57e0007 - Fix Wundef warnings for Support/Compiler.h

Sven van Haastregt via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 19 06:12:42 PST 2020


Author: Sven van Haastregt
Date: 2020-11-19T14:10:55Z
New Revision: 57e0007546abd6c73c54249705f4fe42592fd179

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

LOG: Fix Wundef warnings for Support/Compiler.h

Support/Compiler.h is included by c files (e.g. regcomp.c) where
__cplusplus is not defined at all.  Avoid evaluating the undefined
macro for such files.

Added: 
    

Modified: 
    llvm/include/llvm/Support/Compiler.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
index 80ea76240d6c..d7001a5c289a 100644
--- a/llvm/include/llvm/Support/Compiler.h
+++ b/llvm/include/llvm/Support/Compiler.h
@@ -146,7 +146,7 @@
 /// LLVM_NODISCARD - Warn if a type or return value is discarded.
 
 // Use the 'nodiscard' attribute in C++17 or newer mode.
-#if __cplusplus > 201402L && LLVM_HAS_CPP_ATTRIBUTE(nodiscard)
+#if defined(__cplusplus) && __cplusplus > 201402L && LLVM_HAS_CPP_ATTRIBUTE(nodiscard)
 #define LLVM_NODISCARD [[nodiscard]]
 #elif LLVM_HAS_CPP_ATTRIBUTE(clang::warn_unused_result)
 #define LLVM_NODISCARD [[clang::warn_unused_result]]
@@ -268,7 +268,7 @@
 #endif
 
 /// LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
-#if __cplusplus > 201402L && LLVM_HAS_CPP_ATTRIBUTE(fallthrough)
+#if defined(__cplusplus) && __cplusplus > 201402L && LLVM_HAS_CPP_ATTRIBUTE(fallthrough)
 #define LLVM_FALLTHROUGH [[fallthrough]]
 #elif LLVM_HAS_CPP_ATTRIBUTE(gnu::fallthrough)
 #define LLVM_FALLTHROUGH [[gnu::fallthrough]]


        


More information about the llvm-commits mailing list