Skip to content

Commit

Permalink
pragma: respect pragma in lambda functions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
marxin committed Dec 16, 2021
1 parent c14f38d commit 5b8f5a5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gcc/attribs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
25 changes: 25 additions & 0 deletions gcc/testsuite/g++.target/i386/pr103696.C
Original file line number Diff line number Diff line change
@@ -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" } } */

0 comments on commit 5b8f5a5

Please sign in to comment.