Bug 1308661 - [regression] GCC 6.0.0-0.11.fc24 fails to compile LLVM with "error: should have been declared inside"
[regression] GCC 6.0.0-0.11.fc24 fails to compile LLVM with "error: should ha...
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Jakub Jelinek
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2016-02-15 12:12 EST by Vedran Miletić
Modified: 2016-02-16 14:03 EST (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2016-02-15 18:28:37 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
File resulting from -save-temps (3.11 MB, text/plain)
2016-02-15 12:55 EST, Vedran Miletić
no flags Details

  None (edit)
Description Vedran Miletić 2016-02-15 12:12:02 EST
Description of problem:
[ 67%] Building CXX object lib/Target/Hexagon/CMakeFiles/LLVMHexagonCodeGen.dir/BitTracker.cpp.o
/home/vedranm/workspace/llvm/lib/Target/Hexagon/BitTracker.cpp:87:70: error: ‘llvm::raw_ostream& llvm::operator<<(llvm::raw_ostream&, const llvm::BitTracker::BitValue&)’ should have been declared inside ‘llvm’
 raw_ostream &llvm::operator<<(raw_ostream &OS, const BT::BitValue &BV) {
/home/vedranm/workspace/llvm/lib/Target/Hexagon/BitTracker.cpp:105:74: error: ‘llvm::raw_ostream& llvm::operator<<(llvm::raw_ostream&, const llvm::BitTracker::RegisterCell&)’ should have been declared inside ‘llvm’
 raw_ostream &llvm::operator<<(raw_ostream &OS, const BT::RegisterCell &RC) {
lib/Target/Hexagon/CMakeFiles/LLVMHexagonCodeGen.dir/build.make:62: recipe for target 'lib/Target/Hexagon/CMakeFiles/LLVMHexagonCodeGen.dir/BitTracker.cpp.o' failed
make[2]: *** [lib/Target/Hexagon/CMakeFiles/LLVMHexagonCodeGen.dir/BitTracker.cpp.o] Error 1
CMakeFiles/Makefile2:6611: recipe for target 'lib/Target/Hexagon/CMakeFiles/LLVMHexagonCodeGen.dir/all' failed
make[1]: *** [lib/Target/Hexagon/CMakeFiles/LLVMHexagonCodeGen.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

Version-Release number of selected component (if applicable):

How reproducible:
Every time.

Steps to Reproduce:
Clone LLVM from Git and try to build it.

Additional info:
6.0.0-0.10.fc24 does not have the same problem.
Comment 1 Jakub Jelinek 2016-02-15 12:13:43 EST
Please attach preprocessed source (e.g. use -save-temps) and g++ options used to compile it.
Comment 2 Vedran Miletić 2016-02-15 12:55 EST
Created attachment 1127388 [details]
File resulting from -save-temps

Full command: /usr/bin/g++ -DGTEST_HAS_RTTI=0 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/vedranm/workspace/llvm/another-build/lib/Target/Hexagon -I/home/vedranm/workspace/llvm/lib/Target/Hexagon -I/home/vedranm/workspace/llvm/another-build/include -I/home/vedranm/workspace/llvm/include -save-temps -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -std=c++11 -ffunction-sections -fdata-sections -fPIC -fno-exceptions -fno-rtti -o CMakeFiles/LLVMHexagonCodeGen.dir/BitTracker.cpp.o -c /home/vedranm/workspace/llvm/lib/Target/Hexagon/BitTracker.cpp
Comment 3 Vedran Miletić 2016-02-15 13:02:58 EST
Oh, and thanks for the insanely fast reply.
Comment 4 Marek Polacek 2016-02-15 13:04:46 EST
We reject this since

commit ce20a5bdb5a7f81bb974210ae75bdde5913f60b1
Author: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Wed Feb 10 15:34:59 2016 +0000

        PR c++/69657
        * name-lookup.c (ambiguous_decl): Call remove_hidden_names.
        (lookup_name_real_1): Likewise.
        (remove_hidden_names): Handle non-functions too.
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233278 138bc75d-0d04-0410-961f-82ee72b054a4
Comment 5 Vedran Miletić 2016-02-15 18:28:37 EST
OK, thanks for the information. I submitted a fix to LLVM: http://reviews.llvm.org/D17281
Comment 6 Marek Polacek 2016-02-15 18:38:43 EST

namespace llvm {
struct A {
  struct B;
  struct C;
  friend int &operator<<(int &, const B &);
  friend int operator<<(int, C);
int &llvm::operator<<(int &, const A::B &);
Comment 7 Jakub Jelinek 2016-02-16 01:58:50 EST
I got
namespace llvm
  class A;
  void operator<<(int, A);
  struct B
    struct C;
    friend int &operator<<(int &, const C &);
int &llvm::operator<<(int &, const llvm::B::C &);

Anyway, if it is ok these testcases are rejected, perhaps we should add them to gcc testsuite.
Comment 8 Jason Merrill 2016-02-16 14:03:26 EST
I've checked in a patch lowering the error to a pedwarn.

Note You need to log in before you can comment on or make changes to this bug.