| Summary: | Unexpected syntax error for a struct declaration containing an extended keyword | ||
|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Richard Horbach <richard.horbach> |
| Component: | cdt-parser | Assignee: | Project Inbox <cdt-parser-inbox> |
| Status: | RESOLVED WORKSFORME | QA Contact: | Markus Schorn <mschorn.eclipse> |
| Severity: | normal | ||
| Priority: | P3 | CC: | cdtdoug |
| Version: | 8.0 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
|
Description
Richard Horbach
The problem depends a lot on the implementation of your scanner extension configuration. Please provide the implementation. I rather don't want to upload our sources to bugzilla, so I will send them -along with some notes- to you directly.
The GNU notation using attributes is like this:
(1) struct test_t { } __attribute__((__packed__));
TASKING style (short) notation:
(2) struct __packed__ { } test_1;
or alternatively:
(3) __packed__ struct { } test_1;
My problem is that the GNU parser does accept notation (3), but does not accept notation (2).
(In reply to comment #2) Modelling __packed__ as an alternative decl-specifier (IExtensionToken.t__otherDeclSpecModifierFirst) does not work because the keyword struct cannot be followed by such a modifier. For example it is valid to use 'const struct { ...} x;', however you can't have 'struct const { ...} x;' If you simply define __packed__ to be the empty token, all three examples parse fine: public class CustomLanguage extends GCCLanguage { protected static final GCCScannerExtensionConfiguration SCANNER_EXT= new GCCScannerExtensionConfiguration() { { addMacro("__packed__", ""); } }; @Override public String getId() { return "customLanguage.customid"; } @Override protected IScannerExtensionConfiguration getScannerExtensionConfiguration() { return SCANNER_EXT; } } *** cdt cvs genie on behalf of mschorn *** Bug 340773: Correctly consider alternate decl-specifiers. [*] AbstractGNUSourceCodeParser.java 1.159 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java?root=Tools_Project&r1=1.158&r2=1.159 (In reply to comment #3) > If you simply define __packed__ to be the empty token, all three examples parse > fine: I will use the workaround as you suggest. Thanks. |