summaryrefslogtreecommitdiffstats
path: root/test/Analysis/blocks-no-inline.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/blocks-no-inline.c')
-rw-r--r--test/Analysis/blocks-no-inline.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/test/Analysis/blocks-no-inline.c b/test/Analysis/blocks-no-inline.c
index 1ec14e8..de6f959 100644
--- a/test/Analysis/blocks-no-inline.c
+++ b/test/Analysis/blocks-no-inline.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=none -fblocks -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config ipa=none -fblocks -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config ipa=none -fblocks -verify -x c++ %s
void clang_analyzer_eval(int);
@@ -11,3 +12,29 @@ void testInvalidation() {
// Under inlining, we will know that i == 1.
clang_analyzer_eval(i == 0); // expected-warning{{UNKNOWN}}
}
+
+
+const int globalConstant = 1;
+void testCapturedConstants() {
+ const int localConstant = 2;
+ static const int staticConstant = 3;
+
+ ^{
+ clang_analyzer_eval(globalConstant == 1); // expected-warning{{TRUE}}
+ clang_analyzer_eval(localConstant == 2); // expected-warning{{TRUE}}
+ clang_analyzer_eval(staticConstant == 3); // expected-warning{{TRUE}}
+ }();
+}
+
+typedef const int constInt;
+constInt anotherGlobalConstant = 1;
+void testCapturedConstantsTypedef() {
+ constInt localConstant = 2;
+ static constInt staticConstant = 3;
+
+ ^{
+ clang_analyzer_eval(anotherGlobalConstant == 1); // expected-warning{{TRUE}}
+ clang_analyzer_eval(localConstant == 2); // expected-warning{{TRUE}}
+ clang_analyzer_eval(staticConstant == 3); // expected-warning{{TRUE}}
+ }();
+}
OpenPOWER on IntegriCloud