Hi Thomas,
On 5/11/25 10:34, Thomas Koenig via Gcc wrote:
As PR120139 has shown (again), it is too easy to create regressions
for dumping C prototypes from Fortran. The main problem
is that there is currently no test in the testsuite.
So, what to do? I see several possibilities:
1a) Change the relevant options so that they optionally
create a file (something like -fc-prototypes=filename.h)
and then scan for the presence/absence of patterns in that
file. (Is it OK just to open and close a file anywhere
in the front end?). The generated files should then be
removed afterwards (how?).
1b) Instead of checking for patterns in the output create a header file
which is then included in a C file for testing. Same questions
as above, with the additional question on how to ensure that
compilation of the C file only happens after the header file
has been generated.
2) Dump to standard output and check for the presence of certain
regexps, ignoring anything else. Again, this is something I don't
know how to do.
for something along this variant you can try multiline-output
as in the attached sample.
There may be better ways...
Cheers,
Harald
This is really something I would like to have fixed for gcc-16.
Other ideas? Comments? Suggestions?
Best regards
Thomas
! { dg-options "-fc-prototypes" }
subroutine foo (x, k) bind(c)
integer, value :: k
real :: x(k)
end
#if 0
{ dg-begin-multiline-output "" }
#include <stddef.h>
#ifdef __cplusplus
#include <complex>
#define __GFORTRAN_FLOAT_COMPLEX std::complex<float>
#define __GFORTRAN_DOUBLE_COMPLEX std::complex<double>
#define __GFORTRAN_LONG_DOUBLE_COMPLEX std::complex<long double>
extern "C" {
#else
#define __GFORTRAN_FLOAT_COMPLEX float _Complex
#define __GFORTRAN_DOUBLE_COMPLEX double _Complex
#define __GFORTRAN_LONG_DOUBLE_COMPLEX long double _Complex
#endif
void foo (float x /* WARNING: non-interoperable KIND */ , int k /* WARNING: non-interoperable KIND */ );
#ifdef __cplusplus
}
#endif
{ dg-end-multiline-output "" }
#endif