xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/cxx1y-user-defined-literals.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c++1y %s -include %s -verify
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc #ifndef INCLUDED
4*f4a2713aSLionel Sambuc #define INCLUDED
5*f4a2713aSLionel Sambuc 
6*f4a2713aSLionel Sambuc #pragma clang system_header
7*f4a2713aSLionel Sambuc namespace std {
8*f4a2713aSLionel Sambuc   using size_t = decltype(sizeof(0));
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc   struct duration {};
11*f4a2713aSLionel Sambuc   duration operator""ns(unsigned long long);
12*f4a2713aSLionel Sambuc   duration operator""us(unsigned long long);
13*f4a2713aSLionel Sambuc   duration operator""ms(unsigned long long);
14*f4a2713aSLionel Sambuc   duration operator""s(unsigned long long);
15*f4a2713aSLionel Sambuc   duration operator""min(unsigned long long);
16*f4a2713aSLionel Sambuc   duration operator""h(unsigned long long);
17*f4a2713aSLionel Sambuc 
18*f4a2713aSLionel Sambuc   struct string {};
19*f4a2713aSLionel Sambuc   string operator""s(const char*, size_t);
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc   template<typename T> struct complex {};
22*f4a2713aSLionel Sambuc   complex<float> operator""if(long double);
23*f4a2713aSLionel Sambuc   complex<float> operator""if(unsigned long long);
24*f4a2713aSLionel Sambuc   complex<double> operator""i(long double);
25*f4a2713aSLionel Sambuc   complex<double> operator""i(unsigned long long);
26*f4a2713aSLionel Sambuc   complex<long double> operator""il(long double);
27*f4a2713aSLionel Sambuc   complex<long double> operator""il(unsigned long long);
28*f4a2713aSLionel Sambuc }
29*f4a2713aSLionel Sambuc 
30*f4a2713aSLionel Sambuc #else
31*f4a2713aSLionel Sambuc 
32*f4a2713aSLionel Sambuc using namespace std;
33*f4a2713aSLionel Sambuc duration a = 1ns, b = 1us, c = 1ms, d = 1s, e = 1min, f = 1h;
34*f4a2713aSLionel Sambuc string s = "foo"s;
35*f4a2713aSLionel Sambuc char error = 'x's; // expected-error {{invalid suffix}} expected-error {{expected ';'}}
36*f4a2713aSLionel Sambuc 
37*f4a2713aSLionel Sambuc int _1z = 1z; // expected-error {{invalid suffix}}
38*f4a2713aSLionel Sambuc int _1b = 1b; // expected-error {{invalid digit}}
39*f4a2713aSLionel Sambuc 
40*f4a2713aSLionel Sambuc complex<float> cf1 = 1if, cf2 = 2.if, cf3 = 0x3if;
41*f4a2713aSLionel Sambuc complex<double> cd1 = 1i, cd2 = 2.i, cd3 = 0b0110101i;
42*f4a2713aSLionel Sambuc complex<long double> cld1 = 1il, cld2 = 2.il, cld3 = 0047il;
43*f4a2713aSLionel Sambuc 
44*f4a2713aSLionel Sambuc #endif
45