typecheck-binop.c revision e7450f5dbd5bed63b8ef9db86350a8fc3db011e8
1/* RUN: clang-cc %s -fsyntax-only -pedantic -verify
2 */
3struct incomplete; // expected-note{{forward declaration of 'struct incomplete'}}
4
5int sub1(int *a, double *b) {
6  return a - b;    /* expected-error{{not pointers to compatible types}} */
7}
8
9void *sub2(struct incomplete *P) {
10  return P-4;      /* expected-error{{subtraction of pointer 'struct incomplete *' requires pointee to be a complete object type}} */
11}
12
13void *sub3(void *P) {
14  return P-4;      /* expected-warning{{GNU void* extension}} */
15}
16
17int sub4(void *P, void *Q) {
18  return P-Q;      /* expected-warning{{GNU void* extension}} */
19}
20
21int sub5(void *P, int *Q) {
22  return P-Q;      /* expected-error{{not pointers to compatible types}} */
23}
24
25int logicaland1(int a) {
26  return a && (void)a; /* expected-error{{invalid operands}} */
27}
28