// RUN: clang-cc -fsyntax-only -verify %s template struct Bitfields { int simple : I; // expected-error{{bit-field 'simple' has zero width}} int parens : (J); }; void test_Bitfields(Bitfields<0, 5> *b) { (void)sizeof(Bitfields<10, 5>); (void)sizeof(Bitfields<0, 1>); // expected-note{{in instantiation of template class 'struct Bitfields<0, 1>' requested here}} } template struct BitfieldPlus { int bitfield : I + J; // expected-error{{bit-field 'bitfield' has zero width}} }; void test_BitfieldPlus() { (void)sizeof(BitfieldPlus<0, 1>); (void)sizeof(BitfieldPlus<-5, 5>); // expected-note{{in instantiation of template class 'struct BitfieldPlus<-5, 5>' requested here}} } template struct BitfieldMinus { int bitfield : I - J; // expected-error{{bit-field 'bitfield' has negative width (-1)}} \ // expected-error{{bit-field 'bitfield' has zero width}} }; void test_BitfieldMinus() { (void)sizeof(BitfieldMinus<5, 1>); (void)sizeof(BitfieldMinus<0, 1>); // expected-note{{in instantiation of template class 'struct BitfieldMinus<0, 1>' requested here}} (void)sizeof(BitfieldMinus<5, 5>); // expected-note{{in instantiation of template class 'struct BitfieldMinus<5, 5>' requested here}} } template struct BitfieldDivide { int bitfield : I / J; // expected-error{{expression is not an integer constant expression}} \ // expected-note{{division by zero}} }; void test_BitfieldDivide() { (void)sizeof(BitfieldDivide<5, 1>); (void)sizeof(BitfieldDivide<5, 0>); // expected-note{{in instantiation of template class 'struct BitfieldDivide<5, 0>' requested here}} } template struct BitfieldDep { int bitfield : I + J; }; void test_BitfieldDep() { (void)sizeof(BitfieldDep); } template struct BitfieldNeg { int bitfield : (-I); // expected-error{{bit-field 'bitfield' has negative width (-5)}} }; template struct BitfieldNeg2 { int bitfield : (-I); // expected-error{{bit-field 'bitfield' has negative width (-5)}} }; void test_BitfieldNeg() { (void)sizeof(BitfieldNeg<-5>); // okay (void)sizeof(BitfieldNeg<5>); // expected-note{{in instantiation of template class 'struct BitfieldNeg<5>' requested here}} (void)sizeof(BitfieldNeg2); // okay (void)sizeof(BitfieldNeg2); // expected-note{{in instantiation of template class 'struct BitfieldNeg2' requested here}} } template void increment(T &x) { (void)++x; } struct Incrementable { Incrementable &operator++(); }; void test_increment(Incrementable inc) { increment(inc); } template void add(const T &x) { (void)(x + x); } struct Addable { Addable operator+(const Addable&) const; }; void test_add(Addable &a) { add(a); }