Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 1 | // RUN: %clangxx -fsanitize=enum %s -O3 -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-PLAIN |
| 2 | // RUN: %clangxx -fsanitize=enum -std=c++11 -DE="class E" %s -O3 -o %t && %run %t |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 3 | // RUN: %clangxx -fsanitize=enum -std=c++11 -DE="class E : bool" %s -O3 -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-BOOL |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 4 | |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 5 | // FIXME: UBSan fails to add the correct instrumentation code for some reason on |
| 6 | // Windows. |
| 7 | // XFAIL: win32 |
| 8 | |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 9 | enum E { a = 1 } e; |
| 10 | #undef E |
| 11 | |
| 12 | int main(int argc, char **argv) { |
| 13 | // memset(&e, 0xff, sizeof(e)); |
| 14 | for (unsigned char *p = (unsigned char*)&e; p != (unsigned char*)(&e + 1); ++p) |
| 15 | *p = 0xff; |
| 16 | |
| 17 | // CHECK-PLAIN: error: load of value 4294967295, which is not a valid value for type 'enum E' |
| 18 | // FIXME: Support marshalling and display of enum class values. |
| 19 | // CHECK-BOOL: error: load of value <unknown>, which is not a valid value for type 'enum E' |
| 20 | return (int)e != -1; |
| 21 | } |