template<int I, int J>
struct Bitfields {
int simple : I; int parens : (J);
};
void test_Bitfields(Bitfields<0, 5> *b) {
(void)sizeof(Bitfields<10, 5>);
(void)sizeof(Bitfields<0, 1>); }
template<int I, int J>
struct BitfieldPlus {
int bitfield : I + J; };
void test_BitfieldPlus() {
(void)sizeof(BitfieldPlus<0, 1>);
(void)sizeof(BitfieldPlus<-5, 5>); }
template<int I, int J>
struct BitfieldMinus {
int bitfield : I - J; };
void test_BitfieldMinus() {
(void)sizeof(BitfieldMinus<5, 1>);
(void)sizeof(BitfieldMinus<0, 1>); (void)sizeof(BitfieldMinus<5, 5>); }
template<int I, int J>
struct BitfieldDivide {
int bitfield : I / J; };
void test_BitfieldDivide() {
(void)sizeof(BitfieldDivide<5, 1>);
(void)sizeof(BitfieldDivide<5, 0>); }
template<typename T, T I, int J>
struct BitfieldDep {
int bitfield : I + J;
};
void test_BitfieldDep() {
(void)sizeof(BitfieldDep<int, 1, 5>);
}
template<int I>
struct BitfieldNeg {
int bitfield : (-I); };
template<typename T, T I>
struct BitfieldNeg2 {
int bitfield : (-I); };
void test_BitfieldNeg() {
(void)sizeof(BitfieldNeg<-5>); (void)sizeof(BitfieldNeg<5>); (void)sizeof(BitfieldNeg2<int, -5>); (void)sizeof(BitfieldNeg2<int, 5>); }
template<typename T>
void increment(T &x) {
(void)++x;
}
struct Incrementable {
Incrementable &operator++();
};
void test_increment(Incrementable inc) {
increment(inc);
}
template<typename T>
void add(const T &x) {
(void)(x + x);
}
namespace PR6237 {
template <typename T>
void f(T t) {
t++;
}
struct B { };
B operator++(B &, int);
template void f(B);
}
struct Addable {
Addable operator+(const Addable&) const;
};
void test_add(Addable &a) {
add(a);
}
struct CallOperator {
int &operator()(int);
double &operator()(double);
};
template<typename Result, typename F, typename Arg1>
Result test_call_operator(F f, Arg1 arg1) {
CallOperator call_op;
int &ir = call_op(17);
return f(arg1);
}
void test_call_operator(CallOperator call_op, int i, double d) {
int &ir = test_call_operator<int&>(call_op, i);
double &dr = test_call_operator<double&>(call_op, d);
}
template<typename T>
void test_asm(T t) {
asm ("nop" : "=r"(*t) : "r"(*t)); }
void test_asm() {
int* a;
test_asm(a);
int b;
test_asm(b); }
namespace PR6424 {
template<int I> struct X {
X() {
int *ip = I; }
};
template<int> struct Y {
typedef X<7> X7;
void f() { X7(); } };
template void Y<3>::f();
template<int I>
struct X2 {
void *operator new(__SIZE_TYPE__) {
int *ip = I; return ip;
}
};
template<int> struct Y2 {
typedef X2<7> X;
void f() {
new X(); }
};
template void Y2<3>::f();
template<typename T>
void rdar10283928(int count) {
(void)new char[count]();
}
template void rdar10283928<int>(int);
}
namespace PR10864 {
template<typename T> class Vals {};
template<> class Vals<int> { public: static const int i = 1; };
template<> class Vals<float> { public: static const double i; };
template<typename T> void test_asm_tied(T o) {
__asm("addl $1, %0" : "=r" (o) : "0"(Vals<T>::i)); }
void test_asm_tied() {
test_asm_tied(1);
test_asm_tied(1.f); }
}
namespace TestAsmCleanup {
struct S {
operator int() const { return 1; }
~S();
};
template <class T>
void foo() {
__asm__ __volatile__("%[i]"
:
: [i] "r"(-S()));
}
void test() { foo<void>(); }
}