Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.other/cond5.C

raw
1 // { dg-do assemble }
2 // Explicit { dg-require-effective-target exceptions_enabled } to avoid verify compiler messages FAILs for '-fno-exceptions'.
3 // { dg-options "-W -pedantic -ansi" }
4
5 // Copyright (C) 1999, 2000 Free Software Foundation, Inc.
6 // Contributed by Nathan Sidwell 1 Sep 1999 <[email protected]>
7 // Derived from bug report from Gabriel Dos Reis
8 // <[email protected]>
9 // http://gcc.gnu.org/ml/gcc-bugs/1999-03n/msg00888.html
10
11 // conditional exprs have some funny rules when one of the types is void.
12 // [expr.cond] 5.16, make sure we do the right things
13 // We have checks for mismatching enumerations, check we give them -- they had
14 // got lost due to changes in add_builtin_candidate and subsequent changes.
15
16 struct X {};
17 enum E1 {e1 = -1};
18 enum E2 {e2 = -1};
19 void f(int, ...);
20
21 void fn(int i)
22 {
23 double d;
24 int j;
25
26 j = (i ? e1 : e2); // { dg-warning "mismatch" }
27 d = (i ? e1 : 1.0); // { dg-warning "non-enumerated" }
28 d = (i ? 1.0 : e2); // { dg-warning "non-enumerated" }
29 E1 e = (i ? e1 : e1); // ok
30 j = (i ? 1 : e2); // ok
31 j = (i ? e1 : 1); // ok
32
33 j = (i ? throw X() : 1); // ok, int
34 j = (i ? 1 : throw X()); // ok, int
35
36 (i ? throw X() : throw X()); // ok, void
37
38 (i ? i : j) = 1; // ok, int &
39 (i ? throw X() : j) = 1; // ok, int &
40 (i ? j : throw X()) = 1; // ok, int &
41 (i ? throw X() : throw X()) = 1; // { dg-error "lvalue" }
42
43 (i ? (void)1 : i++); // { dg-error "throw-expression" }
44 (i ? i++ : (void)1); // { dg-error "throw-expression" }
45
46 }