From patchwork Thu May 23 07:28:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1103860 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-501508-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 458h272n9Sz9s4V for ; Thu, 23 May 2019 17:28:45 +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:date :from:to:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=DjuAlwrgbs2CbOAN5mbGmS0EQ6ja8cFMYZW7lQ98o+1 QGeZkdwCGau55qxUGPbYgJdiOJz3oDNCbGUssXHe4sfYss1AeuWcanCPb4+jHTma BChywXaGv2rMLiQDXc82p2u5IVGuhD8bV+LCgCcBWRk+W6h8TLvcWEEbouq/SlsU = 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:date :from:to:subject:message-id:reply-to:mime-version:content-type; s=default; bh=w2i7wEVYhSv+QKLdYgnNFB2u5LE=; b=DZLMLqz+kVeqsKIP5 5zDBtfT6dO2uqj++EF+7d18j1ildM9O7m9QwO1/5XYntknkm5c+7wVxo4LEeWJTc rJTo2bPnG4KsGYbgAa9aiah9Lh7RM1EIAD7s3onWWRhVQkUOTRM1iN09jm4FAcmU KZj8nbos981i4yB4I5jL0ppHl4= Received: (qmail 81493 invoked by alias); 23 May 2019 07:28:37 -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 81475 invoked by uid 89); 23 May 2019 07:28:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=cpp2a 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, 23 May 2019 07:28:36 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1993D301E12F for ; Thu, 23 May 2019 07:28:34 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-52.ams2.redhat.com [10.36.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B8DC75DC1A for ; Thu, 23 May 2019 07:28:33 +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 x4N7SVQn003020 for ; Thu, 23 May 2019 09:28:32 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id x4N7SVjh003019 for gcc-patches@gcc.gnu.org; Thu, 23 May 2019 09:28:31 +0200 Date: Thu, 23 May 2019 09:28:31 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] Add testcase for std::is_constant_evaluated() vs. explicit(bool) Message-ID: <20190523072831.GK19695@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.11.3 (2019-02-01) X-IsSubscribed: yes Hi! I've noticed we don't have any testcases covering manifestly constant evaluation inside of explicit bool, tested thusly, bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk as obvious. 2019-05-23 Jakub Jelinek * g++.dg/cpp2a/is-constant-evaluated8.C: New test. Jakub --- gcc/testsuite/g++.dg/cpp2a/is-constant-evaluated8.C.jj 2019-05-22 19:00:00.209982223 +0200 +++ gcc/testsuite/g++.dg/cpp2a/is-constant-evaluated8.C 2019-05-22 19:05:11.425937617 +0200 @@ -0,0 +1,19 @@ +// { dg-do compile { target c++11 } } +// { dg-options "" } + +namespace std { + constexpr inline bool + is_constant_evaluated () noexcept + { + return __builtin_is_constant_evaluated (); + } +} + +struct A { explicit (!__builtin_is_constant_evaluated ()) A (int); }; // { dg-warning "'explicit\\(bool\\)' only available with" "" { target c++17_down } } +struct B { explicit (!std::is_constant_evaluated ()) B (int); }; // { dg-warning "'explicit\\(bool\\)' only available with" "" { target c++17_down } } +struct C { explicit (__builtin_is_constant_evaluated ()) C (int); }; // { dg-warning "'explicit\\(bool\\)' only available with" "" { target c++17_down } } +struct D { explicit (std::is_constant_evaluated ()) D (int); }; // { dg-warning "'explicit\\(bool\\)' only available with" "" { target c++17_down } } +A a = 1; +B b = 2; +C c = 3; // { dg-error "conversion from 'int' to non-scalar type 'C' requested" } +D d = 4; // { dg-error "conversion from 'int' to non-scalar type 'D' requested" }