[llvm-bugs] [Bug 32189] New: Can't find previous declaration of a template class friend declaration

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 8 18:02:40 PST 2017


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

            Bug ID: 32189
           Summary: Can't find previous declaration of a template class
                    friend declaration
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: janus926 at gmail.com
                CC: llvm-bugs at lists.llvm.org

The minimal code for reproducing:

  namespace X {
    template<class T>
    class A
    {
    };
  }

  template<class T>
  class B
  {
    template<class U> friend class ::X::A;
  };

Using command:

  clang.exe -Xclang -ast-dump -fsyntax-only test.cpp

r286542 has previous declaration of class A for the friend declaration:

  TranslationUnitDecl 0x1ffc2c75d20 <<invalid sloc>> <invalid sloc>
  |-TypedefDecl 0x1ffc2c762b0 <<invalid sloc>> <invalid sloc> implicit
__int128_t '__int128'
  | `-BuiltinType 0x1ffc2c75f90 '__int128'
  |-TypedefDecl 0x1ffc2c76318 <<invalid sloc>> <invalid sloc> implicit
__uint128_t 'unsigned __int128'
  | `-BuiltinType 0x1ffc2c75fb0 'unsigned __int128'
  |-TypedefDecl 0x1ffc2c76678 <<invalid sloc>> <invalid sloc> implicit
__NSConstantString 'struct __NSConstantString_tag'
  | `-RecordType 0x1ffc2c76400 'struct __NSConstantString_tag'
  |   `-CXXRecord 0x1ffc2c76368 '__NSConstantString_tag'
  |-CXXRecordDecl 0x1ffc2c766c8 <<invalid sloc>> <invalid sloc> implicit class
type_info
  | `-TypeVisibilityAttr 0x1ffc2c76780 <<invalid sloc>> Implicit Default
  |-TypedefDecl 0x1ffc2c767e0 <<invalid sloc>> <invalid sloc> implicit size_t
'unsigned long long'
  | `-BuiltinType 0x1ffc2c75ef0 'unsigned long long'
  |-TypedefDecl 0x1ffc2c76870 <<invalid sloc>> <invalid sloc> implicit
__builtin_ms_va_list 'char *'
  | `-PointerType 0x1ffc2c76830 'char *'
  |   `-BuiltinType 0x1ffc2c75db0 'char'
  |-TypedefDecl 0x1ffc2c768d8 <<invalid sloc>> <invalid sloc> implicit
__builtin_va_list 'char *'
  | `-PointerType 0x1ffc2c76830 'char *'
  |   `-BuiltinType 0x1ffc2c75db0 'char'
  |-NamespaceDecl 0x1ffc2c76928 <test.cpp:1:1, line:6:1> line:1:11 X
  | `-ClassTemplateDecl 0x1ffc2ccf358 <line:2:3, line:5:3> line:3:9 A
  |   |-TemplateTypeParmDecl 0x1ffc2c76990 <line:2:12, col:18> col:18 class T
  |   `-CXXRecordDecl 0x1ffc2ccf2c0 <line:3:3, line:5:3> line:3:9 class A
definition
  |     `-CXXRecordDecl 0x1ffc2ccf5c8 <col:3, col:9> col:9 implicit class A
  `-ClassTemplateDecl 0x1ffc2ccf7a8 <line:8:1, line:12:1> line:9:7 B
    |-TemplateTypeParmDecl 0x1ffc2ccf680 <line:8:10, col:16> col:16 class T
    `-CXXRecordDecl 0x1ffc2ccf710 <line:9:1, line:12:1> line:9:7 class B
definition
      |-CXXRecordDecl 0x1ffc2ccfa18 <col:1, col:7> col:7 implicit class B
      `-FriendDecl 0x1ffc2ccfcd8 <line:11:3, col:39> col:39
        `-ClassTemplateDecl 0x1ffc2ccfc68 parent 0x1ffc2c76928 prev
0x1ffc2ccf358 <col:3, col:39> col:39 A
          |-TemplateTypeParmDecl 0x1ffc2ccfab0 <col:12, col:18> col:18 class U
          `-CXXRecordDecl 0x1ffc2ccfba0 parent 0x1ffc2c76928 prev 0x1ffc2ccf2c0
<col:28, col:39> col:39 class A

r292767 does not:

  TranslationUnitDecl 0x189f677bac0 <<invalid sloc>> <invalid sloc>
  |-TypedefDecl 0x189f677c050 <<invalid sloc>> <invalid sloc> implicit
__int128_t '__int128'
  | `-BuiltinType 0x189f677bd30 '__int128'
  |-TypedefDecl 0x189f677c0b8 <<invalid sloc>> <invalid sloc> implicit
__uint128_t 'unsigned __int128'
  | `-BuiltinType 0x189f677bd50 'unsigned __int128'
  |-TypedefDecl 0x189f677c418 <<invalid sloc>> <invalid sloc> implicit
__NSConstantString 'struct __NSConstantString_tag'
  | `-RecordType 0x189f677c1a0 'struct __NSConstantString_tag'
  |   `-CXXRecord 0x189f677c108 '__NSConstantString_tag'
  |-CXXRecordDecl 0x189f677c468 <<invalid sloc>> <invalid sloc> implicit class
type_info
  | `-TypeVisibilityAttr 0x189f677c520 <<invalid sloc>> Implicit Default
  |-TypedefDecl 0x189f677c580 <<invalid sloc>> <invalid sloc> implicit size_t
'unsigned long long'
  | `-BuiltinType 0x189f677bc90 'unsigned long long'
  |-TypedefDecl 0x189f677c610 <<invalid sloc>> <invalid sloc> implicit
__builtin_ms_va_list 'char *'
  | `-PointerType 0x189f677c5d0 'char *'
  |   `-BuiltinType 0x189f677bb50 'char'
  |-TypedefDecl 0x189f677c678 <<invalid sloc>> <invalid sloc> implicit
__builtin_va_list 'char *'
  | `-PointerType 0x189f677c5d0 'char *'
  |   `-BuiltinType 0x189f677bb50 'char'
  |-NamespaceDecl 0x189f677c6c8 <test.cpp:1:1, line:6:1> line:1:11 X
  | `-ClassTemplateDecl 0x189f67d4a98 <line:2:3, line:5:3> line:3:9 A
  |   |-TemplateTypeParmDecl 0x189f677c730 <line:2:12, col:18> col:18 class T
  |   `-CXXRecordDecl 0x189f67d4a00 <line:3:3, line:5:3> line:3:9 class A
definition
  |     `-CXXRecordDecl 0x189f67d4d08 <col:3, col:9> col:9 implicit class A
  `-ClassTemplateDecl 0x189f67d4ee8 <line:8:1, line:12:1> line:9:7 B
    |-TemplateTypeParmDecl 0x189f67d4dc0 <line:8:10, col:16> col:16 class T
    `-CXXRecordDecl 0x189f67d4e50 <line:9:1, line:12:1> line:9:7 class B
definition
      |-CXXRecordDecl 0x189f67d5158 <col:1, col:7> col:7 implicit class B
      `-FriendDecl 0x189f67d55d8 <line:11:3, col:39> col:39
        `-ClassTemplateDecl 0x189f67d53a8 parent 0x189f677c6c8 <col:3, col:39>
col:39 A
          |-TemplateTypeParmDecl 0x189f67d51f0 <col:12, col:18> col:18 class U
          `-CXXRecordDecl 0x189f67d52e0 parent 0x189f677c6c8 <col:28, col:39>
col:39 class A

I don't know this starts from which revision, but r292767 is the earliest one I
have on my machine.

-- 
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/20170309/c836ae19/attachment.html>


More information about the llvm-bugs mailing list