| 1 |
// { dg-do assemble } |
| 2 |
// Explicit { dg-require-effective-target exceptions_enabled } to avoid verify compiler messages FAILs for '-fno-exceptions'. |
| 3 |
|
| 4 |
// Copyright (C) 1999, 2000 Free Software Foundation, Inc. |
| 5 |
// Contributed by Nathan Sidwell 11 Apr 1999 <[email protected]> |
| 6 |
// Derived from bug report from Gabriel Dos Reis |
| 7 |
// <[email protected]> |
| 8 |
// http://gcc.gnu.org/ml/gcc-bugs/1999-03n/msg00888.html |
| 9 |
|
| 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 implement an extension, allowing one side to be void, check we |
| 13 |
// pedantically moan. |
| 14 |
|
| 15 |
struct X {}; |
| 16 |
void fn(int i) |
| 17 |
{ |
| 18 |
int j; |
| 19 |
|
| 20 |
j = (i ? throw X() : 1); // ok, int |
| 21 |
j = (i ? 1 : throw X()); // ok, int |
| 22 |
|
| 23 |
(i ? throw X() : throw X()); // ok, void |
| 24 |
|
| 25 |
(i ? i : j) = 1; // ok, int & |
| 26 |
(i ? throw X() : j) = 1; // ok, int & |
| 27 |
(i ? j : throw X()) = 1; // ok, int & |
| 28 |
(i ? throw X() : throw X()) = 1; // { dg-error "" } void |
| 29 |
|
| 30 |
(i ? (void)1 : i++); // { dg-error "" } ANSI forbids |
| 31 |
(i ? i++ : (void)1); // { dg-error "" } ANSI forbids |
| 32 |
} |