From 30d309aaf14343dc0e9f00c9cf37075afdfba905 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 3 Mar 2017 11:30:32 +0000 Subject: [PATCH] re PR c++/79825 (Uninitialized uses in aggregate copies of empty structs (missed DCE in C++ gimplify)) 2017-03-03 Richard Biener PR c++/79825 * cp-gimplify.c (simple_empty_class_p): Handle EMPTY_CLASS_EXPR. * g++.dg/warn/Wuninitialized-8.C: New testcase. From-SVN: r245866 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/cp-gimplify.c | 1 + gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/warn/Wuninitialized-8.C | 18 ++++++++++++++++++ 4 files changed, 29 insertions(+) create mode 100644 gcc/testsuite/g++.dg/warn/Wuninitialized-8.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7ff2827e502..f98726eaf59 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2017-03-03 Richard Biener + + PR c++/79825 + * cp-gimplify.c (simple_empty_class_p): Handle EMPTY_CLASS_EXPR. + 2017-03-03 Marek Polacek PR c++/79791 diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 3eec9400fb0..ebb5da96f0a 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -549,6 +549,7 @@ simple_empty_class_p (tree type, tree op) 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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 25450eaeb2b..b223ee24d44 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-03-03 Richard Biener + + PR c++/79825 + * g++.dg/warn/Wuninitialized-8.C: New testcase. + 2017-03-03 Jakub Jelinek * gcc.dg/pr57134.c: Use empty inline asm string literal. diff --git a/gcc/testsuite/g++.dg/warn/Wuninitialized-8.C b/gcc/testsuite/g++.dg/warn/Wuninitialized-8.C new file mode 100644 index 00000000000..cb9cfee6cab --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wuninitialized-8.C @@ -0,0 +1,18 @@ +// { dg-do compile } +// { dg-options "-Wuninitialized" } + +struct A; +struct B +{ + B(A); +}; +struct C +{ + template void m_fn1(PassT p1) { new B(p1); } // { dg-bogus "uninitialized" } +}; +struct A {}; +void fn1() +{ + C a; + a.m_fn1(A()); +} -- 2.30.2