Peter Collingbourne | 49d29ed | 2013-10-20 21:29:32 +0000 | [diff] [blame^] | 1 | // RUN: %clangxx -fsanitize=enum %s -O3 -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-PLAIN |
| 2 | // RUN: %clangxx -fsanitize=enum -std=c++11 -DE="class E" %s -O3 -o %t && %t |
| 3 | // RUN: %clangxx -fsanitize=enum -std=c++11 -DE="class E : bool" %s -O3 -o %t && %t 2>&1 | FileCheck %s --check-prefix=CHECK-BOOL |
Richard Smith | e3eb652 | 2012-12-13 07:12:20 +0000 | [diff] [blame] | 4 | |
| 5 | enum E { a = 1 } e; |
| 6 | #undef E |
| 7 | |
| 8 | int main(int argc, char **argv) { |
| 9 | // memset(&e, 0xff, sizeof(e)); |
| 10 | for (unsigned char *p = (unsigned char*)&e; p != (unsigned char*)(&e + 1); ++p) |
| 11 | *p = 0xff; |
| 12 | |
| 13 | // CHECK-PLAIN: error: load of value 4294967295, which is not a valid value for type 'enum E' |
| 14 | // FIXME: Support marshalling and display of enum class values. |
| 15 | // CHECK-BOOL: error: load of value <unknown>, which is not a valid value for type 'enum E' |
| 16 | return (int)e != -1; |
| 17 | } |