From patchwork Thu Feb 6 17:04:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Fabien_Ch=C3=AAne?= X-Patchwork-Id: 317505 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3DAAC2C00A1 for ; Fri, 7 Feb 2014 04:04:26 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; q= dns; s=default; b=DOtFYgEGpvTa+mIqVSLuaeU9x4O5w7IVT6yeE+v52hmxV6 5b9hp3DI5O/QQd5mPbYkux9IGvSwWfhRgBQdCPO72yMGuVoUkfdYLewplBQ+WEG9 Db+ku+bsQR/Grt5kWTy8Wzr/kC/GOZf8ty8rgv5A5p3kqhZ4fNgiFmO+g4w2c= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; s= default; bh=a/PbgAFeP90otHhV3hbPGfHHxpM=; b=PnfVOMnjzgdODjDeTmTG HH/kKjD+aXQm5z1vMGL8ScvMIwC245Q4/vC2BKfqY0JbBphyNGV8aaupteTvbxhP bow5cX+mbpF7VV+xRJt7Sq/qweIMgiwBGHbIsjcPvjyUwz2uqqm9LFsF3CEUVVE6 Hnrhdys4gRUWwdztBw37D0Y= Received: (qmail 10662 invoked by alias); 6 Feb 2014 17:04:19 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 10643 invoked by uid 89); 6 Feb 2014 17:04:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-vc0-f174.google.com Received: from mail-vc0-f174.google.com (HELO mail-vc0-f174.google.com) (209.85.220.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 06 Feb 2014 17:04:17 +0000 Received: by mail-vc0-f174.google.com with SMTP id im17so1662922vcb.33 for ; Thu, 06 Feb 2014 09:04:15 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.52.170.3 with SMTP id ai3mr1771601vdc.35.1391706255206; Thu, 06 Feb 2014 09:04:15 -0800 (PST) Received: by 10.52.98.134 with HTTP; Thu, 6 Feb 2014 09:04:15 -0800 (PST) Date: Thu, 6 Feb 2014 18:04:15 +0100 Message-ID: Subject: [C++ patch] for C++/52369 From: =?ISO-8859-1?Q?Fabien_Ch=EAne?= To: GCC Patches X-IsSubscribed: yes Hi, This bug seems already fixed on mainline. I have added two testcases, but as the C++11 one is not obvious to me, I guess this path does not qualify as obvious. Incidentally, while writing the C++11 testcase, I realized that the diagnostic was not emitted at the proper location and fixed it. OK for trunk ? 2014-02-06 Fabien Chene PR c++/52369 * cp/method.c (walk_field_subobs): improve the diagnostic locations for both REFERENCE_TYPEs and non-static const members. 2014-02-06 Fabien Chene PR c++/52369 * g++.dg/init/const10.C: New. * g++.dg/init/const11.C: New. Index: gcc/testsuite/g++.dg/init/const10.C =================================================================== --- gcc/testsuite/g++.dg/init/const10.C (revision 0) +++ gcc/testsuite/g++.dg/init/const10.C (revision 0) @@ -0,0 +1,31 @@ +// PR C++/52369 +// { dg-do compile { target c++11 } } + +class B // { dg-message "implicitly deleted" } +{ + int const v_; // { dg-error "uninitialized" } +}; + +struct D : B {}; // { dg-error "deleted" } + +class A // { dg-message "implicitly deleted" } +{ + int& ref; // { dg-error "uninitialized" } +}; + +struct C : A {}; // { dg-error "deleted" } + +void f() +{ + D d; // { dg-error "use of deleted" } + new D; // { dg-error "use of deleted" } + D(); // { dg-error "use of deleted" } + new D(); // { dg-error "use of deleted" } + + C c; // { dg-error "use of deleted" } + new C; // { dg-error "use of deleted" } + C(); // { dg-error "use of deleted" } + new C(); // { dg-error "use of deleted" } +} + + Index: gcc/testsuite/g++.dg/init/const11.C =================================================================== --- gcc/testsuite/g++.dg/init/const11.C (revision 0) +++ gcc/testsuite/g++.dg/init/const11.C (revision 0) @@ -0,0 +1,29 @@ +// PR C++/52369 +// { dg-do compile { target c++98 } } + +class B +{ + int const v_; // { dg-message "should be initialized" } +}; + +struct D : B {}; + +class A +{ + int& ref; // { dg-message "should be initialized" } +}; + +struct C : A {}; + +void f() +{ + D d; // { dg-error "uninitialized" } + new D; // { dg-error "uninitialized" } + D(); + new D(); + + C c; // { dg-error "uninitialized" } + new C; // { dg-error "uninitialized" } + C(); // { dg-error "value-initialization" } + new C(); // { dg-error "value-initialization" } +} Index: gcc/cp/method.c =================================================================== --- gcc/cp/method.c (revision 207406) +++ gcc/cp/method.c (working copy) @@ -1091,15 +1091,15 @@ walk_field_subobs (tree fields, tree fnn && default_init_uninitialized_part (mem_type)) { if (diag) - error ("uninitialized non-static const member %q#D", - field); + error_at (DECL_SOURCE_LOCATION (field), + "uninitialized non-static const member %q#D", field); bad = true; } else if (TREE_CODE (mem_type) == REFERENCE_TYPE) { if (diag) - error ("uninitialized non-static reference member %q#D", - field); + error_at (DECL_SOURCE_LOCATION (field), + "uninitialized non-static reference member %q#D", field); bad = true; }