2 // { dg-options "-W -pedantic -ansi" }
4 // Copyright (C) 1999, 2000 Free Software Foundation, Inc.
5 // Contributed by Nathan Sidwell 1 Sep 1999 <nathan@acm.org>
6 // Derived from bug report from Gabriel Dos Reis
7 // <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
8 // http://gcc.gnu.org/ml/gcc-bugs/1999-03n/msg00888.html
10 // conditional exprs have some funny rules when one of the types is void.
11 // [expr.cond] 5.16, make sure we do the right things
12 // We have checks for mismatching enumerations, check we give them -- they had
13 // got lost due to changes in add_builtin_candidate and subsequent changes.
25 j = (i ? e1 : e2); // { dg-warning "mismatch" }
26 d = (i ? e1 : 1.0); // { dg-warning "non-enumeral" }
27 d = (i ? 1.0 : e2); // { dg-warning "non-enumeral" }
28 E1 e = (i ? e1 : e1); // ok
29 j = (i ? 1 : e2); // ok
30 j = (i ? e1 : 1); // ok
32 j = (i ? throw X() : 1); // ok, int
33 j = (i ? 1 : throw X()); // ok, int
35 (i ? throw X() : throw X()); // ok, void
37 (i ? i : j) = 1; // ok, int &
38 (i ? throw X() : j) = 1; // { dg-error "lvalue" }
39 (i ? j : throw X()) = 1; // { dg-error "lvalue" }
40 (i ? throw X() : throw X()) = 1; // { dg-error "lvalue" }
42 (i ? (void)1 : i++); // { dg-error "throw-expression" }
43 (i ? i++ : (void)1); // { dg-error "throw-expression" }