summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/bind_c_dts_driver.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/bind_c_dts_driver.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/bind_c_dts_driver.c')
-rw-r--r--gcc/testsuite/gfortran.dg/bind_c_dts_driver.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/bind_c_dts_driver.c b/gcc/testsuite/gfortran.dg/bind_c_dts_driver.c
new file mode 100644
index 000000000..bf076ce4a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/bind_c_dts_driver.c
@@ -0,0 +1,66 @@
+double fabs (double);
+
+/* interops with myftype_1 */
+typedef struct {
+ int m, n;
+ float r;
+} myctype_t;
+
+/* interops with particle in f90 */
+typedef struct particle
+{
+ double x; /* x position */
+ double vx; /* velocity in x direction */
+ double y; /* y position */
+ double vy; /* velocity in y direction */
+ double z; /* z position */
+ double vz; /* velocity in z direction */
+ double m; /* mass */
+}particle_t;
+
+extern void abort(void);
+void types_test(particle_t *my_particles, int num_particles);
+/* declared in the fortran module bind_c_dts */
+extern myctype_t myDerived;
+
+int main(int argc, char **argv)
+{
+ particle_t my_particles[100];
+
+ /* the fortran code will modify the middle particle */
+ my_particles[49].x = 1.0;
+ my_particles[49].vx = 1.0;
+ my_particles[49].y = 1.0;
+ my_particles[49].vy = 1.0;
+ my_particles[49].z = 1.0;
+ my_particles[49].vz = 1.0;
+ my_particles[49].m = 1.0;
+
+ myDerived.m = 1;
+ myDerived.n = 2;
+ myDerived.r = 3.0;
+
+ types_test(&(my_particles[0]), 100);
+
+ if(fabs(my_particles[49].x - 1.2) > 0.00000000)
+ abort();
+ if(fabs(my_particles[49].vx - 1.2) > 0.00000000)
+ abort();
+ if(fabs(my_particles[49].y - 1.2) > 0.00000000)
+ abort();
+ if(fabs(my_particles[49].vy - 1.2) > 0.00000000)
+ abort();
+ if(fabs(my_particles[49].z - 1.2) > 0.00000000)
+ abort();
+ if(fabs(my_particles[49].vz - 1.2) > 0.00000000)
+ abort();
+ if(fabs(my_particles[49].m - 1.2) > 0.00000000)
+ abort();
+ if(myDerived.m != 2)
+ abort();
+ if(myDerived.n != 3)
+ abort();
+ if(fabs(myDerived.r - 4.0) > 0.00000000)
+ abort();
+ return 0;
+}/* end main() */