summaryrefslogtreecommitdiff
path: root/clang/test/Sema/cast.c
diff options
context:
space:
mode:
authorZancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au>2012-09-24 09:58:17 +1000
committerZancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au>2012-09-24 09:58:17 +1000
commit222e2a7620e6520ffaf4fc4e69d79c18da31542e (patch)
tree7bfbc05bfa3b41c8f9d2e56d53a0bc3e310df239 /clang/test/Sema/cast.c
parent3d206f03985b50beacae843d880bccdc91a9f424 (diff)
Add the clang library to the repo (with some of my changes, too).
Diffstat (limited to 'clang/test/Sema/cast.c')
-rw-r--r--clang/test/Sema/cast.c159
1 files changed, 159 insertions, 0 deletions
diff --git a/clang/test/Sema/cast.c b/clang/test/Sema/cast.c
new file mode 100644
index 0000000..71c44b4
--- /dev/null
+++ b/clang/test/Sema/cast.c
@@ -0,0 +1,159 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+
+typedef struct { unsigned long bits[(((1) + (64) - 1) / (64))]; } cpumask_t;
+cpumask_t x;
+void foo() {
+ (void)x;
+}
+void bar() {
+ char* a;
+ double b;
+ b = (double)a; // expected-error {{pointer cannot be cast to type}}
+ a = (char*)b; // expected-error {{cannot be cast to a pointer type}}
+}
+
+long bar1(long *next) {
+ return (long)(*next)++;
+}
+
+typedef _Bool Bool;
+typedef int Int;
+typedef long Long;
+typedef float Float;
+typedef double Double;
+typedef _Complex int CInt;
+typedef _Complex long CLong;
+typedef _Complex float CFloat;
+typedef _Complex double CDouble;
+typedef void *VoidPtr;
+typedef char *CharPtr;
+
+void testBool(Bool v) {
+ (void) (Bool) v;
+ (void) (Int) v;
+ (void) (Long) v;
+ (void) (Float) v;
+ (void) (Double) v;
+ (void) (CInt) v;
+ (void) (CLong) v;
+ (void) (CFloat) v;
+ (void) (CDouble) v;
+ (void) (VoidPtr) v;
+ (void) (CharPtr) v;
+}
+
+void testInt(Int v) {
+ (void) (Bool) v;
+ (void) (Int) v;
+ (void) (Long) v;
+ (void) (Float) v;
+ (void) (Double) v;
+ (void) (CInt) v;
+ (void) (CLong) v;
+ (void) (CFloat) v;
+ (void) (CDouble) v;
+ (void) (VoidPtr) v;
+ (void) (CharPtr) v;
+}
+
+void testLong(Long v) {
+ (void) (Bool) v;
+ (void) (Int) v;
+ (void) (Long) v;
+ (void) (Float) v;
+ (void) (Double) v;
+ (void) (CInt) v;
+ (void) (CLong) v;
+ (void) (CFloat) v;
+ (void) (CDouble) v;
+ (void) (VoidPtr) v;
+ (void) (CharPtr) v;
+}
+
+void testFloat(Float v) {
+ (void) (Bool) v;
+ (void) (Int) v;
+ (void) (Long) v;
+ (void) (Float) v;
+ (void) (Double) v;
+ (void) (CInt) v;
+ (void) (CLong) v;
+ (void) (CFloat) v;
+ (void) (CDouble) v;
+}
+
+void testDouble(Double v) {
+ (void) (Bool) v;
+ (void) (Int) v;
+ (void) (Long) v;
+ (void) (Float) v;
+ (void) (Double) v;
+ (void) (CInt) v;
+ (void) (CLong) v;
+ (void) (CFloat) v;
+ (void) (CDouble) v;
+}
+
+void testCI(CInt v) {
+ (void) (Bool) v;
+ (void) (Int) v;
+ (void) (Long) v;
+ (void) (Float) v;
+ (void) (Double) v;
+ (void) (CInt) v;
+ (void) (CLong) v;
+ (void) (CFloat) v;
+ (void) (CDouble) v;
+}
+
+void testCLong(CLong v) {
+ (void) (Bool) v;
+ (void) (Int) v;
+ (void) (Long) v;
+ (void) (Float) v;
+ (void) (Double) v;
+ (void) (CInt) v;
+ (void) (CLong) v;
+ (void) (CFloat) v;
+ (void) (CDouble) v;
+}
+
+void testCFloat(CFloat v) {
+ (void) (Bool) v;
+ (void) (Int) v;
+ (void) (Long) v;
+ (void) (Float) v;
+ (void) (Double) v;
+ (void) (CInt) v;
+ (void) (CLong) v;
+ (void) (CFloat) v;
+ (void) (CDouble) v;
+}
+
+void testCDouble(CDouble v) {
+ (void) (Bool) v;
+ (void) (Int) v;
+ (void) (Long) v;
+ (void) (Float) v;
+ (void) (Double) v;
+ (void) (CInt) v;
+ (void) (CLong) v;
+ (void) (CFloat) v;
+ (void) (CDouble) v;
+}
+
+void testVoidPtr(VoidPtr v) {
+ (void) (Bool) v;
+ (void) (Int) v;
+ (void) (Long) v;
+ (void) (VoidPtr) v;
+ (void) (CharPtr) v;
+}
+
+void testCharPtr(CharPtr v) {
+ (void) (Bool) v;
+ (void) (Int) v;
+ (void) (Long) v;
+ (void) (VoidPtr) v;
+ (void) (CharPtr) v;
+}