Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 1 | // Test for blacklist functionality of initialization-order checker. |
| 2 | |
| 3 | // RUN: %clangxx_asan -O0 %s %p/Helpers/initialization-blacklist-extra.cc\ |
| 4 | // RUN: %p/Helpers/initialization-blacklist-extra2.cc \ |
Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 5 | // RUN: -fsanitize-blacklist=%p/Helpers/initialization-blacklist.txt -o %t |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 6 | // RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:check_initialization_order=true %run %t 2>&1 |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 7 | // RUN: %clangxx_asan -O1 %s %p/Helpers/initialization-blacklist-extra.cc\ |
| 8 | // RUN: %p/Helpers/initialization-blacklist-extra2.cc \ |
Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 9 | // RUN: -fsanitize-blacklist=%p/Helpers/initialization-blacklist.txt -o %t |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 10 | // RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:check_initialization_order=true %run %t 2>&1 |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 11 | // RUN: %clangxx_asan -O2 %s %p/Helpers/initialization-blacklist-extra.cc\ |
| 12 | // RUN: %p/Helpers/initialization-blacklist-extra2.cc \ |
Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 13 | // RUN: -fsanitize-blacklist=%p/Helpers/initialization-blacklist.txt -o %t |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 14 | // RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:check_initialization_order=true %run %t 2>&1 |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 15 | |
| 16 | // Function is defined in another TU. |
| 17 | int readBadGlobal(); |
| 18 | int x = readBadGlobal(); // init-order bug. |
| 19 | |
| 20 | // Function is defined in another TU. |
| 21 | int accessBadObject(); |
| 22 | int y = accessBadObject(); // init-order bug. |
| 23 | |
| 24 | int readBadSrcGlobal(); |
| 25 | int z = readBadSrcGlobal(); // init-order bug. |
| 26 | |
| 27 | int main(int argc, char **argv) { |
| 28 | return argc + x + y + z - 1; |
| 29 | } |