Bug 256071

Summary: KDevelop does not flag uses of non-static field from static member function as illegal
Product: [Applications] kdevelop Reporter: Nathaniel <I>
Component: Language Support: CPP (old)Assignee: kdevelop-bugs-null
Status: RESOLVED FIXED    
Severity: minor    
Priority: NOR    
Version First Reported In: 4.1.60   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 5.0.0
Sentry Crash Report:

Description Nathaniel 2010-11-04 19:58:45 UTC
Version:           4.1.60 (using KDE 4.5.2) 
OS:                Linux

Example:
class X {
public:
   int x;
   static int getX();
}

int X::getX() {
   return x;
}

getX is a static function, therefore it cannot access non-static variable x. However, KDevelop does not flag this. Perhaps it could have one of those handy assistants pop up and ask to change x to be a static field. In any event, it should flag the reference to x as illegal.

Reproducible: Always

Steps to Reproduce:
Type the code above into a project

Actual Results:  
KDevelop highlights x as a static field, with no complaints

Expected Results:  
Should mark x as something illegal, preferably with a note that x is not static, so a static function cannot access it.
Comment 1 Kevin Funk 2016-09-08 20:34:43 UTC
Hello!

We are working on a new clang-based C/C++ language plugin for KDevelop 5 which
supersedes the old C++ plugin in KDevelop 4. See e.g.:
https://www.kdevelop.org/news/first-beta-release-kdevelop-500-available

Due to a lack of manpower, we cannot fix bugs in the old C++ plugin. We rather
want to supply a good Clang based C++ experience for KDevelop 5 than wasting
our time on the legacy C++ support for KDevelop 4.

With the new clang-based C/C++ language plugin, the bug presented here does not
occur. In my testing. For these reasons, I'll close this bug. Please stay tuned
for KDevelop 5.

Note: Tested this; KDevelop correctly flags this as invalid code.