1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 struct AB
{const char *a
; const char*b
;};
5 const char *foo(const struct AB
*ab
) {
6 return ab
->a
+ 'b'; // expected-warning {{adding 'char' to a string pointer does not append to the string}} expected-note {{use array indexing to silence this warning}}
9 void f(const char *s
) {
11 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}}
13 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}}
15 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}}
17 char strArr
[] = "foo";
18 str
= strArr
+ 'c'; // expected-warning {{adding 'char' to a string pointer does not append to the string}} expected-note {{use array indexing to silence this warning}}
19 char *strArr2
[] = {"ac","dc"};
20 str
= strArr2
[0] + 'c'; // expected-warning {{adding 'char' to a string pointer does not append to the string}} expected-note {{use array indexing to silence this warning}}
24 constStr
= foo(&ab
) + 'c'; // expected-warning {{adding 'char' to a string pointer does not append to the string}} expected-note {{use array indexing to silence this warning}}