Constants used in range patterns should not be considered unused

Fixes #18464.