Skip to content

Commit a9cc80d

Browse files
joyeecheungnodejs-github-bot
authored andcommitted
deps: V8: cherry-pick 00508c374a45
Original commit message: Add V8_HAS_WARNING for portable warning checks GCC does not provide the function-like __has_warning macro. Invoking it in a compound preprocessor condition causes a preprocessing error even when __clang__ is false. Add V8_HAS_WARNING to v8config.h, following existing feature-detection helpers. Use it for warning guards in base/macros.h. Compilers without __has_warning now use the fallback value of zero. Change-Id: I41d10799fd6f73a8bacbd3648aa0bb792d6b80cd Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/8385383 Reviewed-by: Igor Sheludko <ishell@chromium.org> Commit-Queue: Igor Sheludko <ishell@chromium.org> Reviewed-by: Maksim Ivanov <emaxx@google.com> Cr-Commit-Position: refs/heads/main@{#109976} Refs: v8/v8@00508c3 Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com> PR-URL: #66537 Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent 801d1c7 commit a9cc80d

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

‎common.gypi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
# Reset this number to 0 on major V8 upgrades.
4646
# Increment by one for each non-official patch applied to deps/v8.
47-
'v8_embedder_string': '-node.7',
47+
'v8_embedder_string': '-node.8',
4848

4949
##### V8 defaults for Node.js #####
5050

‎deps/v8/include/v8config.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ path. Add it with -I<path> to the command line
354354
// V8_HAS_DECLSPEC_NOINLINE - __declspec(noinline) supported
355355
// V8_HAS_DECLSPEC_SELECTANY - __declspec(selectany) supported
356356
// V8_HAS___FORCEINLINE - __forceinline supported
357+
// V8_HAS_WARNING(WARNING) - whether WARNING is supported
357358
//
358359
// Note that testing for compilers and/or features must be done using #if
359360
// not #ifdef. For example, to test for Intel C++ Compiler, use:
@@ -367,6 +368,12 @@ path. Add it with -I<path> to the command line
367368
#define V8_HAS_CPP_ATTRIBUTE(FEATURE) 0
368369
#endif
369370

371+
#if defined(__has_warning)
372+
#define V8_HAS_WARNING(WARNING) __has_warning(WARNING)
373+
#else
374+
#define V8_HAS_WARNING(WARNING) 0
375+
#endif
376+
370377
#if defined(__clang__)
371378

372379
#if defined(__GNUC__) // Clang in gcc mode.

‎deps/v8/src/base/macros.h‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -668,20 +668,18 @@ static_assert(V8_ENABLE_SIMD128);
668668
#endif // defined(__clang__)
669669

670670
// Disable/enable -Wlifetime-safety warnings in code.
671-
#if defined(__clang__) && defined(__has_warning) && \
672-
__has_warning("-Wlifetime-safety")
671+
#if V8_HAS_WARNING("-Wlifetime-safety")
673672
#define START_IGNORE_LIFETIME_SAFETY_WARNINGS() \
674673
_Pragma("clang diagnostic push") \
675674
_Pragma("clang diagnostic ignored \"-Wlifetime-safety\"")
676675
#define END_IGNORE_LIFETIME_SAFETY_WARNINGS() _Pragma("clang diagnostic pop")
677676
#else
678677
#define START_IGNORE_LIFETIME_SAFETY_WARNINGS()
679678
#define END_IGNORE_LIFETIME_SAFETY_WARNINGS()
680-
#endif // defined(__clang__)
679+
#endif // V8_HAS_WARNING("-Wlifetime-safety")
681680

682681
// Disable/enable -Wreturn-stack-address warnings in code.
683-
#if defined(__clang__) && defined(__has_warning) && \
684-
__has_warning("-Wreturn-stack-address")
682+
#if V8_HAS_WARNING("-Wreturn-stack-address")
685683
#define START_IGNORE_RETURN_STACK_ADDRESS_WARNINGS() \
686684
_Pragma("clang diagnostic push") \
687685
_Pragma("clang diagnostic ignored \"-Wreturn-stack-address\"")
@@ -690,6 +688,6 @@ static_assert(V8_ENABLE_SIMD128);
690688
#else
691689
#define START_IGNORE_RETURN_STACK_ADDRESS_WARNINGS()
692690
#define END_IGNORE_RETURN_STACK_ADDRESS_WARNINGS()
693-
#endif // defined(__clang__)
691+
#endif // V8_HAS_WARNING("-Wreturn-stack-address")
694692

695693
#endif // V8_BASE_MACROS_H_

0 commit comments

Comments
 (0)