Skip to content

Commit 3780d3e

Browse files
committed
[flang] Use octal escapes for character literals in modfiles
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
1 parent 353fa44 commit 3780d3e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

flang/lib/Semantics/mod-file.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "mod-file.h"
1010
#include "resolve-names.h"
11+
#include "flang/Common/restorer.h"
1112
#include "flang/Evaluate/tools.h"
1213
#include "flang/Parser/message.h"
1314
#include "flang/Parser/parsing.h"
@@ -99,6 +100,9 @@ class SubprogramSymbolCollector {
99100
};
100101

101102
bool ModFileWriter::WriteAll() {
103+
// this flag affects character literals: force it to be consistent
104+
auto restorer{
105+
common::ScopedSet(parser::useHexadecimalEscapeSequences, false)};
102106
WriteAll(context_.globalScope());
103107
return !context_.AnyFatalError();
104108
}

flang/lib/Semantics/mod-file.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class SemanticsContext;
3232

3333
class ModFileWriter {
3434
public:
35-
ModFileWriter(SemanticsContext &context) : context_{context} {}
35+
explicit ModFileWriter(SemanticsContext &context) : context_{context} {}
3636
bool WriteAll();
3737

3838
private:

0 commit comments

Comments
 (0)