summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/value_4.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/gfortran.dg/value_4.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/gfortran.dg/value_4.c')
-rw-r--r--gcc/testsuite/gfortran.dg/value_4.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/value_4.c b/gcc/testsuite/gfortran.dg/value_4.c
new file mode 100644
index 000000000..a9f9aae23
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/value_4.c
@@ -0,0 +1,49 @@
+/* Passing from fortran to C by value, using VALUE. This is identical
+ to c_by_val_1.c, which performs the same function for %VAL.
+
+ Contributed by Paul Thomas <pault@gcc.gnu.org> */
+
+/* We used to #include <complex.h>, but this fails for some platforms
+ (like cygwin) who don't have it yet. */
+#define complex __complex__
+#define _Complex_I (1.0iF)
+
+extern float *f_to_f__ (float, float*);
+extern int *i_to_i__ (int, int*);
+extern void c_to_c__ (complex float*, complex float, complex float*);
+extern void abort (void);
+
+/* In f_to_f and i_to_i we return the second argument, so that we do
+ not have to worry about keeping track of memory allocation between
+ fortran and C. All three functions check that the argument passed
+ by value is the same as that passed by reference. Then the passed
+ by value argument is modified so that the caller can check that
+ its version has not changed.*/
+
+float *
+f_to_f__(float a1, float *a2)
+{
+ if ( a1 != *a2 ) abort();
+ *a2 = a1 * 2.0;
+ a1 = 0.0;
+ return a2;
+}
+
+int *
+i_to_i__(int i1, int *i2)
+{
+ if ( i1 != *i2 ) abort();
+ *i2 = i1 * 3;
+ i1 = 0;
+ return i2;
+}
+
+void
+c_to_c__(complex float *retval, complex float c1, complex float *c2)
+{
+ if ( c1 != *c2 ) abort();
+ c1 = 0.0 + 0.0 * _Complex_I;
+ *retval = *c2 * 4.0;
+ return;
+}
+