From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17312 invoked by alias); 17 Oct 2019 22:22:48 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 17303 invoked by uid 89); 17 Oct 2019 22:22:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=H*MI:CADzB, cleanup_stmt, H*f:sk:H31BzsO, expr_location X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 17 Oct 2019 22:22:47 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D26DB300BCE9; Thu, 17 Oct 2019 22:22:45 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.36.118.135]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 767A660BE1; Thu, 17 Oct 2019 22:22:45 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id x9HMMgJh009200; Fri, 18 Oct 2019 00:22:43 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id x9HMMfBO009199; Fri, 18 Oct 2019 00:22:41 +0200 Date: Thu, 17 Oct 2019 22:57:00 -0000 From: Jakub Jelinek To: Jason Merrill Cc: Christophe Lyon , Romain Geissler , gcc-patches List , Andrew Sutton Subject: Re: [PATCH] Fix constexpr-dtor3.C FAIL on arm Message-ID: <20191017222241.GF2116@tucnak> Reply-To: Jakub Jelinek References: <20191011082001.GR15914@tucnak> <38e25fad-c315-5f23-7e06-c92125082621@redhat.com> <20191016162755.GN2116@tucnak> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) X-IsSubscribed: yes X-SW-Source: 2019-10/txt/msg01327.txt.bz2 On Wed, Oct 16, 2019 at 04:36:07PM -0400, Jason Merrill wrote: > > As for CLEANUP_STMT, I've tried it (the second patch), but it didn't change > > anything, the diagnostics was still > > constexpr-dtor3.C:16:23: in ‘constexpr’ expansion of ‘f4()’ > > constexpr-dtor3.C:16:24: in ‘constexpr’ expansion of ‘(& w13)->W7::~W7()’ > > constexpr-dtor3.C:5:34: error: inline assembly is not a constant expression > > 5 | constexpr ~W7 () { if (w == 5) asm (""); w = 3; } // { dg-error "inline assembly is not a constant expression" } > > | ^~~ > > constexpr-dtor3.C:5:34: note: only unevaluated inline assembly is allowed in a ‘constexpr’ function in C++2a > > as without that change. > > That's because the patch changes EXPR_LOCATION for evaluation of the > CLEANUP_BODY, but it should be for evaluation of CLEANUP_EXPR instead. Indeed, that works too. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2019-10-18 Jakub Jelinek * constexpr.c (cxx_eval_constant_expression) : Temporarily change input_location to CLEANUP_STMT location. * g++.dg/cpp2a/constexpr-dtor3.C: Expect in 'constexpr' expansion of message on the line with variable declaration. * g++.dg/ext/constexpr-attr-cleanup1.C: Likewise. --- gcc/cp/constexpr.c.jj 2019-10-17 00:15:50.126726231 +0200 +++ gcc/cp/constexpr.c 2019-10-17 11:21:34.400062565 +0200 @@ -4984,14 +4984,20 @@ cxx_eval_constant_expression (const cons non_constant_p, overflow_p, jump_target); if (!CLEANUP_EH_ONLY (t) && !*non_constant_p) - /* Also evaluate the cleanup. If we weren't skipping at the - start of the CLEANUP_BODY, change jump_target temporarily - to &initial_jump_target, so that even a return or break or - continue in the body doesn't skip the cleanup. */ - cxx_eval_constant_expression (ctx, CLEANUP_EXPR (t), true, - non_constant_p, overflow_p, - jump_target ? &initial_jump_target - : NULL); + { + location_t loc = input_location; + if (EXPR_HAS_LOCATION (t)) + input_location = EXPR_LOCATION (t); + /* Also evaluate the cleanup. If we weren't skipping at the + start of the CLEANUP_BODY, change jump_target temporarily + to &initial_jump_target, so that even a return or break or + continue in the body doesn't skip the cleanup. */ + cxx_eval_constant_expression (ctx, CLEANUP_EXPR (t), true, + non_constant_p, overflow_p, + jump_target ? &initial_jump_target + : NULL); + input_location = loc; + } } break; --- gcc/testsuite/g++.dg/cpp2a/constexpr-dtor3.C.jj 2019-10-17 00:15:49.425736657 +0200 +++ gcc/testsuite/g++.dg/cpp2a/constexpr-dtor3.C 2019-10-17 11:20:13.977290046 +0200 @@ -149,7 +149,7 @@ constexpr int x3 = f3 (); constexpr int f4 () { - W7 w13 = 5; + W7 w13 = 5; // { dg-message "in 'constexpr' expansion of" } return 0; } --- gcc/testsuite/g++.dg/ext/constexpr-attr-cleanup1.C.jj 2019-10-03 00:32:15.604526950 +0200 +++ gcc/testsuite/g++.dg/ext/constexpr-attr-cleanup1.C 2019-10-18 00:18:50.248166117 +0200 @@ -15,7 +15,7 @@ cleanup2 (int *x) constexpr bool foo () { - int a __attribute__((cleanup (cleanup))) = 1; + int a __attribute__((cleanup (cleanup))) = 1; // { dg-message "in 'constexpr' expansion of" } return true; } Jakub