We currently diagnose static data members directly contained in unnamed classes, but we should also diagnose when they're in a class that is nested (directly or indirectly) in an unnamed class. Do this by iterating up the list of parent DeclContexts and checking if any is an unnamed class.
Similarly also check for function or method DeclContexts (which includes things like blocks and openmp captured statements) as then the class is considered to be a local class, which means static data members aren't allowed.
This diagnostic actually ignores the tag kind that passed down to it, which should be fixed. Also, you should pass in the tag kind for the actual anonymous class you found.
While I'm looking at this code: isLocalClass is mis-designed and doesn't work for any of our non-FunctionDecl local contexts. This check should be if (RD->getParentFunctionOrMethod()).