What do you call it when a story gives a warning to the reader?

Solution 1:

When a story gives a warning of a plot turn, it is called foreshadowing.

Foreshadow -- To present an indication or a suggestion of beforehand; presage: hostilities that foreshadowed all-out war. - American Heritage Dictionary, 5th Ed.