xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/enum.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple i386-unknown-unknown %s -O3 -emit-llvm -o - | grep 'ret i32 6'
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple i386-unknown-unknown -x c++ %s -O3 -emit-llvm -o - | grep 'ret i32 7'
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc // This test case illustrates a peculiarity of the promotion of
5*f4a2713aSLionel Sambuc // enumeration types in C and C++. In particular, the enumeration type
6*f4a2713aSLionel Sambuc // "z" below promotes to an unsigned int in C but int in C++.
7*f4a2713aSLionel Sambuc static enum { foo, bar = 1U } z;
8*f4a2713aSLionel Sambuc 
main(void)9*f4a2713aSLionel Sambuc int main (void)
10*f4a2713aSLionel Sambuc {
11*f4a2713aSLionel Sambuc   int r = 0;
12*f4a2713aSLionel Sambuc 
13*f4a2713aSLionel Sambuc   if (bar - 2 < 0)
14*f4a2713aSLionel Sambuc     r += 4;
15*f4a2713aSLionel Sambuc   if (foo - 1 < 0)
16*f4a2713aSLionel Sambuc     r += 2;
17*f4a2713aSLionel Sambuc   if (z - 1 < 0)
18*f4a2713aSLionel Sambuc     r++;
19*f4a2713aSLionel Sambuc 
20*f4a2713aSLionel Sambuc   return r;
21*f4a2713aSLionel Sambuc }
22*f4a2713aSLionel Sambuc 
23