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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [cpp0x/] [initlist-lifetime1.C] - Blame information for rev 693

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// Test that we properly extend the lifetime of the initializer_list
2
// array even if the initializer_list is a subobject.
3
// { dg-options -std=c++0x }
4
// { dg-do run }
5
 
6
#include 
7
 
8
extern "C" void abort();
9
bool ok;
10
 
11
bool do_throw;
12
 
13
struct A {
14
  A(int) { if (do_throw) throw 42; }
15
  ~A() { if (!ok) abort(); }
16
};
17
 
18
typedef std::initializer_list AL;
19
typedef std::initializer_list AL2;
20
typedef std::initializer_list AL3;
21
 
22
struct B {
23
  AL al;
24
  const AL& alr;
25
};
26
 
27
int main(int argc, const char** argv)
28
{
29
  do_throw = (argc > 1);        // always false, but optimizer can't tell
30
  AL ar[] = {{1,2},{3,4}};
31
  B b = {{5,6},{7,8}};
32
  AL3 al3 = {{{1},{2},{3}}};
33
  ok = true;
34
}

powered by: WebSVN 2.1.0

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