Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 337583 - Index cannot maintain different typedefs with the same name
Summary: Index cannot maintain different typedefs with the same name
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-indexer (show other bugs)
Version: 8.0   Edit
Hardware: All All
: P3 major with 7 votes (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
: 350479 438305 481283 520322 530348 (view as bug list)
Depends on:
Blocks: 421014 439553 490778 497867 533259 520322
  Show dependency tree
 
Reported: 2011-02-18 11:24 EST by Andrew Gvozdev CLA
Modified: 2020-12-18 13:49 EST (History)
14 users (show)

See Also:


Attachments
sample project (3.46 KB, application/octet-stream)
2011-02-18 11:25 EST, Andrew Gvozdev CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Gvozdev CLA 2011-02-18 11:24:27 EST
When typedefs with the same name are defined in different files parser fails to follow #include strictly and matches wrong typedef (or thinks its ambiguous).

include/file.h:
typedef struct {
	int x;
} SS;

file.c:
#include "include/file.h"
void fun() {
	SS var;
	var.x;
}

Import the attached sample project, reindex and open file.c:
- "var.x" triggers an error "x cannot be resolved"
- content assist on "var." adds "y" instead
- F3 on "SS" gives a popup with 2 choices.

That should not be happening as there is explicit #include "include/file.h" pointing to the proper header.

This problem is pretty severe for big projects and given a chance Codan with the default settings generates tens of thousands of errors for the kinds of projects we are using.
Comment 1 Andrew Gvozdev CLA 2011-02-18 11:25:31 EST
Created attachment 189293 [details]
sample project
Comment 2 Markus Schorn CLA 2011-03-02 05:05:06 EST
Actually the index just maintains a single version for each typedef name. In your example it happens to point to the anonymous struct in file 'other.h', because this file was indexed at a later point.

Because classes, structs and unions can be fwd-declared, we cannot determine whether the same name is meant to name the same type or not. Therefore, there is only one definition for a type-name in the index.

However, there are no fwd-declarations for typedefs and therefore it should be possible to track different version for typedefs with the same name.
Comment 3 Marc-André Laperle CLA 2011-06-27 18:16:10 EDT
*** Bug 350479 has been marked as a duplicate of this bug. ***
Comment 4 Marc-André Laperle CLA 2014-06-27 09:35:29 EDT
*** Bug 438305 has been marked as a duplicate of this bug. ***
Comment 5 Marc-André Laperle CLA 2015-11-04 10:12:22 EST
*** Bug 481283 has been marked as a duplicate of this bug. ***
Comment 6 Nathan Ridge CLA 2018-01-26 02:41:01 EST
*** Bug 530348 has been marked as a duplicate of this bug. ***
Comment 7 Devin Callahan CLA 2020-12-18 13:49:46 EST
*** Bug 520322 has been marked as a duplicate of this bug. ***