OSDN Git Service

* typeck2.c (abstract_virtual_errors): Reword diagnostics, make them
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.old-deja / g++.other / cond5.C
1 // { dg-do assemble  }
2 // { dg-options "-W -pedantic -ansi" }
3
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
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 have checks for mismatching enumerations, check we give them -- they had
13 // got lost due to changes in add_builtin_candidate and subsequent changes.
14
15 struct X {};
16 enum E1 {e1 = -1};
17 enum E2 {e2 = -1};
18 void f(int, ...);
19
20 void fn(int i)
21 {
22   double d;
23   int j;
24
25   j = (i ? e1 : e2);    // { dg-warning "" } mismatch
26   d = (i ? e1 : 1.0);   // { dg-warning "" } mismatch
27   d = (i ? 1.0 : e2);   // { dg-warning "" } mismatch
28   E1 e = (i ? e1 : e1); // ok
29   j = (i ? 1 : e2);     // ok
30   j = (i ? e1 : 1);     // ok
31   
32   j = (i ? throw X() : 1); // ok, int
33   j = (i ? 1 : throw X()); // ok, int
34   
35   (i ? throw X() : throw X());  // ok, void
36   
37   (i ? i : j) = 1; // ok, int &
38   (i ? throw X() : j) = 1;    // { dg-error "" } non lvalue
39   (i ? j : throw X()) = 1;    // { dg-error "" } non lvalue
40   (i ? throw X() : throw X()) = 1;  // { dg-error "" } invalid use of void
41   
42   (i ? (void)1 : i++);        // { dg-warning "" } not a throw
43   (i ? i++ : (void)1);        // { dg-warning "" } not a throw
44   
45 }