summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/enum.c
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-08-28 06:15:15 +0000
committerChris Lattner <sabre@nondot.org>2007-08-28 06:15:15 +0000
commitb8a501ccf17b353b4ded3b2cbf01262061ed1559 (patch)
tree1489996e964c1293a504ef2cd16b7de83dafa160 /clang/test/Sema/enum.c
parentd0e7ed3f2c9ebac7dcdf7d7d32ca3462089c3bae (diff)
downloadbcm5719-llvm-b8a501ccf17b353b4ded3b2cbf01262061ed1559.tar.gz
bcm5719-llvm-b8a501ccf17b353b4ded3b2cbf01262061ed1559.zip
compute the required destination type for an enum, emitting various warnings.
TODO: update the types of the constants and the enum. llvm-svn: 41532
Diffstat (limited to 'clang/test/Sema/enum.c')
-rw-r--r--clang/test/Sema/enum.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/clang/test/Sema/enum.c b/clang/test/Sema/enum.c
new file mode 100644
index 00000000000..1ba3977a785
--- /dev/null
+++ b/clang/test/Sema/enum.c
@@ -0,0 +1,24 @@
+// RUN: clang %s -parse-ast-check -pedantic
+
+enum e {A,
+ B = 42LL << 32, // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
+ C = -4, D = 12456 };
+
+enum f { a = -2147483648, b = 2147483647 }; // ok.
+
+enum g { // too negative
+ c = -2147483649, // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
+ d = 2147483647 };
+enum h { e = -2147483648, // too pos
+ f = 2147483648 // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
+};
+
+// minll maxull
+enum x // expected-warning {{enumeration values exceed range of largest integer}}
+{ y = -9223372036854775807LL-1, // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
+z = 9223372036854775808ULL }; // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
+
+int test() {
+ return sizeof(enum e) ;
+}
+
OpenPOWER on IntegriCloud