summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2009-11-09 08:07:38 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2009-11-09 08:07:38 +0000
commitf06c684a33a89ab89e21b7832eb1cd2b6fecac37 (patch)
tree2b494922cf95c2c2e08de27e6badff4ea11609ce /clang/test
parent65c0db98ab8fbbc70847e6c88d46abbfec03f52b (diff)
downloadbcm5719-llvm-f06c684a33a89ab89e21b7832eb1cd2b6fecac37.tar.gz
bcm5719-llvm-f06c684a33a89ab89e21b7832eb1cd2b6fecac37.zip
Add checker for CWE-588: Attempt to Access Child of a Non-structure Pointer.
llvm-svn: 86529
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Analysis/array-struct.c2
-rw-r--r--clang/test/Analysis/misc-ps-region-store.m2
2 files changed, 2 insertions, 2 deletions
diff --git a/clang/test/Analysis/array-struct.c b/clang/test/Analysis/array-struct.c
index 18a6ed50743..1ab67874c6a 100644
--- a/clang/test/Analysis/array-struct.c
+++ b/clang/test/Analysis/array-struct.c
@@ -153,7 +153,7 @@ struct s3 p[1];
// an ElementRegion of type 'char'. Then load a nonloc::SymbolVal from it and
// assigns to 'a'.
void f16(struct s3 *p) {
- struct s3 a = *((struct s3*) ((char*) &p[0]));
+ struct s3 a = *((struct s3*) ((char*) &p[0])); // expected-warning{{Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption.}}
}
void inv(struct s1 *);
diff --git a/clang/test/Analysis/misc-ps-region-store.m b/clang/test/Analysis/misc-ps-region-store.m
index edea24224b7..2c5180791e0 100644
--- a/clang/test/Analysis/misc-ps-region-store.m
+++ b/clang/test/Analysis/misc-ps-region-store.m
@@ -286,7 +286,7 @@ struct WrappedStruct { unsigned z; };
int test_handle_array_wrapper() {
struct ArrayWrapper x;
test_handle_array_wrapper(&x);
- struct WrappedStruct *p = (struct WrappedStruct*) x.y;
+ struct WrappedStruct *p = (struct WrappedStruct*) x.y; // expected-warning{{Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption.}}
return p->z; // no-warning
}
OpenPOWER on IntegriCloud