# Generating warning message about referring to labels later in document

I'm in the process of drafting a long paper comprising many sections that I'm writing in parallel. As a sanity check, I'd like to make sure that whenever I cite, say Lemma A, then I've already stated Lemma A by that point in the paper. In other words, I want to have LaTeX throw an error or warning if I call \ref{labelname_goes_here} (or its variants) before \label{labelname_goes_here}.

Is there any easy way of ensuring that something like:

\usepackage{amsthm}
\usepackage{cleveref}

\begin{lemma}\label{foo}Let $M$ be a module over blah blah blah.
\end{lemma}

By~\Cref{foo}, the module of etc.


compiles without complaint, but

\usepackage{amsthm}
\usepackage{cleveref}

By~\Cref{foo}, the module of etc.

\begin{lemma}\label{foo}Let $M$ be a module over blah blah blah.
\end{lemma}


at least throws a warning?