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

Bug 320623

Summary: C99 style array initialization does not parse or index properly in
Product: [Tools] CDT Reporter: Greg Bednarek <greg.bednarek+eclipse>
Component: cdt-parserAssignee: Project Inbox <cdt-parser-inbox>
Status: RESOLVED WORKSFORME QA Contact: Mike Kucera <mikekucera>
Severity: normal    
Priority: P3 CC: yevshif
Version: 7.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Greg Bednarek CLA 2010-07-22 09:11:39 EDT
Build Identifier: 20100617-1415

There are 2 previous Eclipse bug reports that seem to be somewhat related to C99 designated initializers (39549 and 210019), but neither addresses array initialization (they focus on struct init).

Reproducible: Always

Steps to Reproduce:
1. Create a C or C++ file
2. Add the following code fragment: int foo[] = {[12]=123, [0]=26, 51};
3. Notice that the parser marks the code as having a syntax error (and consequently, the code is not indexed)

Please refer to http://www.drdobbs.com/184401377 for more examples of C99 initializer syntax.
Comment 1 Greg Bednarek CLA 2010-07-22 09:15:57 EDT
It also appears that there has been a regression on Bug 39549; when I tried the structure initialization code referenced in that defect, Eclipse CDT gives me a parse error.
Comment 2 Markus Schorn CLA 2010-08-03 03:23:52 EDT
I cannot reproduce the problem. Also the example from bug 39549 works for me.
Make sure to test with a c-file, the syntax is not supported for c++.
Comment 3 Greg Bednarek CLA 2010-08-03 11:58:05 EDT
(In reply to comment #2)
> I cannot reproduce the problem. Also the example from bug 39549 works for me.
> Make sure to test with a c-file, the syntax is not supported for c++.

Well that's definitely the problem then - my files are all named .cpp (and need to be named as such due to the idiosyncrasies of my particular CodeWarrior version), even though most of them are straight C.

Is there any way to enable C-style parsing for certain .cpp files in a workspace?




greg
Comment 4 Markus Schorn CLA 2010-08-04 04:17:43 EDT
(In reply to comment #3)
> (In reply to comment #2)
> > I cannot reproduce the problem. Also the example from bug 39549 works for me.
> > Make sure to test with a c-file, the syntax is not supported for c++.
> Well that's definitely the problem then - my files are all named .cpp (and need
> to be named as such due to the idiosyncrasies of my particular CodeWarrior
> version), even though most of them are straight C.
> Is there any way to enable C-style parsing for certain .cpp files in a
> workspace?
> greg

You should be able to do that via the langage mappings. I think there is a property page for that on project, folder and file level.