From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by sourceware.org (Postfix) with ESMTPS id C3EEE3857C47 for ; Wed, 26 Aug 2020 19:39:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C3EEE3857C47 Received: by mail-pf1-x444.google.com with SMTP id t9so1552416pfq.8 for ; Wed, 26 Aug 2020 12:39:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=yqZcBKbR+V6lveIwfoO37B5L3ynCJ/Z1HqhuhaNhq+8=; b=YUvDSA8scHxbP4Ogj7r0s3WwAxAySreD/mXOOdFecofklaV8arUDzDuegIKXlIbScA shq3kqV1XxZXVRIgWySbE/UbDUuuvFvi/eaJctBi14ch2H1X7Ho2ABN8eN2thzW9h0FZ Ow2djf0AfUL/Fb7RFNlt88JaQXUaH8bFc0qIx0Qg7jFbHdAk4zHkajwBdeTM5FtuUkLL 8aZkUlbop5ltyPBzlDeAK2EuIiDLMCmxcvbC2eVR6Cwrq4gtmT32IikgMhRGSy8dltOc jJn7Rcc4+V4Ur6KTcYHLe7CtgBEOHySF95U1CLyxsrrE1QG5VmqWsqBd9Dmme7r+RNO0 vkXA== X-Gm-Message-State: AOAM531aanjGVTRpiK7XIDZj4JTGAl/WWgJFo2l4OfEFB12D/pW4aGFW DSYsHl2kVMw5P8I3kb2H2JLnWaOBkCk= X-Google-Smtp-Source: ABdhPJz/shsl4h4l0675qGNgW5Z7diH3Zo5h2hDBmW+oienRQ52+USLTQwgU4wEmfUoIaJr2uV91Gg== X-Received: by 2002:a17:902:d215:: with SMTP id t21mr2990273ply.116.1598470790478; Wed, 26 Aug 2020 12:39:50 -0700 (PDT) Received: from gnu-cfl-2.localdomain (c-69-181-90-243.hsd1.ca.comcast.net. [69.181.90.243]) by smtp.gmail.com with ESMTPSA id z23sm3045776pgv.57.2020.08.26.12.39.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 12:39:50 -0700 (PDT) Received: from gnu-cfl-2.localdomain (localhost [IPv6:::1]) by gnu-cfl-2.localdomain (Postfix) with ESMTP id 28F6F1A0117 for ; Wed, 26 Aug 2020 12:39:49 -0700 (PDT) From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Subject: [PATCH] x86: Reject target("no-general-regs-only") Date: Wed, 26 Aug 2020 12:39:48 -0700 Message-Id: <20200826193948.2418618-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Aug 2020 19:39:53 -0000 Reject target("no-general-regs-only") pragma and attribute. gcc/ PR target/96802 * config/i386/i386-options.c (ix86_valid_target_attribute_inner_p): Reject target("no-general-regs-only"). gcc/testsuite/ PR target/96802 * gcc.target/i386/pr96802-1.c: New test. * gcc.target/i386/pr96802-2.c: Likewise. --- gcc/config/i386/i386-options.c | 7 +++++++ gcc/testsuite/gcc.target/i386/pr96802-1.c | 12 ++++++++++++ gcc/testsuite/gcc.target/i386/pr96802-2.c | 16 ++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 gcc/testsuite/gcc.target/i386/pr96802-1.c create mode 100644 gcc/testsuite/gcc.target/i386/pr96802-2.c diff --git a/gcc/config/i386/i386-options.c b/gcc/config/i386/i386-options.c index e0fc68c27bf..b93c338346f 100644 --- a/gcc/config/i386/i386-options.c +++ b/gcc/config/i386/i386-options.c @@ -1189,6 +1189,13 @@ ix86_valid_target_attribute_inner_p (tree fndecl, tree args, char *p_strings[], { if (mask == OPTION_MASK_GENERAL_REGS_ONLY) { + if (!opt_set_p) + { + error_at (loc, "pragma or attribute % " + "does not allow a negated form", p); + return false; + } + if (type != ix86_opt_ix86_yes) gcc_unreachable (); diff --git a/gcc/testsuite/gcc.target/i386/pr96802-1.c b/gcc/testsuite/gcc.target/i386/pr96802-1.c new file mode 100644 index 00000000000..e6ceb95d238 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr96802-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +/* Reject the negated form of non-negatable attributes. */ + +__attribute__ ((target ("no-general-regs-only"))) +int +foo (int a) +{ + return a + 1; +} + +/* { dg-error "does not allow a negated form" "" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/gcc.target/i386/pr96802-2.c b/gcc/testsuite/gcc.target/i386/pr96802-2.c new file mode 100644 index 00000000000..515f5673777 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr96802-2.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ + +/* Reject the negated form of non-negatable pragma target. */ + +#pragma GCC push_options +#pragma GCC target("no-general-regs-only") + +int +foo (int a) +{ + return a + 1; +} + +#pragma GCC pop_options + +/* { dg-error "does not allow a negated form" "" { target *-*-* } 0 } */ -- 2.26.2