I humbly believe this does not belong to the compiler. These sort of things belong to a static code analyser TOOL. Think of checkstyle/findbugs in Java, or flake8/pep8 in Python world.
I can't put it differently than this: you're simply wrong, in my opinion. It's *provably impossible* do do this statically.