From feb624a435932b9c7888cc3a0a80b683f72a8554 Mon Sep 17 00:00:00 2001 From: John McCall Date: Tue, 23 Nov 2010 20:48:44 +0000 Subject: A few tweaks to the value-kind computation: - Default argument expressions pick up the value kind of the incoming expression, not the value kind of the parameter it initializes. - When building a template argument for substitution, A::x is an rvalue if x is an instance method. - Anonymous struct/union paths pick up value kind the same way that normal member accesses do; extract out a common code path for this. Enable the value-kind assertion, now that it passes self-host. llvm-svn: 120055 --- clang/lib/Sema/SemaTemplate.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'clang/lib/Sema/SemaTemplate.cpp') diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index daa1e726a06..53d7c10ede7 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -3365,9 +3365,17 @@ Sema::BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, ClassType.getTypePtr()); CXXScopeSpec SS; SS.setScopeRep(Qualifier); + + // The actual value-ness of this is unimportant, but for + // internal consistency's sake, references to instance methods + // are r-values. + ExprValueKind VK = VK_LValue; + if (isa(VD) && cast(VD)->isInstance()) + VK = VK_RValue; + ExprResult RefExpr = BuildDeclRefExpr(VD, VD->getType().getNonReferenceType(), - VK_LValue, + VK, Loc, &SS); if (RefExpr.isInvalid()) -- cgit v1.2.3