OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [g++.dg/] [tree-ssa/] [pr20280.C] - Blame information for rev 338

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.