Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | /* RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify |
Chris Lattner | 6e4ab61 | 2007-12-09 21:53:25 +0000 | [diff] [blame] | 2 | */ |
Douglas Gregor | e7450f5 | 2009-03-24 19:52:54 +0000 | [diff] [blame] | 3 | struct incomplete; // expected-note{{forward declaration of 'struct incomplete'}} |
Chris Lattner | 6e4ab61 | 2007-12-09 21:53:25 +0000 | [diff] [blame] | 4 | |
| 5 | int sub1(int *a, double *b) { |
| 6 | return a - b; /* expected-error{{not pointers to compatible types}} */ |
| 7 | } |
| 8 | |
| 9 | void *sub2(struct incomplete *P) { |
Chandler Carruth | 13b21be | 2011-06-27 08:02:19 +0000 | [diff] [blame] | 10 | return P-4; /* expected-error{{arithmetic on a pointer to an incomplete type 'struct incomplete'}} */ |
Chris Lattner | 6e4ab61 | 2007-12-09 21:53:25 +0000 | [diff] [blame] | 11 | } |
| 12 | |
| 13 | void *sub3(void *P) { |
Chandler Carruth | 13b21be | 2011-06-27 08:02:19 +0000 | [diff] [blame] | 14 | return P-4; /* expected-warning{{arithmetic on a pointer to void is a GNU extension}} */ |
Chris Lattner | 6e4ab61 | 2007-12-09 21:53:25 +0000 | [diff] [blame] | 15 | } |
| 16 | |
| 17 | int sub4(void *P, void *Q) { |
Chandler Carruth | 13b21be | 2011-06-27 08:02:19 +0000 | [diff] [blame] | 18 | return P-Q; /* expected-warning{{arithmetic on pointers to void is a GNU extension}} */ |
Chris Lattner | 6e4ab61 | 2007-12-09 21:53:25 +0000 | [diff] [blame] | 19 | } |
| 20 | |
Douglas Gregor | e7450f5 | 2009-03-24 19:52:54 +0000 | [diff] [blame] | 21 | int sub5(void *P, int *Q) { |
| 22 | return P-Q; /* expected-error{{not pointers to compatible types}} */ |
| 23 | } |
| 24 | |
Eli Friedman | 5773a6c | 2008-05-13 20:16:47 +0000 | [diff] [blame] | 25 | int logicaland1(int a) { |
| 26 | return a && (void)a; /* expected-error{{invalid operands}} */ |
| 27 | } |