xref: /minix3/external/bsd/llvm/dist/clang/test/Sema/string-plus-char.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 
3 void f(const char *s) {
4   char *str = 0;
5   char *str2 = str + 'c'; // expected-warning {{adding 'char' to a string pointer does not append to the string}} expected-note {{use array indexing to silence this warning}}
6 
7   const char *constStr = s + 'c'; // expected-warning {{adding 'char' to a string pointer does not append to the string}} expected-note {{use array indexing to silence this warning}}
8 
9   str = 'c' + str;// expected-warning {{adding 'char' to a string pointer does not append to the string}} expected-note {{use array indexing to silence this warning}}
10 
11   // no-warning
12   char c = 'c';
13   str = str + c;
14   str = c + str;
15 }
16