From 796cdb659f4c0f015e92c41b3fcf3ff1ad7c3f88 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Sun, 7 Jan 2001 11:26:15 +0000 Subject: [PATCH] c-common.c (c_common_nodes_and_builtins): Add _Exit builtin. * 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 | 5 ++ gcc/c-common.c | 4 +- gcc/extend.texi | 10 ++- gcc/testsuite/ChangeLog | 4 + .../gcc.c-torture/execute/builtin-noret-1.c | 86 +++++++++++++++++++ 5 files changed, 104 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/builtin-noret-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0f68b9033b4..2aa50d0edec 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2001-01-07 Joseph S. Myers + + * c-common.c (c_common_nodes_and_builtins): Add _Exit builtin. + * extend.texi: Document _Exit builtin. + 2001-01-07 Neil Booth * (initialize, initialize_builtins, diff --git a/gcc/c-common.c b/gcc/c-common.c index 1e36874190c..3a76510428e 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -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, diff --git a/gcc/extend.texi b/gcc/extend.texi index 5778a9bde1b..e893c67f15c 100644 --- a/gcc/extend.texi +++ b/gcc/extend.texi @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e24ff842f04..0626643f7e2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2001-01-07 Joseph S. Myers + + * gcc.c-torture/execute/builtin-noret-1.c: New test. + 2001-01-07 Joseph S. Myers * 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 index 00000000000..cfd78991214 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/builtin-noret-1.c @@ -0,0 +1,86 @@ +/* Test for builtin noreturn attributes. */ +/* Origin: Joseph Myers */ + +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 -- 2.30.2