From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- clang/test/CodeGen/enum.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 clang/test/CodeGen/enum.c (limited to 'clang/test/CodeGen/enum.c') diff --git a/clang/test/CodeGen/enum.c b/clang/test/CodeGen/enum.c new file mode 100644 index 0000000..0e239f1 --- /dev/null +++ b/clang/test/CodeGen/enum.c @@ -0,0 +1,22 @@ +// 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; +} + -- cgit v1.2.3