From patchwork Thu Mar 27 21:32:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Fabien_Ch=C3=AAne?= X-Patchwork-Id: 334466 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 D5145140094 for ; Fri, 28 Mar 2014 08:32:34 +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:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; q=dns; s=default; b=gyJZ0033W4S32lNDkq Fy3p8PmSsuOjzQ+CoV3S0J/RA6Np04+Ff3PMIKMt+xkuc1HEYBNE4fGcsQWvOCKw lL3cm6l52lFj1NelFlAb2/iDCXHaF3ph8KuTIdE8CtnIMkKcZslS45fKNA20oHU7 18A5o99r9m8Ogi9cBidXoDjOQ= 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:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; s=default; bh=BhmdJBpQqzST8oDMjSb02Nyw S6U=; b=G5eFzJZvYD1lcj7v595FYYTka15dWWUvmDP7Ct+Fga/gDH0K9i3xgTTw PwyTUODNU7oj3Blw1a4qnM0HIu1Doq6AvxVWYhX/nsTAJLWYQQzHLJ2wrtM48jFj Uq4zj9BbzRBlUhndpzNRr3Er6FJDoIq0psEBZ86NorbDnXMBTgw= Received: (qmail 29506 invoked by alias); 27 Mar 2014 21:32:26 -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 29492 invoked by uid 89); 27 Mar 2014 21:32:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No 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-f177.google.com Received: from mail-vc0-f177.google.com (HELO mail-vc0-f177.google.com) (209.85.220.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 27 Mar 2014 21:32:24 +0000 Received: by mail-vc0-f177.google.com with SMTP id if17so4921984vcb.36 for ; Thu, 27 Mar 2014 14:32:22 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.220.10.2 with SMTP id n2mr3466825vcn.26.1395955942035; Thu, 27 Mar 2014 14:32:22 -0700 (PDT) Received: by 10.52.103.105 with HTTP; Thu, 27 Mar 2014 14:32:21 -0700 (PDT) In-Reply-To: <5330698D.5010107@redhat.com> References: <530F8315.5010703@redhat.com> <5310FF29.6060102@redhat.com> <5313D7EB.8080801@redhat.com> <5330698D.5010107@redhat.com> Date: Thu, 27 Mar 2014 22:32:21 +0100 Message-ID: Subject: Re: [C++ patch] for C++/52369 From: =?ISO-8859-1?Q?Fabien_Ch=EAne?= To: Jason Merrill Cc: GCC Patches X-IsSubscribed: yes Hi, As a followup, the following patch homogeneise some diagnostics that relate to uninitialized const or reference members. Tested x86_64 linux in progress, OK to commit for next stage 1 if that succeeds ? (or trunk otherwise, I dare to mention it). 2014-03-28 Fabien Chêne * cp/init.c (perform_member_init): homogeneize uninitialized diagnostics. 2014-03-28 Fabien Chêne * g++.dg/init/ctor4.C: Adjust. * g++.dg/init/ctor4-1.C: New. 2014-03-24 18:21 GMT+01:00 Jason Merrill : > OK, thanks. > > Jason Index: gcc/testsuite/g++.dg/init/ctor4-1.C =================================================================== --- gcc/testsuite/g++.dg/init/ctor4-1.C (révision 0) +++ gcc/testsuite/g++.dg/init/ctor4-1.C (révision 0) @@ -0,0 +1,21 @@ +// { dg-do compile } + +class foo { +public: + foo(); +}; + +class bar: public foo { // { dg-error "uninitialized" } + // { dg-message "implicitly deleted" "" { target c++11 } 8 } +private: + int const a; // { dg-message "should be initialized" } +}; + +foo::foo() { +} + +int main(int argc, char **argv) +{ + bar x; // { dg-error "deleted" "" { target c++11 } } + // { dg-message "synthesized" "" { target { ! c++11 } } 19 } +} Index: gcc/testsuite/g++.dg/init/ctor4.C =================================================================== --- gcc/testsuite/g++.dg/init/ctor4.C (révision 208853) +++ gcc/testsuite/g++.dg/init/ctor4.C (copie de travail) @@ -6,9 +6,10 @@ public: foo(); }; -class bar: public foo { // { dg-error "reference|bar::bar" } +class bar: public foo { // { dg-error "uninitialized" } + // { dg-message "implicitly deleted" "" { target c++11 } 9 } private: - int &a; + int &a; // { dg-message "should be initialized" } }; foo::foo() { @@ -16,5 +17,6 @@ foo::foo() { int main(int argc, char **argv) { - bar x; // { dg-message "synthesized|deleted" } + bar x; // { dg-error "deleted" "" { target c++11 } } + // { dg-message "synthesized" "" { target { ! c++11 } } 20 } } Index: gcc/cp/init.c =================================================================== --- gcc/cp/init.c (révision 208854) +++ gcc/cp/init.c (copie de travail) @@ -710,13 +710,19 @@ perform_member_init (tree member, tree i tree core_type; /* member traversal: note it leaves init NULL */ if (TREE_CODE (type) == REFERENCE_TYPE) - permerror (DECL_SOURCE_LOCATION (current_function_decl), - "uninitialized reference member %qD", - member); + { + permerror (DECL_SOURCE_LOCATION (current_function_decl), + "uninitialized reference member in %q#T", type); + inform (DECL_SOURCE_LOCATION (member), + "%q#D should be initialized", member); + } else if (CP_TYPE_CONST_P (type)) - permerror (DECL_SOURCE_LOCATION (current_function_decl), - "uninitialized member %qD with % type %qT", - member, type); + { + permerror (DECL_SOURCE_LOCATION (current_function_decl), + "uninitialized const member in %q#T", type); + inform (DECL_SOURCE_LOCATION (member), + "%q#D should be initialized", member ); + } core_type = strip_array_types (type);