From patchwork Fri Sep 29 17:04:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 820020 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-463213-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="qtFAiXrk"; 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 3y3dG00RL9z9rxj for ; Sat, 30 Sep 2017 03:04:39 +1000 (AEST) 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=Zb8kMIOlFnO9gqp6v9HuG2Ulxs4DtYvRi8Q4sIPOiPwkIS51uW 9Ou9X69qmjvkHau0AHwMKlcdiiVFkLPGSlybFSKm1VGL0APBNmBhjiQa/VVtvedl chLge2hIIYyL5iRJOmYoZ5/YJALs9aAwH7hP+PAXyojL31GU823MMAQu4= 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=qLHlJEM9iQC/8VX4jEusYhsCjpA=; b=qtFAiXrkXaup0V9AQ3j3 WT25SyCbNrrs92TZUUBzCVVQzEmGChEG+KX18DPSKrw6CqW2oI+s4UIzb586OyeG Uf7NTW2pkuBvG35UZe63RK9F4aqEXCTIw0g8ukt0lIMZtYPkcWVLb6QzW+FpnQkR 1upzn6yKIAgwkewAtInwbDc= Received: (qmail 74153 invoked by alias); 29 Sep 2017 17:04:21 -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 74132 invoked by uid 89); 29 Sep 2017 17:04:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=annoying, Early, H*r:ip*192.168.1.4 X-HELO: userp1040.oracle.com Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 29 Sep 2017 17:04:20 +0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v8TH4G6W024899 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Sep 2017 17:04:16 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v8TH4Gaw010043 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Sep 2017 17:04:16 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v8TH4FsH016992; Fri, 29 Sep 2017 17:04:15 GMT Received: from [192.168.1.4] (/87.11.227.199) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 29 Sep 2017 10:04:15 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill , Nathan Sidwell From: Paolo Carlini Subject: [C++ Patch] PR 68754 ("Explicitly defaulted constexpr assignment operator fails to compile") Message-ID: <6a0fd1cd-d933-b66f-1c10-19215db8d942@oracle.com> Date: Fri, 29 Sep 2017 19:04:09 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, the main issue, a C++14 rejects-valid, is already fixed in trunk, and a while ago I added a testcase for that. However, Andrew noticed that in C++11 mode we emit redundant and also a bit puzzling diagnostic (ending with one of those annoying "... because:" and nothing after which unfortunately we emit in some other cases too). Comparing to, eg, clang too, I think we can make progress by simply returning early after the first hard error. Also, as an additional tweak, we might replace the second error with an inform, per the usual scheme. Tested x86_64-linux. Thanks, Paolo. ////////////////////////// /cp 2017-09-29 Paolo Carlini PR c++/68754 * method.c (defaulted_late_check): Early return if the defaulted declaration does not match the expected signature. /testsuite 2017-09-29 Paolo Carlini PR c++/68754 * g++.dg/cpp1y/constexpr-68754.C: Move... * g++.dg/cpp0x/constexpr-68754.C: ... here, adjust. Index: cp/method.c =================================================================== --- cp/method.c (revision 253283) +++ cp/method.c (working copy) @@ -2191,9 +2191,11 @@ defaulted_late_check (tree fn) || !compparms (TYPE_ARG_TYPES (TREE_TYPE (fn)), TYPE_ARG_TYPES (TREE_TYPE (implicit_fn)))) { - error ("defaulted declaration %q+D", fn); - error_at (DECL_SOURCE_LOCATION (fn), - "does not match expected signature %qD", implicit_fn); + error ("defaulted declaration %q+D does not match the " + "expected signature", fn); + inform (DECL_SOURCE_LOCATION (fn), + "expected signature: %qD", implicit_fn); + return; } if (DECL_DELETED_FN (implicit_fn)) Index: testsuite/g++.dg/cpp0x/constexpr-68754.C =================================================================== --- testsuite/g++.dg/cpp0x/constexpr-68754.C (revision 253283) +++ testsuite/g++.dg/cpp0x/constexpr-68754.C (working copy) @@ -1,7 +1,7 @@ // PR c++/68754 -// { dg-do compile { target c++14 } } +// { dg-do compile { target c++11 } } struct base { }; struct derived : base { - constexpr derived& operator=(derived const&) = default; + constexpr derived& operator=(derived const&) = default; // { dg-error "defaulted declaration" "" { target { ! c++14 } } } }; Index: testsuite/g++.dg/cpp1y/constexpr-68754.C =================================================================== --- testsuite/g++.dg/cpp1y/constexpr-68754.C (revision 253283) +++ testsuite/g++.dg/cpp1y/constexpr-68754.C (working copy) @@ -1,7 +0,0 @@ -// PR c++/68754 -// { dg-do compile { target c++14 } } - -struct base { }; -struct derived : base { - constexpr derived& operator=(derived const&) = default; -};