From patchwork Sun Jul 16 10:01:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volker Reichelt X-Patchwork-Id: 789079 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 3x9MRd6gGMz9s2s for ; Sun, 16 Jul 2017 20:02:35 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="n/mmb4sF"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:subject:to:cc:in-reply-to:message-id:references :mime-version:content-type; q=dns; s=default; b=OQzo3VfRYnOjmcka 3P4nWlL39fQoRmP4abrsycDbsVaBZPYJVq/LbyM3YyDjTUIbVMOx8BUgITNU8OGk I1L12ZZWX4s9kEsEoczhifxZM7i+IZXZuUqJ68fmvexvNZlsQSjO0OnCe6rZPEk1 6Zb3MTE7hFM3GID5xXh1XpgZMWw= 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:date :from:subject:to:cc:in-reply-to:message-id:references :mime-version:content-type; s=default; bh=OMN0nxH37o7ZfhdfdVgf1L dD8EI=; b=n/mmb4sFHuLrMSK8AKvDR8fx/FjKmV+a7AH9www7SXld1Utm+v6XU1 QU20AhvgT5dgXG7Yg3B9qqG3BzPvyrZHI044pDh1wgMViLb1TDN3o84AKlf+Rc/L sCVFIXvA9ryoRA4Edb8ItUBiK77vD+1hG4oSAwhBkOYy26e7RnSVc= Received: (qmail 6067 invoked by alias); 16 Jul 2017 10:02:04 -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 118371 invoked by uid 89); 16 Jul 2017 10:01:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-6.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPAM_BODY, SPF_PASS autolearn=ham version=3.3.2 spammy=enumeration, UD:netcologne.de X-HELO: cc-smtpout1.netcologne.de Received: from cc-smtpout1.netcologne.de (HELO cc-smtpout1.netcologne.de) (89.1.8.211) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 16 Jul 2017 10:01:44 +0000 Received: from cc-smtpin1.netcologne.de (cc-smtpin1.netcologne.de [89.1.8.201]) by cc-smtpout1.netcologne.de (Postfix) with ESMTP id E70D5131C3; Sun, 16 Jul 2017 12:01:39 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cc-smtpin1.netcologne.de (Postfix) with ESMTP id DA14B11DF4; Sun, 16 Jul 2017 12:01:39 +0200 (CEST) Received: from [89.0.9.63] (helo=cc-smtpin1.netcologne.de) by localhost with ESMTP (eXpurgate 4.1.9) (envelope-from ) id 596b3983-021e-7f0000012729-7f000001c7bc-1 for ; Sun, 16 Jul 2017 12:01:39 +0200 Received: from linux-mqtz.fritz.box (xdsl-89-0-9-63.netcologne.de [89.0.9.63]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by cc-smtpin1.netcologne.de (Postfix) with ESMTPSA; Sun, 16 Jul 2017 12:01:33 +0200 (CEST) Date: Sun, 16 Jul 2017 12:01:33 +0200 (CEST) From: Volker Reichelt Subject: Re: [PING] C++ Re: [PATCH] C/C++: fix quoting of "aka" typedef information (PR 62170) To: Martin Sebor , gcc-patches List cc: Jason Merrill , David Malcolm , Gerald Pfeifer In-Reply-To: Message-ID: References: <1496689294-11629-1-git-send-email-dmalcolm@redhat.com> <1497973859.7551.171.camel@redhat.com> <1497985575.7551.179.camel@redhat.com> MIME-Version: 1.0 Content-Disposition: INLINE On 14 Jul, Martin Sebor wrote: > On 06/21/2017 01:59 AM, Volker Reichelt wrote: >> On 20 Jun, Jason Merrill wrote: >>> On Tue, Jun 20, 2017 at 3:06 PM, David Malcolm wrote: >>>> It's not clear to me what the issue alluded to with negative >>>> obstack_blank is, but I chose to follow the above docs and use >>>> obstack_blank_fast; am testing an updated patch in which the above line >>>> now looks like: >>>> >>>> obstack_blank_fast (ob, -(type_start + type_len)); >>>> >>>> Is the patch OK with that change? (assuming bootstrap®rtesting >>>> pass), or should I re-post? >>> >>> OK with that change. >>> >>>> On a related matter, this patch conflicts with Volker's patch here: >>>> >>>> https://gcc.gnu.org/ml/gcc-patches/2017-04/msg01576.html >>>> >>>> in which he removes the trailing "{enum}" info (and hence all of our >>>> changes to the testsuite conflict between the two patches...) >>>> >>>> Do you have any thoughts on that other patch? [Ccing Volker] >>> >>> That patch makes sense to me; I prefer "enum E" to "E {enum}". >>> >>> Jason >> >> Is 'makes sense' equivalent to 'OK for trunk' here? If so, should my >> patch go in before David's or should we do it the other way round? > > I missed this and have been pinging your patch on your behalf > (below). In the interest on making progress on this, IMO trivial, > change I recommend taking Jason's comment as approval. > > https://gcc.gnu.org/ml/gcc-patches/2017-07/msg00472.html > > Martin After several pings https://gcc.gnu.org/ml/gcc-patches/2017-05/msg01248.html https://gcc.gnu.org/ml/gcc-patches/2017-06/msg00207.html https://gcc.gnu.org/ml/gcc-patches/2017-06/msg00712.html (by Gerald) https://gcc.gnu.org/ml/gcc-patches/2017-06/msg01487.html (by Martin) https://gcc.gnu.org/ml/gcc-patches/2017-07/msg00472.html (by Martin) (thanks Gerald and Martin!) for https://gcc.gnu.org/ml/gcc-patches/2017-04/msg01576.html I went with Martin's suggestion and took Jason's 'make sense' as an OK for this trivial patch. Due to changes of an error message and a testcase the patch had to be updated slightly (attached below) Bootstrapped and regtested again on x86_64-pc-linux-gnu. Applied to trunk. Regards, Volker 2017-07-16 Volker Reichelt * parser.c (cp_parser_cast_expression): Use %q#T instead of %qT in old-style cast diagnostic. * typeck.c (maybe_warn_about_useless_cast): Use %q#T instead of %qT in useless cast diagnostic. * error.c (type_to_string): Remove enum special handling. =================================================================== Index: gcc/cp/parser.c =================================================================== --- gcc/cp/parser.c (revision 250230) +++ gcc/cp/parser.c (working copy) @@ -8890,7 +8890,7 @@ maybe_add_cast_fixit (&rich_loc, open_paren_loc, close_paren_loc, expr, type); warning_at_rich_loc (&rich_loc, OPT_Wold_style_cast, - "use of old-style cast to %qT", type); + "use of old-style cast to %q#T", type); } /* Only type conversions to integral or enumeration types Index: gcc/cp/typeck.c =================================================================== --- gcc/cp/typeck.c (revision 250230) +++ gcc/cp/typeck.c (working copy) @@ -6681,7 +6681,7 @@ ? xvalue_p (expr) : lvalue_p (expr)) && same_type_p (TREE_TYPE (expr), TREE_TYPE (type))) || same_type_p (TREE_TYPE (expr), type)) - warning (OPT_Wuseless_cast, "useless cast to type %qT", type); + warning (OPT_Wuseless_cast, "useless cast to type %q#T", type); } } Index: gcc/cp/error.c =================================================================== --- gcc/cp/error.c (revision 250230) +++ gcc/cp/error.c (working copy) @@ -3172,10 +3172,6 @@ if (len == aka_len && memcmp (p, p+aka_start, len) == 0) p[len] = '\0'; } - - if (typ && TYPE_P (typ) && TREE_CODE (typ) == ENUMERAL_TYPE) - pp_string (cxx_pp, M_(" {enum}")); - return pp_ggc_formatted_text (cxx_pp); } =================================================================== 2017-07-16 Volker Reichelt * g++.dg/cpp1z/direct-enum-init1.C: Revert special enum handling. * g++.dg/warn/pr12242.C: Likewise. Index: gcc/testsuite/g++.dg/cpp1z/direct-enum-init1.C =================================================================== --- gcc/testsuite/g++.dg/cpp1z/direct-enum-init1.C (revision 250230) +++ gcc/testsuite/g++.dg/cpp1z/direct-enum-init1.C (working copy) @@ -17,67 +17,67 @@ void foo () { - A a1 { 5 }; // { dg-error "invalid conversion from 'int' to 'A {enum}'" } - B b1 { 7 }; // { dg-error "invalid conversion from 'int' to 'B {enum}'" "" { target c++14_down } } + A a1 { 5 }; // { dg-error "invalid conversion from 'int' to 'A'" } + B b1 { 7 }; // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } } C c1 { s }; - D d1 { D(t) }; // { dg-error "invalid cast from type 'T' to type 'D {enum}'" } - D d2 { t }; // { dg-error "cannot convert 'T' to 'D {enum}' in initialization" "" { target c++14_down } } - // { dg-error "invalid cast from type 'T' to type 'D {enum}'" "" { target c++1z } .-1 } - D d3 { 9 }; // { dg-error "cannot convert 'int' to 'D {enum}' in initialization" "" { target c++14_down } } - D d4 { l }; // { dg-error "cannot convert 'long int' to 'D {enum}' in initialization" "" { target c++14_down } } + D d1 { D(t) }; // { dg-error "invalid cast from type 'T' to type 'D'" } + D d2 { t }; // { dg-error "cannot convert 'T' to 'D' in initialization" "" { target c++14_down } } + // { dg-error "invalid cast from type 'T' to type 'D'" "" { target c++1z } .-1 } + D d3 { 9 }; // { dg-error "cannot convert 'int' to 'D' in initialization" "" { target c++14_down } } + D d4 { l }; // { dg-error "cannot convert 'long int' to 'D' in initialization" "" { target c++14_down } } D d5 { D(l) }; - D d6 { G }; // { dg-error "cannot convert 'A {enum}' to 'D {enum}' in initialization" "" { target c++14_down } } - E e1 { 5 }; // { dg-error "cannot convert 'int' to 'E {enum}' in initialization" "" { target c++14_down } } - E e2 { -1 }; // { dg-error "cannot convert 'int' to 'E {enum}' in initialization" "" { target c++14_down } } + D d6 { G }; // { dg-error "cannot convert 'A' to 'D' in initialization" "" { target c++14_down } } + E e1 { 5 }; // { dg-error "cannot convert 'int' to 'E' in initialization" "" { target c++14_down } } + E e2 { -1 }; // { dg-error "cannot convert 'int' to 'E' in initialization" "" { target c++14_down } } // { dg-error "narrowing conversion of '-1' from 'int' to 'unsigned char' inside" "" { target c++1z } .-1 } - E e3 { 5.0 }; // { dg-error "cannot convert 'double' to 'E {enum}' in initialization" "" { target c++14_down } } + E e3 { 5.0 }; // { dg-error "cannot convert 'double' to 'E' in initialization" "" { target c++14_down } } // { dg-error "narrowing conversion of '5.0e.0' from 'double' to 'unsigned char' inside" "" { target c++1z } .-1 } - E e4 { 5.2 }; // { dg-error "cannot convert 'double' to 'E {enum}' in initialization" "" { target c++14_down } } + E e4 { 5.2 }; // { dg-error "cannot convert 'double' to 'E' in initialization" "" { target c++14_down } } // { dg-error "narrowing conversion of '5.\[0-9]*e.0' from 'double' to 'unsigned char' inside" "" { target c++1z } .-1 } - B b2 = { 7 }; // { dg-error "invalid conversion from 'int' to 'B {enum}'" } - C c2 = { C { 8 } }; // { dg-error "cannot convert 'int' to 'C {enum}' in initialization" "" { target c++14_down } } + B b2 = { 7 }; // { dg-error "invalid conversion from 'int' to 'B'" } + C c2 = { C { 8 } }; // { dg-error "cannot convert 'int' to 'C' in initialization" "" { target c++14_down } } - D *d7 = new D { 9 }; // { dg-error "cannot convert \[^\n\r]* to 'D {enum}' in initialization" "" { target c++14_down } } - E *e5 = new E { -4 }; // { dg-error "cannot convert \[^\n\r]* to 'E {enum}' in initialization" "" { target c++14_down } } + D *d7 = new D { 9 }; // { dg-error "cannot convert \[^\n\r]* to 'D' in initialization" "" { target c++14_down } } + E *e5 = new E { -4 }; // { dg-error "cannot convert \[^\n\r]* to 'E' in initialization" "" { target c++14_down } } // { dg-error "narrowing conversion of '-4' from 'int' to 'unsigned char' inside" "" { target c++1z } .-1 } - bar ({ 10 }); // { dg-error "cannot convert \[^\n\r]* to 'E {enum}' for argument" } - bar (E { 9 }); // { dg-error "cannot convert 'int' to 'E {enum}' in initialization" "" { target c++14_down } } - V v1 = { { 11 } }; // { dg-error "braces around scalar initializer for type 'E {enum}'" } - V v2 = { E { 12 } }; // { dg-error "cannot convert 'int' to 'E {enum}' in initialization" "" { target c++14_down } } - V v3 = { E { 5.0 } }; // { dg-error "cannot convert 'double' to 'E {enum}' in initialization" "" { target c++14_down } } + bar ({ 10 }); // { dg-error "cannot convert \[^\n\r]* to 'E' for argument" } + bar (E { 9 }); // { dg-error "cannot convert 'int' to 'E' in initialization" "" { target c++14_down } } + V v1 = { { 11 } }; // { dg-error "braces around scalar initializer for type 'E'" } + V v2 = { E { 12 } }; // { dg-error "cannot convert 'int' to 'E' in initialization" "" { target c++14_down } } + V v3 = { E { 5.0 } }; // { dg-error "cannot convert 'double' to 'E' in initialization" "" { target c++14_down } } // { dg-error "narrowing conversion of '5.0e.0' from 'double' to 'unsigned char' inside" "" { target c++1z } .-1 } - V v4 = { 13 }; // { dg-error "cannot convert 'int' to 'E {enum}' in initialization" } - if (B b3 { 5 }) // { dg-error "invalid conversion from 'int' to 'B {enum}'" "" { target c++14_down } } + V v4 = { 13 }; // { dg-error "cannot convert 'int' to 'E' in initialization" } + if (B b3 { 5 }) // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } } ; - if (B b4 { 4.0 }) // { dg-error "cannot convert 'double' to 'B {enum}' in initialization" "" { target c++14_down } } + if (B b4 { 4.0 }) // { dg-error "cannot convert 'double' to 'B' in initialization" "" { target c++14_down } } ; // { dg-error "narrowing conversion of '4.0e.0' from 'double' to 'short int' inside" "" { target c++1z } .-1 } - C c3 { 8L }; // { dg-error "cannot convert 'long int' to 'C {enum}' in initialization" "" { target c++14_down } } - B b4 {short (c + 5)}; // { dg-error "invalid conversion from 'short int' to 'B {enum}'" "" { target c++14_down } } - B b5 {c + 5}; // { dg-error "invalid conversion from 'int' to 'B {enum}'" "" { target c++14_down } } + C c3 { 8L }; // { dg-error "cannot convert 'long int' to 'C' in initialization" "" { target c++14_down } } + B b4 {short (c + 5)}; // { dg-error "invalid conversion from 'short int' to 'B'" "" { target c++14_down } } + B b5 {c + 5}; // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } } // { dg-error "narrowing conversion of \[^\n\r]* from 'int' to 'short int' inside" "" { target c++1z } .-1 } - C c4 { ll }; // { dg-error "cannot convert 'long long int' to 'C {enum}' in initialization" "" { target c++14_down } } + C c4 { ll }; // { dg-error "cannot convert 'long long int' to 'C' in initialization" "" { target c++14_down } } // { dg-error "narrowing conversion of 'll' from 'long long int' to 'int' inside" "" { target c++1z } .-1 } - C c5 {short (c + 5)}; // { dg-error "cannot convert 'short int' to 'C {enum}' in initialization" "" { target c++14_down } } - C c6 {c + 5}; // { dg-error "cannot convert 'int' to 'C {enum}' in initialization" "" { target c++14_down } } + C c5 {short (c + 5)}; // { dg-error "cannot convert 'short int' to 'C' in initialization" "" { target c++14_down } } + C c6 {c + 5}; // { dg-error "cannot convert 'int' to 'C' in initialization" "" { target c++14_down } } } struct U { - U () : e { 5 } {} // { dg-error "cannot convert \[^\n\r]* to 'E {enum}' in initialization" "" { target c++14_down } } - U (int) : e { 5.0 } {}// { dg-error "cannot convert \[^\n\r]* to 'E {enum}' in initialization" "" { target c++14_down } } + U () : e { 5 } {} // { dg-error "cannot convert \[^\n\r]* to 'E' in initialization" "" { target c++14_down } } + U (int) : e { 5.0 } {}// { dg-error "cannot convert \[^\n\r]* to 'E' in initialization" "" { target c++14_down } } // { dg-error "narrowing conversion of '5.0e.0' from 'double' to 'unsigned char' inside" "" { target c++1z } .-1 } U (float) : e({ 6 }) {}// { dg-error "list-initializer for non-class type must not be parenthesized" } - // { dg-error "cannot convert \[^\n\r]* to 'E {enum}' in initialization" "" { target *-*-* } .-1 } + // { dg-error "cannot convert \[^\n\r]* to 'E' in initialization" "" { target *-*-* } .-1 } E e; }; struct W { - A a { 5 }; // { dg-error "invalid conversion from 'int' to 'A {enum}'" } - B b { 6 }; // { dg-error "invalid conversion from 'int' to 'B {enum}'" "" { target c++14_down } } - C c { 3.0f }; // { dg-error "cannot convert \[^\n\r]* to 'C {enum}' in initialization" "" { target c++14_down } } + A a { 5 }; // { dg-error "invalid conversion from 'int' to 'A'" } + B b { 6 }; // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } } + C c { 3.0f }; // { dg-error "cannot convert \[^\n\r]* to 'C' in initialization" "" { target c++14_down } } // { dg-error "narrowing conversion of '3.0e.0f' from 'float' to 'int' inside" "" { target c++1z } .-1 } - D d = { 7 }; // { dg-error "cannot convert \[^\n\r]* to 'D {enum}' in initialization" } + D d = { 7 }; // { dg-error "cannot convert \[^\n\r]* to 'D' in initialization" } }; template @@ -84,54 +84,54 @@ void foo2 () { - A a1 { 5 }; // { dg-error "invalid conversion from 'int' to 'A {enum}'" } - B b1 { 7 }; // { dg-error "invalid conversion from 'int' to 'B {enum}'" "" { target c++14_down } } + A a1 { 5 }; // { dg-error "invalid conversion from 'int' to 'A'" } + B b1 { 7 }; // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } } C c1 { s }; - D d1 { D(t) }; // { dg-error "invalid cast from type 'T' to type 'D {enum}'" } - D d2 { t }; // { dg-error "cannot convert 'T' to 'D {enum}' in initialization" "" { target c++14_down } } - // { dg-error "invalid cast from type 'T' to type 'D {enum}'" "" { target c++1z } .-1 } - D d3 { 9 }; // { dg-error "cannot convert 'int' to 'D {enum}' in initialization" "" { target c++14_down } } - D d4 { l }; // { dg-error "cannot convert 'long int' to 'D {enum}' in initialization" "" { target c++14_down } } + D d1 { D(t) }; // { dg-error "invalid cast from type 'T' to type 'D'" } + D d2 { t }; // { dg-error "cannot convert 'T' to 'D' in initialization" "" { target c++14_down } } + // { dg-error "invalid cast from type 'T' to type 'D'" "" { target c++1z } .-1 } + D d3 { 9 }; // { dg-error "cannot convert 'int' to 'D' in initialization" "" { target c++14_down } } + D d4 { l }; // { dg-error "cannot convert 'long int' to 'D' in initialization" "" { target c++14_down } } D d5 { D(l) }; - D d6 { G }; // { dg-error "cannot convert 'A {enum}' to 'D {enum}' in initialization" "" { target c++14_down } } - E e1 { 5 }; // { dg-error "cannot convert 'int' to 'E {enum}' in initialization" "" { target c++14_down } } - E e2 { -1 }; // { dg-error "cannot convert 'int' to 'E {enum}' in initialization" "" { target c++14_down } } + D d6 { G }; // { dg-error "cannot convert 'A' to 'D' in initialization" "" { target c++14_down } } + E e1 { 5 }; // { dg-error "cannot convert 'int' to 'E' in initialization" "" { target c++14_down } } + E e2 { -1 }; // { dg-error "cannot convert 'int' to 'E' in initialization" "" { target c++14_down } } // { dg-error "narrowing conversion of '-1' from 'int' to 'unsigned char' inside" "" { target c++1z } .-1 } - E e3 { 5.0 }; // { dg-error "cannot convert 'double' to 'E {enum}' in initialization" "" { target c++14_down } } + E e3 { 5.0 }; // { dg-error "cannot convert 'double' to 'E' in initialization" "" { target c++14_down } } // { dg-error "narrowing conversion of '5.0e.0' from 'double' to 'unsigned char' inside" "" { target c++1z } .-1 } - E e4 { 5.2 }; // { dg-error "cannot convert 'double' to 'E {enum}' in initialization" "" { target c++14_down } } + E e4 { 5.2 }; // { dg-error "cannot convert 'double' to 'E' in initialization" "" { target c++14_down } } // { dg-error "narrowing conversion of '5.\[0-9]*e.0' from 'double' to 'unsigned char' inside" "" { target c++1z } .-1 } - B b2 = { 7 }; // { dg-error "invalid conversion from 'int' to 'B {enum}'" } - C c2 = { C { 8 } }; // { dg-error "cannot convert 'int' to 'C {enum}' in initialization" "" { target c++14_down } } - D *d7 = new D { 9 }; // { dg-error "cannot convert \[^\n\r]* to 'D {enum}' in initialization" "" { target c++14_down } } - E *e5 = new E { -4 }; // { dg-error "cannot convert \[^\n\r]* to 'E {enum}' in initialization" "" { target c++14_down } } + B b2 = { 7 }; // { dg-error "invalid conversion from 'int' to 'B'" } + C c2 = { C { 8 } }; // { dg-error "cannot convert 'int' to 'C' in initialization" "" { target c++14_down } } + D *d7 = new D { 9 }; // { dg-error "cannot convert \[^\n\r]* to 'D' in initialization" "" { target c++14_down } } + E *e5 = new E { -4 }; // { dg-error "cannot convert \[^\n\r]* to 'E' in initialization" "" { target c++14_down } } // { dg-error "narrowing conversion of '-4' from 'int' to 'unsigned char' inside" "" { target c++1z } .-1 } - bar ({ 10 }); // { dg-error "cannot convert \[^\n\r]* to 'E {enum}' for argument" } - bar (E { 9 }); // { dg-error "cannot convert 'int' to 'E {enum}' in initialization" "" { target c++14_down } } - V v1 = { { 11 } }; // { dg-error "braces around scalar initializer for type 'E {enum}'" } - V v2 = { E { 12 } }; // { dg-error "cannot convert 'int' to 'E {enum}' in initialization" "" { target c++14_down } } - V v3 = { E { 5.0 } }; // { dg-error "cannot convert 'double' to 'E {enum}' in initialization" "" { target c++14_down } } + bar ({ 10 }); // { dg-error "cannot convert \[^\n\r]* to 'E' for argument" } + bar (E { 9 }); // { dg-error "cannot convert 'int' to 'E' in initialization" "" { target c++14_down } } + V v1 = { { 11 } }; // { dg-error "braces around scalar initializer for type 'E'" } + V v2 = { E { 12 } }; // { dg-error "cannot convert 'int' to 'E' in initialization" "" { target c++14_down } } + V v3 = { E { 5.0 } }; // { dg-error "cannot convert 'double' to 'E' in initialization" "" { target c++14_down } } // { dg-error "narrowing conversion of '5.0e.0' from 'double' to 'unsigned char' inside" "" { target c++1z } .-1 } - V v4 = { 13 }; // { dg-error "cannot convert 'int' to 'E {enum}' in initialization" } - if (B b3 { 5 }) // { dg-error "invalid conversion from 'int' to 'B {enum}'" "" { target c++14_down } } + V v4 = { 13 }; // { dg-error "cannot convert 'int' to 'E' in initialization" } + if (B b3 { 5 }) // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } } ; - if (B b4 { 4.0 }) // { dg-error "cannot convert 'double' to 'B {enum}' in initialization" "" { target c++14_down } } + if (B b4 { 4.0 }) // { dg-error "cannot convert 'double' to 'B' in initialization" "" { target c++14_down } } ; // { dg-error "narrowing conversion of '4.0e.0' from 'double' to 'short int' inside" "" { target c++1z } .-1 } - C c3 { 8L }; // { dg-error "cannot convert 'long int' to 'C {enum}' in initialization" "" { target c++14_down } } - B b4 {short (c + 5)}; // { dg-error "invalid conversion from 'short int' to 'B {enum}'" "" { target c++14_down } } - B b5 {c + 5}; // { dg-error "invalid conversion from 'int' to 'B {enum}'" "" { target c++14_down } } + C c3 { 8L }; // { dg-error "cannot convert 'long int' to 'C' in initialization" "" { target c++14_down } } + B b4 {short (c + 5)}; // { dg-error "invalid conversion from 'short int' to 'B'" "" { target c++14_down } } + B b5 {c + 5}; // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } } // { dg-error "narrowing conversion of \[^\n\r]* from 'int' to 'short int' inside" "" { target c++1z } .-1 } - C c4 { ll }; // { dg-error "cannot convert 'long long int' to 'C {enum}' in initialization" "" { target c++14_down } } + C c4 { ll }; // { dg-error "cannot convert 'long long int' to 'C' in initialization" "" { target c++14_down } } // { dg-error "narrowing conversion of 'll' from 'long long int' to 'int' inside" "" { target c++1z } .-1 } - C c5 {short (c + 5)}; // { dg-error "cannot convert 'short int' to 'C {enum}' in initialization" "" { target c++14_down } } - C c6 {c + 5}; // { dg-error "cannot convert 'int' to 'C {enum}' in initialization" "" { target c++14_down } } + C c5 {short (c + 5)}; // { dg-error "cannot convert 'short int' to 'C' in initialization" "" { target c++14_down } } + C c6 {c + 5}; // { dg-error "cannot convert 'int' to 'C' in initialization" "" { target c++14_down } } } template struct U2 { - U2 () : e { 5 } {} // { dg-error "cannot convert \[^\n\r]* to 'E {enum}' in initialization" "" { target c++14_down } } - U2 (int) : e { 5.0 } {}// { dg-error "cannot convert \[^\n\r]* to 'E {enum}' in initialization" "" { target c++14_down } } + U2 () : e { 5 } {} // { dg-error "cannot convert \[^\n\r]* to 'E' in initialization" "" { target c++14_down } } + U2 (int) : e { 5.0 } {}// { dg-error "cannot convert \[^\n\r]* to 'E' in initialization" "" { target c++14_down } } // { dg-error "narrowing conversion of '5.0e.0' from 'double' to 'unsigned char' inside" "" { target c++1z } .-1 } U2 (float) : e({ 6 }) {} E e; @@ -140,11 +140,11 @@ template struct W2 { - A a { 5 }; // { dg-error "invalid conversion from 'int' to 'A {enum}'" "" { target *-*-* } .-2 } - B b { 6 }; // { dg-error "invalid conversion from 'int' to 'B {enum}'" "" { target c++14_down } .-3 } - C c { 3.0f }; // { dg-error "cannot convert \[^\n\r]* to 'C {enum}' in initialization" "" { target c++14_down } .-4 } + A a { 5 }; // { dg-error "invalid conversion from 'int' to 'A'" "" { target *-*-* } .-2 } + B b { 6 }; // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } .-3 } + C c { 3.0f }; // { dg-error "cannot convert \[^\n\r]* to 'C' in initialization" "" { target c++14_down } .-4 } // { dg-error "narrowing conversion of '3.0e.0f' from 'float' to 'int' inside" "" { target c++1z } .-5 } - D d = { 7 }; // { dg-error "cannot convert \[^\n\r]* to 'D {enum}' in initialization" "" { target *-*-* } .-6 } + D d = { 7 }; // { dg-error "cannot convert \[^\n\r]* to 'D' in initialization" "" { target *-*-* } .-6 } }; template @@ -152,54 +152,54 @@ foo3 () { void bar3 (L); - H a1 { 5 }; // { dg-error "invalid conversion from 'int' to 'A {enum}'" } - I b1 { 7 }; // { dg-error "invalid conversion from 'int' to 'B {enum}'" "" { target c++14_down } } + H a1 { 5 }; // { dg-error "invalid conversion from 'int' to 'A'" } + I b1 { 7 }; // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } } J c1 { s }; - K d1 { K(t) }; // { dg-error "invalid cast from type 'T' to type 'D {enum}'" } - K d2 { t }; // { dg-error "cannot convert 'T' to 'D {enum}' in initialization" "" { target c++14_down } } - // { dg-error "invalid cast from type 'T' to type 'D {enum}'" "" { target c++1z } .-1 } - K d3 { 9 }; // { dg-error "cannot convert 'int' to 'D {enum}' in initialization" "" { target c++14_down } } - K d4 { l }; // { dg-error "cannot convert 'long int' to 'D {enum}' in initialization" "" { target c++14_down } } + K d1 { K(t) }; // { dg-error "invalid cast from type 'T' to type 'D'" } + K d2 { t }; // { dg-error "cannot convert 'T' to 'D' in initialization" "" { target c++14_down } } + // { dg-error "invalid cast from type 'T' to type 'D'" "" { target c++1z } .-1 } + K d3 { 9 }; // { dg-error "cannot convert 'int' to 'D' in initialization" "" { target c++14_down } } + K d4 { l }; // { dg-error "cannot convert 'long int' to 'D' in initialization" "" { target c++14_down } } K d5 { K(l) }; - K d6 { G }; // { dg-error "cannot convert 'A {enum}' to 'D {enum}' in initialization" "" { target c++14_down } } - L e1 { 5 }; // { dg-error "cannot convert 'int' to 'E {enum}' in initialization" "" { target c++14_down } } - L e2 { -1 }; // { dg-error "cannot convert 'int' to 'E {enum}' in initialization" "" { target c++14_down } } + K d6 { G }; // { dg-error "cannot convert 'A' to 'D' in initialization" "" { target c++14_down } } + L e1 { 5 }; // { dg-error "cannot convert 'int' to 'E' in initialization" "" { target c++14_down } } + L e2 { -1 }; // { dg-error "cannot convert 'int' to 'E' in initialization" "" { target c++14_down } } // { dg-error "narrowing conversion of '-1' from 'int' to 'unsigned char' inside" "" { target c++1z } .-1 } - L e3 { 5.0 }; // { dg-error "cannot convert 'double' to 'E {enum}' in initialization" "" { target c++14_down } } + L e3 { 5.0 }; // { dg-error "cannot convert 'double' to 'E' in initialization" "" { target c++14_down } } // { dg-error "narrowing conversion of '5.0e.0' from 'double' to 'unsigned char' inside" "" { target c++1z } .-1 } - L e4 { 5.2 }; // { dg-error "cannot convert 'double' to 'E {enum}' in initialization" "" { target c++14_down } } + L e4 { 5.2 }; // { dg-error "cannot convert 'double' to 'E' in initialization" "" { target c++14_down } } // { dg-error "narrowing conversion of '5.\[0-9]*e.0' from 'double' to 'unsigned char' inside" "" { target c++1z } .-1 } - I b2 = { 7 }; // { dg-error "invalid conversion from 'int' to 'B {enum}'" } - J c2 = { J { 8 } }; // { dg-error "cannot convert 'int' to 'C {enum}' in initialization" "" { target c++14_down } } - K *d7 = new K { 9 }; // { dg-error "cannot convert \[^\n\r]* to 'D {enum}' in initialization" "" { target c++14_down } } - L *e5 = new L { -4 }; // { dg-error "cannot convert \[^\n\r]* to 'E {enum}' in initialization" "" { target c++14_down } } + I b2 = { 7 }; // { dg-error "invalid conversion from 'int' to 'B'" } + J c2 = { J { 8 } }; // { dg-error "cannot convert 'int' to 'C' in initialization" "" { target c++14_down } } + K *d7 = new K { 9 }; // { dg-error "cannot convert \[^\n\r]* to 'D' in initialization" "" { target c++14_down } } + L *e5 = new L { -4 }; // { dg-error "cannot convert \[^\n\r]* to 'E' in initialization" "" { target c++14_down } } // { dg-error "narrowing conversion of '-4' from 'int' to 'unsigned char' inside" "" { target c++1z } .-1 } - bar3 ({ 10 }); // { dg-error "cannot convert \[^\n\r]* to 'E {enum}' for argument" } - bar3 (E { 9 }); // { dg-error "cannot convert 'int' to 'E {enum}' in initialization" "" { target c++14_down } } - M v1 = { { 11 } }; // { dg-error "braces around scalar initializer for type 'E {enum}'" } - M v2 = { L { 12 } }; // { dg-error "cannot convert 'int' to 'E {enum}' in initialization" "" { target c++14_down } } - M v3 = { L { 5.0 } }; // { dg-error "cannot convert 'double' to 'E {enum}' in initialization" "" { target c++14_down } } + bar3 ({ 10 }); // { dg-error "cannot convert \[^\n\r]* to 'E' for argument" } + bar3 (E { 9 }); // { dg-error "cannot convert 'int' to 'E' in initialization" "" { target c++14_down } } + M v1 = { { 11 } }; // { dg-error "braces around scalar initializer for type 'E'" } + M v2 = { L { 12 } }; // { dg-error "cannot convert 'int' to 'E' in initialization" "" { target c++14_down } } + M v3 = { L { 5.0 } }; // { dg-error "cannot convert 'double' to 'E' in initialization" "" { target c++14_down } } // { dg-error "narrowing conversion of '5.0e.0' from 'double' to 'unsigned char' inside" "" { target c++1z } .-1 } - M v4 = { 13 }; // { dg-error "cannot convert 'int' to 'E {enum}' in initialization" } - if (I b3 { 5 }) // { dg-error "invalid conversion from 'int' to 'B {enum}'" "" { target c++14_down } } + M v4 = { 13 }; // { dg-error "cannot convert 'int' to 'E' in initialization" } + if (I b3 { 5 }) // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } } ; - if (I b4 { 4.0 }) // { dg-error "cannot convert 'double' to 'B {enum}' in initialization" "" { target c++14_down } } + if (I b4 { 4.0 }) // { dg-error "cannot convert 'double' to 'B' in initialization" "" { target c++14_down } } ; // { dg-error "narrowing conversion of '4.0e.0' from 'double' to 'short int' inside" "" { target c++1z } .-1 } - J c3 { 8L }; // { dg-error "cannot convert 'long int' to 'C {enum}' in initialization" "" { target c++14_down } } - I b4 {short (c + 5)}; // { dg-error "invalid conversion from 'short int' to 'B {enum}'" "" { target c++14_down } } - I b5 {c + 5}; // { dg-error "invalid conversion from 'int' to 'B {enum}'" "" { target c++14_down } } + J c3 { 8L }; // { dg-error "cannot convert 'long int' to 'C' in initialization" "" { target c++14_down } } + I b4 {short (c + 5)}; // { dg-error "invalid conversion from 'short int' to 'B'" "" { target c++14_down } } + I b5 {c + 5}; // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } } // { dg-error "narrowing conversion of \[^\n\r]* from 'int' to 'short int' inside" "" { target c++1z } .-1 } - J c4 { ll }; // { dg-error "cannot convert 'long long int' to 'C {enum}' in initialization" "" { target c++14_down } } + J c4 { ll }; // { dg-error "cannot convert 'long long int' to 'C' in initialization" "" { target c++14_down } } // { dg-error "narrowing conversion of 'll' from 'long long int' to 'int' inside" "" { target c++1z } .-1 } - J c5 {short (c + 5)}; // { dg-error "cannot convert 'short int' to 'C {enum}' in initialization" "" { target c++14_down } } - J c6 {c + 5}; // { dg-error "cannot convert 'int' to 'C {enum}' in initialization" "" { target c++14_down } } + J c5 {short (c + 5)}; // { dg-error "cannot convert 'short int' to 'C' in initialization" "" { target c++14_down } } + J c6 {c + 5}; // { dg-error "cannot convert 'int' to 'C' in initialization" "" { target c++14_down } } } template struct U3 { - U3 () : e { 5 } {} // { dg-error "cannot convert \[^\n\r]* to 'E {enum}' in initialization" "" { target c++14_down } } - U3 (int) : e { 5.0 } {}// { dg-error "cannot convert \[^\n\r]* to 'E {enum}' in initialization" "" { target c++14_down } } + U3 () : e { 5 } {} // { dg-error "cannot convert \[^\n\r]* to 'E' in initialization" "" { target c++14_down } } + U3 (int) : e { 5.0 } {}// { dg-error "cannot convert \[^\n\r]* to 'E' in initialization" "" { target c++14_down } } // { dg-error "narrowing conversion of '5.0e.0' from 'double' to 'unsigned char' inside" "" { target c++1z } .-1 } U3 (float) : e({ 6 }) {} L e; @@ -208,11 +208,11 @@ template struct W3 { - H a { 5 }; // { dg-error "invalid conversion from 'int' to 'A {enum}'" "" { target *-*-* } .-2 } - I b { 6 }; // { dg-error "invalid conversion from 'int' to 'B {enum}'" "" { target c++14_down } .-3 } - J c { 3.0f }; // { dg-error "cannot convert \[^\n\r]* to 'C {enum}' in initialization" "" { target c++14_down } .-4 } + H a { 5 }; // { dg-error "invalid conversion from 'int' to 'A'" "" { target *-*-* } .-2 } + I b { 6 }; // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } .-3 } + J c { 3.0f }; // { dg-error "cannot convert \[^\n\r]* to 'C' in initialization" "" { target c++14_down } .-4 } // { dg-error "narrowing conversion of '3.0e.0f' from 'float' to 'int' inside" "" { target c++1z } .-5 } - K d = { 7 }; // { dg-error "cannot convert \[^\n\r]* to 'D {enum}' in initialization" "" { target *-*-* } .-6 } + K d = { 7 }; // { dg-error "cannot convert \[^\n\r]* to 'D' in initialization" "" { target *-*-* } .-6 } }; void @@ -221,17 +221,17 @@ foo2<0> (); U2<0> u20; U2<1> u21 (5); - W2<0> w2; // { dg-error "invalid conversion from 'int' to 'A {enum}'" } - // { dg-error "invalid conversion from 'int' to 'B {enum}'" "" { target c++14_down } .-1 } - // { dg-error "cannot convert \[^\n\r]* to 'C {enum}' in initialization" "" { target c++14_down } .-2 } + W2<0> w2; // { dg-error "invalid conversion from 'int' to 'A'" } + // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } .-1 } + // { dg-error "cannot convert \[^\n\r]* to 'C' in initialization" "" { target c++14_down } .-2 } // { dg-error "narrowing conversion of '3.0e.0f' from 'float' to 'int' inside" "" { target c++1z } .-3 } - // { dg-error "cannot convert \[^\n\r]* to 'D {enum}' in initialization" "" { target *-*-* } .-4 } + // { dg-error "cannot convert \[^\n\r]* to 'D' in initialization" "" { target *-*-* } .-4 } foo3 (); U3 u30; U3 u31 (5); - W3 w3; // { dg-error "invalid conversion from 'int' to 'A {enum}'" } - // { dg-error "invalid conversion from 'int' to 'B {enum}'" "" { target c++14_down } .-1 } - // { dg-error "cannot convert \[^\n\r]* to 'C {enum}' in initialization" "" { target c++14_down } .-2 } + W3 w3; // { dg-error "invalid conversion from 'int' to 'A'" } + // { dg-error "invalid conversion from 'int' to 'B'" "" { target c++14_down } .-1 } + // { dg-error "cannot convert \[^\n\r]* to 'C' in initialization" "" { target c++14_down } .-2 } // { dg-error "narrowing conversion of '3.0e.0f' from 'float' to 'int' inside" "" { target c++1z } .-3 } - // { dg-error "cannot convert \[^\n\r]* to 'D {enum}' in initialization" "" { target *-*-* } .-4 } + // { dg-error "cannot convert \[^\n\r]* to 'D' in initialization" "" { target *-*-* } .-4 } } Index: gcc/testsuite/g++.dg/warn/pr12242.C =================================================================== --- gcc/testsuite/g++.dg/warn/pr12242.C (revision 250230) +++ gcc/testsuite/g++.dg/warn/pr12242.C (working copy) @@ -10,14 +10,14 @@ X x; Y y; - x = 10; // { dg-warning "invalid conversion from .int. to .X {enum}." "invalid" } + x = 10; // { dg-warning "invalid conversion from .int. to .X." "invalid" } // { dg-warning "unspecified" "unspecified" { target *-*-* } .-1 } - x = 1; // { dg-warning "invalid conversion from .int. to .X {enum}." } - x = C; // { dg-error "cannot convert .Y {enum}. to .X {enum}. in assignment" } - x = D; // { dg-error "cannot convert .Y {enum}. to .X {enum}. in assignment" } - y = A; // { dg-error "cannot convert .X {enum}. to .Y {enum}. in assignment" } - x = y; // { dg-error "cannot convert .Y {enum}. to .X {enum}. in assignment" } - x = i; // { dg-warning "invalid conversion from .int. to .X {enum}." } + x = 1; // { dg-warning "invalid conversion from .int. to .X." } + x = C; // { dg-error "cannot convert .Y. to .X. in assignment" } + x = D; // { dg-error "cannot convert .Y. to .X. in assignment" } + y = A; // { dg-error "cannot convert .X. to .Y. in assignment" } + x = y; // { dg-error "cannot convert .Y. to .X. in assignment" } + x = i; // { dg-warning "invalid conversion from .int. to .X." } } void foo ()