From 3780d3eb1001fd25d4b4cf953ae621a0f3b30ee5 Mon Sep 17 00:00:00 2001 From: Tim Keith Date: Mon, 13 Jul 2020 12:19:17 -0700 Subject: [PATCH] [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 --- flang/lib/Semantics/mod-file.cpp | 4 ++++ flang/lib/Semantics/mod-file.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/flang/lib/Semantics/mod-file.cpp b/flang/lib/Semantics/mod-file.cpp index 2f813d9..6fa59f0 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 @@ private: }; 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 8823c5f..17ffe804 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: -- 2.7.4