1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 14:15:23 +02:00

fix bug 99256 - allow anonymous structures

Patch from Devin Steffler for bug 99262 - __null builtin
This commit is contained in:
Andrew Niefer 2005-06-10 18:46:10 +00:00
parent 2162c8b56f
commit 60bb3058a1
4 changed files with 40 additions and 2 deletions

View file

@ -4739,4 +4739,21 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame( i, col.getName(2).resolveBinding() );
assertSame( j, col.getName(5).resolveBinding() );
}
public void testBug99262() throws Exception {
parse("void foo() {void *f; f=__null;}", ParserLanguage.CPP, true, true );
}
public void testBug99262B() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("int foo2(void *) {\n"); //$NON-NLS-1$
buffer.append("return 0;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("int foo3() {\n"); //$NON-NLS-1$
buffer.append("return foo2(__null);\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP, true, true );
assertTrue(((IASTIdExpression)((IASTFunctionCallExpression)((IASTReturnStatement)((IASTCompoundStatement)((IASTFunctionDefinition)tu.getDeclarations()[1]).getBody()).getStatements()[0]).getReturnValue()).getFunctionNameExpression()).getName().resolveBinding() instanceof IFunction);
}
}

View file

@ -3160,4 +3160,21 @@ public class AST2Tests extends AST2BaseTest {
IEnumerator etor = (IEnumerator) col.getName(2).resolveBinding();
assertSame( etor, col.getName(6).resolveBinding() );
}
public void testBug99262() throws Exception {
parse("void foo() {void *f; f=__null;}", ParserLanguage.C, true, true );
}
public void testBug99262B() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("int foo2(void *) {\n"); //$NON-NLS-1$
buffer.append("return 0;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("int foo3() {\n"); //$NON-NLS-1$
buffer.append("return foo2(__null);\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true, true );
assertTrue(((IASTIdExpression)((IASTFunctionCallExpression)((IASTReturnStatement)((IASTCompoundStatement)((IASTFunctionDefinition)tu.getDeclarations()[1]).getBody()).getStatements()[0]).getReturnValue()).getFunctionNameExpression()).getName().resolveBinding() instanceof IFunction);
}
}

View file

@ -1464,8 +1464,8 @@ public class CPPSemantics {
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) declSpec;
specName = compSpec.getName();
//anonymous union?
if( declarators.length == 0 && compSpec.getKey() == IASTCompositeTypeSpecifier.k_union &&
//anonymous union? //GCC supports anonymous structs too
if( declarators.length == 0 && /*compSpec.getKey() == IASTCompositeTypeSpecifier.k_union &&*/
specName.toCharArray().length == 0 )
{
Object o = null;

View file

@ -71,6 +71,9 @@ public abstract class GNUScannerExtensionConfiguration implements IScannerExtens
private static final ObjectStyleMacro __imag__ = new ObjectStyleMacro(
"__imag__".toCharArray(), "(int)".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
private static final ObjectStyleMacro __null = new ObjectStyleMacro(
"__null".toCharArray(), "(void *)0".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
private static final FunctionStyleMacro __attribute__ = new FunctionStyleMacro(
"__attribute__".toCharArray(), //$NON-NLS-1$
@ -109,6 +112,7 @@ public abstract class GNUScannerExtensionConfiguration implements IScannerExtens
realDefinitions.put(__signed__.name, __signed__);
realDefinitions.put(__complex__.name, __complex__);
realDefinitions.put(__imag__.name, __imag__);
realDefinitions.put( __null.name, __null );
realDefinitions.put(__real__.name, __real__);
realDefinitions.put(__builtin_va_arg.name, __builtin_va_arg);
realDefinitions.put(__builtin_constant_p.name, __builtin_constant_p);