summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/builtins/abs-1-lib.c
blob: 57446b263c9d1ab4e1de00711c350a9cb648c6c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
extern void abort (void);
extern int abs_called;
extern int inside_main;

/* The labs call should have been optimized, but the abs call
   shouldn't have been.  */

int
abs (int x)
{
  if (inside_main)
    abs_called = 1;
  return (x < 0 ? -x : x);
}

long
labs (long x)
{
  if (inside_main)
    abort ();
  return (x < 0 ? -x : x);
}