-
Notifications
You must be signed in to change notification settings - Fork 17k
[flang] Main program symbol no longer conflicts with the other symbols #149169
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
Changes from 12 commits
f7cc4e8
336c138
f6507f5
632cd4b
ce7b837
3e3d5d4
cbc5e33
7b1df7b
37dbcbf
8cd6fa1
103af16
cbb6ec9
13b2ec4
82f1fc2
2c8950c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -489,15 +489,32 @@ class ParseTreeAnalyzer { | |
|
|
||
| // C1401 | ||
| void Post(const parser::MainProgram &mainProgram) { | ||
| if (const parser::CharBlock * | ||
| endName{GetStmtName(std::get<parser::Statement<parser::EndProgramStmt>>( | ||
| mainProgram.t))}) { | ||
| if (const auto &program{ | ||
| std::get<std::optional<parser::Statement<parser::ProgramStmt>>>( | ||
| mainProgram.t)}) { | ||
| if (*endName != program->statement.v.source) { | ||
| // Uppercase the name of the main program, so that its symbol name | ||
| // would be unique from similarly named non-main-program symbols. | ||
| auto upperCaseCharBlock = [](const parser::CharBlock &cb) { | ||
| char *ch = const_cast<char *>(cb.begin()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please always use braced initialization in the bits of flang-new that are modern C++. |
||
| char *endCh = ch + cb.size(); | ||
| while (ch != endCh) { | ||
| *ch++ = parser::ToUpperCaseLetter(*ch); | ||
| } | ||
| }; | ||
| const parser::CharBlock *progName{nullptr}; | ||
| if (const auto &program{ | ||
| std::get<std::optional<parser::Statement<parser::ProgramStmt>>>( | ||
| mainProgram.t)}) { | ||
| progName = &program->statement.v.source; | ||
| } | ||
| if (progName) { | ||
| upperCaseCharBlock(*progName); | ||
| } | ||
| const parser::CharBlock *endName{GetStmtName( | ||
| std::get<parser::Statement<parser::EndProgramStmt>>(mainProgram.t))}; | ||
| if (endName) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these two |
||
| upperCaseCharBlock(*endName); | ||
| if (progName) { | ||
| if (*endName != *progName) { | ||
| context_.Say(*endName, "END PROGRAM name mismatch"_err_en_US) | ||
| .Attach(program->statement.v.source, "should be"_en_US); | ||
| .Attach(*progName, "should be"_en_US); | ||
| } | ||
| } else { | ||
| context_.Say(*endName, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.