Alexey Samsonov | 5afe6aa | 2013-04-05 07:51:49 +0000 | [diff] [blame^] | 1 | // Constexpr: |
| 2 | // We need to check that a global variable initialized with a constexpr |
| 3 | // constructor can be accessed during dynamic initialization (as a constexpr |
| 4 | // constructor implies that it was initialized during constant initialization, |
| 5 | // not dynamic initialization). |
| 6 | |
| 7 | // RUN: %clangxx_asan -m64 -O0 %s %p/Helpers/initialization-constexpr-extra.cc\ |
| 8 | // RUN: --std=c++11 -fsanitize=init-order -o %t |
| 9 | // RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1 |
| 10 | // RUN: %clangxx_asan -m64 -O1 %s %p/Helpers/initialization-constexpr-extra.cc\ |
| 11 | // RUN: --std=c++11 -fsanitize=init-order -o %t |
| 12 | // RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1 |
| 13 | // RUN: %clangxx_asan -m64 -O2 %s %p/Helpers/initialization-constexpr-extra.cc\ |
| 14 | // RUN: --std=c++11 -fsanitize=init-order -o %t |
| 15 | // RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1 |
| 16 | // RUN: %clangxx_asan -m64 -O3 %s %p/Helpers/initialization-constexpr-extra.cc\ |
| 17 | // RUN: --std=c++11 -fsanitize=init-order -o %t |
| 18 | // RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1 |
| 19 | // RUN: %clangxx_asan -m32 -O0 %s %p/Helpers/initialization-constexpr-extra.cc\ |
| 20 | // RUN: --std=c++11 -fsanitize=init-order -o %t |
| 21 | // RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1 |
| 22 | // RUN: %clangxx_asan -m32 -O1 %s %p/Helpers/initialization-constexpr-extra.cc\ |
| 23 | // RUN: --std=c++11 -fsanitize=init-order -o %t |
| 24 | // RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1 |
| 25 | // RUN: %clangxx_asan -m32 -O2 %s %p/Helpers/initialization-constexpr-extra.cc\ |
| 26 | // RUN: --std=c++11 -fsanitize=init-order -o %t |
| 27 | // RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1 |
| 28 | // RUN: %clangxx_asan -m32 -O3 %s %p/Helpers/initialization-constexpr-extra.cc\ |
| 29 | // RUN: --std=c++11 -fsanitize=init-order -o %t |
| 30 | // RUN: ASAN_OPTIONS=check_initialization_order=true %t 2>&1 |
| 31 | |
| 32 | class Integer { |
| 33 | private: |
| 34 | int value; |
| 35 | |
| 36 | public: |
| 37 | constexpr Integer(int x = 0) : value(x) {} |
| 38 | int getValue() {return value;} |
| 39 | }; |
| 40 | Integer coolestInteger(42); |
| 41 | int getCoolestInteger() { return coolestInteger.getValue(); } |
| 42 | |
| 43 | int main() { return 0; } |