The title of this issue is different than the p4c issue linked below. There is definitely some overlap in desired functionality here, which is why I am linking to it, even though it is not identical:
A more closely related issue with some proposals on how to implement this feature in p4c: