1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-01 13:25:45 +02:00

Fix for 180815: defining multiple globals variables at structure definition causes dublicate struct tag entries in outline view

This commit is contained in:
Anton Leherbauer 2007-04-06 09:23:25 +00:00
parent dd4ecbc909
commit 0addd64850
4 changed files with 29 additions and 17 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2002, 2005 IBM Corporation and others.
* Copyright (c) 2002, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -131,6 +131,17 @@ public class CModelElementsTests extends TestCase {
checkTemplates(namespace);
checkArrays(tu);
checkBug180815(tu);
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=180815
private void checkBug180815(IParent parent) throws CModelException {
List structs = parent.getChildrenOfType(ICElement.C_STRUCT);
assertEquals(1, structs.size());
IStructure struct= (IStructure)structs.get(0);
assertEquals("bug180815", struct.getElementName());
assertEquals(2, struct.getChildren().length);
}
private void checkInclude(IParent tu) throws CModelException{
@ -397,11 +408,11 @@ public class CModelElementsTests extends TestCase {
// struct no name
IStructure struct2;
if (IParent.class.isAssignableFrom(ITypeDef.class)) {
List nsTypeDefs = namespace.getChildrenOfType(ICElement.C_TYPEDEF);
ITypeDef td = (ITypeDef) nsTypeDefs.get(1);
if (td instanceof IParent) {
// nested in typedef decl
List nsTypeDefs = namespace.getChildrenOfType(ICElement.C_TYPEDEF);
ITypeDef td2 = (ITypeDef) nsTypeDefs.get(1);
struct2 = (IStructure) td2.getChildren()[0];
struct2 = (IStructure) ((IParent)td).getChildren()[0];
} else {
struct2 = (IStructure) nsStructs.get(1);
}
@ -418,7 +429,6 @@ public class CModelElementsTests extends TestCase {
fail("field visibility should be public!");
// typedefs
List nsTypeDefs = namespace.getChildrenOfType(ICElement.C_TYPEDEF);
ITypeDef td1 = (ITypeDef) nsTypeDefs.get(0);
assertEquals(td1.getElementName(), new String ("myStruct"));
checkElementOffset(td1);
@ -428,7 +438,7 @@ public class CModelElementsTests extends TestCase {
assertEquals(td2.getElementName(), new String ("myTypedef"));
checkElementOffset(td2);
assertEquals(td2.getTypeName(), new String ("struct"));
checkLineNumbers(td2, 101, 103);
checkLineNumbers(td2, 103, 103);
// union
List nsUnions = namespace.getChildrenOfType(ICElement.C_UNION);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -399,11 +399,11 @@ public class StructuralCModelElementsTests extends TestCase {
// struct no name
IStructure struct2;
if (IParent.class.isAssignableFrom(ITypeDef.class)) {
List nsTypeDefs = namespace.getChildrenOfType(ICElement.C_TYPEDEF);
ITypeDef td = (ITypeDef) nsTypeDefs.get(1);
if (td instanceof IParent) {
// nested in typedef decl
List nsTypeDefs = namespace.getChildrenOfType(ICElement.C_TYPEDEF);
ITypeDef td2 = (ITypeDef) nsTypeDefs.get(1);
struct2 = (IStructure) td2.getChildren()[0];
struct2 = (IStructure) ((IParent)td).getChildren()[0];
} else {
struct2 = (IStructure) nsStructs.get(1);
}
@ -420,7 +420,6 @@ public class StructuralCModelElementsTests extends TestCase {
fail("field visibility should be public!"); //$NON-NLS-1$
// typedefs
List nsTypeDefs = namespace.getChildrenOfType(ICElement.C_TYPEDEF);
ITypeDef td1 = (ITypeDef) nsTypeDefs.get(0);
assertEquals(td1.getElementName(), new String ("myStruct")); //$NON-NLS-1$
checkElementOffset(td1);
@ -430,7 +429,7 @@ public class StructuralCModelElementsTests extends TestCase {
assertEquals(td2.getElementName(), new String ("myTypedef")); //$NON-NLS-1$
checkElementOffset(td2);
assertEquals(td2.getTypeName(), new String ("struct")); //$NON-NLS-1$
checkLineNumbers(td2, 101, 103);
checkLineNumbers(td2, 103, 103);
// union
List nsUnions = namespace.getChildrenOfType(ICElement.C_UNION);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2006 QNX Software Systems and others.
* Copyright (c) 2000, 2007 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -37,7 +37,7 @@ public class TranslationUnitTests extends TranslationUnitBaseTest {
* number of places in the tests
*/
String[] expectedStringList = { "stdio.h", "unistd.h", "func2p",
"globalvar", "myenum", "mystruct_t", "myunion",
"globalvar", "myenum", "mystruct_t", "mystruct", "myunion",
"mytype", "func1", "func2", "main", "func3" };
int[] expectedLines = { 12, 14, 17, 20, 23, 28, 32, 35, 42, 47, 53, 58, 65,

View file

@ -134,5 +134,8 @@ namespace MyPackage
int main(int argc, char * argv[])
{
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=180815
struct bug180815 {
int i,j;
} bug180815_var0, bug180815_var1;