summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/cpp/mac-dir-1.c
blob: 002c47f5f2bf05c66c9f3da3fca2799ef7b65985 (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
32
33
34
/* Copyright (C) 2002 Free Software Foundation, Inc.  */

/* { dg-do preprocess } */

/* Source: Neil Booth, 26 Feb 2002.

   Test that we allow directives in macro arguments.  */

/* { dg-do run } */
/* { dg-options "" } */

#define f(x) x
extern void abort (void);

int main ()
{
  if (f (
#if f(1)			/* True.  */
	0))			/* False. */
#else
    	1))
#endif
     abort ();

     /* Outer f expands to original definition, f in argument expands
	to new definition, so result is: if (1 != 2 - 1).  */
     if (1 != f(2
#undef f
#define f - 1
     f))
     abort ();

     return 0;
}