xref: /minix3/external/bsd/llvm/dist/clang/test/CXX/expr/p9.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc // expected-no-diagnostics
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc // floating-point overloads
5*f4a2713aSLionel Sambuc 
6*f4a2713aSLionel Sambuc __typeof__(0 + 0.0L) ld0;
7*f4a2713aSLionel Sambuc long double &ldr = ld0;
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc __typeof__(0 + 0.0) d0;
10*f4a2713aSLionel Sambuc double &dr = d0;
11*f4a2713aSLionel Sambuc 
12*f4a2713aSLionel Sambuc __typeof__(0 + 0.0f) f0;
13*f4a2713aSLionel Sambuc float &fr = f0;
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc // integral promotions
16*f4a2713aSLionel Sambuc 
17*f4a2713aSLionel Sambuc signed char c0;
18*f4a2713aSLionel Sambuc __typeof__(c0 + c0) c1;
19*f4a2713aSLionel Sambuc int &cr = c1;
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc unsigned char uc0;
22*f4a2713aSLionel Sambuc __typeof__(uc0 + uc0) uc1;
23*f4a2713aSLionel Sambuc int &ucr = uc1;
24*f4a2713aSLionel Sambuc 
25*f4a2713aSLionel Sambuc short s0;
26*f4a2713aSLionel Sambuc __typeof__(s0 + s0) s1;
27*f4a2713aSLionel Sambuc int &sr = s1;
28*f4a2713aSLionel Sambuc 
29*f4a2713aSLionel Sambuc unsigned short us0;
30*f4a2713aSLionel Sambuc __typeof__(us0 + us0) us1;
31*f4a2713aSLionel Sambuc int &usr = us1;
32*f4a2713aSLionel Sambuc 
33*f4a2713aSLionel Sambuc // integral overloads
34*f4a2713aSLionel Sambuc 
35*f4a2713aSLionel Sambuc __typeof__(0 + 0UL) ul0;
36*f4a2713aSLionel Sambuc unsigned long &ulr = ul0;
37*f4a2713aSLionel Sambuc 
38*f4a2713aSLionel Sambuc template<bool T> struct selector;
39*f4a2713aSLionel Sambuc template<> struct selector<true> { typedef long type; };
40*f4a2713aSLionel Sambuc template<> struct selector<false> {typedef unsigned long type; };
41*f4a2713aSLionel Sambuc __typeof__(0U + 0L) ui_l0;
42*f4a2713aSLionel Sambuc selector<(sizeof(long) > sizeof(unsigned int))>::type &ui_lr = ui_l0;
43*f4a2713aSLionel Sambuc 
44*f4a2713aSLionel Sambuc __typeof__(0 + 0L) l0;
45*f4a2713aSLionel Sambuc long &lr = l0;
46*f4a2713aSLionel Sambuc 
47*f4a2713aSLionel Sambuc __typeof__(0 + 0U) u0;
48*f4a2713aSLionel Sambuc unsigned &ur = u0;
49*f4a2713aSLionel Sambuc 
50*f4a2713aSLionel Sambuc __typeof__(0 + 0) i0;
51*f4a2713aSLionel Sambuc int &ir = i0;
52