]> granicus.if.org Git - clang/commitdiff
Fix the isReferenced bit on parameters in a couple of edge cases. PR12153.
authorEli Friedman <eli.friedman@gmail.com>
Thu, 1 Mar 2012 21:32:56 +0000 (21:32 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Thu, 1 Mar 2012 21:32:56 +0000 (21:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151837 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
lib/Sema/SemaTemplateVariadic.cpp
test/SemaCXX/warn-unused-parameters.cpp

index 027ec73d49460c6ecbdacaa834d38e8a158bfd67..149201192f31d7d576ae2163dcfee4faf1847073 100644 (file)
@@ -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
index 15a308575a0bec478ffcbfee8e9226619905009f..3a547ddf68a537d615434723daedfac2742d466e 100644 (file)
@@ -779,6 +779,8 @@ ExprResult Sema::ActOnSizeofParameterPackExpr(Scope *S,
     return ExprError();
   }
 
+  MarkAnyDeclReferenced(OpLoc, ParameterPack);
+
   return new (Context) SizeOfPackExpr(Context.getSizeType(), OpLoc, 
                                       ParameterPack, NameLoc, RParenLoc);
 }
index 75d8dcc549c9dd8fb1c12afe6b3f1c7f66e0326c..00ce1a98c6c8a69d49152de256a6b286db0a9186 100644 (file)
@@ -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<typename T>
 struct X {
   T f0(T x);
@@ -24,3 +24,11 @@ void test_X(X<int> &x, int i) {
   x.f4(i);
   x.f5(i);
 }
+
+// Make sure both parameters aren't considered unused.
+template <typename... T>
+static int test_pack(T... t, T... s)
+{
+  auto l = [&t...]() { return sizeof...(s); };
+  return l();
+}