diff --git a/flang/lib/Semantics/mod-file.h b/flang/lib/Semantics/mod-file.h --- a/flang/lib/Semantics/mod-file.h +++ b/flang/lib/Semantics/mod-file.h @@ -32,11 +32,13 @@ class ModFileWriter { public: - ModFileWriter(SemanticsContext &context) : context_{context} {} + ModFileWriter(SemanticsContext &); + ~ModFileWriter(); bool WriteAll(); private: SemanticsContext &context_; + const bool saveUseHexadecimalEscapeSequences_; // Buffer to use with raw_string_ostream std::string usesBuf_; std::string useExtraAttrsBuf_; diff --git a/flang/lib/Semantics/mod-file.cpp b/flang/lib/Semantics/mod-file.cpp --- a/flang/lib/Semantics/mod-file.cpp +++ b/flang/lib/Semantics/mod-file.cpp @@ -98,6 +98,17 @@ } }; +ModFileWriter::ModFileWriter(SemanticsContext &context) + : context_{context}, saveUseHexadecimalEscapeSequences_{ + parser::useHexadecimalEscapeSequences} { + // this flag affects character literals: force it to be consistent + parser::useHexadecimalEscapeSequences = false; +} + +ModFileWriter::~ModFileWriter() { + parser::useHexadecimalEscapeSequences = saveUseHexadecimalEscapeSequences_; +} + bool ModFileWriter::WriteAll() { WriteAll(context_.globalScope()); return !context_.AnyFatalError();