aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2001-12-08 22:29:03 +0000
committerAldy Hernandez <aldyh@gcc.gnu.org>2001-12-08 22:29:03 +0000
commit1ec9bf8aa0d0b2375e43668f4a6c186856c9dbc9 (patch)
tree5eae308c903e4276f6f8ba94e5407354ed462b7a
parent79dc3d44fbb3e5461396f95725eab5b442c7d9a8 (diff)
downloadgcc-1ec9bf8aa0d0b2375e43668f4a6c186856c9dbc9.zip
gcc-1ec9bf8aa0d0b2375e43668f4a6c186856c9dbc9.tar.gz
gcc-1ec9bf8aa0d0b2375e43668f4a6c186856c9dbc9.tar.bz2
builtin-types-compatible-p.c: New.
2001-10-08 Aldy Hernandez <aldyh@redhat.com> * testsuite/gcc.c-torture/execute/builtin-types-compatible-p.c: New. * testsuite/gcc.c-torture/gcc.dg/builtin-choose-expr.c: New. From-SVN: r47797
-rw-r--r--gcc/testsuite/ChangeLog10
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/builtin-types-compatible-p.c35
-rw-r--r--gcc/testsuite/gcc.dg/builtin-choose-expr.c88
3 files changed, 133 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5e09976..1320d3c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,13 @@
+2001-10-08 Aldy Hernandez <aldyh@redhat.com>
+
+ * gcc.c-torture/execute/builtin-types-compatible-p.c: New.
+
+ * gcc.dg/builtin-choose-expr.c: New.
+
+2001-12-07 Aldy Hernandez <aldyh@redhat.com>
+
+ * gcc.dg/altivec-2.c: New.
+
2001-12-07 Richard Henderson <rth@redhat.com>
* gcc.dg/cpp/ucs.c: Adjust expected warning for 64-bit hosts.
diff --git a/gcc/testsuite/gcc.c-torture/execute/builtin-types-compatible-p.c b/gcc/testsuite/gcc.c-torture/execute/builtin-types-compatible-p.c
new file mode 100644
index 0000000..a901c72
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/builtin-types-compatible-p.c
@@ -0,0 +1,35 @@
+int i;
+double d;
+
+/* Make sure we return a constant. */
+float rootbeer[__builtin_types_compatible_p (int, typeof(i))];
+
+typedef enum { hot, dog, poo, bear } dingos;
+typedef enum { janette, laura, amanda } cranberry;
+
+typedef float same1;
+typedef float same2;
+
+int main (void);
+
+int main (void)
+{
+ /* Compatible types. */
+ if (!(__builtin_types_compatible_p (int, const int)
+ && __builtin_types_compatible_p (typeof (hot), int)
+ && __builtin_types_compatible_p (typeof (hot), typeof (laura))
+ && __builtin_types_compatible_p (int[5], int[])
+ && __builtin_types_compatible_p (typeof (dingos), typeof (cranberry))
+ && __builtin_types_compatible_p (same1, same2)))
+ abort ();
+
+ /* Incompatible types. */
+ if (__builtin_types_compatible_p (char *, int)
+ || __builtin_types_compatible_p (char *, const char *)
+ || __builtin_types_compatible_p (long double, double)
+ || __builtin_types_compatible_p (typeof (i), typeof (d))
+ || __builtin_types_compatible_p (char, int)
+ || __builtin_types_compatible_p (char *, char **))
+ abort ();
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/builtin-choose-expr.c b/gcc/testsuite/gcc.dg/builtin-choose-expr.c
new file mode 100644
index 0000000..045dc6c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/builtin-choose-expr.c
@@ -0,0 +1,88 @@
+/* { dg-do run } */
+/* { dg-options "-O1 -Wall" } */
+
+#define choose __builtin_choose_expr
+
+/* Check the type of __builtin_choose_expr between E1 and E2, both
+ ways round and with both 0 and 1 as the condition. */
+#define ASSERT_COND_TYPE(E1, E2) \
+ do { \
+ typedef __typeof(E1) T1; \
+ typedef __typeof(E2) T2; \
+ typedef T1 **T1pp; \
+ typedef T2 **T2pp; \
+ typedef __typeof(choose (1, (E1), (E2))) T1a; \
+ typedef __typeof(choose (0, (E2), (E1))) T1b; \
+ typedef __typeof(choose (1, (E2), (E1))) T2a; \
+ typedef __typeof(choose (0, (E1), (E2))) T2b; \
+ typedef T1a **T1app; \
+ typedef T1b **T1bpp; \
+ typedef T2a **T2app; \
+ typedef T2b **T2bpp; \
+ T1pp t1 = 0; \
+ T2pp t2 = 0; \
+ T1app t1a = 0; \
+ T1bpp t1b = 0; \
+ T2app t2a = 0; \
+ T2bpp t2b = 0; \
+ t1 = t1a; \
+ t1 = t1b; \
+ t2 = t2a; \
+ t2 = t2b; \
+ } while (0)
+
+
+extern void abort ();
+extern void exit ();
+
+void bad ()
+{
+ abort ();
+}
+
+void good ()
+{
+ exit (0);
+}
+
+int main (void)
+{
+ signed char sc1, sc2;
+ void *v1;
+ int i, j;
+ double dd;
+ float f;
+ typedef void (*fpt)(void);
+ fpt triple;
+ struct S { int x, y; } pour, some, sugar;
+ union u { int p; } united, nations;
+
+ if (__builtin_choose_expr (0, 12, 0)
+ || !__builtin_choose_expr (45, 5, 0)
+ || !__builtin_choose_expr (45, 3, 0))
+ abort ();
+
+ ASSERT_COND_TYPE (sc1, sc2);
+ ASSERT_COND_TYPE (v1, sc1);
+ ASSERT_COND_TYPE (i, j);
+ ASSERT_COND_TYPE (dd, main);
+ ASSERT_COND_TYPE ((float)dd, i);
+ ASSERT_COND_TYPE (4, f);
+ ASSERT_COND_TYPE (triple, some);
+ ASSERT_COND_TYPE (united, nations);
+ ASSERT_COND_TYPE (nations, main);
+
+ pour.y = 69;
+ __builtin_choose_expr (0, bad (), sugar) = pour;
+ if (sugar.y != 69)
+ abort ();
+
+ __builtin_choose_expr (sizeof (int), f, bad ()) = 3.5F;
+
+ if (f != 3.5F)
+ abort ();
+
+ __builtin_choose_expr (1, good, bad)();
+
+ exit (0);
+}