]> granicus.if.org Git - clang/commitdiff
[analyzer] Test variable modified types.
authorAnna Zaks <ganna@apple.com>
Fri, 11 May 2012 23:34:14 +0000 (23:34 +0000)
committerAnna Zaks <ganna@apple.com>
Fri, 11 May 2012 23:34:14 +0000 (23:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156664 91177308-0d34-0410-b5e6-96231b3b80d8

test/Analysis/test-variably-modified-types.c [new file with mode: 0644]

diff --git a/test/Analysis/test-variably-modified-types.c b/test/Analysis/test-variably-modified-types.c
new file mode 100644 (file)
index 0000000..a833434
--- /dev/null
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyze-function=testVariablyModifiedTypes -verify %s
+
+// Test that we process variably modified type correctly - the call graph construction should pick up function_with_bug while recursively visiting test_variably_modifiable_types.
+unsigned getArraySize(int *x) {
+  if (!x)
+    return *x; // expected-warning {{Dereference of null pointer}}
+  return 1;
+}
+
+int testVariablyModifiedTypes(int *x) {
+  int mytype[getArraySize(x)];
+  return 0;
+}