[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / SemaCXX / constexpr-default-arg.cpp
blob0cef4aa578af3ce638ecbd2b0a7f5bc3b36cbd8a
1 // RUN: %clang_cc1 -std=c++1y -S -o - -emit-llvm -verify %s
3 namespace default_arg_temporary {
5 constexpr bool equals(const float& arg = 1.0f) {
6 return arg == 1.0f;
9 constexpr const int &x(const int &p = 0) {
10 return p;
13 struct S {
14 constexpr S(const int &a = 0) {}
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] = {};
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(), "");
28 // Test that constant expression evaluation produces distinct lvalues for
29 // each call.
30 static_assert(&x() != &x(), "");
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}}