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

Bug 364138

Summary: Code analysis shows semantic error for enum although code is OK
Product: [Tools] CDT Reporter: Michael N. Lipp <mnl>
Component: cdt-indexerAssignee: Project Inbox <cdt-indexer-inbox>
Status: CLOSED DUPLICATE QA Contact: Markus Schorn <mschorn.eclipse>
Severity: normal    
Priority: P3 CC: cdtdoug, malaperle, mnl
Version: 8.0   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Source code none

Description Michael N. Lipp CLA 2011-11-18 06:29:56 EST
Build Identifier: 20110916-0149

For the appended code, CDT shows a "semanic error" in line 16 of main.cpp although there is none. (Code builds fine, even no warnings.)

Reproducible: Always

Steps to Reproduce:
1. Import Project
2. Have a look
Comment 1 Michael N. Lipp CLA 2011-11-18 06:31:58 EST
Created attachment 207212 [details]
Source code
Comment 2 Marc-André Laperle CLA 2011-11-18 09:22:02 EST
Hi Michael, I tested the project with CDT 8.0.0, 8.0.1 and the latest 8.1 (master) on Windows and 8.0.1 on Linux and couldn't reproduce the problem. Can you try rebuilding the index by right-clicking on the project, Index, Rebuild?
Comment 3 Michael N. Lipp CLA 2011-11-18 09:58:31 EST
Hi Marc-Andre, thanks, this does indeed help. But before I close the bug, do you have an explanation why the index hasn't been rebuild automatically? I'm quite sure that while trying to get rid of the error, I modified each of the three source files several times. Shouldn't any "index" be automatically updated in that case?
Comment 4 Marc-André Laperle CLA 2011-11-18 10:34:04 EST
(In reply to comment #3)
> Hi Marc-Andre, thanks, this does indeed help. But before I close the bug, do
> you have an explanation why the index hasn't been rebuild automatically? 

I don't have an explanation sorry.

> I'm
> quite sure that while trying to get rid of the error, I modified each of the
> three source files several times. Shouldn't any "index" be automatically
> updated in that case?

Yes the index should be updated automatically when files are saved. We should try to find in which case it is not being updated properly. I tried commenting out the enum an uncommenting it but that worked correctly.
Comment 5 Michael N. Lipp CLA 2011-11-18 11:28:03 EST
It turns out that it is rather easy to reproduce. Manually (by editing) rename the enumeration type e.g. from "t_iniMode" to "e_iniMode". First in the .h-file in the declaration and in the constructor (parameter's type) and save.

Then go to the cpp-file and find the constructor parameter and the case label being marked (correct). Edit the type of the constructor's parameter. The error marker at this line goes away as expected, but the case labels remain being marked! Program compiles fine, of course, but markers at labels won't go away.

To get an erroneous marker in main.cpp, simply declare a new variable of type e_iniMode and initialize it with e.g. INIT_ZEROS. Note that no completions are offered. When having typed everything, e_iniMode is accepted as a type (no error indication) but INIT_ZEROS remains as "cannot be resolved".
Comment 6 Marc-André Laperle CLA 2011-11-18 14:02:50 EST
Thank you for finding the repro steps. I can reproduce this on 8.0.1 but not master (8.1). I tracked down the commit, this was fixed part of bug 356057.

*** This bug has been marked as a duplicate of bug 356057 ***