1 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin -emit-llvm -o - %s -std=c++1y | FileCheck %s
2 // expected-no-diagnostics
3 
4 struct A {
5   constexpr A() : n(1) {}
6   ~A();
7   int n;
8 };
9 struct B : A {
10   A a[3];
11   constexpr B() {
12     ++a[0].n;
13     a[1].n += 2;
14     a[2].n = n + a[1].n;
15   }
16 };
17 B b;
18 
19 // CHECK: @b = global {{.*}} i32 1, {{.*}} { i32 2 }, {{.*}} { i32 3 }, {{.*}} { i32 4 }
20 // CHECK-NOT: _ZN1BC
21 
22 namespace ModifyStaticTemporary {
23   struct A { int &&temporary; int x; };
24   constexpr int f(int &r) { r *= 9; return r - 12; }
25   A a = { 6, f(a.temporary) };
26   // CHECK: @_ZGRN21ModifyStaticTemporary1aE = private global i32 54
27   // CHECK: @_ZN21ModifyStaticTemporary1aE = global {{.*}} i32* @_ZGRN21ModifyStaticTemporary1aE, i32 42
28 
29   A b = { 7, ++b.temporary };
30   // CHECK: @_ZGRN21ModifyStaticTemporary1bE = private global i32 8
31   // CHECK: @_ZN21ModifyStaticTemporary1bE = global {{.*}} i32* @_ZGRN21ModifyStaticTemporary1bE, i32 8
32 
33   // Can't emit all of 'c' as a constant here, so emit the initial value of
34   // 'c.temporary', not the value as modified by the partial evaluation within
35   // the initialization of 'c.x'.
36   A c = { 10, (++c.temporary, b.x) };
37   // CHECK: @_ZGRN21ModifyStaticTemporary1cE = private global i32 10
38   // CHECK: @_ZN21ModifyStaticTemporary1cE = global {{.*}} zeroinitializer
39 }
40 
41 // CHECK: __cxa_atexit({{.*}} @_ZN1BD1Ev {{.*}} @b
42 
43 // CHECK: define
44 // CHECK-NOT: @_ZGRN21ModifyStaticTemporary1cE
45 // CHECK: store {{.*}} @_ZGRN21ModifyStaticTemporary1cE, {{.*}} @_ZN21ModifyStaticTemporary1cE
46 // CHECK: add
47 // CHECK: store
48 // CHECK: load {{.*}} @_ZN21ModifyStaticTemporary1bE
49 // CHECK: store {{.*}} @_ZN21ModifyStaticTemporary1cE
50