[llvm-branch-commits] [cfe-branch] r120665 - in /cfe/branches/Apple/whitney: lib/Sema/SemaExpr.cpp test/SemaCXX/friend.cpp
Daniel Dunbar
daniel at zuster.org
Wed Dec 1 18:52:15 PST 2010
Author: ddunbar
Date: Wed Dec 1 20:52:15 2010
New Revision: 120665
URL: http://llvm.org/viewvc/llvm-project?rev=120665&view=rev
Log:
Merge r120299:
--
Author: Nico Weber <nicolasweber at gmx.de>
Date: Mon Nov 29 18:19:25 2010 +0000
Always use a function's decl context when building default arguments. Fixes http://http://llvm.org/pr8479.
Modified:
cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp
cfe/branches/Apple/whitney/test/SemaCXX/friend.cpp
Modified: cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp?rev=120665&r1=120664&r2=120665&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp (original)
+++ cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp Wed Dec 1 20:52:15 2010
@@ -3477,8 +3477,8 @@
}
ExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc,
- FunctionDecl *FD,
- ParmVarDecl *Param) {
+ FunctionDecl *FD,
+ ParmVarDecl *Param) {
if (Param->hasUnparsedDefaultArg()) {
Diag(CallLoc,
diag::err_use_of_default_argument_to_function_declared_later) <<
@@ -3495,12 +3495,20 @@
MultiLevelTemplateArgumentList ArgList
= getTemplateInstantiationArgs(FD, 0, /*RelativeToPrimary=*/true);
- std::pair<const TemplateArgument *, unsigned> Innermost
+ std::pair<const TemplateArgument *, unsigned> Innermost
= ArgList.getInnermost();
InstantiatingTemplate Inst(*this, CallLoc, Param, Innermost.first,
Innermost.second);
- ExprResult Result = SubstExpr(UninstExpr, ArgList);
+ ExprResult Result;
+ {
+ // C++ [dcl.fct.default]p5:
+ // The names in the [default argument] expression are bound, and
+ // the semantic constraints are checked, at the point where the
+ // default argument expression appears.
+ ContextRAII SavedContext(*this, FD->getDeclContext());
+ Result = SubstExpr(UninstExpr, ArgList);
+ }
if (Result.isInvalid())
return ExprError();
Modified: cfe/branches/Apple/whitney/test/SemaCXX/friend.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/SemaCXX/friend.cpp?rev=120665&r1=120664&r2=120665&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/test/SemaCXX/friend.cpp (original)
+++ cfe/branches/Apple/whitney/test/SemaCXX/friend.cpp Wed Dec 1 20:52:15 2010
@@ -79,3 +79,36 @@
struct B { friend void B(); };
}
+
+// PR8479
+namespace test6_1 {
+ class A {
+ public:
+ private:
+ friend class vectorA;
+ A() {}
+ };
+ class vectorA {
+ public:
+ vectorA(int i, const A& t = A()) {}
+ };
+ void f() {
+ vectorA v(1);
+ }
+}
+namespace test6_2 {
+ template<class T>
+ class vector {
+ public:
+ vector(int i, const T& t = T()) {}
+ };
+ class A {
+ public:
+ private:
+ friend class vector<A>;
+ A() {}
+ };
+ void f() {
+ vector<A> v(1);
+ }
+}
More information about the llvm-branch-commits
mailing list