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.
}
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;
--- /dev/null
+// 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" } } */