brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 901123b Raw
40 lines · cpp
1// RUN: %clang_cc1 -std=c++1y -o - -emit-llvm -verify %s2// RUN: %clang_cc1 -std=c++1y -fexperimental-new-constant-interpreter -o - -emit-llvm -verify %s3 4namespace default_arg_temporary {5 6constexpr bool equals(const float& arg = 1.0f) {7  return arg == 1.0f;8}9 10constexpr const int &x(const int &p = 0) {11  return p;12}13 14struct S {15  constexpr S(const int &a = 0) {}16};17 18void test_default_arg2() {19  // This piece of code used to cause an assertion failure in20  // CallStackFrame::createTemporary because the same MTE is used to initilize21  // both elements of the array (see PR33140).22  constexpr S s[2] = {};23 24  // This piece of code used to cause an assertion failure in25  // CallStackFrame::createTemporary because multiple CXXDefaultArgExpr share26  // the same MTE (see PR33140).27  static_assert(equals() && equals(), "");28 29  // Test that constant expression evaluation produces distinct lvalues for30  // each call.31  static_assert(&x() != &x(), "");32}33 34// Check that multiple CXXDefaultInitExprs don't cause an assertion failure.35struct A { int &&r = 0; };36struct B { A x, y; };37B b = {}; // expected-no-diagnostics38 39}40