2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.eh / cond1.C
blob1b2de1d10e80d5733675965e2707ae6dd96c698a
1 // { dg-do assemble  }
3 // Copyright (C) 1999, 2000 Free Software Foundation, Inc.
4 // Contributed by Nathan Sidwell 11 Apr 1999 <nathan@acm.org>
5 // Derived from bug report from Gabriel Dos Reis
6 // <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
7 // http://gcc.gnu.org/ml/gcc-bugs/1999-03n/msg00888.html
9 // conditional exprs have some funny rules when one of the types is void.
10 // [expr.cond] 5.16, make sure we do the right things
11 // We implement an extension, allowing one side to be void, check we
12 // pedantically moan.
14 struct X {};
15 void fn(int i)
17   int j;
19   j = (i ? throw X() : 1); // ok, int
20   j = (i ? 1 : throw X()); // ok, int
21   
22   (i ? throw X() : throw X());  // ok, void
23   
24   (i ? i : j) = 1; // ok, int &
25   (i ? throw X() : j) = 1; // { dg-error "" } non-lvalue
26   (i ? j : throw X()) = 1; // { dg-error "" } non-lvalue
27   (i ? throw X() : throw X()) = 1;  // { dg-error "" } void
28   
29   (i ? (void)1 : i++); // { dg-error "" } ANSI forbids
30   (i ? i++ : (void)1); // { dg-error "" } ANSI forbids