diff options
author | Nico Weber <nicolasweber@gmx.de> | 2011-09-17 22:59:41 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2011-09-17 22:59:41 +0000 |
commit | 7c29980d2090e47cb05f627eed604c9dea3a6ce6 (patch) | |
tree | 758cfde6575debb56bb8f9e4aca25cf78e437c7b /clang/test/SemaCXX/array-bounds.cpp | |
parent | db8015c4497a0527de48c4865edfc09403091eb9 (diff) | |
download | bcm5719-llvm-7c29980d2090e47cb05f627eed604c9dea3a6ce6.tar.gz bcm5719-llvm-7c29980d2090e47cb05f627eed604c9dea3a6ce6.zip |
Let -Warray-bounds handle casted array types without false positives.
Fixes PR10771.
llvm-svn: 139990
Diffstat (limited to 'clang/test/SemaCXX/array-bounds.cpp')
-rw-r--r-- | clang/test/SemaCXX/array-bounds.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/array-bounds.cpp b/clang/test/SemaCXX/array-bounds.cpp index 2bbb4776ada..e071bc7b5bd 100644 --- a/clang/test/SemaCXX/array-bounds.cpp +++ b/clang/test/SemaCXX/array-bounds.cpp @@ -214,3 +214,15 @@ int test_more() { else return foo[5]; // expected-warning {{array index of '5' indexes past the end of an array (that contains 5 elements)}} } + +void test_pr10771() { + double foo[4096]; // expected-note {{array 'foo' declared here}} + + ((char*)foo)[sizeof(foo) - 1] = '\0'; // no-warning + *(((char*)foo) + sizeof(foo) - 1) = '\0'; // no-warning + + ((char*)foo)[sizeof(foo)] = '\0'; // expected-warning {{array index of '32768' indexes past the end of an array (that contains 32768 elements)}} + + // TODO: This should probably warn, too. + *(((char*)foo) + sizeof(foo)) = '\0'; // no-warning +} |