summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/dfp/composite-type.c
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.dg/dfp/composite-type.c
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gcc.dg/dfp/composite-type.c')
-rw-r--r--gcc/testsuite/gcc.dg/dfp/composite-type.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/dfp/composite-type.c b/gcc/testsuite/gcc.dg/dfp/composite-type.c
new file mode 100644
index 000000000..69ecb1421
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/dfp/composite-type.c
@@ -0,0 +1,55 @@
+/* { dg-do compile } */
+/* { dg-options "-O -Wall" } */
+
+/* C99 6.2.7: Compatible type and composite type. */
+
+#define DECIMAL_COMPOSITE_DECL(TYPE) \
+ _Decimal##TYPE g1_##TYPE(); \
+ _Decimal##TYPE g2_##TYPE(); \
+ _Decimal##TYPE (*h1_##TYPE)[2]; \
+ _Decimal##TYPE (*h2_##TYPE)[3]; \
+ _Decimal##TYPE (*h3_##TYPE)[4]; \
+ _Decimal##TYPE f1_##TYPE(_Decimal##TYPE(*)()); \
+ _Decimal##TYPE f1_##TYPE(_Decimal##TYPE(*)(_Decimal##TYPE*)); \
+ _Decimal##TYPE f1_##TYPE (_Decimal##TYPE(*g)(_Decimal##TYPE*)) \
+ { \
+ _Decimal##TYPE d##TYPE; \
+ d##TYPE = ((_Decimal##TYPE (*) (_Decimal##TYPE*)) g)(&d##TYPE); \
+ d##TYPE = ((_Decimal##TYPE (*) ()) g); \
+ return d##TYPE; \
+ } \
+ _Decimal##TYPE f2_##TYPE(_Decimal##TYPE(*)[]); \
+ _Decimal##TYPE f2_##TYPE(_Decimal##TYPE(*)[3]);
+
+#define DECIMAL_COMPOSITE_TEST(TYPE) \
+do \
+{ \
+ _Decimal##TYPE d##TYPE; \
+ d##TYPE = f1_##TYPE(g1_##TYPE); \
+ d##TYPE = f1_##TYPE(g2_##TYPE); \
+ d##TYPE = f2_##TYPE(h1_##TYPE); \
+ d##TYPE = f2_##TYPE(h2_##TYPE); \
+ d##TYPE = f2_##TYPE(h3_##TYPE); \
+ (void) d##TYPE; \
+} while(0)
+
+DECIMAL_COMPOSITE_DECL(32); /* { dg-error "incompatible types when assigning to type '\[^\n\]*' from type '\[^\n\]*'" } */
+/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } 36 } */
+
+
+DECIMAL_COMPOSITE_DECL(64); /* { dg-error "incompatible types when assigning to type '\[^\n\]*' from type '\[^\n\]*'" } */
+/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } 40 } */
+
+
+DECIMAL_COMPOSITE_DECL(128); /* { dg-error "incompatible types when assigning to type '\[^\n\]*' from type '\[^\n\]*'" } */
+/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } 44 } */
+
+
+int main()
+{
+ DECIMAL_COMPOSITE_TEST(32); /* { dg-warning "incompatible pointer type" } */
+ DECIMAL_COMPOSITE_TEST(64); /* { dg-warning "incompatible pointer type" } */
+ DECIMAL_COMPOSITE_TEST(128); /* { dg-warning "incompatible pointer type" } */
+
+ return 0;
+}