Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple i386-unknown-unknown %s -O3 -emit-llvm -o - | FileCheck -check-prefix=CHECK-C %s |
| 2 | // RUN: %clang_cc1 -triple i386-unknown-unknown -x c++ %s -O3 -emit-llvm -o - | FileCheck -check-prefix=CHECK-CXX %s |
| 3 | // CHECK-C: ret i32 6 |
| 4 | // CHECK-CXX: ret i32 7 |
Chris Lattner | d5bbce4 | 2007-08-29 17:48:46 +0000 | [diff] [blame] | 5 | |
Douglas Gregor | 6eb5be8 | 2011-01-18 18:38:18 +0000 | [diff] [blame] | 6 | // This test case illustrates a peculiarity of the promotion of |
| 7 | // enumeration types in C and C++. In particular, the enumeration type |
| 8 | // "z" below promotes to an unsigned int in C but int in C++. |
Chris Lattner | d5bbce4 | 2007-08-29 17:48:46 +0000 | [diff] [blame] | 9 | static enum { foo, bar = 1U } z; |
| 10 | |
| 11 | int main (void) |
| 12 | { |
| 13 | int r = 0; |
| 14 | |
| 15 | if (bar - 2 < 0) |
| 16 | r += 4; |
| 17 | if (foo - 1 < 0) |
| 18 | r += 2; |
| 19 | if (z - 1 < 0) |
| 20 | r++; |
| 21 | |
| 22 | return r; |
| 23 | } |