* typeck.c (maybe_warn_about_returning_address_of_local): Look
through COMPONENT_REF and ARRAY_REF.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116714
138bc75d-0d04-0410-961f-
82ee72b054a4
2006-09-05 Jason Merrill <jason@redhat.com>
+ PR c++/26671
+ * typeck.c (maybe_warn_about_returning_address_of_local): Look
+ through COMPONENT_REF and ARRAY_REF.
+
PR c++/26102
* name-lookup.c (do_class_using_decl): Try to find the base even
if bases_dependent_p.
}
}
+ while (TREE_CODE (whats_returned) == COMPONENT_REF
+ || TREE_CODE (whats_returned) == ARRAY_REF)
+ whats_returned = TREE_OPERAND (whats_returned, 0);
+
if (DECL_P (whats_returned)
&& DECL_NAME (whats_returned)
&& DECL_FUNCTION_SCOPE_P (whats_returned)
--- /dev/null
+// PR c++/26671
+
+class A
+{
+public:
+ int first;
+ int second;
+
+};
+
+int &f()
+{
+ A a; // { dg-error "local" }
+ return a.second;
+}
+
+int &g()
+{
+ int ar[42]; // { dg-error "local" }
+ return ar[20];
+}