blob: 53619ea8186c7cc9394ce5348dd42bc94e454c32 [file] [log] [blame]
Alexey Samsonov5afe6aa2013-04-05 07:51:49 +00001// 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
Alexey Samsonove595e1a2014-06-13 17:53:44 +00007// RUN: %clangxx_asan -O0 %s %p/Helpers/initialization-constexpr-extra.cc --std=c++11 -o %t
Reid Kleckner85220d02015-08-12 23:50:12 +00008// RUN: %env_asan_opts=check_initialization_order=true %run %t 2>&1
Alexey Samsonove595e1a2014-06-13 17:53:44 +00009// RUN: %clangxx_asan -O1 %s %p/Helpers/initialization-constexpr-extra.cc --std=c++11 -o %t
Reid Kleckner85220d02015-08-12 23:50:12 +000010// RUN: %env_asan_opts=check_initialization_order=true %run %t 2>&1
Alexey Samsonove595e1a2014-06-13 17:53:44 +000011// RUN: %clangxx_asan -O2 %s %p/Helpers/initialization-constexpr-extra.cc --std=c++11 -o %t
Reid Kleckner85220d02015-08-12 23:50:12 +000012// RUN: %env_asan_opts=check_initialization_order=true %run %t 2>&1
Alexey Samsonove595e1a2014-06-13 17:53:44 +000013// RUN: %clangxx_asan -O3 %s %p/Helpers/initialization-constexpr-extra.cc --std=c++11 -o %t
Reid Kleckner85220d02015-08-12 23:50:12 +000014// RUN: %env_asan_opts=check_initialization_order=true %run %t 2>&1
Alexey Samsonov5afe6aa2013-04-05 07:51:49 +000015
16class Integer {
17 private:
18 int value;
19
20 public:
21 constexpr Integer(int x = 0) : value(x) {}
22 int getValue() {return value;}
23};
24Integer coolestInteger(42);
25int getCoolestInteger() { return coolestInteger.getValue(); }
26
27int main() { return 0; }