From patchwork Fri Jan 18 11:13:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1027211 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-494294-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="L9+MaWdt"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="0Bjs3aNW"; 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 43gyxc0Jqzz9sBQ for ; Fri, 18 Jan 2019 22:13:55 +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:from :subject:to:cc:message-id:date:mime-version:content-type; q=dns; s=default; b=H+aXCr4K4JjYir9y3Ui92hzRSJfWzQMcRpImS2h+vmxr/ji9eb V8dk3e/C5xqUy19A4jHYq8ZLz+07/gNtA+dh//1+7MQeBYi5ALYhEMJyDRhlLeHZ kwmUIhePP4anBPMsMALjbQCsIFARn/brUO+jeAfMEcgcD6EkCrwGz6YSI= 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:from :subject:to:cc:message-id:date:mime-version:content-type; s= default; bh=fFALpUrQHy9I5/jSAfdyz631n/4=; b=L9+MaWdt4uTg5gXwdzGv aKzESU+Zxy5wOlB3+mQTjtwAbrfV8e/xq6vh4jb8q7chRk0YBvLeLM8edAr/SxoD iYIYwFeXz10BMyN4xB/uggDni6bP4HQbTdDF4UwQcQP0L7ZVSEnvFqFlpBin2uxX 7hRZaOUsmlxdmyQy9c6IfUM= Received: (qmail 104244 invoked by alias); 18 Jan 2019 11:13:49 -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 104229 invoked by uid 89); 18 Jan 2019 11:13:48 -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, SPF_PASS autolearn=ham version=3.3.2 spammy=type_quals, Locations X-HELO: userp2130.oracle.com Received: from userp2130.oracle.com (HELO userp2130.oracle.com) (156.151.31.86) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 18 Jan 2019 11:13:45 +0000 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x0IB3lbC134033; Fri, 18 Jan 2019 11:13:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : subject : to : cc : message-id : date : mime-version : content-type; s=corp-2018-07-02; bh=ECEz1dT2B5O27ET04fkPCcXoiuMGAS+ZU6j5A74rEtA=; b=0Bjs3aNWmgVYoQCuU0WitNoISJRXbl1gi1ICQ/SRJ/0KKxRtcptpaTrG/KrfQs3UE1BE YMb36mpYc2Pn6Ot5gyN+oYcYyM5c8sXgltIR3sEL+OitHH7nlxmQmulpkUlJ90q9btm2 Ks+2MPeId3oi2PBYdfY7orJsPdc1g3Hj+Y1JV6q62u4xVqPGJQSX9V+iJPCE7VsRFimW z69wxdenkNVn+xy6o8z8vjwNTkUb4l4FzH7MCOn1whjKrtkRbMrfnca758BqwcBd0APJ ZQrnDAhFjYEYS7Yphf0j7/c37Sj+3pTcn9aOSBvDpeWmNvtCkwOyuGzIIL5ZzoYT/34n qg== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2pybkcw15r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 18 Jan 2019 11:13:43 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x0IBDc8n028224 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 18 Jan 2019 11:13:38 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x0IBDcmw025439; Fri, 18 Jan 2019 11:13:38 GMT Received: from [192.168.1.4] (/79.19.31.237) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 18 Jan 2019 03:13:37 -0800 From: Paolo Carlini Subject: [C++ Patch] Locations related grokdeclarator tweak To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill Message-ID: Date: Fri, 18 Jan 2019 12:13:35 +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, a tweak to typespec_loc, where the existing conditional turns out to be just a special case of the full min_location that we want in order to do the right thing for testcases like diagnostic/trailing1.C. Tested x86_64-linux. Thanks, Paolo. ////////////////////// /cp 2018-01-18 Paolo Carlini * decl.c (grokdeclarator): Fix value assigned to typespec_loc, use min_location. /testsuite 2018-01-18 Paolo Carlini * g++.dg/diagnostic/trailing1.C: New. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 268062) +++ cp/decl.c (working copy) @@ -10341,9 +10341,9 @@ grokdeclarator (const cp_declarator *declarator, location_t typespec_loc = smallest_type_quals_location (type_quals, declspecs->locations); + typespec_loc = min_location (typespec_loc, + declspecs->locations[ds_type_spec]); if (typespec_loc == UNKNOWN_LOCATION) - typespec_loc = declspecs->locations[ds_type_spec]; - if (typespec_loc == UNKNOWN_LOCATION) typespec_loc = input_location; /* Look inside a declarator for the name being declared Index: testsuite/g++.dg/diagnostic/trailing1.C =================================================================== --- testsuite/g++.dg/diagnostic/trailing1.C (nonexistent) +++ testsuite/g++.dg/diagnostic/trailing1.C (working copy) @@ -0,0 +1,5 @@ +// { dg-do compile { target c++11 } } + +int const foo1() -> double; // { dg-error "1:.foo1. function with trailing return type" } +int volatile foo2() -> double; // { dg-error "1:.foo2. function with trailing return type" } +int const volatile foo3() -> double; // { dg-error "1:.foo3. function with trailing return type" }