This patch implements the idea outlined in #17544 (closed):
- 
Accumulate Haddock comments with their locations in the Pmonad. This is handled in the lexer.
- 
After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. 
- 
Report the leftover comments to the user as a warning ( -Winvalid-haddock).
As the result, it fixes #17561 (closed) and #8944 (closed).
Edited  by Vladislav Zavialov