View | Details | Raw Unified | Return to bug 158192 | Differences between
and this patch

Collapse All | Expand All

(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPParserExtensionConfiguration.java (+1 lines)
Lines 32-36 Link Here
32
	public boolean supportKnRC();
32
	public boolean supportKnRC();
33
	public boolean supportGCCOtherBuiltinSymbols();
33
	public boolean supportGCCOtherBuiltinSymbols();
34
	public boolean supportAttributeSpecifiers();
34
	public boolean supportAttributeSpecifiers();
35
	public boolean supportDeclspecSpecifiers();
35
36
36
}
37
}
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java (-2 / +16 lines)
Lines 1975-1981 Link Here
1975
        super(scanner, log, mode, config.supportStatementsInExpressions(),
1975
        super(scanner, log, mode, config.supportStatementsInExpressions(),
1976
                config.supportTypeofUnaryExpressions(), config
1976
                config.supportTypeofUnaryExpressions(), config
1977
                        .supportAlignOfUnaryExpression(), config.supportKnRC(),
1977
                        .supportAlignOfUnaryExpression(), config.supportKnRC(),
1978
                config.supportGCCOtherBuiltinSymbols(), config.supportAttributeSpecifiers());
1978
                config.supportGCCOtherBuiltinSymbols(), config.supportAttributeSpecifiers(),
1979
                config.supportDeclspecSpecifiers());
1979
        allowCPPRestrict = config.allowRestrictPointerOperators();
1980
        allowCPPRestrict = config.allowRestrictPointerOperators();
1980
        supportExtendedTemplateSyntax = config.supportExtendedTemplateSyntax();
1981
        supportExtendedTemplateSyntax = config.supportExtendedTemplateSyntax();
1981
        supportMinAndMaxOperators = config.supportMinAndMaxOperators();
1982
        supportMinAndMaxOperators = config.supportMinAndMaxOperators();
Lines 3473-3478 Link Here
3473
            	else
3474
            	else
3474
            		throwBacktrack(LA(1).getOffset(), LA(1).getLength());
3475
            		throwBacktrack(LA(1).getOffset(), LA(1).getLength());
3475
            	break;
3476
            	break;
3477
            case IGCCToken.t__declspec: // if __declspec appears before identifier
3478
            	if (duple == null && supportDeclspecSpecifiers)
3479
                	__declspec();
3480
            	else
3481
            		throwBacktrack(LA(1).getOffset(), LA(1).getLength());
3482
            	break;
3483
            	
3476
            default:
3484
            default:
3477
                if (supportTypeOfUnaries && LT(1) == IGCCToken.t_typeof) {
3485
                if (supportTypeOfUnaries && LT(1) == IGCCToken.t_typeof) {
3478
                    typeofExpression = unaryTypeofExpression();
3486
                    typeofExpression = unaryTypeofExpression();
Lines 3854-3859 Link Here
3854
            // if __attribute__ is after the pointer ops and before the declarator ex: void * __attribute__((__cdecl__)) foo();
3862
            // if __attribute__ is after the pointer ops and before the declarator ex: void * __attribute__((__cdecl__)) foo();
3855
            if (LT(1) == IGCCToken.t__attribute__ && supportAttributeSpecifiers) // if __attribute__ is after the parameters
3863
            if (LT(1) == IGCCToken.t__attribute__ && supportAttributeSpecifiers) // if __attribute__ is after the parameters
3856
            	__attribute__();
3864
            	__attribute__();
3865
            if (LT(1) == IGCCToken.t__declspec && supportDeclspecSpecifiers) // if __declspec occurs after struct/union/class and before the identifier
3866
            	__declspec();
3857
            
3867
            
3858
            if (!pointerOps.isEmpty())
3868
            if (!pointerOps.isEmpty())
3859
                finalOffset = calculateEndOffset((IASTNode) pointerOps
3869
                finalOffset = calculateEndOffset((IASTNode) pointerOps
Lines 4281-4287 Link Here
4281
4291
4282
        if (LT(1) == IGCCToken.t__attribute__ && supportAttributeSpecifiers) // if __attribute__ occurs after struct/union/class and before the identifier
4292
        if (LT(1) == IGCCToken.t__attribute__ && supportAttributeSpecifiers) // if __attribute__ occurs after struct/union/class and before the identifier
4283
        	__attribute__();
4293
        	__attribute__();
4284
        
4294
        if (LT(1) == IGCCToken.t__declspec && supportDeclspecSpecifiers) // if __declspec occurs after struct/union/class and before the identifier
4295
        	__declspec();
4296
4285
        // class name
4297
        // class name
4286
        if (LT(1) == IToken.tIDENTIFIER)
4298
        if (LT(1) == IToken.tIDENTIFIER)
4287
            name = createName(name());
4299
            name = createName(name());
Lines 4290-4295 Link Here
4290
        
4302
        
4291
        if (LT(1) == IGCCToken.t__attribute__ && supportAttributeSpecifiers) // if __attribute__ occurs after struct/union/class identifier and before the { or ;
4303
        if (LT(1) == IGCCToken.t__attribute__ && supportAttributeSpecifiers) // if __attribute__ occurs after struct/union/class identifier and before the { or ;
4292
        	__attribute__();
4304
        	__attribute__();
4305
        if (LT(1) == IGCCToken.t__declspec && supportDeclspecSpecifiers) // if __declspec occurs after struct/union/class and before the identifier
4306
        	__declspec();
4293
4307
4294
        if (LT(1) != IToken.tCOLON && LT(1) != IToken.tLBRACE) {
4308
        if (LT(1) != IToken.tCOLON && LT(1) != IToken.tLBRACE) {
4295
            IToken errorPoint = LA(1);
4309
            IToken errorPoint = LA(1);
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPParserExtensionConfiguration.java (+9 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.cdt.internal.core.dom.parser.cpp;
11
package org.eclipse.cdt.internal.core.dom.parser.cpp;
12
12
13
import org.eclipse.core.runtime.Platform;
14
13
/**
15
/**
14
 * @author jcamelon
16
 * @author jcamelon
15
 */
17
 */
Lines 100-103 Link Here
100
		return true;
102
		return true;
101
	}
103
	}
102
104
105
	/* (non-Javadoc)
106
	 * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportDeclspecSpecifiers()
107
	 */
108
	public boolean supportDeclspecSpecifiers() {
109
		// XXX: a hack, should use the target's platform
110
		return Platform.getOS().equals(Platform.OS_WIN32);
111
	}
103
}
112
}
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ANSICPPParserExtensionConfiguration.java (+6 lines)
Lines 100-103 Link Here
100
		return false;
100
		return false;
101
	}
101
	}
102
102
103
	/* (non-Javadoc)
104
	 * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportDeclspecSpecifiers()
105
	 */
106
	public boolean supportDeclspecSpecifiers() {
107
		return false;
108
	}
103
}
109
}
(-)parser/org/eclipse/cdt/internal/core/dom/parser/c/ANSICParserExtensionConfiguration.java (+6 lines)
Lines 65-68 Link Here
65
		return false;
65
		return false;
66
	}
66
	}
67
67
68
	/* (non-Javadoc)
69
	 * @see org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration#supportDeclspecSpecifiers()
70
	 */
71
	public boolean supportDeclspecSpecifiers() {
72
		return false;
73
	}
68
}
74
}
(-)parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java (-2 / +25 lines)
Lines 136-142 Link Here
136
                .supportTypeofUnaryExpressions(), config
136
                .supportTypeofUnaryExpressions(), config
137
                .supportAlignOfUnaryExpression(), config
137
                .supportAlignOfUnaryExpression(), config
138
                .supportKnRC(), config.supportGCCOtherBuiltinSymbols(),
138
                .supportKnRC(), config.supportGCCOtherBuiltinSymbols(),
139
                config.supportAttributeSpecifiers());
139
                config.supportAttributeSpecifiers(),
140
                config.supportDeclspecSpecifiers());
140
        supportGCCStyleDesignators = config.supportGCCStyleDesignators();
141
        supportGCCStyleDesignators = config.supportGCCStyleDesignators();
141
    }
142
    }
142
143
Lines 1605-1610 Link Here
1605
	            	else
1606
	            	else
1606
	            		throwBacktrack(LA(1).getOffset(), LA(1).getLength());
1607
	            		throwBacktrack(LA(1).getOffset(), LA(1).getLength());
1607
            	break;
1608
            	break;
1609
            case IGCCToken.t__declspec: // __declspec precedes the identifier
1610
            	if (identifier == null && supportDeclspecSpecifiers)
1611
            		__declspec();
1612
            	else
1613
            		throwBacktrack(LA(1).getOffset(), LA(1).getLength());
1614
            	break;
1608
            default:
1615
            default:
1609
                if (supportTypeOfUnaries && LT(1) == IGCCToken.t_typeof) {
1616
                if (supportTypeOfUnaries && LT(1) == IGCCToken.t_typeof) {
1610
                    typeofExpression = unaryTypeofExpression();
1617
                    typeofExpression = unaryTypeofExpression();
Lines 1757-1762 Link Here
1757
1764
1758
        if (LT(1) == IGCCToken.t__attribute__ && supportAttributeSpecifiers) // if __attribute__ occurs after struct/union/class and before the identifier
1765
        if (LT(1) == IGCCToken.t__attribute__ && supportAttributeSpecifiers) // if __attribute__ occurs after struct/union/class and before the identifier
1759
        	__attribute__();
1766
        	__attribute__();
1767
        if (LT(1) == IGCCToken.t__declspec && supportDeclspecSpecifiers) // if __declspec occurs after struct/union/class and before the identifier
1768
        	__declspec();
1760
        
1769
        
1761
        IToken nameToken = null;
1770
        IToken nameToken = null;
1762
        // class name
1771
        // class name
Lines 1766-1771 Link Here
1766
1775
1767
        if (LT(1) == IGCCToken.t__attribute__ && supportAttributeSpecifiers) // if __attribute__ occurs after struct/union/class identifier and before the { or ;
1776
        if (LT(1) == IGCCToken.t__attribute__ && supportAttributeSpecifiers) // if __attribute__ occurs after struct/union/class identifier and before the { or ;
1768
        	__attribute__();
1777
        	__attribute__();
1778
        if (LT(1) == IGCCToken.t__declspec && supportDeclspecSpecifiers) // if __declspec occurs after struct/union/class and before the identifier
1779
        	__declspec();
1769
        
1780
        
1770
        if (LT(1) != IToken.tLBRACE) {
1781
        if (LT(1) != IToken.tLBRACE) {
1771
            IToken errorPoint = LA(1);
1782
            IToken errorPoint = LA(1);
Lines 1913-1918 Link Here
1913
            // if __attribute__ is after the pointer ops and before the declarator ex: void * __attribute__((__cdecl__)) foo();
1924
            // if __attribute__ is after the pointer ops and before the declarator ex: void * __attribute__((__cdecl__)) foo();
1914
            if (LT(1) == IGCCToken.t__attribute__ && supportAttributeSpecifiers) // if __attribute__ is after the parameters
1925
            if (LT(1) == IGCCToken.t__attribute__ && supportAttributeSpecifiers) // if __attribute__ is after the parameters
1915
            	__attribute__();
1926
            	__attribute__();
1927
            if (LT(1) == IGCCToken.t__declspec && supportDeclspecSpecifiers) // if __declspec is after the parameters
1928
            	__declspec();
1916
            
1929
            
1917
            if (!pointerOps.isEmpty()) {
1930
            if (!pointerOps.isEmpty()) {
1918
                finalOffset = calculateEndOffset((IASTPointerOperator) pointerOps
1931
                finalOffset = calculateEndOffset((IASTPointerOperator) pointerOps
Lines 2081-2086 Link Here
2081
                	else
2094
                	else
2082
                		throwBacktrack(LA(1).getOffset(), LA(1).getLength());
2095
                		throwBacktrack(LA(1).getOffset(), LA(1).getLength());
2083
                	break;
2096
                	break;
2097
                case IGCCToken.t__declspec:
2098
                	if(supportDeclspecSpecifiers)
2099
                		__declspec();
2100
                	else
2101
                		throwBacktrack(LA(1).getOffset(), LA(1).getLength());
2102
                	break;
2103
               	
2084
                default:
2104
                default:
2085
                    break;
2105
                    break;
2086
                }
2106
                }
Lines 2091-2097 Link Here
2091
2111
2092
        if (LT(1) == IGCCToken.t__attribute__ && supportAttributeSpecifiers) // if __attribute__ is after the parameters
2112
        if (LT(1) == IGCCToken.t__attribute__ && supportAttributeSpecifiers) // if __attribute__ is after the parameters
2093
        	__attribute__();
2113
        	__attribute__();
2094
        
2114
2115
        if (LT(1) == IGCCToken.t__declspec && supportDeclspecSpecifiers) // if __attribute__ is after the parameters
2116
        	__declspec();
2117
2095
        IASTDeclarator d = null;
2118
        IASTDeclarator d = null;
2096
        if (numKnRCParms > 0) {
2119
        if (numKnRCParms > 0) {
2097
            ICASTKnRFunctionDeclarator functionDecltor = createKnRFunctionDeclarator();
2120
            ICASTKnRFunctionDeclarator functionDecltor = createKnRFunctionDeclarator();
(-)parser/org/eclipse/cdt/internal/core/dom/parser/c/GCCParserExtensionConfiguration.java (+11 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.cdt.internal.core.dom.parser.c;
11
package org.eclipse.cdt.internal.core.dom.parser.c;
12
12
13
import org.eclipse.core.runtime.Platform;
14
13
/**
15
/**
14
 * @author jcamelon
16
 * @author jcamelon
15
 */
17
 */
Lines 65-68 Link Here
65
		return true;
67
		return true;
66
	}
68
	}
67
	
69
	
70
	/* (non-Javadoc)
71
	 * @see org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration#supportDeclspecSpecifiers()
72
	 */
73
	public boolean supportDeclspecSpecifiers() {
74
		// XXX Yes, this is a hack -- should use the target platform
75
		if (Platform.getOS().equals(Platform.OS_WIN32))
76
			return true;
77
		return false;
78
	}
68
}
79
}
(-)parser/org/eclipse/cdt/internal/core/dom/parser/c/ICParserExtensionConfiguration.java (+6 lines)
Lines 35-38 Link Here
35
	 */
35
	 */
36
	public boolean supportAttributeSpecifiers();
36
	public boolean supportAttributeSpecifiers();
37
37
38
	/**
39
	 * Win32 compiler extensions also supported by GCC on Win32 
40
	 * @return
41
	 */
42
	public boolean supportDeclspecSpecifiers();
43
38
}
44
}
(-)parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java (-1 / +25 lines)
Lines 89-101 Link Here
89
    protected final boolean supportGCCOtherBuiltinSymbols;
89
    protected final boolean supportGCCOtherBuiltinSymbols;
90
    
90
    
91
    protected final boolean supportAttributeSpecifiers;
91
    protected final boolean supportAttributeSpecifiers;
92
    
93
    protected final boolean supportDeclspecSpecifiers;
92
94
93
    protected AbstractGNUSourceCodeParser(IScanner scanner,
95
    protected AbstractGNUSourceCodeParser(IScanner scanner,
94
            IParserLogService logService, ParserMode parserMode,
96
            IParserLogService logService, ParserMode parserMode,
95
            boolean supportStatementsInExpressions,
97
            boolean supportStatementsInExpressions,
96
            boolean supportTypeOfUnaries, boolean supportAlignOfUnaries,
98
            boolean supportTypeOfUnaries, boolean supportAlignOfUnaries,
97
            boolean supportKnRC, boolean supportGCCOtherBuiltinSymbols,
99
            boolean supportKnRC, boolean supportGCCOtherBuiltinSymbols,
98
            boolean supportAttributeSpecifiers) {
100
            boolean supportAttributeSpecifiers, boolean supportDeclspecSpecifiers) {
99
        this.scanner = scanner;
101
        this.scanner = scanner;
100
        this.log = logService;
102
        this.log = logService;
101
        this.mode = parserMode;
103
        this.mode = parserMode;
Lines 105-110 Link Here
105
        this.supportKnRC = supportKnRC;
107
        this.supportKnRC = supportKnRC;
106
        this.supportGCCOtherBuiltinSymbols = supportGCCOtherBuiltinSymbols;
108
        this.supportGCCOtherBuiltinSymbols = supportGCCOtherBuiltinSymbols;
107
        this.supportAttributeSpecifiers = supportAttributeSpecifiers;
109
        this.supportAttributeSpecifiers = supportAttributeSpecifiers;
110
        this.supportDeclspecSpecifiers = supportDeclspecSpecifiers;
108
    }
111
    }
109
112
110
    protected boolean parsePassed = true;
113
    protected boolean parsePassed = true;
Lines 2252-2255 Link Here
2252
    		}
2255
    		}
2253
    	}
2256
    	}
2254
    }
2257
    }
2258
    
2259
    protected void __declspec() throws BacktrackException, EndOfFileException {
2260
    	IToken token = LA(1);
2261
    	
2262
    	if (token.getType() == IGCCToken.t__declspec) {
2263
    		consume();
2264
    		
2265
    		token = LA(1);
2266
    		
2267
    		if (token.getType() == IToken.tLPAREN) {
2268
    			consume();
2269
            	while(true) {
2270
            		token = LA(1);
2271
            		consume();
2272
            		if (token.getType() == IToken.tRPAREN) {
2273
            			break;
2274
            		}
2275
            	}
2276
    		}
2277
    	}
2278
    }    
2255
}
2279
}
(-)parser/org/eclipse/cdt/core/parser/IGCCToken.java (+1 lines)
Lines 22-26 Link Here
22
	public static final int tMAX = tLAST + 3;
22
	public static final int tMAX = tLAST + 3;
23
	public static final int tMIN = tLAST + 4;
23
	public static final int tMIN = tLAST + 4;
24
	public static final int t__attribute__ = tLAST + 5;
24
	public static final int t__attribute__ = tLAST + 5;
25
	public static final int t__declspec = tLAST + 6;
25
	
26
	
26
}
27
}
(-)parser/org/eclipse/cdt/core/parser/GCCKeywords.java (+2 lines)
Lines 20-28 Link Here
20
	public static final String TYPEOF = "typeof"; //$NON-NLS-1$
20
	public static final String TYPEOF = "typeof"; //$NON-NLS-1$
21
	public static final String __ALIGNOF__ = "__alignof__"; //$NON-NLS-1$
21
	public static final String __ALIGNOF__ = "__alignof__"; //$NON-NLS-1$
22
	public static final String __ATTRIBUTE__ = "__attribute__"; //$NON-NLS-1$
22
	public static final String __ATTRIBUTE__ = "__attribute__"; //$NON-NLS-1$
23
	public static final String __DECLSPEC = "__declspec"; //$NON-NLS-1$
23
24
24
	public static final char [] cpTYPEOF = TYPEOF.toCharArray();
25
	public static final char [] cpTYPEOF = TYPEOF.toCharArray();
25
	public static final char [] cp__ALIGNOF__ = __ALIGNOF__.toCharArray();
26
	public static final char [] cp__ALIGNOF__ = __ALIGNOF__.toCharArray();
26
	public static final char [] cp__ATTRIBUTE__ = __ATTRIBUTE__.toCharArray();
27
	public static final char [] cp__ATTRIBUTE__ = __ATTRIBUTE__.toCharArray();
28
	public static final char [] cp__DECLSPEC = __DECLSPEC.toCharArray();
27
29
28
}
30
}
(-)parser/org/eclipse/cdt/internal/core/parser/scanner2/GCCScannerExtensionConfiguration.java (+1 lines)
Lines 69-74 Link Here
69
		result.put( GCCKeywords.cp__ALIGNOF__, IGCCToken.t___alignof__ );
69
		result.put( GCCKeywords.cp__ALIGNOF__, IGCCToken.t___alignof__ );
70
		result.put( GCCKeywords.cpTYPEOF, IGCCToken.t_typeof );
70
		result.put( GCCKeywords.cpTYPEOF, IGCCToken.t_typeof );
71
		result.put( GCCKeywords.cp__ATTRIBUTE__, IGCCToken.t__attribute__ );
71
		result.put( GCCKeywords.cp__ATTRIBUTE__, IGCCToken.t__attribute__ );
72
		result.put( GCCKeywords.cp__DECLSPEC, IGCCToken.t__declspec );
72
        return result;
73
        return result;
73
    }
74
    }
74
75
(-)parser/org/eclipse/cdt/internal/core/parser/scanner2/GPPScannerExtensionConfiguration.java (+1 lines)
Lines 40-45 Link Here
40
		additionalCPPKeywords.put( Keywords.cRESTRICT, IToken.t_restrict );
40
		additionalCPPKeywords.put( Keywords.cRESTRICT, IToken.t_restrict );
41
		additionalCPPKeywords.put( Keywords.c_COMPLEX, IToken.t__Complex );
41
		additionalCPPKeywords.put( Keywords.c_COMPLEX, IToken.t__Complex );
42
		additionalCPPKeywords.put( Keywords.c_IMAGINARY, IToken.t__Imaginary );
42
		additionalCPPKeywords.put( Keywords.c_IMAGINARY, IToken.t__Imaginary );
43
		additionalCPPKeywords.put( GCCKeywords.cp__DECLSPEC, IGCCToken.t__declspec );
43
		return additionalCPPKeywords;
44
		return additionalCPPKeywords;
44
    }
45
    }
45
46

Return to bug 158192