diff options
author | Joseph Myers <jsm28@cam.ac.uk> | 2001-11-18 03:30:57 +0000 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2001-11-18 03:30:57 +0000 |
commit | 7d14c755ce793f99c3e833e7115d954cfbed175c (patch) | |
tree | 3bf2e6da7732b3b856461efc1c4fffe0eba2760d /gcc/testsuite | |
parent | 74a3070ffad610701440467a2bd0b6627a76e568 (diff) | |
download | gcc-7d14c755ce793f99c3e833e7115d954cfbed175c.zip gcc-7d14c755ce793f99c3e833e7115d954cfbed175c.tar.gz gcc-7d14c755ce793f99c3e833e7115d954cfbed175c.tar.bz2 |
c-common.c (struct disabled_builtin, [...]): New.
* c-common.c (struct disabled_builtin, disabled_builtins,
disable_builtin_function, builtin_function_disabled_p): New.
(builtin_function_2): Check for disabled built-in functions.
* c-common.h (disable_builtin_function): Declare.
* c-decl.c (c_decode_option): Handle -fno-builtin-FUNCTION.
* doc/invoke.texi: Document -fno-builtin-FUNCTION.
* doc/extend.texi: Mention -fno-builtin-FUNCTION.
testsuite:
* gcc.dg/no-builtin-1.c: New test.
From-SVN: r47133
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/no-builtin-1.c | 43 |
2 files changed, 47 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d79c9f6..154d9c5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2001-11-18 Joseph S. Myers <jsm28@cam.ac.uk> + + * gcc.dg/no-builtin-1.c: New test. + 2001-11-16 Jakub Jelinek <jakub@redhat.com> * gcc.c-torture/execute/20011115-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/no-builtin-1.c b/gcc/testsuite/gcc.dg/no-builtin-1.c new file mode 100644 index 0000000..4f392e8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/no-builtin-1.c @@ -0,0 +1,43 @@ +/* Test for -fno-builtin-FUNCTION. */ +/* Origin: Joseph Myers <jsm28@cam.ac.uk>. */ +/* { dg-do run } */ +/* { dg-options "-fno-builtin-abs" } */ + +/* GCC normally handles abs and labs as built-in functions even without + optimization. So test that with -fno-builtin-abs, labs is so handled + but abs isn't. */ + +int abs_called = 0; + +extern int abs (int); +extern long labs (long); +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + if (labs (0) != 0) + abort (); + if (abs (0) != 0) + abort (); + if (!abs_called) + abort (); + exit (0); +} + +/* The labs call above should have been optimized, but the abs call + shouldn't have been. */ + +static int +abs (int x) +{ /* { dg-warning "static" "static decl warning" } */ + abs_called = 1; + return (x < 0 ? -1 : x); +} + +static long +labs (long x) +{ + abort (); +} |