M-theory compactifications, G_2-manifolds and anomalies