Makes sure that we have an l-value before checking the storage type of the mem argument passed to an atomic memory operation. Fixes #3332.