aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/cpp/builtin-macro-1.c
blob: 90c2883b4711aba63d5a23704f11a8b7669fbd25 (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
/* Origin PR preprocessor/64803

   This test ensures that the value the __LINE__ macro expands to is
   constant and corresponds to the line of the closing parenthesis of
   the top-most function-like macro expansion it's part of.

   { dg-do run }
   { do-options -no-integrated-cpp }  */

#include <assert.h>

#define C(a, b) a ## b
#define L(x) C(L, x)
#define M(a) int L(__LINE__) = __LINE__; assert(L(__LINE__) == __LINE__);

int
main()
{
  M(a
    );

  assert(L20 == 20);		/* 20 is the line number of the
				   closing parenthesis of the
				   invocation of the M macro.  Please
				   adjust in case the layout of this
				   file changes.  */
  return 0;
}