1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

fix bug 69745

This commit is contained in:
Andrew Niefer 2004-07-12 20:59:31 +00:00
parent efc3b9c4ab
commit af4317e0a4
3 changed files with 26 additions and 2 deletions

View file

@ -115,4 +115,25 @@ public class CompleteParseProblemTest extends CompleteParseBaseTest {
IASTFunction f = (IASTFunction) i.next();
IASTVariable varI = (IASTVariable) i.next();
}
public void testBug69745() throws Exception
{
StringBuffer buffer = new StringBuffer();
buffer.append( "namespace NS{ template < class T > int foo(){}; } \n" ); //$NON-NLS-1$
buffer.append( "void f() { using NS::foo; using NS::foo<int>; } \n" ); //$NON-NLS-1$
String code = buffer.toString();
parse( code, false );
int start = code.indexOf( "using NS::foo<int>;" ); //$NON-NLS-1$
int end = start + "using NS::foo<int>;".length(); //$NON-NLS-1$
assertEquals( callback.problems.size(), 1 );
IProblem p = (IProblem) callback.problems.get( 0 );
assertEquals( p.getSourceStart(), start );
assertEquals( p.getSourceEnd(), end );
assertEquals( p.getID(), IProblem.SEMANTIC_INVALID_USING );
}
}

View file

@ -367,7 +367,10 @@ public abstract class Parser extends ExpressionParser implements IParser
catch (Exception e1)
{
logException( "usingClause:createUsingDeclaration", e1 ); //$NON-NLS-1$
throwBacktrack(firstToken.getOffset(), last.getEndOffset(), firstToken.getLineNumber());
if( e1 instanceof ASTSemanticException && ((ASTSemanticException)e1).getProblem() != null )
throwBacktrack(((ASTSemanticException)e1).getProblem());
else
throwBacktrack(firstToken.getOffset(), last.getEndOffset(), firstToken.getLineNumber());
}
declaration.acceptElement( requestor, astFactory.getReferenceManager() );
setCompletionValues(scope, getCompletionKindForDeclaration(scope, null), KeywordSetKey.DECLARATION );

View file

@ -1547,7 +1547,7 @@ public class ParserSymbolTable {
boolean okToAdd = false;
//7.3.3-5 A using-declaration shall not name a template-id
if( obj.isTemplateMember() && obj.getContainingSymbol().isType( ITypeInfo.t_template ) ){
if( obj.isTemplateInstance() && obj.getInstantiatedSymbol().getContainingSymbol().isType( ITypeInfo.t_template ) ){
okToAdd = false;
}
//7.3.3-4