[cfe-commits] r151837 - in /cfe/trunk: lib/Sema/SemaExpr.cpp lib/Sema/SemaTemplateVariadic.cpp test/SemaCXX/warn-unused-parameters.cpp
Eli Friedman
eli.friedman at gmail.com
Thu Mar 1 13:32:56 PST 2012
Author: efriedma
Date: Thu Mar 1 15:32:56 2012
New Revision: 151837
URL: http://llvm.org/viewvc/llvm-project?rev=151837&view=rev
Log:
Fix the isReferenced bit on parameters in a couple of edge cases. PR12153.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
cfe/trunk/test/SemaCXX/warn-unused-parameters.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=151837&r1=151836&r2=151837&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Mar 1 15:32:56 2012
@@ -9630,6 +9630,7 @@
// 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
Modified: cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp?rev=151837&r1=151836&r2=151837&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp Thu Mar 1 15:32:56 2012
@@ -779,6 +779,8 @@
return ExprError();
}
+ MarkAnyDeclReferenced(OpLoc, ParameterPack);
+
return new (Context) SizeOfPackExpr(Context.getSizeType(), OpLoc,
ParameterPack, NameLoc, RParenLoc);
}
Modified: cfe/trunk/test/SemaCXX/warn-unused-parameters.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-parameters.cpp?rev=151837&r1=151836&r2=151837&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-unused-parameters.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-parameters.cpp Thu Mar 1 15:32:56 2012
@@ -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 @@
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();
+}
More information about the cfe-commits
mailing list