* expr.c (mark_exp_read): Handle NON_DEPENDENT_EXPR.
* pt.c (make_pack_expansion): Call mark_exp_read.
* semantics.c (finish_id_expression): Call mark_type_use in
unevaluated context.
From-SVN: r235221
2016-04-19 Jason Merrill <jason@redhat.com>
+ PR c++/66543
+ * expr.c (mark_exp_read): Handle NON_DEPENDENT_EXPR.
+ * pt.c (make_pack_expansion): Call mark_exp_read.
+ * semantics.c (finish_id_expression): Call mark_type_use in
+ unevaluated context.
+
DR 2137
* call.c (implicit_conversion): If we choose a copy constructor
for list-initialization from the same type, the conversion is an
case ADDR_EXPR:
case INDIRECT_REF:
case FLOAT_EXPR:
+ case NON_DEPENDENT_EXPR:
mark_exp_read (TREE_OPERAND (exp, 0));
break;
case COMPOUND_EXPR:
/* Propagate type and const-expression information. */
TREE_TYPE (result) = TREE_TYPE (arg);
TREE_CONSTANT (result) = TREE_CONSTANT (arg);
+ /* Mark this read now, since the expansion might be length 0. */
+ mark_exp_read (arg);
}
else
/* Just use structural equality for these TYPE_PACK_EXPANSIONS;
if (!scope && decl != error_mark_node && identifier_p (id_expression))
maybe_note_name_used_in_class (id_expression, decl);
+ /* A use in unevaluated operand might not be instantiated appropriately
+ if tsubst_copy builds a dummy parm, or if we never instantiate a
+ generic lambda, so mark it now. */
+ if (processing_template_decl && cp_unevaluated_operand)
+ mark_type_use (decl);
+
/* Disallow uses of local variables from containing functions, except
within lambda-expressions. */
if (outer_automatic_var_p (decl))
--- /dev/null
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wunused-but-set-parameter" }
+
+template <typename... Ts> void sink(Ts...);
+
+struct A { int i; };
+
+template <int... I>
+void f(A a)
+{
+ return sink((a.i + I)...);
+}
+
+int main()
+{
+ f<>(A());
+}
--- /dev/null
+// { dg-do compile { target c++14 } }
+// { dg-options "-Wunused-but-set-parameter" }
+
+auto l = [](auto t) -> decltype(true ? t : 0) { return {}; };
+
+int main()
+{
+ l(42);
+}
--- /dev/null
+// PR c++/66543
+// { dg-do compile { target c++14 } }
+// { dg-options "-Wunused-but-set-variable" }
+
+int main() {
+ auto f = []() { };
+ [=](auto) {
+ using Foo = decltype(f());
+ };
+}
--- /dev/null
+// { dg-do compile { target c++14 } }
+// { dg-options "-Wunused-but-set-variable" }
+
+template <int... I> struct A { };
+template <int... I>
+auto f()
+{
+ constexpr int ar[sizeof...(I)+1] = {I...};
+ return A<ar[I]...>();
+}
+
+int main()
+{
+ f<>();
+}