Skip to content

Commit

Permalink
Fix Wundef warnings for Support/Compiler.h
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
svenvh committed Nov 19, 2020
1 parent 7f4d88a commit 57e0007
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions llvm/include/llvm/Support/Compiler.h
Expand Up @@ -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]]
Expand Down Expand Up @@ -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]]
Expand Down

0 comments on commit 57e0007

Please sign in to comment.