On 20/10/2026 10:10, Jason Merrill wrote:
On 10/20/26 9:17 AM, Nathan Sidwell wrote:
In tandem with my riscv ECF flag patch I fell over this, where the C++ FE doesn't propagate the NO_VOPS flag.  I happen to be using that on our builtins, and we also explicitly declare our builtins (so that code analysis tools are not confused).

Boom, optimizations stop working :(

I wasn't sure whether this was the best place or merge_attribute_bits would be better.  I went with here, as that more closely matches the C FE, which is already propagating these bits.

Do the other two places that call merge_attribute_bits also want these bits 
copied?

I should have looked more closely at the paths adjacent to those calls -- explicit template specializations do not inherit from the general template. And hence merge_attribute_bits is the right place.

nathan

--
Nathan Sidwell
From df94909a273c099847b2d1c118cd5cff03f8e7c1 Mon Sep 17 00:00:00 2001
From: Nathan Sidwell <[email protected]>
Date: Tue, 20 Oct 2026 09:11:52 -0400
Subject: [PATCH] [C++] Fix duplicate-decls flag clearing

	gcc/cp/
	* decl.cc (merge_attribute_bits): Propagate DECL_NO_LIMIT_STACK,
	DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT, DECL_IS_NOVOPS.
---
 gcc/cp/decl.cc | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 593e67fd03b..16ce7cd36b0 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -1705,6 +1705,14 @@ merge_attribute_bits (tree newdecl, tree olddecl)
   TREE_DEPRECATED (olddecl) |= TREE_DEPRECATED (newdecl);
   TREE_UNAVAILABLE (newdecl) |= TREE_UNAVAILABLE (olddecl);
   TREE_UNAVAILABLE (olddecl) |= TREE_UNAVAILABLE (newdecl);
+  DECL_NO_LIMIT_STACK (newdecl) |= DECL_NO_LIMIT_STACK (olddecl);
+  DECL_NO_LIMIT_STACK (olddecl) |= DECL_NO_LIMIT_STACK (newdecl);
+  DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (newdecl)
+    |= DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (olddecl);
+  DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (olddecl)
+    |= DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (newdecl);
+  DECL_IS_NOVOPS (newdecl) |= DECL_IS_NOVOPS (olddecl);
+  DECL_IS_NOVOPS (olddecl) |= DECL_IS_NOVOPS (newdecl);
 }
 
 #define GNU_INLINE_P(fn) (DECL_DECLARED_INLINE_P (fn)			\
-- 
2.56.0

Reply via email to