Community
Participate
Working Groups
struct A { int a; static void m() { a = 0; // a is resolved, but it shouldn't be. } };
*** Bug 318599 has been marked as a duplicate of this bug. ***
The name look-up itself is correct, 'a' does resolve to the non-static field although the use in this context is illegal. Similar to the accessibility, we can ignore the illegal usage for the purpose of creating the correct AST. From a tooling perspective the resolved variable adds value, because you can navigate it. This is for instance necessary if you want to make it static. (It also helps if you want to implement a quick-fix). --> I'd argue the illegal usage should be detected by codan, rather than the parser.
(In reply to comment #2) > --> I'd argue the illegal usage should be detected by codan, rather than the > parser. I agree that deferring the check to codan and context assist is the best solution. This is the approach that is already taken for visibility checks. It works there pretty well. We just have to make sure that the actual code that implements the check is shared between context assist and codan.
(In reply to comment #3) > ... We just have to make sure that the actual code that > implements the check is shared between context assist and codan. It'd make sense to me to have the implementation for checkers that require semantics somewhere in the parser packages. It's likely that we can provide better implementations there. There should probably be a parser mechanism to detect all constructs that are illegal by the standard. (e.g.: this bug, accessibility, illegal assignments, illegal combination of decl specifiers, ...). This could be a single operation on the AST, something like: IASTProblem[] IASTTranslationUnit.computeProblems(EnumSet whichProblems, IProgressMonitor monitor);