c-common.c (c_common_nodes_and_builtins): Add _Exit builtin.
authorJoseph Myers <jsm28@cam.ac.uk>
Sun, 7 Jan 2001 11:26:15 +0000 (11:26 +0000)
committerJoseph Myers <jsm28@gcc.gnu.org>
Sun, 7 Jan 2001 11:26:15 +0000 (11:26 +0000)
* c-common.c (c_common_nodes_and_builtins): Add _Exit builtin.
* extend.texi: Document _Exit builtin.

testsuite:
* gcc.c-torture/execute/builtin-noret-1.c: New test.

From-SVN: r38771

gcc/ChangeLog
gcc/c-common.c
gcc/extend.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/builtin-noret-1.c [new file with mode: 0644]

index 0f68b9033b49c9bd398097350a09ea5fa136885f..2aa50d0edecb4d1a7a03837328c69034ed2e2633 100644 (file)
@@ -1,3 +1,8 @@
+2001-01-07  Joseph S. Myers  <jsm28@cam.ac.uk>
+
+       * c-common.c (c_common_nodes_and_builtins): Add _Exit builtin.
+       * extend.texi: Document _Exit builtin.
+
 2001-01-07  Neil Booth  <neil@daikokuya.demon.co.uk>
 
         * (initialize, initialize_builtins,
index 1e36874190cbd6a96bcede7cd76f934055511873..3a76510428e7d60790d0308bb01118cb41aa5f6e 100644 (file)
@@ -5558,9 +5558,11 @@ c_common_nodes_and_builtins ()
   builtin_function_2 (NULL_PTR, "alloca", NULL_TREE, ptr_ftype_sizetype,
                      BUILT_IN_ALLOCA, BUILT_IN_NORMAL, 0, 1, 0);
 #endif
-  /* Declare _exit just to mark it as non-returning.  */
+  /* Declare _exit and _Exit just to mark them as non-returning.  */
   builtin_function_2 (NULL_PTR, "_exit", NULL_TREE, void_ftype_int,
                      0, NOT_BUILT_IN, 0, 1, 1);
+  builtin_function_2 (NULL_PTR, "_Exit", NULL_TREE, void_ftype_int,
+                     0, NOT_BUILT_IN, 0, !flag_isoc99, 1);
 
   builtin_function_2 ("__builtin_index", "index",
                      string_ftype_cstring_int, string_ftype_cstring_int,
index 5778a9bde1b46ff92fd48d090dbea6a33e60af66..e893c67f15c43f64c08ceb8627a9e0652a06351a 100644 (file)
@@ -3371,6 +3371,7 @@ function as well.
 @findex creall
 @findex exit
 @findex _exit
+@findex _Exit
 @findex fabs
 @findex fabsf
 @findex fabsl
@@ -3421,10 +3422,11 @@ option.  Many of these functions are only optimized in certain cases; if
 not optimized in a particular case, a call to the library function will
 be emitted.
 
-The functions @code{abort}, @code{exit}, and @code{_exit} are recognized
-and presumed not to return, but otherwise are not built in.
-@code{_exit} is not recognized in strict ISO C mode (@samp{-ansi},
-@samp{-std=c89} or @samp{-std=c99}).
+The functions @code{abort}, @code{exit}, @code{_Exit} and @code{_exit}
+are recognized and presumed not to return, but otherwise are not built
+in.  @code{_exit} is not recognized in strict ISO C mode (@samp{-ansi},
+@samp{-std=c89} or @samp{-std=c99}).  @code{_Exit} is not recognized in
+strict C89 mode (@samp{-ansi} or @samp{-std=c89}).
 
 Outside strict ISO C mode, the functions @code{alloca}, @code{bcmp},
 @code{bzero}, @code{index}, @code{rindex} and @code{ffs} may be handled
index e24ff842f0474f4fb979b0007f025579db85d484..0626643f7e2badad56b326f491911373d33f29a4 100644 (file)
@@ -1,3 +1,7 @@
+2001-01-07  Joseph S. Myers  <jsm28@cam.ac.uk>
+
+       * gcc.c-torture/execute/builtin-noret-1.c: New test.
+
 2001-01-07  Joseph S. Myers  <jsm28@cam.ac.uk>
 
        * gcc.dg/format/format.h: New file.
diff --git a/gcc/testsuite/gcc.c-torture/execute/builtin-noret-1.c b/gcc/testsuite/gcc.c-torture/execute/builtin-noret-1.c
new file mode 100644 (file)
index 0000000..cfd7899
--- /dev/null
@@ -0,0 +1,86 @@
+/* Test for builtin noreturn attributes.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+
+extern void abort (void);
+extern void exit (int);
+#if 0 /* Doesn't work with prototype (bug?).  */
+extern void _exit (int);
+extern void _Exit (int);
+#endif
+
+extern void tabort (void);
+extern void texit (void);
+extern void t_exit (void);
+extern void t_Exit (void);
+
+extern void link_failure (void);
+
+int
+main (void)
+{
+  volatile int i = 0;
+  /* The real test here is that the program links.  */
+  if (i)
+    tabort ();
+  if (i)
+    texit ();
+  if (i)
+    t_exit ();
+  if (i)
+    t_Exit ();
+  exit (0);
+}
+
+void
+tabort (void)
+{
+  abort ();
+  link_failure ();
+}
+
+void
+texit (void)
+{
+  exit (1);
+  link_failure ();
+}
+
+void
+t_exit (void)
+{
+  _exit (1);
+  link_failure ();
+}
+
+/* Some non-Unix libcs might not have _exit.  This version should never
+   get called.  */
+static void
+_exit (int i)
+{
+  abort ();
+}
+
+void
+t_Exit (void)
+{
+  _Exit (1);
+  link_failure ();
+}
+
+/* Some libcs might not have _Exit.  This version should never get called.  */
+static void
+_Exit (int i)
+{
+  abort ();
+}
+
+/* When optimizing, no calls to link_failure should remain.  In any case,
+   link_failure should not be called.  */
+
+#ifndef __OPTIMIZE__
+void
+link_failure (void)
+{
+  abort ();
+}
+#endif