+2018-04-04 Alexandre Oliva <aoliva@redhat.com>
+
+ PR c++/84943
+ * typeck.c (cp_build_addr_expr_1): Mark FUNCTION_DECL as
+ used.
+ * decl2.c (mark_used): Return without effects if tf_conv.
+
2018-04-03 Jason Merrill <jason@redhat.com>
PR c++/85092 - C++17 ICE with unused list constructor.
bool
mark_used (tree decl, tsubst_flags_t complain)
{
+ /* If we're just testing conversions or resolving overloads, we
+ don't want any permanent effects like forcing functions to be
+ output or instantiating templates. */
+ if ((complain & tf_conv))
+ return true;
+
/* If DECL is a BASELINK for a single function, then treat it just
like the DECL for the function. Otherwise, if the BASELINK is
for an overloaded function, we don't know which function was
so we can just form an ADDR_EXPR with the correct type. */
if (processing_template_decl || TREE_CODE (arg) != COMPONENT_REF)
{
+ if (TREE_CODE (arg) == FUNCTION_DECL
+ && !mark_used (arg, complain) && !(complain & tf_error))
+ return error_mark_node;
val = build_address (arg);
if (TREE_CODE (arg) == OFFSET_REF)
PTRMEM_OK_P (val) = PTRMEM_OK_P (arg);
+2018-04-04 Alexandre Oliva <aoliva@redhat.com>
+
+ PR c++/84943
+ * g++.dg/pr84943.C: New.
+ * g++.dg/pr84943-2.C: New.
+
2018-04-03 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/85167
--- /dev/null
+// { dg-do run }
+
+// Avoid -pedantic-error default
+// { dg-options "" }
+
+// Make sure the functions referenced by various forms of
+// address-taking are marked as used and compiled in.
+
+static void ac() {}
+void a() {
+ ac[0](); // { dg-warning "arithmetic" }
+}
+
+static void bc() {}
+void b() {
+ (&*&*&*&bc)();
+}
+
+template <typename U> U cc() {}
+void (*c())() {
+ return cc;
+}
+
+template <typename T>
+struct x {
+ void a(int);
+ template <typename U> static U a(x*) {}
+ static void a(long) {}
+ static void a(void *) {}
+ static void a() {
+ void (*p0)(void*) = x().a;
+ p0(0);
+ void (*p1)(long) = a;
+ p1(0);
+ void (*p2)() = a;
+ p2();
+ void (*p3)(x*) = a;
+ p3(0);
+ }
+};
+
+struct z {
+ void a(int);
+ template <typename U> static U a(z*) {}
+ static void a(long) {}
+ static void a(void *) {}
+ static void a() {
+ void (*p0)(void*) = z().a;
+ p0(0);
+ void (*p1)(long) = a;
+ p1(0);
+ void (*p2)() = a;
+ p2();
+ void (*p3)(z*) = a;
+ p3(0);
+ }
+};
+
+int main(int argc, char *argv[]) {
+ if (argc > 1) {
+ x<void>().a();
+ z().a();
+ }
+}
--- /dev/null
+// { dg-do compile }
+
+// Avoid -pedantic-error default
+// { dg-options "" }
+
+void a() {
+ a[0](); // { dg-warning "arithmetic" }
+}