In the H-mode (high-confinement mode) pedestal region of a static or a toroidally rotating D-shaped tokamak plasma, the separatrix or the X-point affects the high-n ballooning stability (n: toroidal mode number) only in a thin layer in the pedestal region. Therefore, D-shaping effectively stabilizes the ballooning modes even for a toroidally rotating plasma with a separatrix.