Anomaly and symmetry-protected critical phases