]> gcc.gnu.org Git - gcc.git/blob - gcc/testsuite/gcc.dg/c99-const-expr-2.c
c-common.c (scanf_flag_specs): Add flags ' and I.
[gcc.git] / gcc / testsuite / gcc.dg / c99-const-expr-2.c
1 /* Test for constant expressions: details of what is a null pointer
2 constant.
3 */
4 /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
5 /* { dg-do compile } */
6 /* { dg-options "-std=iso9899:1999" } */
7 /* Note: not using -pedantic since the -std option alone should be enough
8 to give the correct behavior to conforming programs. If -pedantic is
9 needed to make (say) (0, 0) not be a constant expression, this is a
10 bug.
11 */
12
13 int *a;
14 int b;
15 long *c;
16
17 /* Assertion that n is a null pointer constant: so the conditional expression
18 has type 'int *' instead of 'void *'.
19 */
20 #define ASSERT_NPC(n) (b = *(1 ? a : (n)))
21 /* Assertion that n is not a null pointer constant: so the conditional
22 expresions has type 'void *' instead of 'int *'.
23 */
24 #define ASSERT_NOT_NPC(n) (c = (1 ? a : (n)))
25
26 void
27 foo (void)
28 {
29 ASSERT_NPC (0);
30 ASSERT_NPC ((void *)0);
31 ASSERT_NOT_NPC ((void *)(void *)0); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */
32 ASSERT_NOT_NPC ((void *)(char *)0); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */
33 ASSERT_NOT_NPC ((void *)(0, 0)); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */
34 /* This last one is a null pointer constant in C99 only. */
35 ASSERT_NPC ((void *)(1 ? 0 : (0, 0)));
36 }
This page took 0.036746 seconds and 5 git commands to generate.