57 lines · cpp
1// RUN: %clang_cc1 -std=c++2a %s -include %s -verify2 3#ifndef INCLUDED4#define INCLUDED5 6#pragma clang system_header7namespace std {8 namespace chrono {9 struct day{};10 struct year{};11 }12 constexpr chrono::day operator"" d(unsigned long long d) noexcept;13 constexpr chrono::year operator"" y(unsigned long long y) noexcept;14}15 16#else17 18using namespace std;19chrono::day dec_d = 5d;20chrono::day oct_d = 05d;21chrono::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)}}25chrono::day hex_d = 0x44d;26chrono::year y = 10y;27 28namespace 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}}42 }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}}54 }55}56#endif57