[flang-commits] [flang] 3780d3e - [flang] Use octal escapes for character literals in modfiles
Tim Keith via flang-commits
flang-commits at lists.llvm.org
Mon Jul 13 12:19:32 PDT 2020
Author: Tim Keith
Date: 2020-07-13T12:19:18-07:00
New Revision: 3780d3eb1001fd25d4b4cf953ae621a0f3b30ee5
URL: https://github.com/llvm/llvm-project/commit/3780d3eb1001fd25d4b4cf953ae621a0f3b30ee5
DIFF: https://github.com/llvm/llvm-project/commit/3780d3eb1001fd25d4b4cf953ae621a0f3b30ee5.diff
LOG: [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
Added:
Modified:
flang/lib/Semantics/mod-file.cpp
flang/lib/Semantics/mod-file.h
Removed:
################################################################################
diff --git a/flang/lib/Semantics/mod-file.cpp b/flang/lib/Semantics/mod-file.cpp
index 2f813d95f26b..6fa59f0a82a0 100644
--- a/flang/lib/Semantics/mod-file.cpp
+++ b/flang/lib/Semantics/mod-file.cpp
@@ -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"
@@ -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();
}
diff --git a/flang/lib/Semantics/mod-file.h b/flang/lib/Semantics/mod-file.h
index 8823c5f1e497..17ffe804c5be 100644
--- a/flang/lib/Semantics/mod-file.h
+++ b/flang/lib/Semantics/mod-file.h
@@ -32,7 +32,7 @@ class SemanticsContext;
class ModFileWriter {
public:
- ModFileWriter(SemanticsContext &context) : context_{context} {}
+ explicit ModFileWriter(SemanticsContext &context) : context_{context} {}
bool WriteAll();
private:
More information about the flang-commits
mailing list