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