[PATCH][C++] Fix PR79825

Richard Biener rguenther@suse.de
Fri Mar 3 10:08:00 GMT 2017


The following obvious patch fixes PR79825, we were not treating
EMPTY_CLASS_EXPR as simple_empty_class_p.

Bootstrap / regtest running on x86_64-unknown-linux-gnu.

Richard.

2017-03-03  Richard Biener  <rguenther@suse.de>

	PR c++/79825
	* cp-gimplify.c (simple_empty_class_p): Handle EMPTY_CLASS_EXPR.

	* g++.dg/warn/Wuninitialized-8.C: New testcase.

Index: gcc/cp/cp-gimplify.c
===================================================================
*** gcc/cp/cp-gimplify.c	(revision 245863)
--- gcc/cp/cp-gimplify.c	(working copy)
*************** simple_empty_class_p (tree type, tree op
*** 549,554 ****
--- 549,555 ----
    return
      ((TREE_CODE (op) == COMPOUND_EXPR
        && simple_empty_class_p (type, TREE_OPERAND (op, 1)))
+      || TREE_CODE (op) == EMPTY_CLASS_EXPR
       || is_gimple_lvalue (op)
       || INDIRECT_REF_P (op)
       || (TREE_CODE (op) == CONSTRUCTOR
Index: gcc/testsuite/g++.dg/warn/Wuninitialized-8.C
===================================================================
*** gcc/testsuite/g++.dg/warn/Wuninitialized-8.C	(nonexistent)
--- gcc/testsuite/g++.dg/warn/Wuninitialized-8.C	(working copy)
***************
*** 0 ****
--- 1,18 ----
+ // { dg-do compile }
+ // { dg-options "-Wuninitialized" }
+ 
+ struct A;
+ struct B
+ {
+   B(A);
+ };
+ struct C
+ {
+   template <typename PassT> void m_fn1(PassT p1) { new B(p1); }  // { dg-bogus "uninitialized" }
+ };
+ struct A {};
+ void fn1()
+ {
+   C a;
+   a.m_fn1(A());
+ }



More information about the Gcc-patches mailing list