From 415109ff2f2fe187da92036a895b69a410e3253b Mon Sep 17 00:00:00 2001 From: John Camelon Date: Tue, 12 Jul 2005 19:15:54 +0000 Subject: [PATCH] Fixed Bug Bug 78103 the parser doesn't like unamed structs Committed test case. --- .../cdt/core/parser/tests/ast2/AST2CPPTests.java | 14 ++++++++++++++ .../cdt/core/parser/tests/ast2/AST2Tests.java | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index 96a024c8d4e..280486d1ef5 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -102,6 +102,20 @@ import org.eclipse.cdt.internal.core.parser.ParserException; public class AST2CPPTests extends AST2BaseTest { + public void testBug78103() throws Exception { + StringBuffer buffer = new StringBuffer( "int *p1; int *p2;\n" ); //$NON-NLS-1$ + buffer.append( "union {\n" ); //$NON-NLS-1$ + buffer.append( "struct {int a; int b;} A;\n" ); //$NON-NLS-1$ + buffer.append( "struct {int a; int b;};\n" ); //$NON-NLS-1$ + buffer.append( "} MyStruct;\n" ); //$NON-NLS-1$ + buffer.append( "void test (void) {\n" ); //$NON-NLS-1$ + buffer.append( "p1 = &MyStruct.A.a;\n" ); //$NON-NLS-1$ + buffer.append( "p2 = &MyStruct.b;\n" ); //$NON-NLS-1$ + buffer.append( " MyStruct.b = 1;\n" ); //$NON-NLS-1$ + buffer.append( "}\n" ); //$NON-NLS-1$ + parseAndCheckBindings( buffer.toString() ); + } + public void testBug43579() throws Exception { parseAndCheckBindings("class A { int m; }; \n A * a; int A::*pm; \n int f(){} \n int f(int); \n int x = f(a->*pm);"); //$NON-NLS-1$ parseAndCheckBindings("class A { int m; }; \n A * a; int A::*pm; \n int f(){} \n int f(int); \n int x = f(a->*pm);"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java index ca054f6697d..f532736065a 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java @@ -89,6 +89,20 @@ import org.eclipse.cdt.internal.core.parser.ParserException; */ public class AST2Tests extends AST2BaseTest { + public void testBug78103() throws Exception { + StringBuffer buffer = new StringBuffer( "int *p1; int *p2;\n" ); //$NON-NLS-1$ + buffer.append( "union {\n" ); //$NON-NLS-1$ + buffer.append( "struct {int a; int b;} A;\n" ); //$NON-NLS-1$ + buffer.append( "struct {int a; int b;};\n" ); //$NON-NLS-1$ + buffer.append( "} MyStruct;\n" ); //$NON-NLS-1$ + buffer.append( "void test (void) {\n" ); //$NON-NLS-1$ + buffer.append( "p1 = &MyStruct.A.a;\n" ); //$NON-NLS-1$ + buffer.append( "p2 = &MyStruct.b;\n" ); //$NON-NLS-1$ + buffer.append( " MyStruct.b = 1;\n" ); //$NON-NLS-1$ + buffer.append( "}\n" ); //$NON-NLS-1$ + parseAndCheckBindings( buffer.toString() ); + } + public void testBug43241() throws Exception { parseAndCheckBindings( "int m(int); int (*pm)(int) = &m; int f(int); int x = f((*pm)(5));" ); //$NON-NLS-1$ }