Refactor function that checks that __builtin_returnaddress's argument is constant.

This moves the check up into the parent class so that all targets can use it
without having to copy (and keep in sync) the same error message.