annotate gcc/testsuite/g++.old-deja/g++.other/cond5.C @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // { dg-do assemble }
kono
parents:
diff changeset
2 // { dg-options "-W -pedantic -ansi" }
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 // Copyright (C) 1999, 2000 Free Software Foundation, Inc.
kono
parents:
diff changeset
5 // Contributed by Nathan Sidwell 1 Sep 1999 <nathan@acm.org>
kono
parents:
diff changeset
6 // Derived from bug report from Gabriel Dos Reis
kono
parents:
diff changeset
7 // <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
kono
parents:
diff changeset
8 // http://gcc.gnu.org/ml/gcc-bugs/1999-03n/msg00888.html
kono
parents:
diff changeset
9
kono
parents:
diff changeset
10 // conditional exprs have some funny rules when one of the types is void.
kono
parents:
diff changeset
11 // [expr.cond] 5.16, make sure we do the right things
kono
parents:
diff changeset
12 // We have checks for mismatching enumerations, check we give them -- they had
kono
parents:
diff changeset
13 // got lost due to changes in add_builtin_candidate and subsequent changes.
kono
parents:
diff changeset
14
kono
parents:
diff changeset
15 struct X {};
kono
parents:
diff changeset
16 enum E1 {e1 = -1};
kono
parents:
diff changeset
17 enum E2 {e2 = -1};
kono
parents:
diff changeset
18 void f(int, ...);
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 void fn(int i)
kono
parents:
diff changeset
21 {
kono
parents:
diff changeset
22 double d;
kono
parents:
diff changeset
23 int j;
kono
parents:
diff changeset
24
kono
parents:
diff changeset
25 j = (i ? e1 : e2); // { dg-warning "mismatch" }
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
26 d = (i ? e1 : 1.0); // { dg-warning "non-enumerated" }
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
27 d = (i ? 1.0 : e2); // { dg-warning "non-enumerated" }
111
kono
parents:
diff changeset
28 E1 e = (i ? e1 : e1); // ok
kono
parents:
diff changeset
29 j = (i ? 1 : e2); // ok
kono
parents:
diff changeset
30 j = (i ? e1 : 1); // ok
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 j = (i ? throw X() : 1); // ok, int
kono
parents:
diff changeset
33 j = (i ? 1 : throw X()); // ok, int
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 (i ? throw X() : throw X()); // ok, void
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 (i ? i : j) = 1; // ok, int &
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
38 (i ? throw X() : j) = 1; // ok, int &
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
39 (i ? j : throw X()) = 1; // ok, int &
111
kono
parents:
diff changeset
40 (i ? throw X() : throw X()) = 1; // { dg-error "lvalue" }
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 (i ? (void)1 : i++); // { dg-error "throw-expression" }
kono
parents:
diff changeset
43 (i ? i++ : (void)1); // { dg-error "throw-expression" }
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 }