diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java
index 1b8d8b8d146..9d482eb606d 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * Copyright (c) 2004, 2011 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
@@ -58,7 +58,6 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
private static final String EXTERNAL_SI_PROVIDER_ERROR = "ExternalScannerInfoProvider.Provider_Error"; //$NON-NLS-1$
private static final String GMAKE_ERROR_PARSER_ID = "org.eclipse.cdt.core.GmakeErrorParser"; //$NON-NLS-1$
private static final String PREF_CONSOLE_ENABLED = "org.eclipse.cdt.make.core.scanner.discovery.console.enabled"; //$NON-NLS-1$
- private static final String LANG_ENV_VAR = "LANG"; //$NON-NLS-1$
private static final String NEWLINE = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
private static final String PATH_ENV = "PATH"; //$NON-NLS-1$
@@ -262,21 +261,19 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
private Properties getEnvMap(ICommandLauncher launcher, Properties initialEnv) {
// Set the environmennt, some scripts may need the CWD var to be set.
- Properties props = initialEnv != null ? initialEnv : launcher.getEnvironment();
-
- if (fWorkingDirectory != null) {
+ Properties props = initialEnv != null ? initialEnv : launcher.getEnvironment();
+
+ if (fWorkingDirectory != null) {
props.put("CWD", fWorkingDirectory.toOSString()); //$NON-NLS-1$
props.put("PWD", fWorkingDirectory.toOSString()); //$NON-NLS-1$
}
- // On POSIX (Linux, UNIX) systems reset LANG variable to English with
- // UTF-8 encoding
- // since GNU compilers can handle only UTF-8 characters. English language is chosen
- // beacuse GNU compilers inconsistently handle different locales when generating
- // output of the 'gcc -v' command. Include paths with locale characters will be
- // handled properly regardless of the language as long as the encoding is set to UTF-8.
- if (props.containsKey(LANG_ENV_VAR)) {
- props.put(LANG_ENV_VAR, "en_US.UTF-8"); //$NON-NLS-1$
- }
+ // On POSIX (Linux, UNIX) systems reset LANG variable to English with
+ // UTF-8 encoding since GNU compilers can handle only UTF-8 characters.
+ // Include paths with locale characters will be handled properly regardless
+ // of the language as long as the encoding is set to UTF-8.
+ // English language is chosen because parser relies on English messages
+ // in the output of the 'gcc -v' command.
+ props.put("LC_ALL", "en_US.UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$
return props;
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/GCCSpecsRunSIProvider.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/GCCSpecsRunSIProvider.java
index bd15498025e..8ecb3e935e4 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/GCCSpecsRunSIProvider.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/GCCSpecsRunSIProvider.java
@@ -1,94 +1,93 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 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
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig2;
-
-import java.util.List;
-
-import org.eclipse.cdt.core.CCProjectNature;
-import org.eclipse.cdt.core.CProjectNature;
-import org.eclipse.cdt.make.core.MakeCorePlugin;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
-import org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCScannerConfigUtil;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * Runs a command to retrieve compiler intrinsic scanner info from 'specs' file.
- *
- * @author vhirsl
- */
-public class GCCSpecsRunSIProvider extends DefaultRunSIProvider {
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig2.DefaultRunSIProvider#initialize()
- */
- @Override
- protected boolean initialize() {
- boolean rc = super.initialize();
-
- if (rc) {
- String targetFile = "dummy"; //$NON-NLS-1$
- IProject project = resource.getProject();
- try {
- if (project.hasNature(CCProjectNature.CC_NATURE_ID)) {
- targetFile = GCCScannerConfigUtil.CPP_SPECS_FILE;
- }
- else if (project.hasNature(CProjectNature.C_NATURE_ID)) {
- targetFile = GCCScannerConfigUtil.C_SPECS_FILE;
- }
- // replace string variables in compile arguments
- // TODO Vmir - use string variable replacement
- for (int i = 0; i < fCompileArguments.length; ++i) {
- fCompileArguments[i] = fCompileArguments[i].replaceAll("\\$\\{plugin_state_location\\}", //$NON-NLS-1$
- MakeCorePlugin.getWorkingDirectory().toString());
- fCompileArguments[i] = fCompileArguments[i].replaceAll("\\$\\{specs_file\\}", targetFile); //$NON-NLS-1$
- }
- } catch (CoreException e) {
- //TODO VMIR better error handling
- MakeCorePlugin.log(e.getStatus());
- rc = false;
- }
- }
- return rc;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig2.DefaultRunSIProvider#prepareArguments(boolean)
- */
- @Override
- protected String[] prepareArguments(boolean isDefaultCommand) {
- if (collector == null)
- return fCompileArguments;
-
- @SuppressWarnings("unchecked")
- ListPOINTER_OPERATOR
represents the relationship between an
@@ -111,10 +110,12 @@ public interface IASTDeclarator extends IASTNode, IASTNameOwner {
/**
* @since 5.1
*/
+ @Override
public IASTDeclarator copy();
/**
* @since 5.3
*/
+ @Override
public IASTDeclarator copy(CopyStyle style);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTPointerOperator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTPointerOperator.java
index fe5a585b3ec..343a115cb88 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTPointerOperator.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTPointerOperator.java
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Doug Schaefer (IBM) - Initial API and implementation
+ * Doug Schaefer (IBM) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
@@ -15,19 +15,20 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTPointerOperator extends IASTNode {
-
/**
* Constant/sentinel.
*/
- public static final IASTPointerOperator[] EMPTY_ARRAY = new IASTPointerOperator[0];
+ public static final IASTPointerOperator[] EMPTY_ARRAY = {};
/**
* @since 5.1
*/
+ @Override
public IASTPointerOperator copy();
/**
* @since 5.3
*/
+ @Override
public IASTPointerOperator copy(CopyStyle style);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTReferenceOperator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTReferenceOperator.java
index c0145224e29..37c8c0c0808 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTReferenceOperator.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTReferenceOperator.java
@@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Doug Schaefer (IBM) - Initial API and implementation
- * Markus Schorn (Wind River Systems)
+ * Doug Schaefer (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
@@ -20,7 +20,6 @@ import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPASTReferenceOperator extends IASTPointerOperator {
-
/**
* Returns whether the operator denotes a rvalue reference (e.g. int &&
).
* @since 5.2
@@ -30,10 +29,12 @@ public interface ICPPASTReferenceOperator extends IASTPointerOperator {
/**
* @since 5.1
*/
+ @Override
public ICPPASTReferenceOperator copy();
/**
* @since 5.3
*/
+ @Override
public ICPPASTReferenceOperator copy(CopyStyle style);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/TypeHelper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/TypeHelper.java
index d3c7d53c6e7..222d970da17 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/TypeHelper.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/TypeHelper.java
@@ -52,10 +52,9 @@ public class TypeHelper {
}
SizeofCalculator calc = ((ASTTranslationUnit) ast).getSizeofCalculator();
SizeAndAlignment sizeofPointer = calc.sizeAndAlignmentOfPointer();
- if (sizeofPointer == null)
- return true;
+ long maxSize = sizeofPointer != null ? sizeofPointer.size : 4;
SizeAndAlignment sizeofType = calc.sizeAndAlignment(type);
- if (sizeofType == null || sizeofType.size > sizeofPointer.size)
+ if (sizeofType == null || sizeofType.size > maxSize)
return true;
}
return false;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
index 54e46eacea2..ed744344988 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
@@ -90,6 +90,7 @@ import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver;
*/
public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
public interface ITemplateIdStrategy {
+ boolean shallParseAsTemplateID(IASTName name);
}
protected static class FoundAggregateInitializer extends Exception {
@@ -243,7 +244,8 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
throw backtrack;
}
- public IASTCompletionNode getCompletionNode() {
+ @Override
+ public IASTCompletionNode getCompletionNode() {
return completionNode;
}
@@ -555,7 +557,8 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
parsePassed = false;
}
- public synchronized void cancel() {
+ @Override
+ public synchronized void cancel() {
isCancelled = true;
}
@@ -642,7 +645,8 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
throwBacktrack(n.getOffset(), n.getLength());
}
- public IASTTranslationUnit parse() {
+ @Override
+ public IASTTranslationUnit parse() {
long startTime = System.currentTimeMillis();
translationUnit();
log.traceLog("Parse " //$NON-NLS-1$
@@ -1173,22 +1177,27 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
return fUnaryOperatorOffset;
}
+ @Override
public IASTExpression copy() {
throw new UnsupportedOperationException();
}
+ @Override
public IASTExpression copy(CopyStyle style) {
throw new UnsupportedOperationException();
}
+ @Override
public IType getExpressionType() {
throw new UnsupportedOperationException();
}
+ @Override
public boolean isLValue() {
throw new UnsupportedOperationException();
}
+ @Override
public ValueCategory getValueCategory() {
throw new UnsupportedOperationException();
}
@@ -1198,11 +1207,14 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
if (LT(1) == IToken.tLPAREN) {
final IToken mark= mark();
final int startingOffset= mark.getOffset();
+ final boolean canBeCast= canBeCastExpression();
consume();
IASTTypeId typeId= null;
- try {
- typeId= typeId(DeclarationOptions.TYPEID);
- } catch (BacktrackException e) {
+ if (canBeCast) {
+ try {
+ typeId= typeId(DeclarationOptions.TYPEID);
+ } catch (BacktrackException e) {
+ }
}
if (typeId != null && LT(1) == IToken.tRPAREN) {
consume();
@@ -1562,7 +1574,8 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
return skipProblemConditionInParenthesis(mark.getOffset());
}
- public boolean encounteredError() {
+ @Override
+ public boolean encounteredError() {
return !parsePassed;
}
@@ -1862,9 +1875,11 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
ds = nodeFactory.newDeclarationStatement(d);
setRange(ds, d);
} catch (BacktrackException b) {
- if (expressionStatement == null) {
- IASTNode node = b.getNodeBeforeProblem();
- if (node instanceof IASTDeclaration) {
+ IASTNode node = b.getNodeBeforeProblem();
+ final boolean isProblemDecl = node instanceof IASTDeclaration;
+ if (expressionStatement == null
+ || (!foundSemicolon && isProblemDecl && node.contains(expressionStatement))) {
+ if (isProblemDecl) {
ds= nodeFactory.newDeclarationStatement((IASTDeclaration) node);
b.initialize(b.getProblem(), setRange(ds, node));
}
@@ -2399,7 +2414,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
if (token.getType() == IGCCToken.t__declspec) {
consume();
if (LT(1) == IToken.tLPAREN) {
- skipBrackets(IToken.tLPAREN, IToken.tRPAREN);
+ skipBrackets(IToken.tLPAREN, IToken.tRPAREN, 0);
}
}
}
@@ -2433,24 +2448,68 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
}
}
- /**
- * In case a cast expression is followed by +/- or & we should avoid it:
- * (a)+1 vs. (int)+1;
- * @since 4.0
- */
- protected boolean avoidCastExpressionByHeuristics() throws EndOfFileException {
- if (LT(1) == IToken.tIDENTIFIER) {
- if (LT(2) == IToken.tRPAREN) {
- switch (LT(3)) {
- case IToken.tPLUS:
- case IToken.tMINUS:
- case IToken.tAMPER:
- case IToken.tSTAR:
- return true;
- }
- }
+ protected boolean canBeCompoundLiteral() throws EndOfFileException {
+ IToken m= mark();
+ try {
+ // The parenthesis cannot be followed by a binary operator
+ skipBrackets(IToken.tLPAREN, IToken.tRPAREN, IToken.tSEMI);
+ return LTcatchEOF(1) == IToken.tLBRACE;
+ } catch (BacktrackException bt) {
+ return false;
+ } finally {
+ backup(m);
+ }
+ }
+
+ protected boolean canBeCastExpression() throws EndOfFileException {
+ IToken m= mark();
+ try {
+ // The parenthesis cannot be followed by a binary operator
+ skipBrackets(IToken.tLPAREN, IToken.tRPAREN, IToken.tSEMI);
+ switch (LTcatchEOF(1)) {
+ case IToken.tAMPERASSIGN:
+ case IToken.tAND:
+ case IToken.tARROW:
+ case IToken.tARROWSTAR:
+ case IToken.tASSIGN:
+ case IToken.tBITOR:
+ case IToken.tBITORASSIGN:
+ case IToken.tCOLON:
+ case IToken.tCOMMA:
+ case IToken.tDIV:
+ case IToken.tDIVASSIGN:
+ case IToken.tDOT:
+ case IToken.tDOTSTAR:
+ case IToken.tEQUAL:
+ case IToken.tGT:
+ case IToken.tGT_in_SHIFTR:
+ case IToken.tGTEQUAL:
+ case IToken.tLBRACKET:
+ case IToken.tLTEQUAL:
+ case IToken.tMINUSASSIGN:
+ case IToken.tMOD:
+ case IToken.tMODASSIGN:
+ case IToken.tNOTEQUAL:
+ case IToken.tOR:
+ case IToken.tPLUSASSIGN:
+ case IToken.tQUESTION:
+ case IToken.tRBRACE:
+ case IToken.tRBRACKET:
+ case IToken.tRPAREN:
+ case IToken.tSEMI:
+ case IToken.tSHIFTL:
+ case IToken.tSHIFTLASSIGN:
+ case IToken.tSHIFTR:
+ case IToken.tSHIFTRASSIGN:
+ case IToken.tSTARASSIGN:
+ return false;
+ }
+ return true;
+ } catch (BacktrackException bt) {
+ return false;
+ } finally {
+ backup(m);
}
- return false;
}
protected boolean canBeTypeSpecifier() throws EndOfFileException {
@@ -2511,12 +2570,12 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
}
}
- protected void skipBrackets(int left, int right) throws EndOfFileException, BacktrackException {
+ protected void skipBrackets(int left, int right, int terminator) throws EndOfFileException, BacktrackException {
consume(left);
int nesting= 0;
while(true) {
final int lt1= LT(1);
- if (lt1 == IToken.tEOC)
+ if (lt1 == IToken.tEOC || lt1 == terminator)
throwBacktrack(LA(1));
consume();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java
index 93a7c5213db..b48d03820b7 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java
@@ -29,16 +29,17 @@ public class DeclarationOptions {
final public static int ALLOW_FOLLOWED_BY_BRACE= 0x1000;
final public static int ALLOW_OPAQUE_ENUM= 0x2000;
final public static int SINGLE_DTOR= 0x4000;
+ final public static int ALLOW_FUNCTION_DEFINITION= 0x8000;
public static final DeclarationOptions
- GLOBAL= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | ALLOW_OPAQUE_ENUM),
- FUNCTION_STYLE_ASM= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | NO_INITIALIZER | ALLOW_ABSTRACT),
+ GLOBAL= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | ALLOW_OPAQUE_ENUM | ALLOW_FUNCTION_DEFINITION),
+ FUNCTION_STYLE_ASM= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | NO_INITIALIZER | ALLOW_ABSTRACT | ALLOW_FUNCTION_DEFINITION),
C_MEMBER= new DeclarationOptions(ALLOW_BITFIELD | ALLOW_ABSTRACT),
- CPP_MEMBER= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | ALLOW_BITFIELD | NO_CTOR_STYLE_INITIALIZER),
+ CPP_MEMBER= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | ALLOW_BITFIELD | NO_CTOR_STYLE_INITIALIZER | ALLOW_FUNCTION_DEFINITION),
LOCAL= new DeclarationOptions(ALLOW_OPAQUE_ENUM),
PARAMETER= new DeclarationOptions(ALLOW_ABSTRACT | ALLOW_PARAMETER_PACKS | REQUIRE_SIMPLE_NAME | NO_BRACED_INITIALIZER | NO_CTOR_STYLE_INITIALIZER),
TYPEID= new DeclarationOptions(REQUIRE_ABSTRACT | NO_INITIALIZER),
- TYPEID_TRAILING_RETURN_TYPE= new DeclarationOptions(REQUIRE_ABSTRACT | NO_INITIALIZER | ALLOW_FOLLOWED_BY_BRACE),
+ TYPEID_TRAILING_RETURN_TYPE= new DeclarationOptions(REQUIRE_ABSTRACT | NO_INITIALIZER | ALLOW_FOLLOWED_BY_BRACE | ALLOW_FUNCTION_DEFINITION),
TYPEID_NEW= new DeclarationOptions(REQUIRE_ABSTRACT | NO_INITIALIZER | NO_FUNCTIONS | NO_NESTED | ALLOW_FOLLOWED_BY_BRACE),
TYPEID_CONVERSION= new DeclarationOptions(REQUIRE_ABSTRACT | NO_INITIALIZER | NO_FUNCTIONS | NO_NESTED),
EXCEPTION= new DeclarationOptions(ALLOW_ABSTRACT | NO_INITIALIZER),
@@ -60,6 +61,7 @@ public class DeclarationOptions {
final public boolean fRequireSimpleName;
final public boolean fAllowOpaqueEnum;
final public boolean fSingleDtor;
+ final public boolean fAllowFunctionDefinition;
public DeclarationOptions(int options) {
fAllowEmptySpecifier= (options & ALLOW_EMPTY_SPECIFIER) != 0;
@@ -76,5 +78,6 @@ public class DeclarationOptions {
fCanBeFollowedByBrace= fAllowBracedInitializer || (options & ALLOW_FOLLOWED_BY_BRACE) != 0;
fAllowOpaqueEnum= (options & ALLOW_OPAQUE_ENUM) != 0;
fSingleDtor= (options & SINGLE_DTOR) != 0;
+ fAllowFunctionDefinition= (options & ALLOW_FUNCTION_DEFINITION) != 0;
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
index cb269070476..fc43de3fe4d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
@@ -1754,7 +1754,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
final IToken current = LA(1);
int startingOffset = current.getOffset();
if (current.getType() == IToken.tLBRACKET && supportParameterInfoBlock) {
- skipBrackets(IToken.tLBRACKET, IToken.tRBRACKET);
+ skipBrackets(IToken.tLBRACKET, IToken.tRBRACKET, 0);
}
IASTDeclSpecifier declSpec = null;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReferenceOperator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReferenceOperator.java
index 3820b979e29..395d54479af 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReferenceOperator.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReferenceOperator.java
@@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * John Camelon (IBM) - Initial API and implementation
- * Markus Schorn (Wind River Systems)
+ * John Camelon (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@@ -19,21 +19,23 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
* Reference operator for declarators.
*/
public class CPPASTReferenceOperator extends ASTNode implements ICPPASTReferenceOperator {
-
private final boolean fIsRValue;
public CPPASTReferenceOperator(boolean isRValueReference) {
fIsRValue= isRValueReference;
}
+ @Override
public boolean isRValueReference() {
return fIsRValue;
}
+ @Override
public CPPASTReferenceOperator copy() {
return copy(CopyStyle.withoutLocations);
}
+ @Override
public CPPASTReferenceOperator copy(CopyStyle style) {
CPPASTReferenceOperator copy = new CPPASTReferenceOperator(fIsRValue);
copy.setOffsetAndLength(this);
@@ -47,8 +49,8 @@ public class CPPASTReferenceOperator extends ASTNode implements ICPPASTReference
public boolean accept(ASTVisitor action) {
if (action.shouldVisitPointerOperators) {
switch (action.visit(this)) {
- case ASTVisitor.PROCESS_ABORT : return false;
- case ASTVisitor.PROCESS_SKIP : return true;
+ case ASTVisitor.PROCESS_ABORT: return false;
+ case ASTVisitor.PROCESS_SKIP: return true;
}
if (action.leave(this) == ASTVisitor.PROCESS_ABORT)
return false;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java
index 7240c76ce5e..29f4703398b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java
@@ -25,6 +25,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
+import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
@@ -40,6 +41,7 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
super(name);
}
+ @Override
public IASTExpression getDefault() {
IASTInitializerClause def= getDefaultClause();
if (def instanceof IASTExpression) {
@@ -59,7 +61,7 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
IASTNode parent = name.getParent();
assert parent instanceof IASTDeclarator;
if (parent instanceof IASTDeclarator) {
- IASTDeclarator dtor = (IASTDeclarator) parent;
+ IASTDeclarator dtor = ASTQueries.findOutermostDeclarator((IASTDeclarator) parent);
IASTInitializer initializer = dtor.getInitializer();
if (initializer instanceof IASTEqualsInitializer) {
return ((IASTEqualsInitializer) initializer).getInitializerClause();
@@ -70,6 +72,7 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
return null;
}
+ @Override
public ICPPTemplateArgument getDefaultValue() {
IASTInitializerClause dc= getDefault();
IASTExpression d= null;
@@ -96,6 +99,7 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
return new CPPTemplateArgument(val, t);
}
+ @Override
public IType getType() {
if (type == null) {
IASTNode parent= getPrimaryDeclaration().getParent();
@@ -110,28 +114,36 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
return type;
}
+ @Override
public boolean isParameterPack() {
return getType() instanceof ICPPParameterPackType;
}
+ @Override
public boolean isStatic() {
return false;
}
+ @Override
public boolean isExtern() {
return false;
}
+ @Override
public boolean isAuto() {
return false;
}
+ @Override
public boolean isRegister() {
return false;
}
+ @Override
public IValue getInitialValue() {
return null;
}
+ @Override
public boolean isExternC() {
return false;
}
+ @Override
public boolean isMutable() {
return false;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
index 46bbf254f39..5587d4346f3 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
@@ -209,11 +209,15 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
}
private IASTName qualifiedName() throws BacktrackException, EndOfFileException {
+ return ambiguousQualifiedName(CastExprCtx.eNotInBExpr);
+ }
+
+ private IASTName ambiguousQualifiedName(CastExprCtx ctx) throws BacktrackException, EndOfFileException {
TemplateIdStrategy strat= new TemplateIdStrategy();
IToken m= mark();
for(;;) {
try {
- return qualifiedName(strat, CastExprCtx.eNotInBExpr);
+ return qualifiedName(ctx, strat);
} catch (BacktrackException e) {
if (strat.setNextAlternative()) {
backup(m);
@@ -223,12 +227,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
}
}
}
-
+
/**
* Parses a qualified name.
*/
- private IASTName qualifiedName(ITemplateIdStrategy s, CastExprCtx ctx) throws BacktrackException, EndOfFileException {
- final TemplateIdStrategy strat= (TemplateIdStrategy) s;
+ private IASTName qualifiedName(CastExprCtx ctx, ITemplateIdStrategy strat) throws BacktrackException, EndOfFileException {
+ if (strat == null)
+ return ambiguousQualifiedName(ctx);
+
ICPPASTQualifiedName qname= null;
IASTName name= null;
final int offset= LA(1).getOffset();
@@ -288,11 +294,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (haveArgs == -1) {
templateID= false;
} else if (haveArgs == 0) {
- if (strat.ignoreTemplateID()) {
- templateID= false;
- } else {
- strat.addTemplateName(name);
- }
+ templateID= strat.shallParseAsTemplateID(name);
}
}
if (templateID) {
@@ -350,7 +352,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
return name;
}
- private IASTName addTemplateArguments(IASTName templateName, TemplateIdStrategy strat) throws EndOfFileException, BacktrackException {
+ private IASTName addTemplateArguments(IASTName templateName, ITemplateIdStrategy strat) throws EndOfFileException, BacktrackException {
// Parse for template arguments
consume(IToken.tLT);
List