Am 15.05.2012 um 16:09 schrieb Douglas Gregor > > > I'm a bit uncomfortable with the textual approach here. Why not analyze the > expressions to check whether they are references to named declarations, and > use those names in the diagnostic? It won't catch some macro cases, but it's > far simpler.
I was also uncomfortable with the textual approach, and in fact I first tried seeing if the case expression was a DeclRefExpr that refers to a valid NamedDecl. The problem I found with that approach was that it was not catching very many situations. Doing it that way only works for enums as far as I can tell. Macros, const ints, case overflows, casting, and more complicated expressions (like "case 2+2") are not DeclRefExprs, and I don't see any obvious way to grab the necessary diagnostic info without using a textual approach. To be safer and simpler, it's probably best to only do these smart diagnostics for enums (through DeclRefExpr), unless someone has any suggestions for a better way to do all of this. -Terry _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
