Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

No dump output for programs with semantic errors #51064

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR52097
Status NEW
Importance P enhancement
Reported by Peter Steinfeld (psteinfeld@nvidia.com)
Reported on 2021-10-06 11:36:09 -0700
Last modified on 2021-10-07 13:56:32 -0700
Version unspecified
Hardware PC Windows NT
CC andrzej.warzynski@gmail.com, David.Truby@arm.com, jperier@nvidia.com, kirankumartp@gmail.com, llvm-bugs@lists.llvm.org, sscalpone@nvidia.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
If I invoke the front end on a program with a semantic error and ask it to dump
the symbol table or the parse tree, no dump output appears.

Here's an example program with a semantic error:

program bad
  real,pointer :: x
  x = null()      ! Error - must be pointer assignment
end

If this program is in the file "bad.f90", and I invoke the compiler as follows:

flang-new -fc1 -fdebug-dump-all -I include/flang

I don't get any dump output.  Rather I only get the following messages:

error: Semantic errors in bad.f90
./bad.f90:3:3: error: A NULL() pointer is not allowed in a non-pointer
intrinsic assignment statement
    x = null()      ! Error - must be pointer assignment
    ^^^^^^^^^^
Also, no messages appear that indicate that dumping was skipped.
Quuxplusone commented 3 years ago

Thank you for reporting this, Pete!

Currently, in the presence of semantic errors, the front-end driver will skip the ExecuteAction method corresponding to your action flag. For -fdebug-dump-all that's DebugDumpAllAction::ExecuteAction. It is skipped, because BeginSourceFile for this action [2] returns false when semantic errors are encountered.

This can be relaxed, see https://reviews.llvm.org/D111308. But we should be careful here. Flang lacks a central mechanism to control what happens in presence of errors. If it's implemented on an option-by-option basis, it might become hard to track/control/maintain. It would be great to have some diagnostics engine that would manage this for us. One day!

In the meantime, please try https://reviews.llvm.org/D11130. What are your thoughts?

-Andrzej

[1] https://github.com/llvm/llvm-project/blob/main/flang/lib/Frontend/FrontendActions.cpp#L184-L216 [2] https://github.com/llvm/llvm-project/blob/main/flang/lib/Frontend/FrontendActions.cpp#L39-L41

Quuxplusone commented 3 years ago

Thanks, Andrzej.

I just approved https://reviews.llvm.org/D111308.

I don't follow your reference to https://reviews.llvm.org/D11130. It doesn't seem to have anything to do with this issue. Is this the correct number?

Quuxplusone commented 3 years ago

Sorry, that was a copy&paste error, I meant https://reviews.llvm.org/D111308 instead of https://reviews.llvm.org/D11130. It's the same revision that you've just approved.

-Andrzej