Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 356057

Summary: typedef enum removed from index after changes in header file
Product: [Tools] CDT Reporter: Axel Mueller <aegges>
Component: cdt-indexerAssignee: Markus Schorn <mschorn.eclipse>
Status: RESOLVED FIXED QA Contact: Markus Schorn <mschorn.eclipse>
Severity: major    
Priority: P3 CC: cdtdoug, florian.reinhard, mnl, pouhan
Version: 8.0   
Target Milestone: 8.1.0   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Sample project none

Description Axel Mueller CLA 2011-08-29 05:25:44 EDT
Build Identifier: 20110609-2236, CDT 8.0

I have a header file containing the following typedefed enum

typedef enum
{
  AE_ON = 0,
  AE_OFF = 1
}
  Adaptiv_T;

I use these enums in a cpp file. When I change anything in the header file I get a lot of errors in the cpp saying "Symbol 'AE_ON' could not be resolved. I have to rebuild the complete index to get it working again (F3 does not resolve the symbol and the enum is not shown in the Indexer View).

This bug was newly introduced in the Indigo release. I never had any problems before the update.

Reproducible: Always
Comment 1 Axel Mueller CLA 2011-09-06 14:33:30 EDT
I raised the importance of this bug. We use a lot of typedefed enums in our code and every update of a header file (CVS or local changes) will corrupt the index.
Comment 2 Axel Mueller CLA 2011-09-07 03:52:51 EDT
Created attachment 202859 [details]
Sample project

1) Import the sample project
2) Open Hello.cpp => there should be no CODAN errors
3) Open Hello.h and comment out line 5 (#define mytest 1) and save
4) switch to Hello.cpp => CODAN error ("Symbol AE_OFF could not be resolved")
5) rebuild index => everything is fine

6) uncomment line 5 again and put it at the end of the header (after mystruct declaration); rebuild index (just to be sure we have everything)
7) comment out #define mytest 1 again and save
8) switch to Hello.cpp => no error, everything is fine

As a note, the mytest define should have no effect at all!
Comment 3 Markus Schorn CLA 2011-09-08 05:49:23 EDT
Added testcase and fix.
Comment 4 CDT Genie CLA 2011-09-08 08:23:04 EDT
*** cdt git genie on behalf of Markus Schorn ***

    Bug 356057: Updating unnamed enumerations.

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=ad4729d9540897568c8ffe576f7e465ef21da400
Comment 5 Axel Mueller CLA 2011-09-08 08:53:46 EDT
(In reply to comment #3)
> Added testcase and fix.
Fine. Too late for Indigo SR1?
Comment 6 Markus Schorn CLA 2011-09-09 04:06:24 EDT
(In reply to comment #5)
> Fine. Too late for Indigo SR1?
Yes, it is too late for SR1. It is also a problem to fix the issue for SR2, because I had to change the index layout, which I cannot do on the maintenance branch. 
At least CDT 7.0.2 has the same issue (I have not checked earlier versions), the fix in the next major release may be sufficient.
Comment 7 Axel Mueller CLA 2011-09-09 05:51:43 EDT
(In reply to comment #6)
> At least CDT 7.0.2 has the same issue (I have not checked earlier versions),
> the fix in the next major release may be sufficient.
I never encountered this problem with 7.0.2 (official build from 201102110609)! The problem arised after the update to Indigo.
Comment 8 Markus Schorn CLA 2011-09-09 07:26:37 EDT
(In reply to comment #7)
> I never encountered this problem with 7.0.2 (official build from 201102110609)!
It may be the case that codan did not report the problem, or that you did not use codan with 7.0.2.

> The problem arised after the update to Indigo.
Why can I reproduce it with 7.0.2?
Comment 9 Axel Mueller CLA 2011-09-09 10:00:00 EDT
(In reply to comment #8)
> (In reply to comment #7)
> > I never encountered this problem with 7.0.2 (official build from 201102110609)!
> It may be the case that codan did not report the problem, or that you did not
> use codan with 7.0.2.
Bingo. Codan was deactivated.
Comment 10 Axel Mueller CLA 2011-09-12 03:02:54 EDT
(In reply to comment #3)
> Added testcase and fix.
Is bug #171193 related to this one?
Comment 11 Florian Reinhard CLA 2011-10-25 03:06:10 EDT
This bug is still reproduceable with the sample project on cdt 8.0.x with one small change:

just wrap the typedef enum in
extern "C"
{
typedef enum....
}
Comment 12 Markus Schorn CLA 2011-10-31 10:39:52 EDT
*** Bug 361899 has been marked as a duplicate of this bug. ***
Comment 13 Marc-André Laperle CLA 2011-11-18 14:02:50 EST
*** Bug 364138 has been marked as a duplicate of this bug. ***