Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2008-04-08 12:50:31 +0000
committerMarkus Schorn2008-04-08 12:50:31 +0000
commit52d33205031167af533dd69546ddbb9003c71134 (patch)
tree2cf564365f1f933d2a2c8d4333a2d9d8c138f1d0 /core/org.eclipse.cdt.core
parent61cc1a811f9960c35ade853400a83885e7174d9b (diff)
downloadorg.eclipse.cdt-52d33205031167af533dd69546ddbb9003c71134.tar.gz
org.eclipse.cdt-52d33205031167af533dd69546ddbb9003c71134.tar.xz
org.eclipse.cdt-52d33205031167af533dd69546ddbb9003c71134.zip
Configure gcc-extensions as keywords, rather than macros, bug 226112.
Diffstat (limited to 'core/org.eclipse.cdt.core')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/GNUScannerExtensionConfiguration.java43
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java29
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPScannerExtensionConfiguration.java37
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java16
4 files changed, 74 insertions, 51 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/GNUScannerExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/GNUScannerExtensionConfiguration.java
index 2b0967e17c8..7f7e52349b4 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/GNUScannerExtensionConfiguration.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/GNUScannerExtensionConfiguration.java
@@ -12,8 +12,11 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.parser;
+import org.eclipse.cdt.core.parser.GCCKeywords;
+import org.eclipse.cdt.core.parser.IGCCToken;
import org.eclipse.cdt.core.parser.IMacro;
import org.eclipse.cdt.core.parser.IPreprocessorDirective;
+import org.eclipse.cdt.core.parser.IToken;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
@@ -23,21 +26,12 @@ import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
public abstract class GNUScannerExtensionConfiguration extends AbstractScannerExtensionConfiguration {
private static IMacro[] sAdditionalMacros= new IMacro[] {
- createMacro("__asm__", "asm"), //$NON-NLS-1$//$NON-NLS-2$
createMacro("__complex__", "_Complex"), //$NON-NLS-1$ //$NON-NLS-2$
- createMacro("__const__", "const"), //$NON-NLS-1$ //$NON-NLS-2$
- createMacro("__const", "const"), //$NON-NLS-1$ //$NON-NLS-2$
createMacro("__extension__", ""), //$NON-NLS-1$ //$NON-NLS-2$
- createMacro("__inline__", "inline"), //$NON-NLS-1$ //$NON-NLS-2$
createMacro("__imag__", "(int)"), //$NON-NLS-1$ //$NON-NLS-2$
createMacro("__null", "(void *)0"), //$NON-NLS-1$ //$NON-NLS-2$
createMacro("__real__", "(int)"), //$NON-NLS-1$ //$NON-NLS-2$
- createMacro("__restrict__", "restrict"), //$NON-NLS-1$ //$NON-NLS-2$
- createMacro("__restrict", "restrict"), //$NON-NLS-1$ //$NON-NLS-2$
- createMacro("__volatile__", "volatile"), //$NON-NLS-1$ //$NON-NLS-2$
- createMacro("__signed__", "signed"), //$NON-NLS-1$ //$NON-NLS-2$
createMacro("__stdcall", ""), //$NON-NLS-1$ //$NON-NLS-2$
- createMacro("__typeof__", "typeof"), //$NON-NLS-1$ //$NON-NLS-2$
createMacro("__builtin_va_arg(ap,type)", "*(type *)ap"), //$NON-NLS-1$//$NON-NLS-2$
createMacro("__builtin_constant_p(exp)", "0") //$NON-NLS-1$//$NON-NLS-2$
@@ -46,23 +40,43 @@ public abstract class GNUScannerExtensionConfiguration extends AbstractScannerEx
public static IMacro[] getAdditionalGNUMacros() {
return sAdditionalMacros;
}
-
- public boolean support$InIdentifiers() {
+
+ public static void addAdditionalGNUKeywords(CharArrayIntMap target) {
+ target.put(GCCKeywords.cp__ALIGNOF__, IGCCToken.t___alignof__ );
+ target.put(GCCKeywords.cp__ASM__, IToken.t_asm);
+ target.put(GCCKeywords.cp__ATTRIBUTE__, IGCCToken.t__attribute__ );
+ target.put(GCCKeywords.cp__CONST, IToken.t_const);
+ target.put(GCCKeywords.cp__CONST__, IToken.t_const);
+ target.put(GCCKeywords.cp__DECLSPEC, IGCCToken.t__declspec );
+ target.put(GCCKeywords.cp__INLINE__, IToken.t_inline);
+ target.put(GCCKeywords.cp__RESTRICT, IToken.t_restrict);
+ target.put(GCCKeywords.cp__RESTRICT__, IToken.t_restrict);
+ target.put(GCCKeywords.cp__VOLATILE__, IToken.t_volatile);
+ target.put(GCCKeywords.cp__SIGNED__, IToken.t_signed);
+ target.put(GCCKeywords.cp__TYPEOF__, IGCCToken.t_typeof);
+ target.put(GCCKeywords.cpTYPEOF, IGCCToken.t_typeof );
+ }
+
+ @Override
+ public boolean support$InIdentifiers() {
return true;
}
- public char[] supportAdditionalNumericLiteralSuffixes() {
+ @Override
+ public char[] supportAdditionalNumericLiteralSuffixes() {
return "ij".toCharArray(); //$NON-NLS-1$
}
- public IMacro[] getAdditionalMacros() {
+ @Override
+ public IMacro[] getAdditionalMacros() {
return sAdditionalMacros;
}
/*
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration#getAdditionalPreprocessorKeywords()
*/
- public CharArrayIntMap getAdditionalPreprocessorKeywords() {
+ @Override
+ public CharArrayIntMap getAdditionalPreprocessorKeywords() {
CharArrayIntMap additionalPPKeywords= new CharArrayIntMap(8, IPreprocessorDirective.ppInvalid);
additionalPPKeywords.put(Keywords.cINCLUDE_NEXT, IPreprocessorDirective.ppInclude_next);
additionalPPKeywords.put(Keywords.cIMPORT, IPreprocessorDirective.ppImport);
@@ -73,5 +87,4 @@ public abstract class GNUScannerExtensionConfiguration extends AbstractScannerEx
additionalPPKeywords.put(Keywords.cUNASSERT, IPreprocessorDirective.ppIgnore);
return additionalPPKeywords;
}
-
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java
index 72cdd51afeb..5fb3e258dbc 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java
@@ -1,19 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM - Initial API and implementation
- * Ed Swartz (Nokia)
+ * IBM - Initial API and implementation
+ * Ed Swartz (Nokia)
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.parser.c;
import org.eclipse.cdt.core.dom.parser.GNUScannerExtensionConfiguration;
-import org.eclipse.cdt.core.parser.GCCKeywords;
-import org.eclipse.cdt.core.parser.IGCCToken;
import org.eclipse.cdt.core.parser.IMacro;
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
@@ -23,17 +22,22 @@ import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
public class GCCScannerExtensionConfiguration extends GNUScannerExtensionConfiguration {
private static IMacro[] sAdditionalMacros;
+ private static CharArrayIntMap sAdditionalKeywords;
static {
final IMacro[] macros = GNUScannerExtensionConfiguration.getAdditionalGNUMacros();
sAdditionalMacros= new IMacro[macros.length+1];
System.arraycopy(macros, 0, sAdditionalMacros, 0, macros.length);
sAdditionalMacros[macros.length]= createMacro("_Pragma(arg)", ""); //$NON-NLS-1$//$NON-NLS-2$
+
+ sAdditionalKeywords= new CharArrayIntMap(10, -1);
+ GNUScannerExtensionConfiguration.addAdditionalGNUKeywords(sAdditionalKeywords);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerConfiguration#supportMinAndMaxOperators()
*/
- public boolean supportMinAndMaxOperators() {
+ @Override
+ public boolean supportMinAndMaxOperators() {
return false;
}
@@ -41,20 +45,17 @@ public class GCCScannerExtensionConfiguration extends GNUScannerExtensionConfigu
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerConfiguration#getAdditionalMacros()
*/
- public IMacro[] getAdditionalMacros() {
+ @Override
+ public IMacro[] getAdditionalMacros() {
return sAdditionalMacros;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerConfiguration#getAdditionalKeywords()
*/
- public CharArrayIntMap getAdditionalKeywords() {
- CharArrayIntMap result = new CharArrayIntMap( 4, -1 );
- 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;
+ @Override
+ public CharArrayIntMap getAdditionalKeywords() {
+ return sAdditionalKeywords;
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPScannerExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPScannerExtensionConfiguration.java
index 23e9edeaa23..9eabc9da3c8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPScannerExtensionConfiguration.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPScannerExtensionConfiguration.java
@@ -1,20 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM - Initial API and implementation
- * Ed Swartz (Nokia)
- * Anton Leherbauer (Wind River Systems)
+ * IBM - Initial API and implementation
+ * Ed Swartz (Nokia)
+ * Anton Leherbauer (Wind River Systems)
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.parser.GNUScannerExtensionConfiguration;
-import org.eclipse.cdt.core.parser.GCCKeywords;
-import org.eclipse.cdt.core.parser.IGCCToken;
import org.eclipse.cdt.core.parser.IToken;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
@@ -24,26 +23,28 @@ import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
*/
public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfiguration {
+ private static CharArrayIntMap sAdditionalKeywords;
+ static {
+ sAdditionalKeywords= new CharArrayIntMap(10, -1);
+ GNUScannerExtensionConfiguration.addAdditionalGNUKeywords(sAdditionalKeywords);
+ sAdditionalKeywords.put( Keywords.cRESTRICT, IToken.t_restrict );
+ sAdditionalKeywords.put( Keywords.c_COMPLEX, IToken.t__Complex );
+ sAdditionalKeywords.put( Keywords.c_IMAGINARY, IToken.t__Imaginary );
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerConfiguration#supportMinAndMaxOperators()
*/
- public boolean supportMinAndMaxOperators() {
+ @Override
+ public boolean supportMinAndMaxOperators() {
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerConfiguration#getAdditionalKeywords()
*/
- public CharArrayIntMap getAdditionalKeywords() {
- CharArrayIntMap additionalCPPKeywords = new CharArrayIntMap( 8, -1 );
- additionalCPPKeywords.put( GCCKeywords.cp__ALIGNOF__, IGCCToken.t___alignof__ );
- additionalCPPKeywords.put( GCCKeywords.cpTYPEOF, IGCCToken.t_typeof );
- additionalCPPKeywords.put( GCCKeywords.cp__ATTRIBUTE__, IGCCToken.t__attribute__ );
- 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;
+ @Override
+ public CharArrayIntMap getAdditionalKeywords() {
+ return sAdditionalKeywords;
}
-
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java
index d11d57d633b..98a25406a80 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java
@@ -1,15 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2002, 2007 IBM Corporation and others.
+ * Copyright (c) 2002, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM Rational Software - Initial API and implementation
- * Ed Swartz (Nokia)
+ * IBM Rational Software - Initial API and implementation
+ * Ed Swartz (Nokia)
*******************************************************************************/
-
package org.eclipse.cdt.core.parser;
/**
@@ -28,4 +27,13 @@ public class GCCKeywords {
public static final char [] cp__ATTRIBUTE__ = __ATTRIBUTE__.toCharArray();
public static final char [] cp__DECLSPEC = __DECLSPEC.toCharArray();
+ public static final char [] cp__ASM__= "__asm__".toCharArray(); //$NON-NLS-1$
+ public static final char [] cp__CONST__= "__const__".toCharArray(); //$NON-NLS-1$
+ public static final char [] cp__CONST= "__const".toCharArray(); //$NON-NLS-1$
+ public static final char [] cp__INLINE__= "__inline__".toCharArray(); //$NON-NLS-1$
+ public static final char [] cp__RESTRICT__= "__restrict__".toCharArray(); //$NON-NLS-1$
+ public static final char [] cp__RESTRICT= "__restrict".toCharArray(); //$NON-NLS-1$
+ public static final char [] cp__VOLATILE__= "__volatile__".toCharArray(); //$NON-NLS-1$
+ public static final char [] cp__SIGNED__= "__signed__".toCharArray(); //$NON-NLS-1$
+ public static final char [] cp__TYPEOF__= "__typeof__".toCharArray(); //$NON-NLS-1$
}

Back to the top