1 // RUN: %clang_cc1 -std=c++1y -S -o - -emit-llvm -verify %s
2
3 namespace default_arg_temporary {
4
equals(const float & arg=1.0f)5 constexpr bool equals(const float& arg = 1.0f) {
6 return arg == 1.0f;
7 }
8
x(const int & p=0)9 constexpr const int &x(const int &p = 0) {
10 return p;
11 }
12
13 struct S {
Sdefault_arg_temporary::S14 constexpr S(const int &a = 0) {}
15 };
16
test_default_arg2()17 void test_default_arg2() {
18 // This piece of code used to cause an assertion failure in
19 // CallStackFrame::createTemporary because the same MTE is used to initilize
20 // both elements of the array (see PR33140).
21 constexpr S s[2] = {};
22
23 // This piece of code used to cause an assertion failure in
24 // CallStackFrame::createTemporary because multiple CXXDefaultArgExpr share
25 // the same MTE (see PR33140).
26 static_assert(equals() && equals(), "");
27
28 // Test that constant expression evaluation produces distinct lvalues for
29 // each call.
30 static_assert(&x() != &x(), "");
31 }
32
33 // Check that multiple CXXDefaultInitExprs don't cause an assertion failure.
34 struct A { int &&r = 0; }; // expected-note 2{{default member initializer}}
35 struct B { A x, y; };
36 B b = {}; // expected-warning 2{{not supported}}
37
38 }
39