Skip to content

Commit

Permalink
[flang] Outline operator<< for CharBlock. (flang-compiler/f18#916)
Browse files Browse the repository at this point in the history
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@3ad75d1
Reviewed-on: flang-compiler/f18#916
  • Loading branch information
DavidTruby authored and sscalpone committed Jan 14, 2020
1 parent d731aef commit 05bdb54
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions flang/lib/parser/CMakeLists.txt
Expand Up @@ -9,6 +9,7 @@
add_library(FortranParser
Fortran-parsers.cc
char-buffer.cc
char-block.cc
char-set.cc
characters.cc
debug-parser.cc
Expand Down
18 changes: 18 additions & 0 deletions flang/lib/parser/char-block.cc
@@ -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();
}

}
4 changes: 1 addition & 3 deletions flang/lib/parser/char-block.h
Expand Up @@ -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);

}

Expand Down

0 comments on commit 05bdb54

Please sign in to comment.