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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [gnu99-const-expr-2.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: __builtin_choose_expr.  */
2
/* Origin: Joseph Myers <joseph@codesourcery.com> */
3
/* { dg-do compile } */
4
/* { dg-options "-std=gnu99 -pedantic-errors" } */
5
 
6
#include <limits.h>
7
 
8
int a, b, c;
9
 
10
void
11
f (void)
12
{
13
  /* __builtin_choose_expr acts exactly like the chosen argument for
14
     all constant expression purposes.  */
15
  enum e {
16
    E1 = __builtin_choose_expr (1, 1, ++b)
17
  };
18
  /* The first argument to __builtin_choose_expr must be an integer
19
     constant expression.  */
20
  a = __builtin_choose_expr ((void *)0, b, c); /* { dg-error "constant" } */
21
  a = __builtin_choose_expr (0 * (INT_MAX + 1), b, c); /* { dg-warning "integer overflow in expression" } */
22
  /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 21 } */
23
  a = __builtin_choose_expr (1 / 0, 0, 0); /* { dg-warning "division by zero" } */
24
  /* { dg-error "not a constant" "error" { target *-*-* } 23 } */
25
  a = __builtin_choose_expr ((1 ? 1 : a), b, c); /* { dg-error "constant" } */
26
}

powered by: WebSVN 2.1.0

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