Add casts so that this code can be used with -Wassign-enum.