mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
fix 71331
This commit is contained in:
parent
9df1ac81b8
commit
0bbf50fc98
3 changed files with 26 additions and 20 deletions
|
@ -172,24 +172,6 @@ public class FailedCompleteParseASTTest extends CompleteParseBaseTest
|
|||
// assertFalse(j.hasNext());
|
||||
}
|
||||
|
||||
public void testThisInTemplatedMemberFunction_bug71331() throws Exception {
|
||||
// dereferencing 'this' in a templated member function
|
||||
try {
|
||||
parse("class A { \n int f() {return 0;} \n template<typename T> int g(T*) { return this->f(); } \n }; \n");//$NON-NLS-1$
|
||||
fail();
|
||||
} catch (ParserException e) {
|
||||
assertTrue( e.getMessage().equals( "FAILURE" ) ); //$NON-NLS-1$
|
||||
}
|
||||
// Iterator i = parse("class A { \n int f() {return 0;} \n template<typename T> int g(T*) { return this->f(); } \n }; \n").getDeclarations();//$NON-NLS-1$
|
||||
// IASTAbstractTypeSpecifierDeclaration cd = (IASTAbstractTypeSpecifierDeclaration) i.next();
|
||||
// assertFalse(i.hasNext());
|
||||
// IASTClassSpecifier cs = (IASTClassSpecifier) cd.getTypeSpecifier();
|
||||
// Iterator j = cs.getDeclarations();
|
||||
// IASTMethod md = (IASTMethod) j.next();
|
||||
// IASTTemplateDeclaration tmd = (IASTTemplateDeclaration) j.next();
|
||||
// assertFalse(j.hasNext());
|
||||
}
|
||||
|
||||
public void testParametrizedTypeDefinition_bug69751() throws Exception {
|
||||
try {
|
||||
// a typedef refers to an unknown type in a template parameter
|
||||
|
|
|
@ -1057,4 +1057,15 @@ public class CompleteParseASTTemplateTest extends CompleteParseBaseTest {
|
|||
IASTMethod m = (IASTMethod) j.next();
|
||||
assertFalse(j.hasNext());
|
||||
}
|
||||
|
||||
public void testThisInTemplatedMemberFunction_bug71331() throws Exception {
|
||||
Iterator i = parse("class A { \n int f() {return 0;} \n template<typename T> int g(T*) { return this->f(); } \n }; \n").getDeclarations();//$NON-NLS-1$
|
||||
IASTAbstractTypeSpecifierDeclaration cd = (IASTAbstractTypeSpecifierDeclaration) i.next();
|
||||
assertFalse(i.hasNext());
|
||||
IASTClassSpecifier cs = (IASTClassSpecifier) cd.getTypeSpecifier();
|
||||
Iterator j = cs.getDeclarations();
|
||||
IASTMethod md = (IASTMethod) j.next();
|
||||
IASTTemplateDeclaration tmd = (IASTTemplateDeclaration) j.next();
|
||||
assertFalse(j.hasNext());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -272,13 +272,27 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
|||
return false;
|
||||
}
|
||||
|
||||
if( obj instanceof ITemplateSymbol ){
|
||||
ISymbol templated = ((ITemplateSymbol)obj).getTemplatedSymbol();
|
||||
if( templated instanceof IParameterizedSymbol ){
|
||||
obj = (IParameterizedSymbol) templated;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
IContainerSymbol containing = obj.getContainingSymbol();
|
||||
if( containing instanceof ITemplateSymbol ){
|
||||
containing = containing.getContainingSymbol();
|
||||
}
|
||||
|
||||
ITypeInfo type = obj.getTypeInfo();
|
||||
if( ( !type.isType( ITypeInfo.t_function ) && !type.isType( ITypeInfo.t_constructor) ) ||
|
||||
type.checkBit( ITypeInfo.isStatic ) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
if( obj.getContainingSymbol().isType( ITypeInfo.t_class, ITypeInfo.t_union ) ){
|
||||
if( containing.isType( ITypeInfo.t_class, ITypeInfo.t_union ) ){
|
||||
//check to see if there is already a this object, since using declarations
|
||||
//of function will have them from the original declaration
|
||||
boolean foundThis = false;
|
||||
|
@ -296,7 +310,6 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
|||
if( !foundThis ){
|
||||
ISymbol thisObj = getSymbolTable().newSymbol( ParserSymbolTable.THIS, ITypeInfo.t_type );
|
||||
thisObj.setTypeSymbol( obj.getContainingSymbol() );
|
||||
//thisObj.setCVQualifier( obj.getCVQualifier() );
|
||||
ITypeInfo.PtrOp ptr = new ITypeInfo.PtrOp();
|
||||
ptr.setType( ITypeInfo.PtrOp.t_pointer );
|
||||
thisObj.getTypeInfo().setBit( obj.getTypeInfo().checkBit( ITypeInfo.isConst ), ITypeInfo.isConst );
|
||||
|
|
Loading…
Add table
Reference in a new issue