summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/ptr-arith.c
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2009-11-09 13:23:31 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2009-11-09 13:23:31 +0000
commitab0e27ff0c9ec43edadae21b369205da89e9337f (patch)
tree3df7de93b46eaa4018662b9a0bed5090408e70db /clang/test/Analysis/ptr-arith.c
parentd6e7f9d4b2114b9a27227cef9fb3161b30f6e7fc (diff)
downloadbcm5719-llvm-ab0e27ff0c9ec43edadae21b369205da89e9337f.tar.gz
bcm5719-llvm-ab0e27ff0c9ec43edadae21b369205da89e9337f.zip
Add check for pointer arithmetic on non-array variables.
llvm-svn: 86538
Diffstat (limited to 'clang/test/Analysis/ptr-arith.c')
-rw-r--r--clang/test/Analysis/ptr-arith.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/test/Analysis/ptr-arith.c b/clang/test/Analysis/ptr-arith.c
index b9eecfcf1fe..e53cc544268 100644
--- a/clang/test/Analysis/ptr-arith.c
+++ b/clang/test/Analysis/ptr-arith.c
@@ -41,3 +41,12 @@ void f4() {
int *p;
p = (int*) 0x10000; // expected-warning{{Using a fixed address is not portable because that address will probably not be valid in all environments or platforms.}}
}
+
+void f5() {
+ int x, y;
+ int *p;
+ p = &x + 1; // expected-warning{{Pointer arithmetic done on non array variables means reliance on memory layout, which is dangerous.}}
+
+ int a[10];
+ p = a + 1; // no-warning
+}
OpenPOWER on IntegriCloud