Skip to content
Snippets Groups Projects
Commit b83f3cd3 authored by Marek Polacek's avatar Marek Polacek
Browse files

c++: -Wuninitialized when binding a ref to uninit DM [PR113987]

This PR asks that our -Wuninitialized for mem-initializers does
not warn when binding a reference to an uninitialized data member.
We already check !INDIRECT_TYPE_P in find_uninit_fields_r, but
that won't catch binding a parameter of a reference type to an
uninitialized field, as in:

  struct S { S (int&); };
  struct T {
      T() : s(i) {}
      S s;
      int i;
  };

This patch adds a new function to handle this case.

	PR c++/113987

gcc/cp/ChangeLog:

	* call.cc (conv_binds_to_reference_parm_p): New.
	* cp-tree.h (conv_binds_to_reference_parm_p): Declare.
	* init.cc (find_uninit_fields_r): Call it.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/Wuninitialized-15.C: Turn dg-warning into dg-bogus.
	* g++.dg/warn/Wuninitialized-34.C: New test.
parent bc0e18a9
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment