1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Exceptions parsing boost library, bug 238180.

This commit is contained in:
Markus Schorn 2008-07-02 12:43:04 +00:00
parent 647d9a147e
commit 4fbf9e4dc7
7 changed files with 79 additions and 11 deletions

View file

@ -58,6 +58,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
@ -3039,4 +3040,57 @@ public class AST2TemplateTests extends AST2BaseTest {
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
ba.assertNonProblem("foo();", 3);
}
// namespace result_of {
// template <typename Sequence, typename T, bool is_associative_sequence = false>
// struct find;
//
// template <typename Sequence, typename T>
// struct find<Sequence, T, false> {
// typedef
// detail::static_seq_find_if<
// typename result_of::begin<Sequence>::type
// , typename result_of::end<Sequence>::type
// , is_same<mpl::_, T>
// >
// filter;
// };
//
// template <typename Sequence, typename T>
// struct find<Sequence, T, true> {
// typedef detail::assoc_find<Sequence, T> filter;
// };
// }
public void testBug238180_ArrayOutOfBounds() throws Exception {
// the code above used to trigger an ArrayOutOfBoundsException
parse(getAboveComment(), ParserLanguage.CPP);
}
// namespace detail {
// template<bool AtoB, bool BtoA, bool SameType, class A, class B>
// struct str;
// template<class A, class B>
// struct str<true, true, false, A, B> {
// typedef
// detail::return_type_deduction_failure<str> type;
// // ambiguous type in conditional expression
// };
// template<class A, class B>
// struct str<true, true, true, A, B> {
// typedef A type;
// };
// } // detail
public void testBug238180_ClassCast() throws Exception {
// the code above used to trigger a ClassCastException
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
String tmplId= "str<true, true, false, A, B>";
ICPPClassType p= ba.assertNonProblem(tmplId, tmplId.length(), ICPPClassType.class);
ICPPConstructor con= p.getConstructors()[1];
ICPPReferenceType reftype= (ICPPReferenceType) con.getType().getParameterTypes()[0];
IQualifierType qt= (IQualifierType) reftype.getType();
ICPPDeferredClassInstance dcl= (ICPPDeferredClassInstance) qt.getType();
ICPPClassTemplatePartialSpecialization spec= (ICPPClassTemplatePartialSpecialization) dcl.getSpecializedBinding();
ICPPTemplateTypeParameter tp= (ICPPTemplateTypeParameter) spec.getTemplateParameters()[0];
assertNull(tp.getDefault());
}
}

View file

@ -67,6 +67,9 @@ public class CPPClassTemplatePartialSpecialization extends CPPClassTemplate impl
}
ObjectMap argMap= CPPTemplates.deduceTemplateArguments(getArguments(), args, true);
if (argMap == null)
return null;
if (CPPTemplates.containsDependentArg(argMap)) {
return deferredInstance(argMap, args);
}

View file

@ -136,7 +136,7 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
IBinding binding= getBindingInAST(name, forceResolve);
if (binding == null && forceResolve) {
final IASTTranslationUnit tu = name.getTranslationUnit();
IIndex index = tu.getIndex();
IIndex index = tu == null ? null : tu.getIndex();
if (index != null) {
// Try looking this up in the PDOM
if (physicalNode instanceof IASTTranslationUnit) {

View file

@ -356,7 +356,8 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
ICPPASTTemplateParameter[] ops = origTemplate.getTemplateParameters();
ICPPASTTemplateParameter[] nps = newTemplate.getTemplateParameters();
ICPPInternalBinding temp = null;
for (int i = 0; i < nps.length; i++) {
int end= Math.min(ops.length, nps.length);
for (int i = 0; i < end; i++) {
temp = (ICPPInternalBinding) CPPTemplates.getTemplateParameterName(ops[i]).getBinding();
if (temp != null) {
IASTName n = CPPTemplates.getTemplateParameterName(nps[i]);

View file

@ -95,6 +95,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
@ -1508,23 +1509,25 @@ public class CPPSemantics {
if (bindings == null || bindings.length == 0) {
return null;
} else if (bindings.length == 1) {
// if (bindings[0] instanceof IBinding)
// return (IBinding) bindings[0];
// else if (bindings[0] instanceof IASTName && ((IASTName) bindings[0]).getBinding() != null)
// return ((IASTName) bindings[0]).getBinding();
IBinding candidate= null;
if (bindings[0] instanceof IBinding) {
candidate= (IBinding) bindings[0];
} else if (bindings[0] instanceof IASTName) {
candidate= ((IASTName) bindings[0]).getBinding();
} else {
return null;
}
if (candidate != null) {
if (candidate instanceof IType == false && candidate instanceof ICPPNamespace == false
&& LookupData.typesOnly(name)) {
if (candidate instanceof IType == false && candidate instanceof ICPPNamespace == false
&& LookupData.typesOnly(name)) {
return null;
}
return candidate;
}
// bug 238180
if (candidate instanceof ICPPClassTemplatePartialSpecialization)
return null;
return candidate;
}
}

View file

@ -606,6 +606,11 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
th= e;
} catch (StackOverflowError e) {
th= e;
} catch (Error e) {
try {
swallowError(path, e);
} catch (Throwable ignore) {}
throw e;
}
if (th != null) {
swallowError(path, th);

View file

@ -177,6 +177,8 @@ class PDOMCPPClassTemplatePartialSpecialization extends
}
ObjectMap argMap= CPPTemplates.deduceTemplateArguments(getArguments(), args, true);
if (argMap == null)
return null;
if (CPPTemplates.containsDependentArg(argMap)) {
return deferredInstance(argMap, args);
}