'static' case dropped, as this is not the right place for it. This fixes the 
case with 'friend' specifier only.

Hi rsmith, rjmccall,

http://llvm-reviews.chandlerc.com/D468

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D468?vs=1118&id=1250#toc

Files:
  lib/Parse/ParseDecl.cpp
  test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp

Index: lib/Parse/ParseDecl.cpp
===================================================================
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -4833,12 +4833,14 @@
       //   "pointer to cv-qualifier-seq X" between the optional cv-qualifer-seq
       //   and the end of the function-definition, member-declarator, or
       //   declarator.
+      bool IsMemberContext = D.getContext() == Declarator::MemberContext;
       bool IsCXX11MemberFunction =
         getLangOpts().CPlusPlus11 &&
-        (D.getContext() == Declarator::MemberContext ||
+        (IsMemberContext ||
          (D.getContext() == Declarator::FileContext &&
           D.getCXXScopeSpec().isValid() &&
-          Actions.CurContext->isRecord()));
+          Actions.CurContext->isRecord())) &&
+        !(IsMemberContext && D.getDeclSpec().isFriendSpecified());
       Sema::CXXThisScopeRAII ThisScope(Actions,
                                dyn_cast<CXXRecordDecl>(Actions.CurContext),
                                DS.getTypeQualifiers() |
Index: test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp
===================================================================
--- test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp
+++ test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp
@@ -61,6 +61,22 @@
   }
 }
 
+namespace PR15290 {
+  template<typename T>
+  class A {
+    T v_;
+    friend int add_to_v(A &t) noexcept(noexcept(v_ + 42))
+    {
+      return t.v_ + 42;
+    }
+  };
+  void f()
+  {
+    A<int> t;
+    add_to_v(t);
+  }
+}
+
 namespace Static {
   struct X1 {
     int m;
Index: lib/Parse/ParseDecl.cpp
===================================================================
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -4833,12 +4833,14 @@
       //   "pointer to cv-qualifier-seq X" between the optional cv-qualifer-seq
       //   and the end of the function-definition, member-declarator, or
       //   declarator.
+      bool IsMemberContext = D.getContext() == Declarator::MemberContext;
       bool IsCXX11MemberFunction =
         getLangOpts().CPlusPlus11 &&
-        (D.getContext() == Declarator::MemberContext ||
+        (IsMemberContext ||
          (D.getContext() == Declarator::FileContext &&
           D.getCXXScopeSpec().isValid() &&
-          Actions.CurContext->isRecord()));
+          Actions.CurContext->isRecord())) &&
+        !(IsMemberContext && D.getDeclSpec().isFriendSpecified());
       Sema::CXXThisScopeRAII ThisScope(Actions,
                                dyn_cast<CXXRecordDecl>(Actions.CurContext),
                                DS.getTypeQualifiers() |
Index: test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp
===================================================================
--- test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp
+++ test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp
@@ -61,6 +61,22 @@
   }
 }
 
+namespace PR15290 {
+  template<typename T>
+  class A {
+    T v_;
+    friend int add_to_v(A &t) noexcept(noexcept(v_ + 42))
+    {
+      return t.v_ + 42;
+    }
+  };
+  void f()
+  {
+    A<int> t;
+    add_to_v(t);
+  }
+}
+
 namespace Static {
   struct X1 {
     int m;
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to