[PATCH v3] c,c++: Fix incorrect warning with asm defined symbols

Jakub Jelinek jakub@redhat.com
Thu Jan 29 15:04:04 GMT 2026


On Thu, Jan 29, 2026 at 02:31:12PM +0100, Michal Jires wrote:
> Tested on x86_64-pc-linux-gnu.
> 
> 	PR testsuite/123559
> 
> gcc/c/ChangeLog:
> 
> 	* c-decl.cc (c_write_global_declarations_1): Check asm symbols.
> 	* c-typeck.cc (build_asm_expr): Mark asm symbols.
> 
> gcc/ChangeLog:
> 
> 	* cgraphunit.cc (check_global_declaration): Check asm symbols.
> 	* tree-core.h (struct tree_decl_with_vis): Add defined_in_asm.
> 	* tree.h (DECL_DEFINED_IN_ASM): New.
> 
> gcc/cp/ChangeLog:
> 
> 	* decl.cc (wrapup_namespace_globals): Check asm symbols.
> 	* semantics.cc (finish_asm_stmt): Mark asm symbols.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* c-c++-common/toplevel-extended-asm-1.c: New test.

Can't you just
	      else if (TREE_CODE (TREE_OPERAND (t, 0)) == FUNCTION_DECL)
		suppress_warning (TREE_OPERAND (t, 0), OPT_Wunused_function);
in both FEs?

	Jakub



More information about the Gcc-patches mailing list