1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 367472: NPE creating auto-type for dependent expression.

This commit is contained in:
Markus Schorn 2011-12-23 12:04:22 +01:00
parent 96c0441f69
commit 10372e2841
2 changed files with 17 additions and 26 deletions

View file

@ -5644,7 +5644,19 @@ public class AST2TemplateTests extends AST2BaseTest {
// int main() {
// foo(0);
// }
public void testSFINE_365981() throws Exception {
public void testSyntaxFailureInstantiatingFunctionTemplate_365981() throws Exception {
parseAndCheckBindings();
}
// template<typename _Tp> class vector {};
// template<typename T> struct bar {
// void foo() {
// vector<T> index;
// for (const auto& entry : index) {
// }
// }
// };
public void testResolvingAutoTypeWithDependentExpression_367472() throws Exception {
parseAndCheckBindings();
}
}

View file

@ -44,7 +44,7 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope {
* This field needs to be protected when used in PDOMCPPUnknownScope,
* don't use it outside of {@link #getOrCreateBinding(IASTName, int)}
*/
private CharArrayObjectMap map;
private CharArrayObjectMap<IBinding[]> map;
public CPPUnknownScope(ICPPUnknownBinding binding, IASTName name) {
super();
@ -57,41 +57,26 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope {
return EScopeKind.eClassType;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IScope#getScopeName()
*/
@Override
public IName getScopeName() {
return scopeName;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IScope#getParent()
*/
@Override
public IScope getParent() throws DOMException {
return binding.getScope();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
*/
@Override
public IBinding[] find(String name) {
return null;
return IBinding.EMPTY_BINDING_ARRAY;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IScope#getPhysicalNode()
*/
@Override
public IASTNode getPhysicalNode() {
return scopeName;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IScope#addName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
@Override
public void addName(IASTName name) {
}
@ -101,9 +86,6 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope {
return getBinding(name, resolve, IIndexFileSet.EMPTY);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IScope#getBinding(org.eclipse.cdt.core.dom.ast.IASTName, boolean)
*/
@Override
public IBinding getBinding(final IASTName name, boolean resolve, IIndexFileSet fileSet) {
boolean type= false;
@ -152,10 +134,10 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope {
protected IBinding getOrCreateBinding(final IASTName name, int idx) {
if (map == null)
map = new CharArrayObjectMap(2);
map = new CharArrayObjectMap<IBinding[]>(2);
final char[] c = name.getLookupKey();
IBinding[] o = (IBinding[]) map.get(c);
IBinding[] o = map.get(c);
if (o == null) {
o = new IBinding[3];
map.put(c, o);
@ -210,9 +192,6 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope {
// do nothing, this is part of template magic and not a normal scope
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope#getUnknownBinding()
*/
@Override
public ICPPBinding getScopeBinding() {
return binding;