mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 02:36:01 +02:00
Bug 257818.
This commit is contained in:
parent
2bfba6efb0
commit
a8a55aa932
2 changed files with 18 additions and 13 deletions
|
@ -722,7 +722,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
// void test(B<int>::value_type x) {
|
||||
// f(x); // problem on f
|
||||
// }
|
||||
public void _test257818_1() throws Exception {
|
||||
public void test257818_1() throws Exception {
|
||||
waitForIndexer();
|
||||
|
||||
String[] testData = getContentsForTest(4);
|
||||
|
@ -763,7 +763,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
// void test(B<C> x, C y) {
|
||||
// x.m(&y);
|
||||
// }
|
||||
public void _test257818_2() throws Exception {
|
||||
public void test257818_2() throws Exception {
|
||||
waitForIndexer();
|
||||
|
||||
String[] testData = getContentsForTest(4);
|
||||
|
|
|
@ -32,16 +32,14 @@ import org.eclipse.core.runtime.CoreException;
|
|||
/**
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
class PDOMCPPTypedef extends PDOMCPPBinding
|
||||
implements ITypedef, ITypeContainer, IIndexType {
|
||||
class PDOMCPPTypedef extends PDOMCPPBinding implements ITypedef, ITypeContainer, IIndexType {
|
||||
|
||||
private static final int TYPE = PDOMBinding.RECORD_SIZE + 0;
|
||||
|
||||
@SuppressWarnings("hiding")
|
||||
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
|
||||
|
||||
public PDOMCPPTypedef(PDOM pdom, PDOMNode parent, ITypedef typedef)
|
||||
throws CoreException {
|
||||
public PDOMCPPTypedef(PDOM pdom, PDOMNode parent, ITypedef typedef) throws CoreException {
|
||||
super(pdom, parent, typedef.getNameCharArray());
|
||||
try {
|
||||
setType(parent.getLinkageImpl(), typedef.getType());
|
||||
|
@ -73,31 +71,39 @@ class PDOMCPPTypedef extends PDOMCPPBinding
|
|||
|
||||
private void setType(final PDOMLinkage linkage, IType newType) throws CoreException, DOMException {
|
||||
PDOMNode typeNode = linkage.addType(this, newType);
|
||||
if (introducesRecursion((IType) typeNode, getNameCharArray())) {
|
||||
if (introducesRecursion((IType) typeNode, getParentNodeRec(), getNameCharArray())) {
|
||||
linkage.deleteType((IType) typeNode, record);
|
||||
typeNode= null;
|
||||
}
|
||||
pdom.getDB().putInt(record + TYPE, typeNode != null ? typeNode.getRecord() : 0);
|
||||
}
|
||||
|
||||
private boolean introducesRecursion(IType type, char[] tdname) throws DOMException {
|
||||
private boolean introducesRecursion(IType type, int parentRec, char[] tdname) throws DOMException {
|
||||
int maxDepth= 50;
|
||||
while (--maxDepth > 0) {
|
||||
if (type instanceof ITypedef && CharArrayUtils.equals(((ITypedef) type).getNameCharArray(), tdname)) {
|
||||
return true;
|
||||
if (type instanceof ITypedef) {
|
||||
try {
|
||||
if ((!(type instanceof PDOMNode) || // this should not be the case anyhow
|
||||
((PDOMNode) type).getParentNodeRec() == parentRec) &&
|
||||
CharArrayUtils.equals(((ITypedef) type).getNameCharArray(), tdname)) {
|
||||
return true;
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (type instanceof ITypeContainer) {
|
||||
type= ((ITypeContainer) type).getType();
|
||||
}
|
||||
else if (type instanceof IFunctionType) {
|
||||
IFunctionType ft= (IFunctionType) type;
|
||||
if (introducesRecursion(ft.getReturnType(), tdname)) {
|
||||
if (introducesRecursion(ft.getReturnType(), parentRec, tdname)) {
|
||||
return true;
|
||||
}
|
||||
IType[] params= ft.getParameterTypes();
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
IType param = params[i];
|
||||
if (introducesRecursion(param, tdname)) {
|
||||
if (introducesRecursion(param, parentRec, tdname)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +116,6 @@ class PDOMCPPTypedef extends PDOMCPPBinding
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getRecordSize() {
|
||||
return RECORD_SIZE;
|
||||
|
|
Loading…
Add table
Reference in a new issue