Bug 1308661

Summary: [regression] GCC 6.0.0-0.11.fc24 fails to compile LLVM with "error: should have been declared inside"
Product: [Fedora] Fedora Reporter: Vedran Miletić <vedran>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: davejohansen, jakub, jason, jwakely, law, mpolacek
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-02-15 23:28:37 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
File resulting from -save-temps none

Description Vedran Miletić 2016-02-15 17:12:02 UTC
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):
6.0.0-0.11.fc24

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 17:13:43 UTC
Please attach preprocessed source (e.g. use -save-temps) and g++ options used to compile it.

Comment 2 Vedran Miletić 2016-02-15 17:55:26 UTC
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 18:02:58 UTC
Oh, and thanks for the insanely fast reply.

Comment 4 Marek Polacek 2016-02-15 18:04:46 UTC
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 23:28:37 UTC
OK, thanks for the information. I submitted a fix to LLVM: http://reviews.llvm.org/D17281

Comment 6 Marek Polacek 2016-02-15 23:38:43 UTC
Reduced:

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 06:58:50 UTC
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 19:03:26 UTC
I've checked in a patch lowering the error to a pedwarn.