From: Eli Friedman Date: Thu, 1 Mar 2012 21:32:56 +0000 (+0000) Subject: Fix the isReferenced bit on parameters in a couple of edge cases. PR12153. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=88530d5e138f36ea80a7d70c14f37095b8eba85b;p=clang Fix the isReferenced bit on parameters in a couple of edge cases. PR12153. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151837 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 027ec73d49..149201192f 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -9630,6 +9630,7 @@ static ExprResult captureInLambda(Sema &S, LambdaScopeInfo *LSI, // An entity captured by a lambda-expression is odr-used (3.2) in // the scope containing the lambda-expression. Expr *Ref = new (S.Context) DeclRefExpr(Var, DeclRefType, VK_LValue, Loc); + Var->setReferenced(true); Var->setUsed(true); // When the field has array type, create index variables for each diff --git a/lib/Sema/SemaTemplateVariadic.cpp b/lib/Sema/SemaTemplateVariadic.cpp index 15a308575a..3a547ddf68 100644 --- a/lib/Sema/SemaTemplateVariadic.cpp +++ b/lib/Sema/SemaTemplateVariadic.cpp @@ -779,6 +779,8 @@ ExprResult Sema::ActOnSizeofParameterPackExpr(Scope *S, return ExprError(); } + MarkAnyDeclReferenced(OpLoc, ParameterPack); + return new (Context) SizeOfPackExpr(Context.getSizeType(), OpLoc, ParameterPack, NameLoc, RParenLoc); } diff --git a/test/SemaCXX/warn-unused-parameters.cpp b/test/SemaCXX/warn-unused-parameters.cpp index 75d8dcc549..00ce1a98c6 100644 --- a/test/SemaCXX/warn-unused-parameters.cpp +++ b/test/SemaCXX/warn-unused-parameters.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -Wunused-parameter -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wunused-parameter -verify -std=c++11 %s template struct X { T f0(T x); @@ -24,3 +24,11 @@ void test_X(X &x, int i) { x.f4(i); x.f5(i); } + +// Make sure both parameters aren't considered unused. +template +static int test_pack(T... t, T... s) +{ + auto l = [&t...]() { return sizeof...(s); }; + return l(); +}