if (!gfc_cpp_enabled ())
return false;
+ if (gfc_option.flag_preprocessed)
+ {
+ if (gfc_cpp_preprocess_only ())
+ gfc_fatal_error ("%<-E%> is not supported with %<-fpreprocessed%>");
+ return false;
+ }
+
cpp_change_file (cpp_in, LC_RENAME, source_file);
if (cpp_option->traditional)
static bool
gfc_init (void)
{
- if (!gfc_cpp_enabled ())
+ if (!gfc_cpp_enabled () || gfc_option.flag_preprocessed)
{
linemap_add (line_table, LC_ENTER, false, gfc_source_file, 1);
linemap_add (line_table, LC_RENAME, false, special_fname_builtin (), 0);
gfc_init_decl_processing ();
gfc_static_ctors = NULL_TREE;
- if (gfc_cpp_enabled ())
+ if (gfc_cpp_enabled () && !gfc_option.flag_preprocessed)
gfc_cpp_init ();
gfc_init_1 ();
preprocessing on files where the preprocessor is run automatically, use
@option{-nocpp}.
+When compiling a preprocessed file, use @option{-fpreprocessed}
+(@pxref{Preprocessor Options,,Options Controlling the Preprocessor,gcc,
+Using the GNU Compiler Collection (GCC)}). This skips the C preprocessor.
+
If a preprocessed file includes another file with the Fortran @code{INCLUDE}
statement, the included file is not preprocessed. To preprocess included
files, use the equivalent preprocessor statement @code{#include}.
if (gfc_cpp_enabled ())
{
- gfc_cpp_preprocess (gfc_source_file);
- if (!gfc_cpp_preprocess_only ())
- load_file (gfc_cpp_temporary_file (), gfc_source_file, true);
+ if (gfc_cpp_preprocess (gfc_source_file))
+ {
+ if (!gfc_cpp_preprocess_only ())
+ load_file (gfc_cpp_temporary_file (), gfc_source_file, true);
+ }
+ else
+ load_file (gfc_source_file, NULL, true);
}
else
load_file (gfc_source_file, NULL, true);
--- /dev/null
+# 1 "<test>"
+# 1 "<built-in>"
+# 1 "<command-line>"
+# 1 "<test>"
+! PR fortran/92613
+! { dg-do compile }
+! { dg-options "-cpp -fpreprocessed" }
+program test
+ implicit none
+ write(6,*) 'hello'
+! Comment with apostrophe: it's good!
+! Comment with double quote: "quoted"
+end program
--- /dev/null
+# 1 "<test>"
+# 1 "<built-in>"
+# 1 "<command-line>"
+# 1 "<test>"
+! PR fortran/92613
+! { dg-do preprocess }
+! { dg-options "-cpp -fpreprocessed" }
+! { dg-error ".-E. is not supported with .-fpreprocessed." "" { target *-*-* } 0 }
+! { dg-prune-output "compilation terminated" }
+program test
+end program