[flang] Outline operator<< for CharBlock. (flang-compiler/f18#916)
authorDavid Truby <david.truby@arm.com>
Tue, 14 Jan 2020 06:08:56 +0000 (06:08 +0000)
committerSteve Scalpone <sscalpone@nvidia.com>
Tue, 14 Jan 2020 06:08:56 +0000 (22:08 -0800)
This fixes an issue where the Dump function definitions in dump.cc
were relying on the forward declaration of operator<< for CharBlock
which was marked inline and only present in char-block.h.

This is not allowed under section 6.2.10 of the C++17 standard, and
caused a compilation failure when building with clang 9 as this was
inlining every use of the function and therefore not generating an
outlined definition for linking.

Original-commit: flang-compiler/f18@3ad75d123b666a5081540f2afedbedde930b2518
Reviewed-on: https://github.com/flang-compiler/f18/pull/916

flang/lib/parser/CMakeLists.txt
flang/lib/parser/char-block.cc [new file with mode: 0644]
flang/lib/parser/char-block.h

index feff5ef..9630601 100644 (file)
@@ -9,6 +9,7 @@
 add_library(FortranParser
   Fortran-parsers.cc
   char-buffer.cc
+  char-block.cc
   char-set.cc
   characters.cc
   debug-parser.cc
diff --git a/flang/lib/parser/char-block.cc b/flang/lib/parser/char-block.cc
new file mode 100644 (file)
index 0000000..e8254d0
--- /dev/null
@@ -0,0 +1,18 @@
+//===-- lib/parser/char-block.cc --------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//----------------------------------------------------------------------------//
+
+#include "char-block.h"
+#include <ostream>
+
+namespace Fortran::parser {
+
+std::ostream &operator<<(std::ostream &os, const CharBlock &x) {
+  return os << x.ToString();
+}
+
+}
index 7a234a1..3f5585e 100644 (file)
@@ -134,9 +134,7 @@ inline bool operator>(const char *left, const CharBlock &right) {
   return right < left;
 }
 
-inline std::ostream &operator<<(std::ostream &os, const CharBlock &x) {
-  return os << x.ToString();
-}
+std::ostream &operator<<(std::ostream &os, const CharBlock &x);
 
 }