annotate gcc/testsuite/g++.dg/tree-ssa/pr20280.C @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // PR c++/20280
kono
parents:
diff changeset
2
kono
parents:
diff changeset
3 // { dg-do compile }
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 // Gimplification of the COND_EXPR used to fail because it had an
kono
parents:
diff changeset
6 // addressable type, and create_tmp_var rejected that.
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 struct A
kono
parents:
diff changeset
9 {
kono
parents:
diff changeset
10 ~A();
kono
parents:
diff changeset
11 };
kono
parents:
diff changeset
12
kono
parents:
diff changeset
13 struct B : A {};
kono
parents:
diff changeset
14
kono
parents:
diff changeset
15 A& foo();
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 void bar(bool b)
kono
parents:
diff changeset
18 {
kono
parents:
diff changeset
19 (B&) (b ? foo() : foo());
kono
parents:
diff changeset
20 }
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 // Make sure bit-fields and addressable types don't cause crashes.
kono
parents:
diff changeset
23 // These were not in the original bug report.
kono
parents:
diff changeset
24
kono
parents:
diff changeset
25 // Added by Alexandre Oliva <aoliva@redhat.com>
kono
parents:
diff changeset
26
kono
parents:
diff changeset
27 // Copyright 2005 Free Software Foundation
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 struct X
kono
parents:
diff changeset
30 {
kono
parents:
diff changeset
31 long i : 32, j, k : 32;
kono
parents:
diff changeset
32 };
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 void g(long&);
kono
parents:
diff changeset
35 void h(const long&);
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 void f(X &x, bool b)
kono
parents:
diff changeset
38 {
kono
parents:
diff changeset
39 (b ? x.i : x.j) = 1;
kono
parents:
diff changeset
40 (b ? x.j : x.k) = 2;
kono
parents:
diff changeset
41 (b ? x.i : x.k) = 3;
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 (void)(b ? x.i : x.j);
kono
parents:
diff changeset
44 (void)(b ? x.i : x.k);
kono
parents:
diff changeset
45 (void)(b ? x.j : x.k);
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 g (b ? x.i : x.j); // { dg-error "cannot bind bitfield" }
kono
parents:
diff changeset
48 g (b ? x.i : x.k); // { dg-error "cannot bind bitfield" }
kono
parents:
diff changeset
49 g (b ? x.j : x.k); // { dg-error "cannot bind bitfield" }
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 // It's not entirely clear whether these should be accepted. The
kono
parents:
diff changeset
52 // conditional expressions are lvalues for sure, and 8.5.3/5 exempts
kono
parents:
diff changeset
53 // lvalues for bit-fields, but it's not clear that conditional
kono
parents:
diff changeset
54 // expressions that are lvalues and that have at least one possible
kono
parents:
diff changeset
55 // result that is a bit-field lvalue meets this condition.
kono
parents:
diff changeset
56 h (b ? x.i : x.j);
kono
parents:
diff changeset
57 h (b ? x.i : x.k);
kono
parents:
diff changeset
58 h (b ? x.j : x.k);
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 (long &)(b ? x.i : x.j); // { dg-error "address of bit-field" }
kono
parents:
diff changeset
61 (long &)(b ? x.i : x.k); // { dg-error "address of bit-field" }
kono
parents:
diff changeset
62 (long &)(b ? x.j : x.k); // { dg-error "address of bit-field" }
kono
parents:
diff changeset
63 }