1 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-array-bounds %s -fpascal-strings
2 // RUN: %clang_cc1 -fdiagnostics-parseable-fixits -x c++ %s 2>&1 -Wno-array-bounds -fpascal-strings | FileCheck %s
4 void consume(const char* c
) {}
5 void consume(const unsigned char* c
) {}
6 void consume(const wchar_t* c
) {}
7 void consumeChar(char c
) {}
14 enum OperatorOverloadEnum
{
15 kMyOperatorOverloadedEnum
= 5
18 const char* operator+(const char* c
, OperatorOverloadEnum e
) {
22 const char* operator+(OperatorOverloadEnum e
, const char* c
) {
28 // CHECK: fix-it:"{{.*}}":{31:11-31:11}:"&"
29 // CHECK: fix-it:"{{.*}}":{31:17-31:18}:"["
30 // CHECK: fix-it:"{{.*}}":{31:20-31:20}:"]"
31 consume("foo" + 5); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
32 consume("foo" + index
); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
33 consume("foo" + kMyEnum
); // expected-warning {{adding 'MyEnum' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
34 consume("foo" + kMySmallEnum
); // expected-warning {{adding 'MyEnum' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
36 consume(5 + "foo"); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
37 consume(index
+ "foo"); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
38 consume(kMyEnum
+ "foo"); // expected-warning {{adding 'MyEnum' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
39 consume(kMySmallEnum
+ "foo"); // expected-warning {{adding 'MyEnum' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
41 // FIXME: suggest replacing with "foo"[5]
42 consumeChar(*("foo" + 5)); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
43 consumeChar(*(5 + "foo")); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
45 consume(L
"foo" + 5); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
46 consume(L
"foo" + 2); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
48 consume("foo" + 3); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
49 consume("foo" + 4); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
50 consume("\pfoo" + 4); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
54 consume(A B
+ sizeof(A
) - 1); // expected-warning {{to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
58 consume(&("foo"[index
]));
59 consume(&("foo"[kMyEnum
]));
62 consume("foo" + kMyOperatorOverloadedEnum
);
63 consume(kMyOperatorOverloadedEnum
+ "foo");
68 (void)(sizeof(T
) + ""); // expected-warning {{to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
70 template void PR21848
<int>(); // expected-note {{in instantiation of function template specialization 'PR21848<int>' requested here}}