1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc class A {
4*f4a2713aSLionel Sambuc public:
A()5*f4a2713aSLionel Sambuc   A(): str() { }
A(const char * p)6*f4a2713aSLionel Sambuc   A(const char *p) { }
A(char * p)7*f4a2713aSLionel Sambuc   A(char *p) : str(p + 'a') { } // expected-warning {{adding 'char' to a string pointer does not append to the string}} expected-note {{use array indexing to silence this warning}}
operator +(const char * p)8*f4a2713aSLionel Sambuc   A& operator+(const char *p) { return *this; }
operator +(char ch)9*f4a2713aSLionel Sambuc   A& operator+(char ch) { return *this; }
10*f4a2713aSLionel Sambuc   char * str;
11*f4a2713aSLionel Sambuc };
12*f4a2713aSLionel Sambuc 
f(const char * s)13*f4a2713aSLionel Sambuc void f(const char *s) {
14*f4a2713aSLionel Sambuc   A a = s + 'a'; // // expected-warning {{adding 'char' to a string pointer does not append to the string}} expected-note {{use array indexing to silence this warning}}
15*f4a2713aSLionel Sambuc   a = a + s + 'b'; // no-warning
16*f4a2713aSLionel Sambuc 
17*f4a2713aSLionel Sambuc   char *str = 0;
18*f4a2713aSLionel Sambuc   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}}
19*f4a2713aSLionel Sambuc 
20*f4a2713aSLionel Sambuc   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}}
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc   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}}
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc   wchar_t *wstr;
25*f4a2713aSLionel Sambuc   wstr = wstr + L'c'; // expected-warning {{adding 'wchar_t' to a string pointer does not append to the string}} expected-note {{use array indexing to silence this warning}}
26*f4a2713aSLionel Sambuc   str2 = str + u'a'; // expected-warning {{adding 'char16_t' to a string pointer does not append to the string}} expected-note {{use array indexing to silence this warning}}
27*f4a2713aSLionel Sambuc 
28*f4a2713aSLionel Sambuc   // no-warning
29*f4a2713aSLionel Sambuc   char c = 'c';
30*f4a2713aSLionel Sambuc   str = str + c;
31*f4a2713aSLionel Sambuc   str = c + str;
32*f4a2713aSLionel Sambuc }
33