diff options
Diffstat (limited to 'clang/test/SemaCXX/array-bounds.cpp')
| -rw-r--r-- | clang/test/SemaCXX/array-bounds.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/array-bounds.cpp b/clang/test/SemaCXX/array-bounds.cpp index 6ebff8c9920..495ccaf71bd 100644 --- a/clang/test/SemaCXX/array-bounds.cpp +++ b/clang/test/SemaCXX/array-bounds.cpp @@ -296,3 +296,16 @@ namespace PR39746 { // We can still diagnose this. C &h() { return reinterpret_cast<C *>(xxx)[-1]; } // expected-warning {{array index -1 is before the beginning of the array}} } + +namespace PR41087 { + template <typename Ty> void foo() { + Ty buffer[2]; // expected-note 3{{array 'buffer' declared here}} + ((char *)buffer)[2] = 'A'; // expected-warning 1{{array index 2 is past the end of the array (which contains 2 elements)}} + ((char *)buffer)[-1] = 'A'; // expected-warning 2{{array index -1 is before the beginning of the array}} + } + + void f() { + foo<char>(); // expected-note 1{{in instantiation of function template specialization}} + foo<int>(); // expected-note 1{{in instantiation of function template specialization}} + }; +} |

