r174050 - Added outer template parameter lists to friend type AST nodes.

Nick Lewycky nlewycky at google.com
Tue Feb 5 20:31:28 PST 2013


Hi Enea! This introduced a regression. I've attached an updated testcase to
go into clang, but the affected code looks like:

  template<typename T> class B;

  template <typename T>
  class A {
    template<typename S> friend class B<S>::ty;
  };
  template <typename T> class B {
    struct ty {};
  };

  void test() {
    (void)sizeof(A<int>);
  }

you didn't update CheckFriendTypeDecl or any of its callers.
CheckFriendTypeDecl does this:

  // C++11 [class.friend]p3:
  // A friend declaration that does not declare a function shall have one
  // of the following forms:
  // friend elaborated-type-specifier ;
  // friend simple-type-specifier ;
  // friend typename-specifier ;
  if (getLangOpts().CPlusPlus11 && LocStart != FriendLoc)
    Diag(FriendLoc, diag::err_friend_not_first_in_declaration) << T;

what happens is that LocStart now starts at the "template" keyword while
the FriendLoc is the "friend" keyword.

I'm going to try fixing it tonight, but if I can't then I might have to
revert it temporarily and please resubmit when you have this bug fixed.

Nick

On 31 January 2013 01:54, Enea Zaffanella <zaffanella at cs.unipr.it> wrote:

> Author: enea
> Date: Thu Jan 31 03:54:08 2013
> New Revision: 174050
>
> URL: http://llvm.org/viewvc/llvm-project?rev=174050&view=rev
> Log:
> Added outer template parameter lists to friend type AST nodes.
>
> Modified:
>     cfe/trunk/include/clang/AST/DeclFriend.h
>     cfe/trunk/lib/AST/DeclFriend.cpp
>     cfe/trunk/lib/AST/DeclPrinter.cpp
>     cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>     cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>     cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130205/e9a6d2b8/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: friend-template-decl-testcase-1.patch
Type: application/octet-stream
Size: 857 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130205/e9a6d2b8/attachment.obj>


More information about the cfe-commits mailing list