[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / cxx2a-user-defined-literals.cpp
blob12f672ff640a9d3f00027290d099d626e77afb57
1 // RUN: %clang_cc1 -std=c++2a %s -include %s -verify
3 #ifndef INCLUDED
4 #define INCLUDED
6 #pragma clang system_header
7 namespace std {
8 namespace chrono {
9 struct day{};
10 struct year{};
12 constexpr chrono::day operator"" d(unsigned long long d) noexcept;
13 constexpr chrono::year operator"" y(unsigned long long y) noexcept;
16 #else
18 using namespace std;
19 chrono::day dec_d = 5d;
20 chrono::day oct_d = 05d;
21 chrono::day bin_d = 0b011d;
22 // expected-error@+3{{no viable conversion from 'int' to 'chrono::day'}}
23 // expected-note@9{{candidate constructor (the implicit copy constructor)}}
24 // expected-note@9{{candidate constructor (the implicit move constructor)}}
25 chrono::day hex_d = 0x44d;
26 chrono::year y = 10y;
28 namespace ignore_class_udl_for_numeric_literals {
29 struct A { constexpr A(const char*) {} };
30 struct B { constexpr B(char); };
31 struct C { constexpr C(int); };
32 template<A> void operator""_a();
33 template<B> void operator""_b();
34 template<C> void operator""_c();
35 void test_class_udl_1() {
36 1_a; // expected-error {{no matching}}
37 1_b; // expected-error {{no matching}}
38 1_c; // expected-error {{no matching}}
39 "1"_a;
40 "1"_b; // expected-error {{no matching}}
41 "1"_c; // expected-error {{no matching}}
43 template<char...> void operator""_a();
44 template<char...> void operator""_b();
45 template<char...> void operator""_c();
46 void test_class_udl_2() {
47 1_a;
48 // FIXME: The standard appears to say these two are ambiguous!
49 1_b;
50 1_c;
51 "1"_a;
52 "1"_b; // expected-error {{no matching}}
53 "1"_c; // expected-error {{no matching}}
56 #endif