blob: 0e239f1a8ee34b5b3dcad855a6c85ab9216a94cf [file] [log] [blame]
Daniel Dunbarc7cbed02010-04-02 22:29:38 +00001// RUN: %clang_cc1 -triple i386-unknown-unknown %s -O3 -emit-llvm -o - | grep 'ret i32 6'
2// RUN: %clang_cc1 -triple i386-unknown-unknown -x c++ %s -O3 -emit-llvm -o - | grep 'ret i32 7'
Chris Lattnerd5bbce42007-08-29 17:48:46 +00003
Douglas Gregor6eb5be82011-01-18 18:38:18 +00004// This test case illustrates a peculiarity of the promotion of
5// enumeration types in C and C++. In particular, the enumeration type
6// "z" below promotes to an unsigned int in C but int in C++.
Chris Lattnerd5bbce42007-08-29 17:48:46 +00007static enum { foo, bar = 1U } z;
8
9int main (void)
10{
11 int r = 0;
12
13 if (bar - 2 < 0)
14 r += 4;
15 if (foo - 1 < 0)
16 r += 2;
17 if (z - 1 < 0)
18 r++;
19
20 return r;
21}
22