[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Sema / string-plus-char.c
blob66c1182eb0463e987c8b5db767186eb6b381c979
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) {
10 char *str = 0;
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}}
23 struct AB ab;
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}}
26 // no-warning
27 char c = 'c';
28 str = str + c;
29 str = c + str;