[llvm-bugs] [Bug 28404] New: clang rejects valid C++ code with nested template classes

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jul 3 00:11:44 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=28404

            Bug ID: 28404
           Summary: clang rejects valid C++ code with nested template
                    classes
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: su at cs.ucdavis.edu
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

The current clang trunk rejects the following valid C++ test case (which is
accepted by GCC) on x86_64-linux-gnu in both 32-bit and 64-bit modes. 

It is accepted by 3.1, and rejected by 3.2 and later. 


$ clang++-trunk -v
clang version 3.9.0 (trunk 274430)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/tools/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.1.1
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$ 
$ g++-6.1 -c -Wall -Wextra -pedantic -std=c++11 small.cpp
$ 
$ clang++-trunk -c -std=c++11 small.cpp
small.cpp:10:27: warning: dependent nested name specifier 'A<X>::B::' for
friend class declaration is not supported; turning off access control for 'S'
[-Wunsupported-friend]
  friend void A < X >::B::operator= (Y);
              ~~~~~~~~~~~~^
small.cpp:10:24: error: no member 'A' in 'S<int>'; it has not yet been
instantiated
  friend void A < X >::B::operator= (Y);
                       ^
small.cpp:13:11: note: in instantiation of template class 'S<int>' requested
here
S < int > s; 
          ^
small.cpp:3:29: note: not-yet-instantiated member is declared here
  template < class > struct A
                            ^
1 warning and 1 error generated.
$ 


----------------------------------------------


template < class > struct S
{
  template < class > struct A
  {
    struct B {};
  };

  template < class X > 
  template < class Y > 
  friend void A < X >::B::operator= (Y);
};

S < int > s;

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160703/d59e113b/attachment.html>


More information about the llvm-bugs mailing list