add -Werror=declaration-after-statement only to stdlib extension modules (closes #21121)

Patch from Stefan Krah.
merge 3.4 (#21121)