From patchwork Wed Oct 30 17:46:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 99836 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4BFE4385843D for ; Wed, 30 Oct 2024 17:47:03 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by sourceware.org (Postfix) with ESMTPS id 9358C3858429 for ; Wed, 30 Oct 2024 17:46:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9358C3858429 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=baylibre.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9358C3858429 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::22e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730310389; cv=none; b=fGNNqy/rdrLpWCXteLb0m5d2mIVemlRPTH+Rydlas26I+1Kyy/nbA3SsG2n7s9hH7G7yHzLGA/qC0VGaiT6RvcsXMgHxKCw88H/Xc8EVwb/neHTDKwWC2LcOp5quPwK2yRoxdnFC4jlAXc7gggSW/gjGK4gs8bmu2U0R+GG6QL8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730310389; c=relaxed/simple; bh=DFUjisyDLxsQQF5Qjz5HfPm+MiBGm4pJIyherARCQrk=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=JOmS8fdY/77yLd66qLbaj7d+NRuG/Bf6C7MLZKJ1MFPyRUpHdCpsZuz+g9vHA62Qnq/2qXY8vAsffCdooge+d29SQ8ygyhZGjuywrDkAEHJ5D2wBQsrP1riaAbpKyq+BcQGOGBIkwR35ueUC/8Vu345sSdew9r/QhNH92WT56zE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2fb5a9c7420so217391fa.3 for ; Wed, 30 Oct 2024 10:46:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730310377; x=1730915177; darn=gcc.gnu.org; h=subject:from:to:content-language:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=lwGviqVKNpkasYmrWVpbRNEGn843oQL40X7UTASV+b0=; b=sla0/AladOgmsPL1BykQl4b+GkcRgX2GKpmOaKY0SHiCyk70M2Dsh//4pDmDLuooEq 2ar6xqDpWuaZcecx2hMygDzUGiDwP6SHHmwy8h5sXsoUJ2iDPsxS86IYL1Kku5Y++PV+ 0dPQuYVf0n2jgTniZBvBFysnLgvprHjAExAg2LyP908v3iHlnmudoGXf5jfLFGDxPney rDoF8ISXLDRs1/4IFDoTrQYPmSXsMnNyfSe34/hXlkasLLOGvOW6zpxkXt1aP3GR6hLK u6HdMHwtMzM2S3OreVpVD9lY2IoKlrxSFFK8b2j/j5ox79CxlWXouUevz14bjTOKb/U6 XqiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730310377; x=1730915177; h=subject:from:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lwGviqVKNpkasYmrWVpbRNEGn843oQL40X7UTASV+b0=; b=wICWkq+oUHBOaUHXiat54qF5ZSuvuZ4fwEoFgOQOFDhHB/lpdEaRjV712cJf8q8TUT c5K9g+X/ZBy0tXwwBjscZx1n3BrjtxF7rfPd34q1BpXLFDkSQUKPkz+EVatXqXGHIqaN QhoBe+mPrAWkkkX1O/5Rjb8G6uGS4hQ72bFe6i3BOep7JvftwMkgx+YkyjaHclSG8GSD 5PZClTMxn0wltHgAKhpCylwQPKNyxWQrEQ8jWMuoDNqaBUu8Qqi8A8Wrft2OaVrxDkti dGOroFFVOYUHIOmkP9xrIT25Q1fjku3D/0kOGJbGE+RtOpgGmbsMnhf7YWF2SdvThVRr wWJA== X-Gm-Message-State: AOJu0YwnbXFFSYxuQkz+iLSwVIkimf5FK8rJJwuz6AnKG26a7mB3yRJP 70+PHgpGoBCTClsBCiTODWHXz7m6QApvrfmqo5TvlMkjBRA3dQBfcbD5FnNiYFONt8mSTfO6h4Q C X-Google-Smtp-Source: AGHT+IHS9rN2hYXITn/Iz6uzBPmX/y+j/vqP8jWdK7zL/RCLXyKq4D4V/DmuISwXRqnnrOBGa8djEw== X-Received: by 2002:a05:651c:b20:b0:2f7:543a:3b1a with SMTP id 38308e7fff4ca-2fcbdf62109mr87395901fa.7.1730310376746; Wed, 30 Oct 2024 10:46:16 -0700 (PDT) Received: from [192.168.8.104] (tmo-084-76.customers.d1-online.com. [80.187.84.76]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd918054sm27955005e9.3.2024.10.30.10.46.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 30 Oct 2024 10:46:16 -0700 (PDT) Message-ID: <10446a42-bab7-4325-966c-f0dcabfb8658@baylibre.com> Date: Wed, 30 Oct 2024 18:46:14 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: gcc-patches , Jakub Jelinek From: Tobias Burnus Subject: [Patch] OpenMP/C++: Fix declare variant with reference-returning functions X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, HTML_MESSAGE, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org Before the patch, the included testcase fails with: declare-variant-9.C:4:29: error: could not find variant declaration 4 | #pragma omp declare variant(variant_fn) match(user={condition(1)}) | ^~~~~~~~~~ Comments, remarks, suggestions before I commit it? Tobias OpenMP/C++: Fix declare variant with reference-returning functions gcc/cp/ChangeLog: * decl.cc (omp_declare_variant_finalize_one): Strip indirect ref around function decl when processing variant function. gcc/testsuite/ChangeLog: * g++.dg/gomp/declare-variant-9.C: New test. gcc/cp/decl.cc | 3 +++ gcc/testsuite/g++.dg/gomp/declare-variant-9.C | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index 0bc320a2b39..b638f3af294 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -8375,6 +8375,9 @@ omp_declare_variant_finalize_one (tree decl, tree attr) if (variant == error_mark_node && !processing_template_decl) return true; + if (TREE_CODE (variant) == INDIRECT_REF) + variant = TREE_OPERAND (variant, 0); + variant = cp_get_callee_fndecl_nofold (variant); input_location = save_loc; diff --git a/gcc/testsuite/g++.dg/gomp/declare-variant-9.C b/gcc/testsuite/g++.dg/gomp/declare-variant-9.C new file mode 100644 index 00000000000..7856f7c40cf --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/declare-variant-9.C @@ -0,0 +1,14 @@ +/* { dg-additional-options "-fdump-tree-gimple" } */ +int &variant_fn(); + +#pragma omp declare variant(variant_fn) match(user={condition(1)}) +int &bar(); + +void sub(int &a) +{ + bar(); + a = bar(); +} + +/* { dg-final { scan-tree-dump " variant_fn \\(\\);" "gimple" } } */ +/* { dg-final { scan-tree-dump " _1 = variant_fn \\(\\);" "gimple" } } */