blob: 5dbecf161262730d6bec745c234eb3fefe1052b1 [file] [log] [blame]
Stephen Hines2d1fdb22014-05-28 23:58:16 -07001// 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 Hines6d186232014-11-26 17:56:19 -08003// 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 Hines2d1fdb22014-05-28 23:58:16 -07004
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -08005// FIXME: UBSan fails to add the correct instrumentation code for some reason on
6// Windows.
7// XFAIL: win32
8
Stephen Hines2d1fdb22014-05-28 23:58:16 -07009enum E { a = 1 } e;
10#undef E
11
12int 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}