OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [c90-const-expr-3.c] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* Test for constant expressions: broken optimization with const variables.  */
2
/* Reference: ISO 9989:1990 6.5.15 */
3
/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
4
/* { dg-do compile } */
5
/* { dg-options "-std=iso9899:1990 -O2" } */
6
/* Note: not using -pedantic since the -std option alone should be enough
7
   to give the correct behavior to conforming programs.  */
8
 
9
static const int ZERO = 0;
10
static const double DZERO = 0;
11
 
12
int *a;
13
int b;
14
long *c;
15
 
16
/* Assertion that n is a constant zero: so the conditional expression
17
   has type 'int *' instead of 'void *'.
18
*/
19
#define ASSERT_NPC(n)   (b = *(1 ? a : (n)))
20
/* Assertion that n is not a constant zero: so the conditional
21
   expressions has type 'void *' instead of 'int *'.
22
*/
23
#define ASSERT_NOT_NPC(n)       (c = (1 ? a : (void *)(__SIZE_TYPE__)(n)))
24
 
25
void
26
foo (void)
27
{
28
  ASSERT_NPC (0);
29
  ASSERT_NOT_NPC (ZERO);
30
  ASSERT_NPC (0 + 0);
31
  ASSERT_NOT_NPC (ZERO + 0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
32
  ASSERT_NOT_NPC (ZERO + ZERO); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
33
  ASSERT_NPC (+0);
34
  ASSERT_NOT_NPC (+ZERO); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
35
  ASSERT_NPC (-0);
36
  ASSERT_NOT_NPC (-ZERO); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
37
  ASSERT_NPC ((char) 0);
38
  ASSERT_NOT_NPC ((char) ZERO);
39
  ASSERT_NPC ((int) 0);
40
  ASSERT_NOT_NPC ((int) ZERO);
41
  ASSERT_NPC ((int) 0.0);
42
  ASSERT_NOT_NPC ((int) DZERO);
43
  ASSERT_NOT_NPC ((int) +0.0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
44
  ASSERT_NOT_NPC ((int) (0.0+0.0)); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
45
  ASSERT_NOT_NPC ((int) (double)0.0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
46
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.