PR c++/63657
PR c++/38958
* call.c (set_up_extended_ref_temp): Set TREE_USED on the reference
if the temporary has a non-trivial destructor.
* decl.c (poplevel): Don't look through references.
From-SVN: r217957
2014-11-21 Jason Merrill <jason@redhat.com>
+ PR c++/63657
+ PR c++/38958
+ * call.c (set_up_extended_ref_temp): Set TREE_USED on the reference
+ if the temporary has a non-trivial destructor.
+ * decl.c (poplevel): Don't look through references.
+
PR c++/63942
* name-lookup.c (supplement_binding_1): Override a mangling alias.
* mangle.c (maybe_remove_implicit_alias): New.
/* Check whether the dtor is callable. */
cxx_maybe_build_cleanup (var, tf_warning_or_error);
}
+ /* Avoid -Wunused-variable warning (c++/38958). */
+ if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type)
+ && TREE_CODE (decl) == VAR_DECL)
+ TREE_USED (decl) = DECL_READ_P (decl) = true;
*initp = init;
return var;
push_local_binding where the list of decls returned by
getdecls is built. */
decl = TREE_CODE (d) == TREE_LIST ? TREE_VALUE (d) : d;
- // See through references for improved -Wunused-variable (PR 38958).
- tree type = non_reference (TREE_TYPE (decl));
+ tree type = TREE_TYPE (decl);
if (VAR_P (decl)
&& (! TREE_USED (decl) || !DECL_READ_P (decl))
&& ! DECL_IN_SYSTEM_HEADER (decl)
--- /dev/null
+// PR c++/63657
+// { dg-options "-Wunused-variable" }
+
+class Bar
+{
+ virtual ~Bar() {}
+};
+Bar& getbar();
+void bar()
+{
+ Bar& b = getbar(); // { dg-warning "unused" }
+}