pointer_promotion.c 783 B

1234567891011121314151617
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. void test() {
  3. void *vp;
  4. int *ip;
  5. char *cp;
  6. struct foo *fp;
  7. struct bar *bp;
  8. short sint = 7;
  9. if (ip < cp) {} // expected-warning {{comparison of distinct pointer types ('int *' and 'char *')}}
  10. if (cp < fp) {} // expected-warning {{comparison of distinct pointer types ('char *' and 'struct foo *')}}
  11. if (fp < bp) {} // expected-warning {{comparison of distinct pointer types ('struct foo *' and 'struct bar *')}}
  12. if (ip < 7) {} // expected-warning {{comparison between pointer and integer ('int *' and 'int')}}
  13. if (sint < ip) {} // expected-warning {{comparison between pointer and integer ('int' and 'int *')}}
  14. if (ip == cp) {} // expected-warning {{comparison of distinct pointer types ('int *' and 'char *')}}
  15. }