typecheck-binop.c revision d162584991885ab004a02573a73ce06422b921fc
1/* RUN: clang %s -fsyntax-only -pedantic -verify
2 */
3struct 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 logicaland1(int a) {
22  return a && (void)a; /* expected-error{{invalid operands}} */
23}
24