Reviewers: Benedikt Meurer,

Description:
Introduce a V8_NORETURN macro and use it to make GCC 4.9.2 happy again.

Without that, it has a few false positives about out-of-bounds array accesses.

Please review this at https://codereview.chromium.org/790723002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+20, -2 lines):
  M include/v8config.h
  M src/base/logging.h
  M src/base/platform/platform.h


Index: include/v8config.h
diff --git a/include/v8config.h b/include/v8config.h
index d1ca22c229708a1611e065c4dbe8be10d20504ad..38c7bae05fc932bd81ac3e3922573cb3dab68d85 100644
--- a/include/v8config.h
+++ b/include/v8config.h
@@ -167,6 +167,7 @@
 //                                        supported
// V8_HAS_ATTRIBUTE_DEPRECATED - __attribute__((deprecated)) supported // V8_HAS_ATTRIBUTE_NOINLINE - __attribute__((noinline)) supported +// V8_HAS_ATTRIBUTE_NORETURN - __attribute__((noreturn)) supported
 //  V8_HAS_ATTRIBUTE_UNUSED             - __attribute__((unused)) supported
// V8_HAS_ATTRIBUTE_VISIBILITY - __attribute__((visibility)) supported // V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT - __attribute__((warn_unused_result))
@@ -181,6 +182,7 @@
 //  V8_HAS_DECLSPEC_ALIGN               - __declspec(align(n)) supported
 //  V8_HAS_DECLSPEC_DEPRECATED          - __declspec(deprecated) supported
 //  V8_HAS_DECLSPEC_NOINLINE            - __declspec(noinline) supported
+//  V8_HAS_DECLSPEC_NORETURN            - __declspec(noreturn) supported
// V8_HAS___FINAL - __final supported in non-C++11 mode
 //  V8_HAS___FORCEINLINE                - __forceinline supported
 //
@@ -206,6 +208,7 @@
 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline))
 # define V8_HAS_ATTRIBUTE_DEPRECATED (__has_attribute(deprecated))
 # define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline))
+#define V8_HAS_ATTRIBUTE_NORETURN (__has_attribute(noreturn))
 # define V8_HAS_ATTRIBUTE_UNUSED (__has_attribute(unused))
 # define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility))
 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \
@@ -244,6 +247,7 @@
 # define V8_HAS_ATTRIBUTE_DEPRECATED (V8_GNUC_PREREQ(3, 4, 0))
 # define V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE (V8_GNUC_PREREQ(4, 5, 0))
 # define V8_HAS_ATTRIBUTE_NOINLINE (V8_GNUC_PREREQ(3, 4, 0))
+#define V8_HAS_ATTRIBUTE_NORETURN (V8_GNUC_PREREQ(2, 5, 0))
 # define V8_HAS_ATTRIBUTE_UNUSED (V8_GNUC_PREREQ(2, 95, 0))
 # define V8_HAS_ATTRIBUTE_VISIBILITY (V8_GNUC_PREREQ(4, 3, 0))
 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \
@@ -285,6 +289,7 @@
 # define V8_HAS_DECLSPEC_ALIGN 1
 # define V8_HAS_DECLSPEC_DEPRECATED 1
 # define V8_HAS_DECLSPEC_NOINLINE 1
+#define V8_HAS_DECLSPEC_NORETURN 1

 # define V8_HAS___FORCEINLINE 1

@@ -319,6 +324,18 @@
 #endif


+// A macro used to tell the compiler that a particular function never returns.
+// Use like:
+//   V8_NORETURN int MyAbort() { abort(); }
+#if V8_HAS_ATTRIBUTE_NORETURN
+#define V8_NORETURN __attribute__((noreturn))
+#elif HAS_DECLSPEC_NORETURN
+#define V8_NORETURN __declspec(noreturn)
+#else
+#define V8_NORETURN /* NOT SUPPORTED */
+#endif
+
+
 // A macro to mark classes or functions as deprecated.
 #if defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE
 # define V8_DEPRECATED(message, declarator) \
Index: src/base/logging.h
diff --git a/src/base/logging.h b/src/base/logging.h
index 83c1bb60136c1ec9d626c0230db452f3dbb2bf96..fb216b870ab1297ab01ea5bce3b8577b341e141e 100644
--- a/src/base/logging.h
+++ b/src/base/logging.h
@@ -10,7 +10,8 @@

 #include "src/base/build_config.h"

-extern "C" void V8_Fatal(const char* file, int line, const char* format, ...);
+extern "C" V8_NORETURN void V8_Fatal(const char* file, int line,
+                                     const char* format, ...);


 // The FATAL, UNREACHABLE and UNIMPLEMENTED macros are useful during
Index: src/base/platform/platform.h
diff --git a/src/base/platform/platform.h b/src/base/platform/platform.h
index 0bf102723acfd74d6d130e2a6f01ae5e1975d6e8..eebc4096dc54ac50dc5424505953635e0c8df8d3 100644
--- a/src/base/platform/platform.h
+++ b/src/base/platform/platform.h
@@ -192,7 +192,7 @@ class OS {
   static void Sleep(const int milliseconds);

   // Abort the current process.
-  static void Abort();
+  V8_NORETURN static void Abort();

   // Debug break.
   static void DebugBreak();


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to