mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 294730: Extern templates.
This commit is contained in:
parent
c6176c6b67
commit
648f5c9331
10 changed files with 136 additions and 116 deletions
|
@ -44,6 +44,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||||
|
@ -4777,4 +4778,13 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
f= bh.assertNonProblem("f<int,char>();", -3);
|
f= bh.assertNonProblem("f<int,char>();", -3);
|
||||||
assertEquals("<int,char>", ASTTypeUtil.getArgumentListString(f.getTemplateArguments(), true));
|
assertEquals("<int,char>", ASTTypeUtil.getArgumentListString(f.getTemplateArguments(), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template<typename T> class CT {};
|
||||||
|
// extern template class CT<int>;
|
||||||
|
public void testExternTemplates_294730() throws Exception {
|
||||||
|
final String code= getAboveComment();
|
||||||
|
IASTTranslationUnit tu= parseAndCheckBindings(code, ParserLanguage.CPP);
|
||||||
|
ICPPASTExplicitTemplateInstantiation ti= getDeclaration(tu, 1);
|
||||||
|
assertEquals(ICPPASTExplicitTemplateInstantiation.EXTERN, ti.getModifier());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* John Camelon (IBM) - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
|
@ -14,13 +15,29 @@ import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface represents an explict template instantiation.
|
* This interface represents an explicit template instantiation.
|
||||||
*
|
*
|
||||||
* @noextend This interface is not intended to be extended by clients.
|
* @noextend This interface is not intended to be extended by clients.
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface ICPPASTExplicitTemplateInstantiation extends IASTDeclaration {
|
public interface ICPPASTExplicitTemplateInstantiation extends IASTDeclaration {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gnu extension.
|
||||||
|
* @since 5.2
|
||||||
|
*/
|
||||||
|
public static final int STATIC = 1;
|
||||||
|
/**
|
||||||
|
* Gnu extension.
|
||||||
|
* @since 5.2
|
||||||
|
*/
|
||||||
|
public static final int INLINE = 2;
|
||||||
|
/**
|
||||||
|
* C++0x.
|
||||||
|
* @since 5.2
|
||||||
|
*/
|
||||||
|
public static final int EXTERN = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>OWNED_DECLARATION</code> represents the role of the inner
|
* <code>OWNED_DECLARATION</code> represents the role of the inner
|
||||||
* declaration that this template refers to.
|
* declaration that this template refers to.
|
||||||
|
@ -47,4 +64,16 @@ public interface ICPPASTExplicitTemplateInstantiation extends IASTDeclaration {
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
public ICPPASTExplicitTemplateInstantiation copy();
|
public ICPPASTExplicitTemplateInstantiation copy();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns {@link #STATIC}, {@link #INLINE}, {@link #EXTERN}, or <code>0</code>.
|
||||||
|
* @since 5.2
|
||||||
|
*/
|
||||||
|
public int getModifier();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the modifier value, not allowed on frozen ast.
|
||||||
|
* @since 5.2
|
||||||
|
*/
|
||||||
|
public void setModifier(int value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.INodeFactory;
|
import org.eclipse.cdt.core.dom.ast.INodeFactory;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
|
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
|
@ -144,8 +143,6 @@ public interface ICPPNodeFactory extends INodeFactory {
|
||||||
|
|
||||||
public ICPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiation(IASTDeclaration declaration);
|
public ICPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiation(IASTDeclaration declaration);
|
||||||
|
|
||||||
public IGPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiationGPP(IASTDeclaration declaration);
|
|
||||||
|
|
||||||
public ICPPASTTemplateSpecialization newTemplateSpecialization(IASTDeclaration declaration);
|
public ICPPASTTemplateSpecialization newTemplateSpecialization(IASTDeclaration declaration);
|
||||||
|
|
||||||
public ICPPASTTryBlockStatement newTryBlockStatement(IASTStatement body);
|
public ICPPASTTryBlockStatement newTryBlockStatement(IASTStatement body);
|
||||||
|
@ -227,4 +224,12 @@ public interface ICPPNodeFactory extends INodeFactory {
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP();
|
public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Replaced by {@link #newExplicitTemplateInstantiation(IASTDeclaration)}.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiationGPP(IASTDeclaration declaration);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -14,42 +14,29 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* G++ allows for instantiations to be qualified w/modifiers for scoping.
|
* G++ allows for instantiations to be qualified w/modifiers for scoping.
|
||||||
|
* @deprecated Replaced by {@link ICPPASTExplicitTemplateInstantiation}
|
||||||
*
|
*
|
||||||
* @noextend This interface is not intended to be extended by clients.
|
* @noextend This interface is not intended to be extended by clients.
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public interface IGPPASTExplicitTemplateInstantiation extends
|
public interface IGPPASTExplicitTemplateInstantiation extends
|
||||||
ICPPASTExplicitTemplateInstantiation {
|
ICPPASTExplicitTemplateInstantiation {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>ti_static</code> implies 'static' keyword is used.
|
* <code>ti_static</code> implies 'static' keyword is used.
|
||||||
*/
|
*/
|
||||||
public static final int ti_static = 1;
|
public static final int ti_static = ICPPASTExplicitTemplateInstantiation.STATIC;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>ti_inline</code> implies 'inline' keyword is used.
|
* <code>ti_inline</code> implies 'inline' keyword is used.
|
||||||
*/
|
*/
|
||||||
public static final int ti_inline = 2;
|
public static final int ti_inline = ICPPASTExplicitTemplateInstantiation.INLINE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>ti_extern</code> implies 'extern' keyword is used.
|
* <code>ti_extern</code> implies 'extern' keyword is used.
|
||||||
*/
|
*/
|
||||||
public static final int ti_extern = 3;
|
public static final int ti_extern = ICPPASTExplicitTemplateInstantiation.EXTERN;
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the modifier.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public int getModifier();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the modifier value.
|
|
||||||
*
|
|
||||||
* @param value
|
|
||||||
* (int)
|
|
||||||
*/
|
|
||||||
public void setModifier(int value);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -18,12 +19,13 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* Models explicit instantiations.
|
||||||
*/
|
*/
|
||||||
public class CPPASTExplicitTemplateInstantiation extends ASTNode implements
|
public class CPPASTExplicitTemplateInstantiation extends ASTNode implements
|
||||||
ICPPASTExplicitTemplateInstantiation, IASTAmbiguityParent {
|
ICPPASTExplicitTemplateInstantiation, IASTAmbiguityParent {
|
||||||
|
|
||||||
private IASTDeclaration declaration;
|
private IASTDeclaration declaration;
|
||||||
|
private int modifier;
|
||||||
|
|
||||||
|
|
||||||
public CPPASTExplicitTemplateInstantiation() {
|
public CPPASTExplicitTemplateInstantiation() {
|
||||||
|
@ -36,6 +38,7 @@ public class CPPASTExplicitTemplateInstantiation extends ASTNode implements
|
||||||
public CPPASTExplicitTemplateInstantiation copy() {
|
public CPPASTExplicitTemplateInstantiation copy() {
|
||||||
CPPASTExplicitTemplateInstantiation copy = new CPPASTExplicitTemplateInstantiation();
|
CPPASTExplicitTemplateInstantiation copy = new CPPASTExplicitTemplateInstantiation();
|
||||||
copy.setDeclaration(declaration == null ? null : declaration.copy());
|
copy.setDeclaration(declaration == null ? null : declaration.copy());
|
||||||
|
copy.setModifier(modifier);
|
||||||
copy.setOffsetAndLength(this);
|
copy.setOffsetAndLength(this);
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
@ -53,6 +56,16 @@ public class CPPASTExplicitTemplateInstantiation extends ASTNode implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getModifier() {
|
||||||
|
return modifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModifier(int mod) {
|
||||||
|
assertNotFrozen();
|
||||||
|
modifier= mod;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept( ASTVisitor action ){
|
||||||
if( action.shouldVisitDeclarations ){
|
if( action.shouldVisitDeclarations ){
|
||||||
|
|
|
@ -104,7 +104,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTWhileStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNodeFactory;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNodeFactory;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
|
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
|
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
|
@ -399,10 +398,6 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
||||||
return new CPPASTExplicitTemplateInstantiation(declaration);
|
return new CPPASTExplicitTemplateInstantiation(declaration);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IGPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiationGPP(IASTDeclaration declaration) {
|
|
||||||
return new GPPASTExplicitTemplateInstantiation(declaration);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICPPASTTemplateSpecialization newTemplateSpecialization(IASTDeclaration declaration) {
|
public ICPPASTTemplateSpecialization newTemplateSpecialization(IASTDeclaration declaration) {
|
||||||
return new CPPASTTemplateSpecialization(declaration);
|
return new CPPASTTemplateSpecialization(declaration);
|
||||||
}
|
}
|
||||||
|
@ -529,4 +524,14 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
||||||
public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP() {
|
public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP() {
|
||||||
return new GPPASTSimpleDeclSpecifier();
|
return new GPPASTSimpleDeclSpecifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Replaced by {@link #newExplicitTemplateInstantiation(IASTDeclaration)}.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiationGPP(IASTDeclaration declaration) {
|
||||||
|
return new GPPASTExplicitTemplateInstantiation(declaration);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNodeFactory;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNodeFactory;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTTypeIdExpression;
|
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTTypeIdExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
|
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
|
||||||
import org.eclipse.cdt.core.dom.parser.IExtensionToken;
|
import org.eclipse.cdt.core.dom.parser.IExtensionToken;
|
||||||
|
@ -1587,63 +1586,50 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* request for a backtrack
|
* request for a backtrack
|
||||||
*/
|
*/
|
||||||
protected IASTDeclaration templateDeclaration(DeclarationOptions option) throws EndOfFileException, BacktrackException {
|
protected IASTDeclaration templateDeclaration(DeclarationOptions option) throws EndOfFileException, BacktrackException {
|
||||||
IToken firstToken = null;
|
final int offset= LA(1).getOffset();
|
||||||
boolean exported = false;
|
boolean exported = false;
|
||||||
boolean encounteredExtraMod = false;
|
int explicitInstMod= 0;
|
||||||
if (LT(1) == IToken.t_export) {
|
switch(LT(1)) {
|
||||||
|
case IToken.t_export:
|
||||||
exported = true;
|
exported = true;
|
||||||
firstToken = consume();
|
consume();
|
||||||
consume(IToken.t_template);
|
break;
|
||||||
} else {
|
|
||||||
if (supportExtendedTemplateSyntax) {
|
|
||||||
switch (LT(1)) {
|
|
||||||
case IToken.t_static:
|
|
||||||
case IToken.t_extern:
|
case IToken.t_extern:
|
||||||
|
consume();
|
||||||
|
explicitInstMod= ICPPASTExplicitTemplateInstantiation.EXTERN;
|
||||||
|
break;
|
||||||
|
case IToken.t_static:
|
||||||
|
consume();
|
||||||
|
explicitInstMod= ICPPASTExplicitTemplateInstantiation.STATIC;
|
||||||
|
break;
|
||||||
case IToken.t_inline:
|
case IToken.t_inline:
|
||||||
firstToken = consume();
|
consume();
|
||||||
|
explicitInstMod= ICPPASTExplicitTemplateInstantiation.INLINE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
consume(IToken.t_template);
|
consume(IToken.t_template);
|
||||||
encounteredExtraMod = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
firstToken = consume(IToken.t_template);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
firstToken = consume(IToken.t_template);
|
|
||||||
}
|
|
||||||
if (LT(1) != IToken.tLT) {
|
if (LT(1) != IToken.tLT) {
|
||||||
// explicit-instantiation
|
// explicit-instantiation
|
||||||
ICPPASTExplicitTemplateInstantiation templateInstantiation = null;
|
|
||||||
if (encounteredExtraMod && supportExtendedTemplateSyntax) {
|
|
||||||
IGPPASTExplicitTemplateInstantiation temp = nodeFactory.newExplicitTemplateInstantiationGPP(null);
|
|
||||||
switch (firstToken.getType()) {
|
|
||||||
case IToken.t_static:
|
|
||||||
temp.setModifier(IGPPASTExplicitTemplateInstantiation.ti_static);
|
|
||||||
break;
|
|
||||||
case IToken.t_extern:
|
|
||||||
temp.setModifier(IGPPASTExplicitTemplateInstantiation.ti_extern);
|
|
||||||
break;
|
|
||||||
case IToken.t_inline:
|
|
||||||
temp.setModifier(IGPPASTExplicitTemplateInstantiation.ti_inline);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
templateInstantiation = temp;
|
|
||||||
} else {
|
|
||||||
templateInstantiation = nodeFactory.newExplicitTemplateInstantiation(null);
|
|
||||||
}
|
|
||||||
IASTDeclaration d = declaration(option);
|
IASTDeclaration d = declaration(option);
|
||||||
((ASTNode) templateInstantiation).setOffsetAndLength(firstToken
|
ICPPASTExplicitTemplateInstantiation ti= nodeFactory.newExplicitTemplateInstantiation(d);
|
||||||
.getOffset(), calculateEndOffset(d) - firstToken.getOffset());
|
ti.setModifier(explicitInstMod);
|
||||||
templateInstantiation.setDeclaration(d);
|
setRange(ti, offset, calculateEndOffset(d));
|
||||||
return templateInstantiation;
|
return ti;
|
||||||
}
|
}
|
||||||
consume(); // check for LT made before
|
|
||||||
|
// Modifiers for explicit instantiations
|
||||||
|
if (explicitInstMod != 0) {
|
||||||
|
throwBacktrack(LA(1));
|
||||||
|
}
|
||||||
|
consume(IToken.tLT);
|
||||||
if (LT(1) == IToken.tGT) {
|
if (LT(1) == IToken.tGT) {
|
||||||
// explicit-specialization
|
// explicit-specialization
|
||||||
consume();
|
consume();
|
||||||
IASTDeclaration d = declaration(option);
|
IASTDeclaration d = declaration(option);
|
||||||
ICPPASTTemplateSpecialization templateSpecialization = nodeFactory.newTemplateSpecialization(d);
|
ICPPASTTemplateSpecialization templateSpecialization = nodeFactory.newTemplateSpecialization(d);
|
||||||
((ASTNode) templateSpecialization).setOffsetAndLength(firstToken.getOffset(), calculateEndOffset(d) - firstToken.getOffset());
|
setRange(templateSpecialization, offset, calculateEndOffset(d));
|
||||||
return templateSpecialization;
|
return templateSpecialization;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1651,7 +1637,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
consume(IToken.tGT, IToken.tGT_in_SHIFTR);
|
consume(IToken.tGT, IToken.tGT_in_SHIFTR);
|
||||||
IASTDeclaration d = declaration(option);
|
IASTDeclaration d = declaration(option);
|
||||||
ICPPASTTemplateDeclaration templateDecl = nodeFactory.newTemplateDeclaration(d);
|
ICPPASTTemplateDeclaration templateDecl = nodeFactory.newTemplateDeclaration(d);
|
||||||
((ASTNode) templateDecl).setOffsetAndLength(firstToken.getOffset(), calculateEndOffset(d) - firstToken.getOffset());
|
setRange(templateDecl, offset, calculateEndOffset(d));
|
||||||
templateDecl.setExported(exported);
|
templateDecl.setExported(exported);
|
||||||
for (int i = 0; i < parms.size(); ++i) {
|
for (int i = 0; i < parms.size(); ++i) {
|
||||||
ICPPASTTemplateParameter parm = parms.get(i);
|
ICPPASTTemplateParameter parm = parms.get(i);
|
||||||
|
@ -1806,7 +1792,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
case IToken.t_extern:
|
case IToken.t_extern:
|
||||||
if (LT(2) == IToken.tSTRING)
|
if (LT(2) == IToken.tSTRING)
|
||||||
return linkageSpecification();
|
return linkageSpecification();
|
||||||
if (supportExtendedTemplateSyntax && LT(2) == IToken.t_template)
|
if (LT(2) == IToken.t_template)
|
||||||
return templateDeclaration(option);
|
return templateDeclaration(option);
|
||||||
break;
|
break;
|
||||||
case IToken.t_static:
|
case IToken.t_static:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -14,8 +14,9 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation;
|
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @deprecated Replaced by {@link CPPASTExplicitTemplateInstantiation}.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public class GPPASTExplicitTemplateInstantiation extends
|
public class GPPASTExplicitTemplateInstantiation extends
|
||||||
CPPASTExplicitTemplateInstantiation implements
|
CPPASTExplicitTemplateInstantiation implements
|
||||||
IGPPASTExplicitTemplateInstantiation {
|
IGPPASTExplicitTemplateInstantiation {
|
||||||
|
@ -28,25 +29,13 @@ public class GPPASTExplicitTemplateInstantiation extends
|
||||||
super(declaration);
|
super(declaration);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int mod;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GPPASTExplicitTemplateInstantiation copy() {
|
public GPPASTExplicitTemplateInstantiation copy() {
|
||||||
GPPASTExplicitTemplateInstantiation copy = new GPPASTExplicitTemplateInstantiation();
|
GPPASTExplicitTemplateInstantiation copy = new GPPASTExplicitTemplateInstantiation();
|
||||||
IASTDeclaration declaration = getDeclaration();
|
IASTDeclaration declaration = getDeclaration();
|
||||||
copy.setDeclaration(declaration == null ? null : declaration.copy());
|
copy.setDeclaration(declaration == null ? null : declaration.copy());
|
||||||
copy.mod = mod;
|
copy.setModifier(getModifier());
|
||||||
copy.setOffsetAndLength(this);
|
copy.setOffsetAndLength(this);
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getModifier() {
|
|
||||||
return mod;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setModifier(int value) {
|
|
||||||
this.mod = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik
|
* Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik
|
||||||
* Rapperswil, University of applied sciences and others
|
* Rapperswil, University of applied sciences and others
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
@ -35,7 +35,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation;
|
|
||||||
import org.eclipse.cdt.core.parser.Keywords;
|
import org.eclipse.cdt.core.parser.Keywords;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
||||||
|
@ -236,20 +235,17 @@ public class DeclarationWriter extends NodeWriter{
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeExplicitTemplateInstantiation(ICPPASTExplicitTemplateInstantiation explicitTemplateInstantiation) {
|
private void writeExplicitTemplateInstantiation(ICPPASTExplicitTemplateInstantiation explicitTemplateInstantiation) {
|
||||||
if (explicitTemplateInstantiation instanceof IGPPASTExplicitTemplateInstantiation) {
|
switch(explicitTemplateInstantiation.getModifier()){
|
||||||
IGPPASTExplicitTemplateInstantiation gppExplicitTemplateInstantiation = (IGPPASTExplicitTemplateInstantiation) explicitTemplateInstantiation;
|
case ICPPASTExplicitTemplateInstantiation.EXTERN:
|
||||||
switch(gppExplicitTemplateInstantiation.getModifier()){
|
|
||||||
case IGPPASTExplicitTemplateInstantiation.ti_extern:
|
|
||||||
scribe.print(EXTERN);
|
scribe.print(EXTERN);
|
||||||
break;
|
break;
|
||||||
case IGPPASTExplicitTemplateInstantiation.ti_inline:
|
case ICPPASTExplicitTemplateInstantiation.INLINE:
|
||||||
scribe.print(INLINE);
|
scribe.print(INLINE);
|
||||||
break;
|
break;
|
||||||
case IGPPASTExplicitTemplateInstantiation.ti_static:
|
case ICPPASTExplicitTemplateInstantiation.STATIC:
|
||||||
scribe.print(STATIC);
|
scribe.print(STATIC);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
scribe.print(TEMPLATE);
|
scribe.print(TEMPLATE);
|
||||||
explicitTemplateInstantiation.getDeclaration().accept(visitor);
|
explicitTemplateInstantiation.getDeclaration().accept(visitor);
|
||||||
|
|
|
@ -49,6 +49,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
|
||||||
|
@ -61,7 +62,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexName;
|
import org.eclipse.cdt.core.index.IIndexName;
|
||||||
|
@ -216,9 +216,9 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
|
||||||
IASTASMDeclaration asmDecl = (IASTASMDeclaration) node;
|
IASTASMDeclaration asmDecl = (IASTASMDeclaration) node;
|
||||||
|
|
||||||
return trailASMDecl.getAssembly().equals(asmDecl.getAssembly());
|
return trailASMDecl.getAssembly().equals(asmDecl.getAssembly());
|
||||||
} else if (trailNode instanceof IGPPASTExplicitTemplateInstantiation) {
|
} else if (trailNode instanceof ICPPASTExplicitTemplateInstantiation) {
|
||||||
IGPPASTExplicitTemplateInstantiation trailTempl = (IGPPASTExplicitTemplateInstantiation) trailNode;
|
ICPPASTExplicitTemplateInstantiation trailTempl = (ICPPASTExplicitTemplateInstantiation) trailNode;
|
||||||
IGPPASTExplicitTemplateInstantiation templ = (IGPPASTExplicitTemplateInstantiation) node;
|
ICPPASTExplicitTemplateInstantiation templ = (ICPPASTExplicitTemplateInstantiation) node;
|
||||||
|
|
||||||
return trailTempl.getModifier() == templ.getModifier();
|
return trailTempl.getModifier() == templ.getModifier();
|
||||||
} else if (trailNode instanceof ICPPASTLinkageSpecification) {
|
} else if (trailNode instanceof ICPPASTLinkageSpecification) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue