annotate gcc/testsuite/gcc.dg/c99-const-expr-3.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Test for constant expressions: broken optimization with const variables. */
kono
parents:
diff changeset
2 /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
kono
parents:
diff changeset
3 /* { dg-do compile } */
kono
parents:
diff changeset
4 /* { dg-options "-std=iso9899:1999 -O2" } */
kono
parents:
diff changeset
5 /* Note: not using -pedantic since the -std option alone should be enough
kono
parents:
diff changeset
6 to give the correct behavior to conforming programs. */
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 static const int ZERO = 0;
kono
parents:
diff changeset
9 static const double DZERO = 0;
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 int *a;
kono
parents:
diff changeset
12 int b;
kono
parents:
diff changeset
13 long *c;
kono
parents:
diff changeset
14
kono
parents:
diff changeset
15 /* Assertion that n is a constant zero: so the conditional expression
kono
parents:
diff changeset
16 has type 'int *' instead of 'void *'.
kono
parents:
diff changeset
17 */
kono
parents:
diff changeset
18 #define ASSERT_NPC(n) (b = *(1 ? a : (n)))
kono
parents:
diff changeset
19 /* Assertion that n is not a constant zero: so the conditional
kono
parents:
diff changeset
20 expressions has type 'void *' instead of 'int *'.
kono
parents:
diff changeset
21 */
kono
parents:
diff changeset
22 #define ASSERT_NOT_NPC(n) (c = (1 ? a : (void *)(__SIZE_TYPE__)(n)))
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 void
kono
parents:
diff changeset
25 foo (void)
kono
parents:
diff changeset
26 {
kono
parents:
diff changeset
27 ASSERT_NPC (0);
kono
parents:
diff changeset
28 ASSERT_NOT_NPC (ZERO);
kono
parents:
diff changeset
29 ASSERT_NPC (0 + 0);
kono
parents:
diff changeset
30 ASSERT_NOT_NPC (ZERO + 0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
kono
parents:
diff changeset
31 ASSERT_NOT_NPC (ZERO + ZERO); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
kono
parents:
diff changeset
32 ASSERT_NPC (+0);
kono
parents:
diff changeset
33 ASSERT_NOT_NPC (+ZERO); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
kono
parents:
diff changeset
34 ASSERT_NPC (-0);
kono
parents:
diff changeset
35 ASSERT_NOT_NPC (-ZERO); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
kono
parents:
diff changeset
36 ASSERT_NPC ((char) 0);
kono
parents:
diff changeset
37 ASSERT_NOT_NPC ((char) ZERO);
kono
parents:
diff changeset
38 ASSERT_NPC ((int) 0);
kono
parents:
diff changeset
39 ASSERT_NOT_NPC ((int) ZERO);
kono
parents:
diff changeset
40 ASSERT_NPC ((int) 0.0);
kono
parents:
diff changeset
41 ASSERT_NOT_NPC ((int) DZERO);
kono
parents:
diff changeset
42 ASSERT_NOT_NPC ((int) +0.0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
kono
parents:
diff changeset
43 ASSERT_NOT_NPC ((int) (0.0+0.0)); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
kono
parents:
diff changeset
44 ASSERT_NOT_NPC ((int) (double)0.0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
kono
parents:
diff changeset
45 }