From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id 3FBE53858D28; Thu, 16 Dec 2021 16:52:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3FBE53858D28 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Martin Liska To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-6018] pragma: respect pragma in lambda functions X-Act-Checkin: gcc X-Git-Author: Martin Liska X-Git-Refname: refs/heads/master X-Git-Oldrev: c14f38d4292ec22462a4080841d526f87428130a X-Git-Newrev: 5b8f5a50a93c5fd44fa1ecb6f431fee1df267571 Message-Id: <20211216165204.3FBE53858D28@sourceware.org> Date: Thu, 16 Dec 2021 16:52:04 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Dec 2021 16:52:04 -0000 https://gcc.gnu.org/g:5b8f5a50a93c5fd44fa1ecb6f431fee1df267571 commit r12-6018-g5b8f5a50a93c5fd44fa1ecb6f431fee1df267571 Author: Martin Liska Date: Wed Dec 15 17:27:56 2021 +0100 pragma: respect pragma in lambda functions In g:01ad8c54fdca we started supporting target pragma changes that are primarily caused by optimization option. The same can happen in the opposite way and we need to check for changes both in optimization_current_node and target_option_current_node. PR c++/103696 gcc/ChangeLog: * attribs.c (decl_attributes): Check if target_option_current_node is changed. gcc/testsuite/ChangeLog: * g++.target/i386/pr103696.C: New test. Diff: --- gcc/attribs.c | 3 ++- gcc/testsuite/g++.target/i386/pr103696.C | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/gcc/attribs.c b/gcc/attribs.c index 01a9ed66485..29703e75fba 100644 --- a/gcc/attribs.c +++ b/gcc/attribs.c @@ -605,7 +605,8 @@ decl_attributes (tree *node, tree attributes, int flags, } if (TREE_CODE (*node) == FUNCTION_DECL - && optimization_current_node != optimization_default_node + && (optimization_current_node != optimization_default_node + || target_option_current_node != target_option_default_node) && !DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node)) { DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node) = optimization_current_node; diff --git a/gcc/testsuite/g++.target/i386/pr103696.C b/gcc/testsuite/g++.target/i386/pr103696.C new file mode 100644 index 00000000000..de7d5c68be9 --- /dev/null +++ b/gcc/testsuite/g++.target/i386/pr103696.C @@ -0,0 +1,25 @@ +// PR c++/103696 +// { dg-options "-O2 -std=c++14 -fdump-tree-optimized" } + +int global_var; + +void fn() { +} + +#pragma GCC optimize("finite-math-only") +#pragma GCC target("sse3") + +void fn2() { +} + +void fn3() { +} + +int solve() { + auto nested = []() { + return global_var; + }; + return nested(); +} + +/* { dg-final { scan-tree-dump-not "lambda" "optimized" } } */