minix/external/bsd/llvm/dist/clang/test/CodeGen/enum.c
Lionel Sambuc f4a2713ac8 Importing netbsd clang -- pristine
Change-Id: Ia40e9ffdf29b5dab2f122f673ff6802a58bc690f
2014-07-28 17:05:57 +02:00

22 lines
555 B
C

// RUN: %clang_cc1 -triple i386-unknown-unknown %s -O3 -emit-llvm -o - | grep 'ret i32 6'
// RUN: %clang_cc1 -triple i386-unknown-unknown -x c++ %s -O3 -emit-llvm -o - | grep 'ret i32 7'
// This test case illustrates a peculiarity of the promotion of
// enumeration types in C and C++. In particular, the enumeration type
// "z" below promotes to an unsigned int in C but int in C++.
static enum { foo, bar = 1U } z;
int main (void)
{
int r = 0;
if (bar - 2 < 0)
r += 4;
if (foo - 1 < 0)
r += 2;
if (z - 1 < 0)
r++;
return r;
}