Skip to content

[FLANG] Fix for issue #127426 #150008

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions flang/lib/Parser/prescan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void Prescanner::Statement() {
EmitChar(tokens, '!');
++at_, ++column_;
for (const char *sp{directiveSentinel_}; *sp != '\0';
++sp, ++at_, ++column_) {
++sp, ++at_, ++column_) {
EmitChar(tokens, *sp);
}
if (inFixedForm_) {
Expand Down Expand Up @@ -435,6 +435,7 @@ void Prescanner::LabelField(TokenSequence &token) {
int outCol{1};
const char *start{at_};
std::optional<int> badColumn;
SkipCComments();
for (; *at_ != '\n' && column_ <= 6; ++at_) {
if (*at_ == '\t') {
++at_;
Expand Down Expand Up @@ -1218,7 +1219,7 @@ std::optional<std::size_t> Prescanner::IsIncludeLine(const char *start) const {
}
if (IsDecimalDigit(*p)) { // accept & ignore a numeric kind prefix
for (p = SkipWhiteSpace(p + 1); IsDecimalDigit(*p);
p = SkipWhiteSpace(p + 1)) {
p = SkipWhiteSpace(p + 1)) {
}
if (*p != '_') {
return std::nullopt;
Expand Down Expand Up @@ -1266,7 +1267,7 @@ void Prescanner::FortranInclude(const char *firstQuote) {
llvm::raw_string_ostream error{buf};
Provenance provenance{GetProvenance(nextLine_)};
std::optional<std::string> prependPath;
if (const SourceFile * currentFile{allSources_.GetSourceFile(provenance)}) {
if (const SourceFile *currentFile{allSources_.GetSourceFile(provenance)}) {
prependPath = DirectoryName(currentFile->path());
}
const SourceFile *included{
Expand Down
4 changes: 4 additions & 0 deletions flang/test/Parser/inc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Old-style C comments
* Comments
*/
#define VAL 1
14 changes: 14 additions & 0 deletions flang/test/Parser/test.F
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
! RUN: %flang_fc1 -fdebug-unparse-no-sema %s 2>&1 | FileCheck %s

! CHECK: SUBROUTINE foo
! CHECK: INTEGER i
! CHECK: i = 1
! CHECK: PRINT *, i
! CHECK: END SUBROUTINE foo

subroutine foo()
#include "inc.h"
integer :: i
i = VAL
print *, i
end subroutine foo
Loading