1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Fix and test-case for 182464, NPE in name resolution for plain C.

This commit is contained in:
Markus Schorn 2007-05-09 08:35:53 +00:00
parent a678504f0b
commit 098117e25d
2 changed files with 13 additions and 3 deletions

View file

@ -153,7 +153,11 @@ public class AST2Tests extends AST2BaseTest {
} }
protected IASTTranslationUnit parseAndCheckBindings( String code, ParserLanguage lang ) throws Exception { protected IASTTranslationUnit parseAndCheckBindings( String code, ParserLanguage lang ) throws Exception {
IASTTranslationUnit tu = parse( code, lang ); return parseAndCheckBindings(code, lang, false);
}
protected IASTTranslationUnit parseAndCheckBindings( String code, ParserLanguage lang, boolean useGnuExtensions) throws Exception {
IASTTranslationUnit tu = parse( code, lang, useGnuExtensions );
CNameCollector col = new CNameCollector(); CNameCollector col = new CNameCollector();
tu.accept(col); tu.accept(col);
assertNoProblemBindings( col ); assertNoProblemBindings( col );
@ -3679,4 +3683,10 @@ public class AST2Tests extends AST2BaseTest {
} }
// int __builtin_sin;
public void testBug182464() throws Exception {
StringBuffer buffer = getContents(1)[0];
for (int i = 0; i < LANGUAGES.length; i++)
parseAndCheckBindings( buffer.toString(), LANGUAGES[i], true);
}
} }

View file

@ -151,8 +151,8 @@ public class CScope implements ICScope, IASTInternalScope {
bindings[type] = new CharArrayObjectMap(1); bindings[type] = new CharArrayObjectMap(1);
char [] n = name.toCharArray(); char [] n = name.toCharArray();
IASTName current = (IASTName) bindings[type].get( n ); Object current= bindings[type].get( n );
if( current == null || ((CASTName)current).getOffset() > ((CASTName) name).getOffset() ){ if( !(current instanceof IASTName) || ((CASTName)current).getOffset() > ((CASTName) name).getOffset() ){
bindings[type].put( n, name ); bindings[type].put( n, name );
} }
} }