Skip to content

Commit

Permalink
[flang] Use octal escapes for character literals in modfiles
Browse files Browse the repository at this point in the history
Character literals can be formatted using octal or hex escapes for
non-ascii characters. This is so that the program can be unparsed for
either pgf90 or gfortran to compile. But modfiles should not be affected
by that -- they should be consistent.

This changes causes modfiles to always have character literals formatted
with octal escapes.

Differential Revision: https://reviews.llvm.org/D83703
  • Loading branch information
tskeith committed Jul 13, 2020
1 parent 353fa44 commit 3780d3e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions flang/lib/Semantics/mod-file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "mod-file.h"
#include "resolve-names.h"
#include "flang/Common/restorer.h"
#include "flang/Evaluate/tools.h"
#include "flang/Parser/message.h"
#include "flang/Parser/parsing.h"
Expand Down Expand Up @@ -99,6 +100,9 @@ class SubprogramSymbolCollector {
};

bool ModFileWriter::WriteAll() {
// this flag affects character literals: force it to be consistent
auto restorer{
common::ScopedSet(parser::useHexadecimalEscapeSequences, false)};
WriteAll(context_.globalScope());
return !context_.AnyFatalError();
}
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Semantics/mod-file.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SemanticsContext;

class ModFileWriter {
public:
ModFileWriter(SemanticsContext &context) : context_{context} {}
explicit ModFileWriter(SemanticsContext &context) : context_{context} {}
bool WriteAll();

private:
Expand Down

0 comments on commit 3780d3e

Please sign in to comment.