Commit 3780d3eb authored by Tim Keith's avatar Tim Keith
Browse files

[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
parent 353fa440
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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();
}
+1 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ class SemanticsContext;

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

private: