From patchwork Wed Nov 20 16:40:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1198328 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-514192-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="eJIynFWP"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="BNqfJOmT"; 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 47J7jZ17XBz9sPW for ; Thu, 21 Nov 2019 03:40:49 +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=wxNn+tg+dUNxCQ7E4xKp6ZtiJ0K3Dx44zXhC5GGyiEvyQOPQ49 ca8wf4TtsxMOBVU5eJdEEhvaR+QAiBmZEQFQQEIey1gwWrrxnxpbiUTFpvUMnz4q KwskuyX/nbkdoi6YhZeyMO9brjaXMvucwExl7z1Q+1Pe7Sr4CzPfDKclI= 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=LxbAQZCKy+qamKCPb6gZhu18Zhs=; b=eJIynFWPcHHGFKhocUt5 9wa8X+MoTWHFdwvkIQxEVgAQtKmSsBK6C0gPVxvaY8J2gXaq0Cmygwi+cXThYQMT dlWeEKdWYoSCpz92C2HQRQy1HlW0D8hfjV5YxNUkfL47IcOYoX2te2NE9GfNVuc9 givnon5Ee3FrECUhZ4HvuQE= Received: (qmail 110937 invoked by alias); 20 Nov 2019 16:40:42 -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 110926 invoked by uid 89); 20 Nov 2019 16:40:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= 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; Wed, 20 Nov 2019 16:40:40 +0000 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAKGdhVL104724; Wed, 20 Nov 2019 16:40:38 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-2019-08-05; bh=jxrmwM381O6PGGb3GW+gV4UiPMYBcl3CZ9w4yIxPMOw=; b=BNqfJOmTWm9aLg8G4+A252azYucsSGffJHxupRUTfyYuEeR/0274/lwixM4UY+2xZv/B ywMkorZ7KIFo7iGS/GJKeIusPlsMZc6Lr3m/nWn4wD0jhHLZOD43dmpqQvWuZGhkzcNN hkhIw/WVmFX6YLCELG/7SdEF4dra58mi7aeSuuxdB6goWboxeGGZrdXsTgLPodJtip0r RNOcYt5ZkFwgs9b/jTNAHJ67bSwHLIIHKkSsUK+ZprIbC3LzyaNnvtdEZMpmRLaQOGAe ssKjRmgS6J+rDgktLLQAeezXwKlwxegQWQpKJ99K5UMFn6Gf+is5BzhO9mcS+kH7upc4 yw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2wa8htxsh0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Nov 2019 16:40:38 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAKGcaKf135159; Wed, 20 Nov 2019 16:40:37 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2wcemgpjt7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Nov 2019 16:40:37 +0000 Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id xAKGeaOa017570; Wed, 20 Nov 2019 16:40:36 GMT Received: from [192.168.1.4] (/95.246.235.231) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 20 Nov 2019 08:40:35 -0800 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] Avoid redundant error messages from build_x_arrow Message-ID: Date: Wed, 20 Nov 2019 17:40:33 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.1 MIME-Version: 1.0 X-IsSubscribed: yes Hi, while working on improving the locations of cp_build_indirect_ref_1 & co, I noticed this nit which seems a separate issue. In a nutshell, at variance with many other cases, in build_x_arrow we don't immediately check for error_mark_node the return value of decay_conversion. Then, for the testcase, after a sensible: error: invalid use of member function ‘C* C::f()’ (did you forget the ‘()’ ?) we also issue: error: base operand of ‘->’ is not a pointer which is certainly redundant and a bit misleading, is talking about the 'f' mentioned in the first message. The amended behavior is also consistent with EDG and CLANG. Tested x86_64-linux, as usual. Thanks, Paolo. ////////////////////////// /gcc 2019-11-20 Paolo Carlini * typeck2.c (build_x_arrow): Early return if decay_conversion returns error_mark_node. /testsuite 2019-11-20 Paolo Carlini * g++.dg/parse/error43.C: Adjust expected error. Index: cp/typeck2.c =================================================================== --- cp/typeck2.c (revision 278499) +++ cp/typeck2.c (working copy) @@ -2044,7 +2044,11 @@ build_x_arrow (location_t loc, tree expr, tsubst_f last_rval = convert_from_reference (last_rval); } else - last_rval = decay_conversion (expr, complain); + { + last_rval = decay_conversion (expr, complain); + if (last_rval == error_mark_node) + return error_mark_node; + } if (TYPE_PTR_P (TREE_TYPE (last_rval))) { Index: testsuite/g++.dg/parse/error43.C =================================================================== --- testsuite/g++.dg/parse/error43.C (revision 278499) +++ testsuite/g++.dg/parse/error43.C (working copy) @@ -2,4 +2,4 @@ // { dg-options "" } class C { public: C* f(); int get(); }; -int f(C* p) { return p->f->get(); } // { dg-error "forget the '\\(\\)'|base operand" } +int f(C* p) { return p->f->get(); } // { dg-error "25:invalid use of member function" }