Partial fix for #5555. Improved pure/const attributes handling