fix #12207: FP variableScope with brace init
As noted in the ticket, this is caused by a bad simplification for any struct UPPERCASENAME varname declaration. If anything, we should fix that and not add another hack elsewhere.
1: struct S { int * p@var1 ; } ;
2:
3: void f ( ) {
4: int i@var2 [@exprUNIQUE 2 ] ;
5: struct s { i@var2 } ;
6: }
So the simplification happens before the macros are expanded?
I think we try to proceed even when there are unknown macros (by removing tokens that look like a macro name), which we shouldn't do in the first place.
removeMacroInClassDef was added 10ish years ago. Maybe it has become unnecessary since then? If the preprocessing/project import has improved.
Here's a related ticket: https://trac.cppcheck.net/ticket/11048 I would say we should just bail out with an error message on ambiguous code. But we also generally try to handle incomplete code, so there has to be some kind of trade-off.
... so there has to be some kind of trade-off.
Prehaps remove it only if it's longer than one character? class S isn't unheard of, but a longer class name in uppercase only is probably not very common.
In the case of #12207, we should track that S has already been defined, so struct S s; unambigously declares a variable. But this is probably difficult to implement. A different heuristic for type names would just be moving the goal posts IMHO.