string-plus-char.c revision 02debf605cd904edac8dceb196e5f142ce3d14eb
1// RUN: %clang_cc1 -fsyntax-only -verify %s
2
3void 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