blob: be52d0bd844478c0ebbf2ddc6b336780f29757a9 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001/* RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify
Chris Lattner6e4ab612007-12-09 21:53:25 +00002 */
Douglas Gregore7450f52009-03-24 19:52:54 +00003struct incomplete; // expected-note{{forward declaration of 'struct incomplete'}}
Chris Lattner6e4ab612007-12-09 21:53:25 +00004
5int sub1(int *a, double *b) {
6 return a - b; /* expected-error{{not pointers to compatible types}} */
7}
8
9void *sub2(struct incomplete *P) {
Chandler Carruth13b21be2011-06-27 08:02:19 +000010 return P-4; /* expected-error{{arithmetic on a pointer to an incomplete type 'struct incomplete'}} */
Chris Lattner6e4ab612007-12-09 21:53:25 +000011}
12
13void *sub3(void *P) {
Chandler Carruth13b21be2011-06-27 08:02:19 +000014 return P-4; /* expected-warning{{arithmetic on a pointer to void is a GNU extension}} */
Chris Lattner6e4ab612007-12-09 21:53:25 +000015}
16
17int sub4(void *P, void *Q) {
Chandler Carruth13b21be2011-06-27 08:02:19 +000018 return P-Q; /* expected-warning{{arithmetic on pointers to void is a GNU extension}} */
Chris Lattner6e4ab612007-12-09 21:53:25 +000019}
20
Douglas Gregore7450f52009-03-24 19:52:54 +000021int sub5(void *P, int *Q) {
22 return P-Q; /* expected-error{{not pointers to compatible types}} */
23}
24
Eli Friedman5773a6c2008-05-13 20:16:47 +000025int logicaland1(int a) {
26 return a && (void)a; /* expected-error{{invalid operands}} */
27}