aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/torture/builtin-location.C
blob: cad53de4b485c2a2ac09a746f96155dd0be92eb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// { dg-do run }

#include <cstring>

const char *gfile;
const char *gfn;
int gline;

void bar (const char *file = __builtin_FILE (),
	  const char *function = __builtin_FUNCTION (),
	  int line = __builtin_LINE ())
{
  gfile = file;
  gfn = function;
  gline = line;
}

extern "C" void abort (void);

int main()
{
  int here;
  bar (); here = __LINE__;
  if (std::strcmp (gfn, __FUNCTION__) != 0)
    abort ();
  if (std::strcmp (gfile, __FILE__) != 0)
    abort ();
  if (gline != here)
    abort ();
  return 0;
}