summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/asan/lit_tests/initialization-constexpr.cc
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2013-04-05 07:51:49 +0000
committerAlexey Samsonov <samsonov@google.com>2013-04-05 07:51:49 +0000
commit5afe6aa1419681389ba87cb06638cdf11d1a2f7a (patch)
tree32b3b402951e5bf8ae81d168b2abc016b557190d /compiler-rt/lib/asan/lit_tests/initialization-constexpr.cc
parentcb9efbe6d727d2eb8a62fd7df2a91055b037f11b (diff)
downloadbcm5719-llvm-5afe6aa1419681389ba87cb06638cdf11d1a2f7a.tar.gz
bcm5719-llvm-5afe6aa1419681389ba87cb06638cdf11d1a2f7a.zip
[ASan] init-order checker tests: move constexpr test that requires -std=c++11 to a separate test case. Check that structs with no ctor but non-trivial dtor are ignored.
llvm-svn: 178857
Diffstat (limited to 'compiler-rt/lib/asan/lit_tests/initialization-constexpr.cc')
-rw-r--r--compiler-rt/lib/asan/lit_tests/initialization-constexpr.cc43
1 files changed, 43 insertions, 0 deletions
diff --git a/compiler-rt/lib/asan/lit_tests/initialization-constexpr.cc b/compiler-rt/lib/asan/lit_tests/initialization-constexpr.cc
new file mode 100644
index 00000000000..ba5410674f7
--- /dev/null
+++ b/compiler-rt/lib/asan/lit_tests/initialization-constexpr.cc
@@ -0,0 +1,43 @@
+// Constexpr:
+// We need to check that a global variable initialized with a constexpr
+// constructor can be accessed during dynamic initialization (as a constexpr
+// constructor implies that it was initialized during constant initialization,
+// not dynamic initialization).
+
+// RUN: %clangxx_asan -m64 -O0 %s %p/Helpers/initialization-constexpr-extra.cc\
+// RUN: --std=c++11 -fsanitize=init-order -o %t
+// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
+// RUN: %clangxx_asan -m64 -O1 %s %p/Helpers/initialization-constexpr-extra.cc\
+// RUN: --std=c++11 -fsanitize=init-order -o %t
+// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
+// RUN: %clangxx_asan -m64 -O2 %s %p/Helpers/initialization-constexpr-extra.cc\
+// RUN: --std=c++11 -fsanitize=init-order -o %t
+// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
+// RUN: %clangxx_asan -m64 -O3 %s %p/Helpers/initialization-constexpr-extra.cc\
+// RUN: --std=c++11 -fsanitize=init-order -o %t
+// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
+// RUN: %clangxx_asan -m32 -O0 %s %p/Helpers/initialization-constexpr-extra.cc\
+// RUN: --std=c++11 -fsanitize=init-order -o %t
+// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
+// RUN: %clangxx_asan -m32 -O1 %s %p/Helpers/initialization-constexpr-extra.cc\
+// RUN: --std=c++11 -fsanitize=init-order -o %t
+// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
+// RUN: %clangxx_asan -m32 -O2 %s %p/Helpers/initialization-constexpr-extra.cc\
+// RUN: --std=c++11 -fsanitize=init-order -o %t
+// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
+// RUN: %clangxx_asan -m32 -O3 %s %p/Helpers/initialization-constexpr-extra.cc\
+// RUN: --std=c++11 -fsanitize=init-order -o %t
+// RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1
+
+class Integer {
+ private:
+ int value;
+
+ public:
+ constexpr Integer(int x = 0) : value(x) {}
+ int getValue() {return value;}
+};
+Integer coolestInteger(42);
+int getCoolestInteger() { return coolestInteger.getValue(); }
+
+int main() { return 0; }
OpenPOWER on IntegriCloud