+ if (gfc_option.flag_preprocessed)
+ {
+ /* For preprocessed files, if the first tokens are of the form # NUM.
+ handle the directives so we know the original file name. */
+ gfc_source_file = gfc_read_orig_filename (filename, &canon_source_file);
+ if (gfc_source_file == NULL)
+ gfc_source_file = filename;
+ else
+ *pfilename = gfc_source_file;
+ }
+ else
+ gfc_source_file = filename;
+
+ if (canon_source_file == NULL)
+ canon_source_file = gfc_source_file;
+
+ /* Adds the path where the source file is to the list of include files. */
+
+ i = strlen (canon_source_file);
+ while (i > 0 && !IS_DIR_SEPARATOR (canon_source_file[i]))
+ i--;
+ if (i != 0)
+ {
+ source_path = alloca (i + 1);
+ memcpy (source_path, canon_source_file, i);
+ source_path[i] = 0;
+ gfc_add_include_path (source_path);
+ }
+ else
+ gfc_add_include_path (".");
+
+ if (canon_source_file != gfc_source_file)
+ gfc_free ((void *) canon_source_file);
+
+ /* Decide which form the file will be read in as. */
+
+ if (gfc_option.source_form != FORM_UNKNOWN)
+ gfc_current_form = gfc_option.source_form;
+ else
+ {
+ gfc_current_form = form_from_filename (filename);
+
+ if (gfc_current_form == FORM_UNKNOWN)
+ {
+ gfc_current_form = FORM_FREE;
+ gfc_warning_now ("Reading file '%s' as free form.",
+ (filename[0] == '\0') ? "<stdin>" : filename);
+ }
+ }
+
+ /* If the user specified -fd-lines-as-{code|comments} verify that we're
+ in fixed form. */
+ if (gfc_current_form == FORM_FREE)
+ {
+ if (gfc_option.flag_d_lines == 0)
+ gfc_warning_now ("'-fd-lines-as-comments' has no effect "
+ "in free form.");
+ else if (gfc_option.flag_d_lines == 1)
+ gfc_warning_now ("'-fd-lines-as-code' has no effect "
+ "in free form.");
+ }