Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include statement is ignored #843

Closed
fghanim opened this issue Nov 25, 2019 · 5 comments
Closed

Include statement is ignored #843

fghanim opened this issue Nov 25, 2019 · 5 comments
Assignees

Comments

@fghanim
Copy link

fghanim commented Nov 25, 2019

Whenever a Fortran source has an include for a header file, the include statement is ignored.

  • If the header file exists, it is not included. When the -funparse command line option is used, the generated output does not contain the include.
  • If the header file does not exist, no errors are generated.
@tskeith
Copy link
Collaborator

tskeith commented Nov 25, 2019

The second point is a bug -- an error should be reported if the file is not found.

For the first one, the unparsed output is not expected to contain the include line. It contains the unparsed form of the Fortran source included from the file.

@fghanim
Copy link
Author

fghanim commented Nov 25, 2019

Maybe I should explain the first point more. The expected behavior is what you say, if you include a header file, the contents of that file is included instead.
only that's not what happens. nothing is included from that file. Not even the things that are used.

So based on that, I assumed that given that include in fortran is a statement, not a preprocessor directive. Maybe flang parsed it like other fortran statements and so it didn't replace it, with the intention that the other compiler will handle it - which means unparsing should produce it back, and that didn't happen either. and so I mentioned it.

@klausler
Copy link
Collaborator

klausler commented Nov 25, 2019

$ cat a.f90
include 'b.f90'
end
$ cat b.f90
print *, 'works'
$ f18 a.f90
$ ./a.out
 works

@sscalpone
Copy link
Member

Using Peter's example from above with the -funparse option:

% f18 -funparse a.f90
 PRINT *, "works"
END PROGRAM

@fghanim
Copy link
Author

fghanim commented Nov 25, 2019

I stand corrected. It turns out I was including a file with the wrong path. So when I didn't get an error, I mistakenly thought It was being ignored, when in reality it was just the same bug in the second point from my original post.

@klausler klausler self-assigned this Dec 3, 2019
klausler added a commit that referenced this issue Dec 3, 2019
Fix bug #843, bad recovery from failed opens of source files
@klausler klausler closed this as completed Dec 3, 2019
peterwaller-arm pushed a commit to peterwaller-arm/f18 that referenced this issue Dec 5, 2019
…files

Original merge commit: db7214e

######

Fix bug flang-compiler#843, bad recovery from failed opens of source files


Original commit: 27d9db6
-------
swift-ci pushed a commit to apple/llvm-project that referenced this issue Apr 9, 2020
swift-ci pushed a commit to apple/llvm-project that referenced this issue Apr 9, 2020
…/pmk-853

Fix bug flang-compiler/f18#843, bad recovery from failed opens of source files

Original-commit: flang-compiler/f18@db7214e
Reviewed-on: flang-compiler/f18#850
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this issue Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants