Revise the approach from commit 844244cc (automoc: avoid compiler warnings in linker-warning-silencing code, 2022-08-10, v3.24.1~6^2) to avoid `-Wmissing-declarations` warnings too. Issue: #23823