Classical BRST cohomology and invariant functions on constraint manifolds. I