https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122640
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Eric Botcazou <[email protected]>: https://gcc.gnu.org/g:b0e56bc6ad9fc54841070d676bc2bd9b5e2f8b6d commit r16-5185-gb0e56bc6ad9fc54841070d676bc2bd9b5e2f8b6d Author: Eric Botcazou <[email protected]> Date: Wed Nov 12 09:03:18 2025 +0100 Ada: Fix variable initialized with if-expression not flagged as constant This is a regression present on the mainline and 15 branch: the -gnatwk switch no longer flags a string variable initialized with an if-expression as constant when it is not modified in the program. The fix is to set the Has_Initial_Value and Never_Set_In_Source flags earlier during analysis in the Analyze_Object_Declaration procedure. gcc/ada/ PR ada/122640 * sem_ch3.adb (Analyze_Object_Declaration): Set Is_True_Constant on entry for constants and Never_Set_In_Source in all cases. If an initialization expression is present, set Has_Initial_Value and Is_True_Constant on variables. gcc/testsuite/ * gnat.dg/warn34.adb: New test.
