Let $K$ be a number field and $F$ a polynomial with coefficients in $K$. Class field theory shows that the following properties of $F$ are equivalent:
(1) There is subgroup $H$ of a generalized ideal class group $C_{\mathfrak m}$ (of some appropriately chosen conductor $\mathfrak m$) and a finite set of prime ideals $S$ (including all primes involved in the denominators of $F$) such that $F$ splits completely modulo $\wp$ (for $\wp \not\in S$) if and only if the class of $\wp$ in $C_{\mathfrak m}$ lies in $H$.
(2) The splitting field of $F$ over $K$ is an abelian extension.
In Shimura's example, the field $K$ is $\mathbf Q$, the conductor is $7$, the set $S$ is ${7}$, \{7\}$, and the splitting field is the degree 3 extension of $\mathbf Q$ contained in ${\mathbf Q}(\zeta_7)$.
So in general, to construct $F$ of the type considered by Shimura, one must construct abelian extensions of number fields $K$. The theory of complex multiplication is one tool that allows one to do this.

