Bug 55202 - Problems parsing global variables (it jumps to one of the places where they are declared with external)
Summary: Problems parsing global variables (it jumps to one of the places where they a...
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (old) (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: KDevelop-Devel List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-26 10:48 UTC by Amilcar do Carmo Lucas
Modified: 2013-03-31 00:45 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Amilcar do Carmo Lucas 2003-02-26 10:48:47 UTC
Version:            (using KDE KDE 3.1)
Compiler:          gcc 2.95.3 
OS:          Linux

I have a couple of global variables in my main file:

int foo;
int bar;
int main(){
}

Then in some other files I would like to access these variables so I write on the top of the files:
external int foo;
external int bar;

These variables are correctly parsed as global variables, but when I click on them in the class viewer, it jumps to one of the files where they are declared as external instead of their main declaration (the only declaration without the external).
 
This is also present in the KDevelop 2.1.5 parser.
Comment 1 Amilcar do Carmo Lucas 2003-08-07 13:46:40 UTC
With the new cpp-parser/class viewer This error was partialy solved. 
Now intead of one instance that when clicked jumps to some wrong location, I 
get all of the instances shown on the class viewer (the global and correct 
one, and all the others from the other files that decalare the variable as 
external). 
This new behavior is better, but still not perfect. 
Comment 2 Gunther Piez 2003-09-23 10:11:31 UTC
I'm usually moving my "external" declarations to a header file and #include 
that header instead. In this case the variable shows up only twice, makes you 
jump to the wrong loaction only half the time :-) 
The bug is still there. 
Comment 3 Roberto Raggi 2003-11-04 15:52:30 UTC
Subject: kdevelop/languages/cpp

CVS commit by raggi: 

skip "external" variable declaration 

CCMAIL: 55202-done@bugs.kde.org


  M +8 -1      store_walker.cpp   1.56
  M +1 -0      store_walker.h   1.13


--- kdevelop/languages/cpp/store_walker.cpp  #1.55:1.56
@@ -42,4 +42,5 @@ void StoreWalker::parseTranslationUnit( 
     m_inSlots = false;
     m_inSignals = false;
+    m_inStorageSpec = false;
     m_anon = 0;
     m_imports.clear();
@@ -57,5 +58,8 @@ void StoreWalker::parseDeclaration( Decl
 void StoreWalker::parseLinkageSpecification( LinkageSpecificationAST* ast )
 {
+    int inStorageSpec = m_inStorageSpec;
+    m_inStorageSpec = true;
     TreeParser::parseLinkageSpecification( ast );
+    m_inStorageSpec = inStorageSpec;
 }
 
@@ -348,4 +352,7 @@ void StoreWalker::parseTypeDeclaratation
 void StoreWalker::parseDeclaration( GroupAST* funSpec, GroupAST* storageSpec, TypeSpecifierAST* typeSpec, InitDeclaratorAST* decl )
 {
+    if( m_inStorageSpec )
+            return;
+    
     DeclaratorAST* d = decl->declarator();
 

--- kdevelop/languages/cpp/store_walker.h  #1.12:1.13
@@ -72,4 +72,5 @@ private:
     bool m_inSignals;
     int m_anon;
+    bool m_inStorageSpec;
 
     QValueStack<NamespaceDom> m_currentNamespace;


Comment 4 Aleix Pol 2013-03-31 00:45:41 UTC
Moving all the bugs from the CPP Parser. It was not well defined the difference between it and C++ Language Support and people kept reporting in both places indistinctively