From patchwork Thu Jan 17 09:59:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1026496 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-494222-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="x5Q0U87B"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="d5+3GT+t"; dkim-atps=neutral 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 43gKLv1Gzqz9sD4 for ; Thu, 17 Jan 2019 21:00:05 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=CAM6jcs+zE/buFEfWbwdBPTMGplG556sNYXp0HqZpO5AmxX05+ RqI7tHgldZ+fbezGpeqig7Y+sHlpAWsWyzjeaZN0XG0jB37ME34Znu4vXwUBGvO4 EzenirZ/VZxwebvj5zakTZLil0Zy+IvuvdqJYHHIueNCMPFTVYjWrW8XQ= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=PyWv0L+NFrrtF80kpeg0CLgYCBw=; b=x5Q0U87BipLoYZ3qazxg fsMABYyOzs/RghWHo3dmHMTpHXv3E5L1efnXznW6k6QRuzZHBavjDEKC2C6zZjda JDKL7xE8PMyEF24/ouuvbQGouDBAa2vtg7F03eNp0uixxCJRdDVhIRFORIqAhChX Tlk0ESx0WomoZzs4Equr/9o= Received: (qmail 18157 invoked by alias); 17 Jan 2019 09:59:57 -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 18140 invoked by uid 89); 17 Jan 2019 09:59:57 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=37, oracle.com, *declarator, oraclecom X-HELO: aserp2130.oracle.com Received: from aserp2130.oracle.com (HELO aserp2130.oracle.com) (141.146.126.79) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 17 Jan 2019 09:59:53 +0000 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x0H9xkpj118464; Thu, 17 Jan 2019 09:59:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=to : cc : from : subject : message-id : date : mime-version : content-type; s=corp-2018-07-02; bh=m+d3+SVj1ZSYx1C2rWt/vGliMQlplHFS5NmSeTeHo80=; b=d5+3GT+tDpXFyX6XySuKmysWFEXqWHDHhgHY+VX2EgsrcCVHPe/J6Xm7bXFdehu32N0k xbJrRqGNeVJAQpemdmCqCXOAdODjLFSAybq0ge/Dt4G7jULRJdIRbEImdUDxgvDzdAXh K22gXiZdFAQWs5PecnZtDQUjpMjnM9AziPxFS/vah9e6Szlofmm/x6Tn9VYaPzWLs23j X1R+Cwas5G4bWyaAO03jvv+5Hf2foxpI9FQMfS7L/Kk50Yl+i44Y7T0Cxs1LV4xWUfkQ WAo1UWoi96hitGlyv3uDOsnxqK53J7hVDuC1F/1B2ahs/Ic4nfr0U/sxaBSoblEx/i/d Pg== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2130.oracle.com with ESMTP id 2pybjnxxw7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Jan 2019 09:59:51 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x0H9xp2f003998 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Jan 2019 09:59:51 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x0H9xpxk000351; Thu, 17 Jan 2019 09:59:51 GMT Received: from [192.168.1.4] (/79.19.31.237) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 17 Jan 2019 01:59:50 -0800 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] In grokdeclarator, use typespec_loc in error messages about 'auto' and trailing return type Message-ID: Date: Thu, 17 Jan 2019 10:59:48 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, just use in more places the carefully constructed typespec_loc. Note for another time: the 'type name' we print for tests like cpp0x/auto52.C doesn't seem particularly clear to me. Tested x86_64-linux, as usual. Thanks, Paolo. //////////////////////// /cp 2019-01-17 Paolo Carlini * decl.c (grokdeclarator): Use typespec_loc in error messages about 'auto' and trailing return type. /testsuite 2019-01-17 Paolo Carlini * g++.dg/cpp0x/auto52.C: Test locations too. * g++.dg/cpp0x/trailing2.C: Likewise. * g++.dg/cpp1y/auto-fn18.C: Likewise. * g++.dg/cpp1y/auto-fn25.C: Likewise. * g++.dg/cpp1y/auto-fn52.C: Likewise. * g++.dg/cpp1y/auto-fn53.C: Likewise. * g++.dg/cpp1y/auto-fn54.C: Likewise. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 267986) +++ cp/decl.c (working copy) @@ -11287,35 +11288,37 @@ grokdeclarator (const cp_declarator *declarator, /* OK for C++11 lambdas. */; else if (cxx_dialect < cxx14) { - error ("%qs function uses " - "% type specifier without trailing " - "return type", name); - inform (input_location, "deduced return type " - "only available with -std=c++14 or " - "-std=gnu++14"); + error_at (typespec_loc, "%qs function uses " + "% type specifier without " + "trailing return type", name); + inform (typespec_loc, + "deduced return type only available " + "with -std=c++14 or -std=gnu++14"); } else if (virtualp) { - error ("virtual function cannot " - "have deduced return type"); + error_at (typespec_loc, "virtual function " + "cannot have deduced return type"); virtualp = false; } } else if (!is_auto (type) && sfk != sfk_conversion) { - error ("%qs function with trailing return type has" - " %qT as its type rather than plain %", - name, type); + error_at (typespec_loc, "%qs function with trailing " + "return type has %qT as its type rather " + "than plain %", name, type); return error_mark_node; } else if (is_auto (type) && AUTO_IS_DECLTYPE (type)) { if (funcdecl_p) - error ("%qs function with trailing return type has " - "% as its type rather than " - "plain %", name); + error_at (typespec_loc, + "%qs function with trailing return type " + "has % as its type " + "rather than plain %", name); else - error ("invalid use of %"); + error_at (typespec_loc, + "invalid use of %"); return error_mark_node; } tree tmpl = CLASS_PLACEHOLDER_TEMPLATE (auto_node); @@ -11359,11 +11362,13 @@ grokdeclarator (const cp_declarator *declarator, if (cxx_dialect < cxx11) /* Not using maybe_warn_cpp0x because this should always be an error. */ - error ("trailing return type only available with " - "-std=c++11 or -std=gnu++11"); + error_at (typespec_loc, + "trailing return type only available " + "with -std=c++11 or -std=gnu++11"); else - error ("%qs function with trailing return type not " - "declared with % type specifier", name); + error_at (typespec_loc, "%qs function with trailing " + "return type not declared with % " + "type specifier", name); return error_mark_node; } } Index: testsuite/g++.dg/cpp0x/auto52.C =================================================================== --- testsuite/g++.dg/cpp0x/auto52.C (revision 267977) +++ testsuite/g++.dg/cpp0x/auto52.C (working copy) @@ -2,5 +2,5 @@ // { dg-do compile { target c++11 } } using T = auto() -> int; -using U = void() -> int; // { dg-error "function with trailing return type not declared with .auto." } -using W = auto(); // { dg-error "invalid use of .auto." } +using U = void() -> int; // { dg-error "11:.type name. function with trailing return type not declared with .auto." } +using W = auto(); // { dg-error "11:invalid use of .auto." } Index: testsuite/g++.dg/cpp0x/trailing2.C =================================================================== --- testsuite/g++.dg/cpp0x/trailing2.C (revision 267977) +++ testsuite/g++.dg/cpp0x/trailing2.C (working copy) @@ -3,14 +3,14 @@ // { dg-do compile { target c++11 } } auto f1 () -> int; -auto f2 (); // { dg-error "without trailing return type" "" { target { ! c++14 } } } -int f3 () -> int; // { dg-error "trailing return type" } -auto *f4 () -> int; // { dg-error "trailing return type" } +auto f2 (); // { dg-error "1:.f2. function uses .auto. type specifier without trailing return type" "" { target { ! c++14 } } } +int f3 () -> int; // { dg-error "1:.f3. function with trailing return type" } +auto *f4 () -> int; // { dg-error "1:.f4. function with trailing return type" } struct A { auto f5 () const -> int; - auto f6 (); // { dg-error "without trailing return type" "" { target { ! c++14 } } } - int f7 () -> int; // { dg-error "trailing return type" } - auto *f8 () -> int; // { dg-error "trailing return type" } + auto f6 (); // { dg-error "3:.f6. function uses .auto. type specifier without trailing return type" "" { target { ! c++14 } } } + int f7 () -> int; // { dg-error "3:.f7. function with trailing return type" } + auto *f8 () -> int; // { dg-error "3:.f8. function with trailing return type" } }; Index: testsuite/g++.dg/cpp1y/auto-fn18.C =================================================================== --- testsuite/g++.dg/cpp1y/auto-fn18.C (revision 267977) +++ testsuite/g++.dg/cpp1y/auto-fn18.C (working copy) @@ -3,7 +3,7 @@ struct A { virtual int f() { return 1; } // { dg-message "overridden" } - virtual auto g() { return 1; } // { dg-error "virtual" } + virtual auto g() { return 1; } // { dg-error "11:virtual" } }; struct B: A Index: testsuite/g++.dg/cpp1y/auto-fn25.C =================================================================== --- testsuite/g++.dg/cpp1y/auto-fn25.C (revision 267977) +++ testsuite/g++.dg/cpp1y/auto-fn25.C (working copy) @@ -5,7 +5,7 @@ struct A { - virtual auto foo() {} // { dg-error "virtual.*deduced" } + virtual auto foo() {} // { dg-error "11:virtual.*deduced" } }; struct B : A Index: testsuite/g++.dg/cpp1y/auto-fn52.C =================================================================== --- testsuite/g++.dg/cpp1y/auto-fn52.C (revision 267977) +++ testsuite/g++.dg/cpp1y/auto-fn52.C (working copy) @@ -1,4 +1,4 @@ // PR c++/67012 // { dg-do compile { target c++14 } } -decltype(auto) f() -> int; // { dg-error "function with trailing return type has" } +decltype(auto) f() -> int; // { dg-error "1:.f. function with trailing return type has" } Index: testsuite/g++.dg/cpp1y/auto-fn53.C =================================================================== --- testsuite/g++.dg/cpp1y/auto-fn53.C (revision 267977) +++ testsuite/g++.dg/cpp1y/auto-fn53.C (working copy) @@ -1,4 +1,4 @@ // PR c++/86942 // { dg-do compile { target c++14 } } -using T = decltype(auto) () -> int; // { dg-error "invalid use of" } +using T = decltype(auto) () -> int; // { dg-error "11:invalid use of" } Index: testsuite/g++.dg/cpp1y/auto-fn54.C =================================================================== --- testsuite/g++.dg/cpp1y/auto-fn54.C (revision 267977) +++ testsuite/g++.dg/cpp1y/auto-fn54.C (working copy) @@ -1,3 +1,3 @@ // { dg-do compile { target c++14 } } -using T = int () -> decltype(auto); // { dg-error "function with trailing return type not declared with .auto." } +using T = int () -> decltype(auto); // { dg-error "11:.type name. function with trailing return type not declared with .auto." }