+2019-05-12 Janne Blomqvist <jb@gcc.gnu.org>
+
+ * dump-parse-tree.c (get_c_type_name): Use macros for complex type
+ names.
+ * parse.c (gfc_parse_file): Define complex macros, add CPP support
+ when printing C prototypes.
+
2019-05-10 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/61968
else if (strcmp (*type_name, "size_t") == 0)
*type_name = "ssize_t";
else if (strcmp (*type_name, "float_complex") == 0)
- *type_name = "float complex";
+ *type_name = "__GFORTRAN_FLOAT_COMPLEX";
else if (strcmp (*type_name, "double_complex") == 0)
- *type_name = "double complex";
+ *type_name = "__GFORTRAN_DOUBLE_COMPLEX";
else if (strcmp (*type_name, "long_double_complex") == 0)
- *type_name = "long double complex";
+ *type_name = "__GFORTRAN_LONG_DOUBLE_COMPLEX";
ret = T_OK;
}
else if (strcmp (*type_name, "size_t") == 0)
*type_name = "ssize_t";
else if (strcmp (*type_name, "float_complex") == 0)
- *type_name = "float complex";
+ *type_name = "__GFORTRAN_FLOAT_COMPLEX";
else if (strcmp (*type_name, "double_complex") == 0)
- *type_name = "double complex";
+ *type_name = "__GFORTRAN_DOUBLE_COMPLEX";
else if (strcmp (*type_name, "long_double_complex") == 0)
- *type_name = "long double complex";
+ *type_name = "__GFORTRAN_LONG_DOUBLE_COMPLEX";
ret = T_WARN;
break;
}
/* Dump C prototypes. */
+ if (flag_c_prototypes || flag_c_prototypes_external)
+ {
+ fprintf (stdout,
+ _("#include <stddef.h>\n"
+ "#ifdef __cplusplus\n"
+ "#include <complex>\n"
+ "#define __GFORTRAN_FLOAT_COMPLEX std::complex<float>\n"
+ "#define __GFORTRAN_DOUBLE_COMPLEX std::complex<double>\n"
+ "#define __GFORTRAN_LONG_DOUBLE_COMPLEX std::complex<long double>\n"
+ "extern \"C\" {\n"
+ "#else\n"
+ "#define __GFORTRAN_FLOAT_COMPLEX float _Complex\n"
+ "#define __GFORTRAN_DOUBLE_COMPLEX double _Complex\n"
+ "#define __GFORTRAN_LONG_DOUBLE_COMPLEX long double _Complex\n"
+ "#endif\n\n"));
+ }
+
+ /* First dump BIND(C) prototypes. */
if (flag_c_prototypes)
{
for (gfc_current_ns = gfc_global_ns_list; gfc_current_ns;
if (flag_c_prototypes_external)
gfc_dump_external_c_prototypes (stdout);
+ if (flag_c_prototypes || flag_c_prototypes_external)
+ fprintf (stdout,
+ _("\n#ifdef __cplusplus\n}\n#endif\n"));
+
/* Do the translation. */
translate_all_program_units (gfc_global_ns_list);