template<int Bounds>
struct HasExtInt {
_BitInt(Bounds) b;
unsigned _BitInt(Bounds) b2;
};
_BitInt(33) Declarations(_BitInt(48) &Param) { short _BitInt(43) a; _BitInt(43) long b;
const _BitInt(5) c = 3;
const unsigned _BitInt(5) d; unsigned _BitInt(5) e = 5;
_BitInt(5) unsigned f;
_BitInt(-3) g; _BitInt(0) h; _BitInt(1) i; _BitInt(2) j;;
unsigned _BitInt(0) k; unsigned _BitInt(1) l;
signed _BitInt(1) m;
constexpr _BitInt(6) n = 33; constexpr _BitInt(7) o = 33;
_BitInt(129) p; unsigned _BitInt(0xFFFFFFFFFF) q;
HasExtInt<-1> r;
HasExtInt<0> s;
HasExtInt<1> t;
HasExtInt<2> u;
_BitInt(-3.0) v; _BitInt(3.0) x;
return 0;
}
template <_BitInt(5) I>
struct ExtIntTemplParam {
static constexpr _BitInt(5) Var = I;
};
template<typename T>
void deduced_whole_type(T){}
template<int I>
void deduced_bound(_BitInt(I)){}
void Templates() {
ExtIntTemplParam<13> a;
constexpr _BitInt(3) b = 1;
ExtIntTemplParam<b> c;
constexpr _BitInt(9) d = 1;
ExtIntTemplParam<b> e;
deduced_whole_type(b);
deduced_bound(b);
}
template <typename T, typename U>
struct is_same {
static constexpr bool value = false;
};
template <typename T>
struct is_same<T,T> {
static constexpr bool value = true;
};
typedef _BitInt(32) __attribute__((vector_size(16))) VecTy;
_Complex _BitInt(3) Cmplx;
_Atomic _BitInt(4) TooSmallAtomic;
_Atomic _BitInt(9) NotPow2Atomic;
_Atomic _BitInt(128) JustRightAtomic;
void Ops() {
_BitInt(43) x43_s = 1, y43_s = 1;
_BitInt(sizeof(int) * 8) x32_s = 1, y32_s = 1;
unsigned _BitInt(sizeof(unsigned) * 8) x32_u = 1, y32_u = 1;
_BitInt(4) x4_s = 1, y4_s = 1;
unsigned _BitInt(43) x43_u = 1, y43_u = 1;
unsigned _BitInt(4) x4_u = 1, y4_u = 1;
int x_int = 1, y_int = 1;
unsigned x_uint = 1, y_uint = 1;
bool b;
x43_u + y43_s;
x4_s - y4_u;
x43_s * y43_u;
x4_u / y4_s;
x43_s + y4_s;
x43_s - y4_u;
x43_u * y4_u;
x4_u / y43_u;
x43_s + x_int;
x43_u - x_int;
x32_s * x_int;
x32_u / x_int;
x32_s * x_uint;
x32_u / x_uint;
x4_s + x_int;
x4_u - x_int;
x4_s + b;
x4_u - b;
x43_s + b;
x43_u - b;
static_assert(is_same<decltype(x43_s + x_int), _BitInt(43)>::value, "");
static_assert(is_same<decltype(x43_u + x_int), unsigned _BitInt(43)>::value, "");
static_assert(is_same<decltype(x32_s + x_int), int>::value, "");
static_assert(is_same<decltype(x32_u + x_int), unsigned int>::value, "");
static_assert(is_same<decltype(x32_s + x_uint), unsigned int>::value, "");
static_assert(is_same<decltype(x32_u + x_uint), unsigned int>::value, "");
static_assert(is_same<decltype(x4_s + x_int), int>::value, "");
static_assert(is_same<decltype(x4_u + x_int), int>::value, "");
static_assert(is_same<decltype(x4_s + x_uint), unsigned int>::value, "");
static_assert(is_same<decltype(x4_u + x_uint), unsigned int>::value, "");
x43_s % y4_u;
x43_u % y4_s;
x4_s | y43_u;
x4_u | y43_s;
x43_s += 33;
x43_s > 33;
x4_s > 33;
static_assert(is_same<decltype(x43_s + y43_s), _BitInt(43)>::value,"");
static_assert(is_same<decltype(x4_s - y4_s), _BitInt(4)>::value,"");
static_assert(is_same<decltype(x43_u * y43_u), unsigned _BitInt(43)>::value,"");
static_assert(is_same<decltype(x4_u / y4_u), unsigned _BitInt(4)>::value,"");
static_assert(is_same<decltype(~x43_s), _BitInt(43)>::value,"");
static_assert(is_same<decltype(~x4_s), _BitInt(4)>::value,"");
static_assert(is_same<decltype(+x43_s), _BitInt(43)>::value,"");
static_assert(is_same<decltype(+x4_s), _BitInt(4)>::value,"");
static_assert(is_same<decltype(-x43_u), unsigned _BitInt(43)>::value,"");
static_assert(is_same<decltype(-x4_u), unsigned _BitInt(4)>::value,"");
static_assert(is_same<decltype(++x43_s), _BitInt(43)&>::value,"");
static_assert(is_same<decltype(--x4_s), _BitInt(4)&>::value,"");
static_assert(is_same<decltype(x43_s--), _BitInt(43)>::value,"");
static_assert(is_same<decltype(x4_s++), _BitInt(4)>::value,"");
static_assert(is_same<decltype(x4_s >> 1), _BitInt(4)>::value,"");
static_assert(is_same<decltype(x4_u << 1), unsigned _BitInt(4)>::value,"");
static_assert(sizeof(x43_s) == 8, "");
static_assert(sizeof(x4_s) == 1, "");
static_assert(alignof(decltype(x43_s)) == 8, "");
static_assert(alignof(decltype(x4_s)) == 1, "");
}
constexpr int func() { return 42;}
void ConstexprBitsize() {
_BitInt(func()) F;
static_assert(is_same<decltype(F), _BitInt(42)>::value, "");
}
enum AsEnumUnderlyingType : _BitInt(33) {
};
void overloaded(int);
void overloaded(_BitInt(32));
void overloaded(_BitInt(33));
void overloaded(short);
void overloaded2(_BitInt(32));
void overloaded2(_BitInt(33));
void overloaded2(short);
void overload_use() {
int i;
_BitInt(32) i32;
_BitInt(33) i33;
short s;
overloaded(i);
overloaded(i32);
overloaded(i33);
overloaded(s);
overloaded2(i);
overloaded2(i32);
overloaded2(s);
}
struct UsedAsBitField {
_BitInt(3) F : 3;
_BitInt(3) G : 3;
_BitInt(3) H : 3;
};
struct CursedBitField {
_BitInt(4) A : 8; };
typedef _BitInt(33) IllegalMode __attribute__((mode(DI)));
void ImplicitCasts(_BitInt(31) s31, _BitInt(33) s33, int i) {
s31 = i;
s31 = s33;
s33 = i;
s33 = s31;
i = s31;
i = s33;
}
void Ternary(_BitInt(30) s30, _BitInt(31) s31a, _BitInt(31) s31b,
_BitInt(32) s32, bool b) {
b ? s30 : s31a;
b ? s31a : s30;
b ? s32 : (int)0;
(void)(b ? s31a : s31b);
(void)(s30 ? s31a : s31b);
static_assert(is_same<decltype(b ? s30 : s31a), _BitInt(31)>::value, "");
static_assert(is_same<decltype(b ? s32 : s30), _BitInt(32)>::value, "");
static_assert(is_same<decltype(b ? s30 : 0), int>::value, "");
}
void FromPaper1() {
_BitInt(2) a2 = 1;
_BitInt(3) a3 = 2;
_BitInt(33) a33 = 1;
char c = 3;
static_assert(is_same<decltype(a2 * a3), _BitInt(3)>::value, "");
static_assert(is_same<decltype(a2 * c), int>::value, "");
static_assert(is_same<decltype(a33 * c), _BitInt(33)>::value, "");
}
void FromPaper2(_BitInt(8) a1, _BitInt(24) a2) {
static_assert(is_same<decltype(a1 * (_BitInt(32))a2), _BitInt(32)>::value, "");
}