brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · eabfebc Raw
50 lines · c
1// RUN: %clang_cc1 -fsyntax-only -verify -Wall %s -std=c112 3int test1(int *a) {4  return a == '\0'; // expected-warning {{comparing a pointer to a null character constant; did you mean to compare to (void *)0?}}5}6 7int test2(int *a) {8  return '\0' == a; // expected-warning {{comparing a pointer to a null character constant; did you mean to compare to (void *)0?}}9}10 11int test3(int *a) {12  return a == L'\0'; // expected-warning {{comparing a pointer to a null character constant; did you mean to compare to (void *)0?}}13}14 15int test4(int *a) {16  return a == u'\0'; // expected-warning {{comparing a pointer to a null character constant; did you mean to compare to (void *)0?}}17}18 19int test5(int *a) {20  return a == U'\0'; // expected-warning {{comparing a pointer to a null character constant; did you mean to compare to (void *)0?}}21}22 23int test6(int *a) {24  return a == (char)0; // expected-warning {{comparing a pointer to a null character constant; did you mean to compare to (void *)0?}}25}26 27typedef char my_char;28int test7(int *a) {29  return a == (my_char)0;30  // expected-warning@-1 {{comparing a pointer to a null character constant; did you mean to compare to (void *)0?}}31}32 33int test8(int *a) {34  return a != '\0'; // expected-warning {{comparing a pointer to a null character constant; did you mean to compare to (void *)0?}}35}36 37#define NULL (void *)038int test9(int *a) {39  return a == '\0'; // expected-warning {{comparing a pointer to a null character constant; did you mean to compare to NULL?}}40}41 42#define MYCHAR char43int test10(int *a) {44  return a == (MYCHAR)0; // expected-warning {{comparing a pointer to a null character constant; did you mean to compare to NULL?}}45}46 47int test11(int *a) {48  return a > '\0';49}50