### Eclipse Workspace Patch 1.0 #P org.eclipse.cdt.core Index: parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPParserExtensionConfiguration.java =================================================================== RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPParserExtensionConfiguration.java,v retrieving revision 1.5 diff -u -r1.5 ICPPParserExtensionConfiguration.java --- parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPParserExtensionConfiguration.java 15 Jul 2005 14:08:12 -0000 1.5 +++ parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPParserExtensionConfiguration.java 21 Sep 2006 18:49:27 -0000 @@ -32,5 +32,6 @@ public boolean supportKnRC(); public boolean supportGCCOtherBuiltinSymbols(); public boolean supportAttributeSpecifiers(); + public boolean supportDeclspecSpecifiers(); } Index: parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java =================================================================== RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java,v retrieving revision 1.109 diff -u -r1.109 GNUCPPSourceParser.java --- parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java 14 Jun 2006 12:16:08 -0000 1.109 +++ parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java 21 Sep 2006 18:49:27 -0000 @@ -1975,7 +1975,8 @@ super(scanner, log, mode, config.supportStatementsInExpressions(), config.supportTypeofUnaryExpressions(), config .supportAlignOfUnaryExpression(), config.supportKnRC(), - config.supportGCCOtherBuiltinSymbols(), config.supportAttributeSpecifiers()); + config.supportGCCOtherBuiltinSymbols(), config.supportAttributeSpecifiers(), + config.supportDeclspecSpecifiers()); allowCPPRestrict = config.allowRestrictPointerOperators(); supportExtendedTemplateSyntax = config.supportExtendedTemplateSyntax(); supportMinAndMaxOperators = config.supportMinAndMaxOperators(); @@ -3473,6 +3474,13 @@ else throwBacktrack(LA(1).getOffset(), LA(1).getLength()); break; + case IGCCToken.t__declspec: // if __declspec appears before identifier + if (duple == null && supportDeclspecSpecifiers) + __declspec(); + else + throwBacktrack(LA(1).getOffset(), LA(1).getLength()); + break; + default: if (supportTypeOfUnaries && LT(1) == IGCCToken.t_typeof) { typeofExpression = unaryTypeofExpression(); @@ -3854,6 +3862,8 @@ // if __attribute__ is after the pointer ops and before the declarator ex: void * __attribute__((__cdecl__)) foo(); if (LT(1) == IGCCToken.t__attribute__ && supportAttributeSpecifiers) // if __attribute__ is after the parameters __attribute__(); + if (LT(1) == IGCCToken.t__declspec && supportDeclspecSpecifiers) // if __declspec occurs after struct/union/class and before the identifier + __declspec(); if (!pointerOps.isEmpty()) finalOffset = calculateEndOffset((IASTNode) pointerOps @@ -4281,7 +4291,9 @@ if (LT(1) == IGCCToken.t__attribute__ && supportAttributeSpecifiers) // if __attribute__ occurs after struct/union/class and before the identifier __attribute__(); - + if (LT(1) == IGCCToken.t__declspec && supportDeclspecSpecifiers) // if __declspec occurs after struct/union/class and before the identifier + __declspec(); + // class name if (LT(1) == IToken.tIDENTIFIER) name = createName(name()); @@ -4290,6 +4302,8 @@ if (LT(1) == IGCCToken.t__attribute__ && supportAttributeSpecifiers) // if __attribute__ occurs after struct/union/class identifier and before the { or ; __attribute__(); + if (LT(1) == IGCCToken.t__declspec && supportDeclspecSpecifiers) // if __declspec occurs after struct/union/class and before the identifier + __declspec(); if (LT(1) != IToken.tCOLON && LT(1) != IToken.tLBRACE) { IToken errorPoint = LA(1); Index: parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPParserExtensionConfiguration.java =================================================================== RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPParserExtensionConfiguration.java,v retrieving revision 1.5 diff -u -r1.5 GPPParserExtensionConfiguration.java --- parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPParserExtensionConfiguration.java 15 Jul 2005 14:08:12 -0000 1.5 +++ parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPParserExtensionConfiguration.java 21 Sep 2006 18:49:27 -0000 @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; +import org.eclipse.core.runtime.Platform; + /** * @author jcamelon */ @@ -100,4 +102,11 @@ return true; } + /* (non-Javadoc) + * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportDeclspecSpecifiers() + */ + public boolean supportDeclspecSpecifiers() { + // XXX: a hack, should use the target's platform + return Platform.getOS().equals(Platform.OS_WIN32); + } } Index: parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ANSICPPParserExtensionConfiguration.java =================================================================== RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ANSICPPParserExtensionConfiguration.java,v retrieving revision 1.5 diff -u -r1.5 ANSICPPParserExtensionConfiguration.java --- parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ANSICPPParserExtensionConfiguration.java 15 Jul 2005 14:08:12 -0000 1.5 +++ parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ANSICPPParserExtensionConfiguration.java 21 Sep 2006 18:49:26 -0000 @@ -100,4 +100,10 @@ return false; } + /* (non-Javadoc) + * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportDeclspecSpecifiers() + */ + public boolean supportDeclspecSpecifiers() { + return false; + } } Index: parser/org/eclipse/cdt/internal/core/dom/parser/c/ANSICParserExtensionConfiguration.java =================================================================== RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/ANSICParserExtensionConfiguration.java,v retrieving revision 1.5 diff -u -r1.5 ANSICParserExtensionConfiguration.java --- parser/org/eclipse/cdt/internal/core/dom/parser/c/ANSICParserExtensionConfiguration.java 15 Jul 2005 14:08:12 -0000 1.5 +++ parser/org/eclipse/cdt/internal/core/dom/parser/c/ANSICParserExtensionConfiguration.java 21 Sep 2006 18:49:25 -0000 @@ -65,4 +65,10 @@ return false; } + /* (non-Javadoc) + * @see org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration#supportDeclspecSpecifiers() + */ + public boolean supportDeclspecSpecifiers() { + return false; + } } Index: parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java =================================================================== RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java,v retrieving revision 1.78 diff -u -r1.78 GNUCSourceParser.java --- parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java 14 Jun 2006 12:16:12 -0000 1.78 +++ parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java 21 Sep 2006 18:49:26 -0000 @@ -136,7 +136,8 @@ .supportTypeofUnaryExpressions(), config .supportAlignOfUnaryExpression(), config .supportKnRC(), config.supportGCCOtherBuiltinSymbols(), - config.supportAttributeSpecifiers()); + config.supportAttributeSpecifiers(), + config.supportDeclspecSpecifiers()); supportGCCStyleDesignators = config.supportGCCStyleDesignators(); } @@ -1605,6 +1606,12 @@ else throwBacktrack(LA(1).getOffset(), LA(1).getLength()); break; + case IGCCToken.t__declspec: // __declspec precedes the identifier + if (identifier == null && supportDeclspecSpecifiers) + __declspec(); + else + throwBacktrack(LA(1).getOffset(), LA(1).getLength()); + break; default: if (supportTypeOfUnaries && LT(1) == IGCCToken.t_typeof) { typeofExpression = unaryTypeofExpression(); @@ -1757,6 +1764,8 @@ if (LT(1) == IGCCToken.t__attribute__ && supportAttributeSpecifiers) // if __attribute__ occurs after struct/union/class and before the identifier __attribute__(); + if (LT(1) == IGCCToken.t__declspec && supportDeclspecSpecifiers) // if __declspec occurs after struct/union/class and before the identifier + __declspec(); IToken nameToken = null; // class name @@ -1766,6 +1775,8 @@ if (LT(1) == IGCCToken.t__attribute__ && supportAttributeSpecifiers) // if __attribute__ occurs after struct/union/class identifier and before the { or ; __attribute__(); + if (LT(1) == IGCCToken.t__declspec && supportDeclspecSpecifiers) // if __declspec occurs after struct/union/class and before the identifier + __declspec(); if (LT(1) != IToken.tLBRACE) { IToken errorPoint = LA(1); @@ -1913,6 +1924,8 @@ // if __attribute__ is after the pointer ops and before the declarator ex: void * __attribute__((__cdecl__)) foo(); if (LT(1) == IGCCToken.t__attribute__ && supportAttributeSpecifiers) // if __attribute__ is after the parameters __attribute__(); + if (LT(1) == IGCCToken.t__declspec && supportDeclspecSpecifiers) // if __declspec is after the parameters + __declspec(); if (!pointerOps.isEmpty()) { finalOffset = calculateEndOffset((IASTPointerOperator) pointerOps @@ -2081,6 +2094,13 @@ else throwBacktrack(LA(1).getOffset(), LA(1).getLength()); break; + case IGCCToken.t__declspec: + if(supportDeclspecSpecifiers) + __declspec(); + else + throwBacktrack(LA(1).getOffset(), LA(1).getLength()); + break; + default: break; } @@ -2091,7 +2111,10 @@ if (LT(1) == IGCCToken.t__attribute__ && supportAttributeSpecifiers) // if __attribute__ is after the parameters __attribute__(); - + + if (LT(1) == IGCCToken.t__declspec && supportDeclspecSpecifiers) // if __attribute__ is after the parameters + __declspec(); + IASTDeclarator d = null; if (numKnRCParms > 0) { ICASTKnRFunctionDeclarator functionDecltor = createKnRFunctionDeclarator(); Index: parser/org/eclipse/cdt/internal/core/dom/parser/c/GCCParserExtensionConfiguration.java =================================================================== RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GCCParserExtensionConfiguration.java,v retrieving revision 1.6 diff -u -r1.6 GCCParserExtensionConfiguration.java --- parser/org/eclipse/cdt/internal/core/dom/parser/c/GCCParserExtensionConfiguration.java 15 Jul 2005 14:08:12 -0000 1.6 +++ parser/org/eclipse/cdt/internal/core/dom/parser/c/GCCParserExtensionConfiguration.java 21 Sep 2006 18:49:25 -0000 @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; +import org.eclipse.core.runtime.Platform; + /** * @author jcamelon */ @@ -65,4 +67,13 @@ return true; } + /* (non-Javadoc) + * @see org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration#supportDeclspecSpecifiers() + */ + public boolean supportDeclspecSpecifiers() { + // XXX Yes, this is a hack -- should use the target platform + if (Platform.getOS().equals(Platform.OS_WIN32)) + return true; + return false; + } } Index: parser/org/eclipse/cdt/internal/core/dom/parser/c/ICParserExtensionConfiguration.java =================================================================== RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/ICParserExtensionConfiguration.java,v retrieving revision 1.5 diff -u -r1.5 ICParserExtensionConfiguration.java --- parser/org/eclipse/cdt/internal/core/dom/parser/c/ICParserExtensionConfiguration.java 15 Jul 2005 14:08:12 -0000 1.5 +++ parser/org/eclipse/cdt/internal/core/dom/parser/c/ICParserExtensionConfiguration.java 21 Sep 2006 18:49:26 -0000 @@ -35,4 +35,10 @@ */ public boolean supportAttributeSpecifiers(); + /** + * Win32 compiler extensions also supported by GCC on Win32 + * @return + */ + public boolean supportDeclspecSpecifiers(); + } Index: parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java =================================================================== RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java,v retrieving revision 1.72 diff -u -r1.72 AbstractGNUSourceCodeParser.java --- parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java 14 Jun 2006 12:16:10 -0000 1.72 +++ parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java 21 Sep 2006 18:49:25 -0000 @@ -89,13 +89,15 @@ protected final boolean supportGCCOtherBuiltinSymbols; protected final boolean supportAttributeSpecifiers; + + protected final boolean supportDeclspecSpecifiers; protected AbstractGNUSourceCodeParser(IScanner scanner, IParserLogService logService, ParserMode parserMode, boolean supportStatementsInExpressions, boolean supportTypeOfUnaries, boolean supportAlignOfUnaries, boolean supportKnRC, boolean supportGCCOtherBuiltinSymbols, - boolean supportAttributeSpecifiers) { + boolean supportAttributeSpecifiers, boolean supportDeclspecSpecifiers) { this.scanner = scanner; this.log = logService; this.mode = parserMode; @@ -105,6 +107,7 @@ this.supportKnRC = supportKnRC; this.supportGCCOtherBuiltinSymbols = supportGCCOtherBuiltinSymbols; this.supportAttributeSpecifiers = supportAttributeSpecifiers; + this.supportDeclspecSpecifiers = supportDeclspecSpecifiers; } protected boolean parsePassed = true; @@ -2252,4 +2255,25 @@ } } } + + protected void __declspec() throws BacktrackException, EndOfFileException { + IToken token = LA(1); + + if (token.getType() == IGCCToken.t__declspec) { + consume(); + + token = LA(1); + + if (token.getType() == IToken.tLPAREN) { + consume(); + while(true) { + token = LA(1); + consume(); + if (token.getType() == IToken.tRPAREN) { + break; + } + } + } + } + } } Index: parser/org/eclipse/cdt/core/parser/IGCCToken.java =================================================================== RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IGCCToken.java,v retrieving revision 1.7 diff -u -r1.7 IGCCToken.java --- parser/org/eclipse/cdt/core/parser/IGCCToken.java 23 Jun 2006 17:26:58 -0000 1.7 +++ parser/org/eclipse/cdt/core/parser/IGCCToken.java 21 Sep 2006 18:49:25 -0000 @@ -22,5 +22,6 @@ public static final int tMAX = tLAST + 3; public static final int tMIN = tLAST + 4; public static final int t__attribute__ = tLAST + 5; + public static final int t__declspec = tLAST + 6; } Index: parser/org/eclipse/cdt/core/parser/GCCKeywords.java =================================================================== RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java,v retrieving revision 1.7 diff -u -r1.7 GCCKeywords.java --- parser/org/eclipse/cdt/core/parser/GCCKeywords.java 23 Jun 2006 17:26:58 -0000 1.7 +++ parser/org/eclipse/cdt/core/parser/GCCKeywords.java 21 Sep 2006 18:49:25 -0000 @@ -20,9 +20,11 @@ public static final String TYPEOF = "typeof"; //$NON-NLS-1$ public static final String __ALIGNOF__ = "__alignof__"; //$NON-NLS-1$ public static final String __ATTRIBUTE__ = "__attribute__"; //$NON-NLS-1$ + public static final String __DECLSPEC = "__declspec"; //$NON-NLS-1$ public static final char [] cpTYPEOF = TYPEOF.toCharArray(); public static final char [] cp__ALIGNOF__ = __ALIGNOF__.toCharArray(); public static final char [] cp__ATTRIBUTE__ = __ATTRIBUTE__.toCharArray(); + public static final char [] cp__DECLSPEC = __DECLSPEC.toCharArray(); } Index: parser/org/eclipse/cdt/internal/core/parser/scanner2/GCCScannerExtensionConfiguration.java =================================================================== RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/GCCScannerExtensionConfiguration.java,v retrieving revision 1.3 diff -u -r1.3 GCCScannerExtensionConfiguration.java --- parser/org/eclipse/cdt/internal/core/parser/scanner2/GCCScannerExtensionConfiguration.java 15 Jul 2005 14:08:12 -0000 1.3 +++ parser/org/eclipse/cdt/internal/core/parser/scanner2/GCCScannerExtensionConfiguration.java 21 Sep 2006 18:49:27 -0000 @@ -69,6 +69,7 @@ result.put( GCCKeywords.cp__ALIGNOF__, IGCCToken.t___alignof__ ); result.put( GCCKeywords.cpTYPEOF, IGCCToken.t_typeof ); result.put( GCCKeywords.cp__ATTRIBUTE__, IGCCToken.t__attribute__ ); + result.put( GCCKeywords.cp__DECLSPEC, IGCCToken.t__declspec ); return result; } Index: parser/org/eclipse/cdt/internal/core/parser/scanner2/GPPScannerExtensionConfiguration.java =================================================================== RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/GPPScannerExtensionConfiguration.java,v retrieving revision 1.3 diff -u -r1.3 GPPScannerExtensionConfiguration.java --- parser/org/eclipse/cdt/internal/core/parser/scanner2/GPPScannerExtensionConfiguration.java 15 Jul 2005 14:08:12 -0000 1.3 +++ parser/org/eclipse/cdt/internal/core/parser/scanner2/GPPScannerExtensionConfiguration.java 21 Sep 2006 18:49:27 -0000 @@ -40,6 +40,7 @@ additionalCPPKeywords.put( Keywords.cRESTRICT, IToken.t_restrict ); additionalCPPKeywords.put( Keywords.c_COMPLEX, IToken.t__Complex ); additionalCPPKeywords.put( Keywords.c_IMAGINARY, IToken.t__Imaginary ); + additionalCPPKeywords.put( GCCKeywords.cp__DECLSPEC, IGCCToken.t__declspec ); return additionalCPPKeywords; }