1 // RUN: %clang_cc1 -x c -fsyntax-only -verify %s 2 // RUN: %clang_cc1 -x c++ -fsyntax-only -verify=expected,cxx %s 3 // RUN: %clang_cc1 -x c++ -std=c++26 -fsyntax-only -verify=expected,cxx26 %s 4 5 #define DELIM "/" 6 #define DOT "." 7 #define NULL (void *)0 8 9 void test(const char *d) { 10 if ("/" != d) // expected-warning {{result of comparison against a string literal is unspecified (use an explicit string comparison function instead)}} 11 return; 12 if (d == "/") // expected-warning {{result of comparison against a string literal is unspecified (use an explicit string comparison function instead)}} 13 return; 14 if ("/" != NULL) 15 return; 16 if (NULL == "/") 17 return; 18 if ("/" != DELIM) // expected-warning {{result of comparison against a string literal is unspecified (use an explicit string comparison function instead)}} 19 return; // cxx-warning@-1 {{comparison between two arrays}} cxx26-error@-1 {{comparison between two arrays is ill-formed in C++26}} 20 if (DELIM == "/") // expected-warning {{result of comparison against a string literal is unspecified (use an explicit string comparison function instead)}} 21 return; // cxx-warning@-1 {{comparison between two arrays}} cxx26-error@-1 {{comparison between two arrays is ill-formed in C++26}} 22 if (DELIM != NULL) 23 return; 24 if (NULL == DELIM) 25 return; 26 if (DOT != DELIM) // expected-warning {{result of comparison against a string literal is unspecified (use an explicit string comparison function instead)}} 27 return; // cxx-warning@-1 {{comparison between two arrays}} cxx26-error@-1 {{comparison between two arrays is ill-formed in C++26}} 28 if (DELIM == DOT) // expected-warning {{result of comparison against a string literal is unspecified (use an explicit string comparison function instead)}} 29 return; // cxx-warning@-1 {{comparison between two arrays}} cxx26-error@-1 {{comparison between two arrays is ill-formed in C++26}} 30 } 31