1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-09 01:05:38 +02:00

Bug 312423: Replace null-types with problem types.

This commit is contained in:
Markus Schorn 2010-10-12 07:10:52 +00:00
parent d03bee7bc7
commit 9ed8866605
46 changed files with 274 additions and 211 deletions

View file

@ -76,8 +76,10 @@ import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IParameter; import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IProblemType;
import org.eclipse.cdt.core.dom.ast.IQualifierType; import org.eclipse.cdt.core.dom.ast.IQualifierType;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.dom.ast.IVariable;
@ -8409,9 +8411,11 @@ public class AST2CPPTests extends AST2BaseTest {
ICPPVariable t= bh.assertNonProblem("t =", 1); ICPPVariable t= bh.assertNonProblem("t =", 1);
assertEquals("std::initializer_list<double> *", ASTTypeUtil.getType(t.getType())); assertEquals("std::initializer_list<double> *", ASTTypeUtil.getType(t.getType()));
ICPPVariable x= bh.assertNonProblem("x;", 1); ICPPVariable x= bh.assertNonProblem("x;", 1);
assertNull(x.getType()); IProblemType pt= (IProblemType) x.getType();
assertEquals(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE, pt.getID());
ICPPVariable y= bh.assertNonProblem("y =", 1); ICPPVariable y= bh.assertNonProblem("y =", 1);
assertNull(y.getType()); pt= (IProblemType) y.getType();
assertEquals(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE, pt.getID());
} }
// auto x = x; // Self referring type. // auto x = x; // Self referring type.
@ -8419,7 +8423,8 @@ public class AST2CPPTests extends AST2BaseTest {
String code= getAboveComment(); String code= getAboveComment();
BindingAssertionHelper bh= new BindingAssertionHelper(code, true); BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
ICPPVariable x= bh.assertNonProblem("x =", 1); ICPPVariable x= bh.assertNonProblem("x =", 1);
assertNull(x.getType()); IProblemType pt= (IProblemType) x.getType();
assertEquals(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE, pt.getID());
} }
// struct A { auto a = 1; }; // Auto-typed non-static fields are not allowed. // struct A { auto a = 1; }; // Auto-typed non-static fields are not allowed.
@ -8428,7 +8433,8 @@ public class AST2CPPTests extends AST2BaseTest {
String code= getAboveComment(); String code= getAboveComment();
BindingAssertionHelper bh= new BindingAssertionHelper(code, true); BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
ICPPVariable a= bh.assertNonProblem("a =", 1); ICPPVariable a= bh.assertNonProblem("a =", 1);
assertNull(a.getType()); IProblemType pt= (IProblemType) a.getType();
assertEquals(ISemanticProblem.TYPE_AUTO_FOR_NON_STATIC_FIELD, pt.getID());
ICPPVariable b= bh.assertNonProblem("b =", 1); ICPPVariable b= bh.assertNonProblem("b =", 1);
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others. * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -46,7 +46,9 @@ import org.eclipse.cdt.core.dom.ast.ILabel;
import org.eclipse.cdt.core.dom.ast.IParameter; import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IProblemType;
import org.eclipse.cdt.core.dom.ast.IQualifierType; import org.eclipse.cdt.core.dom.ast.IQualifierType;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.dom.ast.IVariable;
@ -1569,8 +1571,7 @@ public class CompleteParser2Tests extends BaseTestCase {
assertInstances( col, foo, 2 ); assertInstances( col, foo, 2 );
} }
public void testErrorHandling_1() throws Exception public void testErrorHandling_1() throws Exception {
{
IASTTranslationUnit tu = parse( "A anA; int x = c; class A {}; A * anotherA = &anA; int b;", false ); //$NON-NLS-1$ IASTTranslationUnit tu = parse( "A anA; int x = c; class A {}; A * anotherA = &anA; int b;", false ); //$NON-NLS-1$
CPPNameCollector col = new CPPNameCollector(); CPPNameCollector col = new CPPNameCollector();
@ -1589,7 +1590,8 @@ public class CompleteParser2Tests extends BaseTestCase {
assertNotNull( p ); assertNotNull( p );
assertNotNull( p2 ); assertNotNull( p2 );
assertSame( anA.getType(), p ); IProblemType pt= (IProblemType) anA.getType();
assertEquals(ISemanticProblem.TYPE_UNRESOLVED_NAME, pt.getID());
} }
public void testBug44340() throws Exception { public void testBug44340() throws Exception {

View file

@ -44,6 +44,7 @@ import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IFunction; import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.dom.ast.IVariable;
@ -2211,7 +2212,7 @@ public class IndexBugsTests extends BaseTestCase {
tu = TestSourceReader.createIndexBasedAST(index, fCProject, s2); tu = TestSourceReader.createIndexBasedAST(index, fCProject, s2);
sdecl= (IASTSimpleDeclaration) tu.getDeclarations()[0]; sdecl= (IASTSimpleDeclaration) tu.getDeclarations()[0];
var= (IVariable) sdecl.getDeclarators()[0].getName().resolveBinding(); var= (IVariable) sdecl.getDeclarators()[0].getName().resolveBinding();
assertTrue(var.getType() instanceof IProblemBinding); assertTrue(var.getType() instanceof ISemanticProblem);
} finally { } finally {
index.releaseReadLock(); index.releaseReadLock();
} }

View file

@ -23,7 +23,7 @@ import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IProblemType;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.index.IndexFilter; import org.eclipse.cdt.core.index.IndexFilter;
@ -85,17 +85,17 @@ public class PDOMCBugsTest extends BaseTestCase {
assertEquals(7, bindings.length); assertEquals(7, bindings.length);
Set bnames= new HashSet(); Set bnames= new HashSet();
for (IBinding binding : bindings) { for (IBinding binding : bindings) {
final String name = binding.getName();
bnames.add(name);
assertTrue("expected typedef, got "+binding, binding instanceof ITypedef); assertTrue("expected typedef, got "+binding, binding instanceof ITypedef);
bnames.add(binding.getName());
IType type= SemanticUtil.getUltimateType((IType)binding, false); IType type= SemanticUtil.getUltimateType((IType)binding, false);
if (name.equals("J")) {
if(binding.getName().equals("J")) {
// for plain C the second J has to be interpreted as a (useless) parameter name. // for plain C the second J has to be interpreted as a (useless) parameter name.
assertTrue(type instanceof IFunctionType); assertTrue(type instanceof IFunctionType);
IFunctionType ft= (IFunctionType) type; IFunctionType ft= (IFunctionType) type;
assertEquals("int (int)", ASTTypeUtil.getType(ft)); assertEquals("int (int)", ASTTypeUtil.getType(ft));
} else { } else {
assertTrue("expected ITypedef, got "+type, type == null || type instanceof ITypedef || type instanceof IPointerType); assertTrue(type instanceof IProblemType);
} }
} }

View file

@ -19,6 +19,11 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface ISemanticProblem { public interface ISemanticProblem {
int TYPE_NO_NAME = 10000;
int TYPE_UNRESOLVED_NAME = 10001;
int TYPE_AUTO_FOR_NON_STATIC_FIELD = 10002;
int TYPE_CANNOT_DEDUCE_AUTO_TYPE = 10003;
int TYPE_UNKNOWN_FOR_EXPRESSION = 10004;
/** /**
* Returns the ID of the problem. * Returns the ID of the problem.

View file

@ -26,6 +26,7 @@ public interface ITypeMarshalBuffer {
final static byte REFERENCE= 6; final static byte REFERENCE= 6;
final static byte POINTER_TO_MEMBER= 7; final static byte POINTER_TO_MEMBER= 7;
final static byte PACK_EXPANSION= 8; final static byte PACK_EXPANSION= 8;
final static byte PROBLEM_TYPE= 9;
static final byte KIND_MASK = 0xf; static final byte KIND_MASK = 0xf;
final static int FLAG1 = 0x10; final static int FLAG1 = 0x10;

View file

@ -13,12 +13,13 @@ package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.IProblemType; import org.eclipse.cdt.core.dom.ast.IProblemType;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.internal.core.parser.ParserMessages; import org.eclipse.cdt.internal.core.parser.ParserMessages;
import org.eclipse.core.runtime.CoreException;
/** /**
* Implementation of problem types. * Implementation of problem types.
*/ */
public class ProblemType implements IProblemType { public class ProblemType implements IProblemType, ISerializableType {
private final int fID; private final int fID;
public ProblemType(int id) { public ProblemType(int id) {
@ -45,4 +46,13 @@ public class ProblemType implements IProblemType {
return null; return null;
} }
} }
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
buffer.putByte(ITypeMarshalBuffer.PROBLEM_TYPE);
buffer.putShort((short) getID());
}
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
return new ProblemType(buffer.getShort() & 0xffff);
}
} }

View file

@ -16,9 +16,11 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement; import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement; import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
import org.eclipse.cdt.core.dom.ast.IASTStatement; import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression; import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
/** /**
* Compound statement for c * Compound statement for c
@ -83,7 +85,7 @@ public class CASTCompoundStatementExpression extends ASTNode implements IGNUASTC
if (st instanceof IASTExpressionStatement) if (st instanceof IASTExpressionStatement)
return ((IASTExpressionStatement)st).getExpression().getExpressionType(); return ((IASTExpressionStatement)st).getExpression().getExpressionType();
} }
return null; return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
} }
public boolean isLValue() { public boolean isLValue() {

View file

@ -16,10 +16,12 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpressionList; import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
/** /**
* Expression list in C * Expression list in C
@ -100,7 +102,7 @@ public class CASTExpressionList extends ASTNode implements IASTExpressionList,
if (expr != null) if (expr != null)
return expr.getExpressionType(); return expr.getExpressionType();
} }
return null; return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
} }
public boolean isLValue() { public boolean isLValue() {

View file

@ -21,10 +21,12 @@ import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
/** /**
* Field reference in C. * Field reference in C.
@ -141,7 +143,7 @@ public class CASTFieldReference extends ASTNode implements IASTFieldReference, I
return e.getProblem(); return e.getProblem();
} }
} }
return null; return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
} }

View file

@ -19,10 +19,12 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
/** /**
* Function call expression in C. * Function call expression in C.
@ -133,7 +135,7 @@ public class CASTFunctionCallExpression extends ASTNode implements
type = ((ITypeContainer) type).getType(); type = ((ITypeContainer) type).getType();
if (type instanceof IFunctionType) if (type instanceof IFunctionType)
return ((IFunctionType) type).getReturnType(); return ((IFunctionType) type).getReturnType();
return null; return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
} }
public boolean isLValue() { public boolean isLValue() {

View file

@ -24,10 +24,12 @@ import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IFunction; import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
/** /**
* ID Expression in C. * ID Expression in C.
@ -103,12 +105,12 @@ public class CASTIdExpression extends ASTNode implements IASTIdExpression, IASTC
return ((IEnumerator)binding).getType(); return ((IEnumerator)binding).getType();
} }
if (binding instanceof IProblemBinding) { if (binding instanceof IProblemBinding) {
return (IProblemBinding)binding; return new ProblemType(ISemanticProblem.TYPE_UNRESOLVED_NAME);
} }
} catch (DOMException e) { } catch (DOMException e) {
return e.getProblem(); return e.getProblem();
} }
return null; return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
} }
public boolean isLValue() { public boolean isLValue() {

View file

@ -16,9 +16,11 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression; import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.IBasicType; import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
/** /**
* Represents a literal * Represents a literal
@ -97,7 +99,7 @@ public class CASTLiteralExpression extends ASTNode implements IASTLiteralExpress
type = new CQualifierType(type, true, false, false); type = new CQualifierType(type, true, false, false);
return new CPointerType(type, 0); return new CPointerType(type, 0);
} }
return null; return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
} }
public boolean isLValue() { public boolean isLValue() {

View file

@ -15,7 +15,9 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTProblem; import org.eclipse.cdt.core.dom.ast.IASTProblem;
import org.eclipse.cdt.core.dom.ast.IASTProblemExpression; import org.eclipse.cdt.core.dom.ast.IASTProblemExpression;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
public class CASTProblemExpression extends CASTProblemOwner implements IASTProblemExpression { public class CASTProblemExpression extends CASTProblemOwner implements IASTProblemExpression {
@ -54,7 +56,7 @@ public class CASTProblemExpression extends CASTProblemOwner implements IASTProbl
} }
public IType getExpressionType() { public IType getExpressionType() {
return null; return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
} }
public boolean isLValue() { public boolean isLValue() {

View file

@ -67,6 +67,7 @@ import org.eclipse.cdt.core.dom.ast.ILabel;
import org.eclipse.cdt.core.dom.ast.IParameter; import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.dom.ast.IVariable;
@ -94,6 +95,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope; import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
/** /**
* Collection of methods to find information in an AST. * Collection of methods to find information in an AST.
@ -1295,16 +1297,17 @@ public class CVisitor extends ASTQueries {
} else if (declSpec instanceof IASTEnumerationSpecifier) { } else if (declSpec instanceof IASTEnumerationSpecifier) {
name = ((IASTEnumerationSpecifier)declSpec).getName(); name = ((IASTEnumerationSpecifier)declSpec).getName();
} else { } else {
return new ProblemBinding(declSpec, IProblemBinding.SEMANTIC_NAME_NOT_FOUND, declSpec.getRawSignature().toCharArray()); throw new IllegalArgumentException();
} }
if (name == null)
return new ProblemType(ISemanticProblem.TYPE_NO_NAME);
binding = name.resolveBinding(); binding = name.resolveBinding();
if (binding instanceof IType) if (binding instanceof IType && !(binding instanceof IProblemBinding))
return (IType) binding; return (IType) binding;
if (binding != null) return new ProblemType(ISemanticProblem.TYPE_UNRESOLVED_NAME);
return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_TYPE, name.toCharArray());
return new ProblemBinding(name, IProblemBinding.SEMANTIC_NAME_NOT_FOUND, name.toCharArray());
} }
public static IType createType(ICASTDeclSpecifier declSpec) { public static IType createType(ICASTDeclSpecifier declSpec) {
@ -1341,7 +1344,7 @@ public class CVisitor extends ASTQueries {
} }
return parmTypes; return parmTypes;
} else { } else {
return null; throw new IllegalArgumentException();
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008, 2009 IBM Wind River Systems, Inc. and others. * Copyright (c) 2008, 2010 IBM Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -55,7 +55,7 @@ public class CPPASTAmbiguousParameterDeclaration extends ASTAmbiguousNode implem
// Setup the ast to use the alternative // Setup the ast to use the alternative
owner.replace(this, fParameterDecl); owner.replace(this, fParameterDecl);
IType t= CPPVisitor.createParameterType(fParameterDecl, true); IType t= CPPVisitor.createType(fParameterDecl, true);
if (!(t instanceof ICPPParameterPackType) || if (!(t instanceof ICPPParameterPackType) ||
!CPPTemplates.containsParameterPack(((ICPPParameterPackType) t).getType())) { !CPPTemplates.containsParameterPack(((ICPPParameterPackType) t).getType())) {
final ICPPASTDeclarator dtor = fParameterDecl.getDeclarator(); final ICPPASTDeclarator dtor = fParameterDecl.getDeclarator();

View file

@ -24,12 +24,14 @@ import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArraySubscriptExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArraySubscriptExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes;
@ -205,8 +207,7 @@ public class CPPASTArraySubscriptExpression extends ASTNode implements ICPPASTAr
return CPPUnknownClass.createUnnamedInstance(); return CPPUnknownClass.createUnnamedInstance();
} }
// mstodo return problem type return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
return null;
} }
public boolean isLValue() { public boolean isLValue() {

View file

@ -25,7 +25,6 @@ import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem; import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression;
@ -35,7 +34,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
@ -337,7 +336,6 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
if (type2 instanceof IPointerType) { if (type2 instanceof IPointerType) {
return type2; return type2;
} }
// mstodo problem type
break; break;
case IASTBinaryExpression.op_minus: case IASTBinaryExpression.op_minus:
@ -347,7 +345,6 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
} }
return type1; return type1;
} }
// mstodo problem type
break; break;
case ICPPASTBinaryExpression.op_pmarrow: case ICPPASTBinaryExpression.op_pmarrow:
@ -361,7 +358,7 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
} }
return glvalueType(t); return glvalueType(t);
} }
return new ProblemBinding(this, IProblemBinding.SEMANTIC_INVALID_TYPE, getRawSignature().toCharArray()); return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
} }
return type1; return type1;
} }

View file

@ -18,9 +18,11 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement; import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement; import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
import org.eclipse.cdt.core.dom.ast.IASTStatement; import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression; import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
/** /**
* Gnu-extension: ({ ... }) * Gnu-extension: ({ ... })
@ -87,7 +89,7 @@ public class CPPASTCompoundStatementExpression extends ASTNode implements IGNUAS
if (st instanceof IASTExpressionStatement) if (st instanceof IASTExpressionStatement)
return prvalueType(((IASTExpressionStatement) st).getExpression().getExpressionType()); return prvalueType(((IASTExpressionStatement) st).getExpression().getExpressionType());
} }
return null; return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
} }
public boolean isLValue() { public boolean isLValue() {

View file

@ -25,7 +25,6 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression; import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem; import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
@ -33,7 +32,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CVQualifier; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CVQualifier;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions;
@ -182,8 +181,10 @@ public class CPPASTConditionalExpression extends ASTNode implements IASTConditio
IType t2 = expr2.getExpressionType(); IType t2 = expr2.getExpressionType();
IType t3 = expr3.getExpressionType(); IType t3 = expr3.getExpressionType();
if (t2 == null || t3 == null) if (t2 == null || t3 == null) {
fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
return; return;
}
final IType uqt2= getNestedType(t2, TDEF | REF | CVTYPE); final IType uqt2= getNestedType(t2, TDEF | REF | CVTYPE);
final IType uqt3= getNestedType(t3, TDEF | REF | CVTYPE); final IType uqt3= getNestedType(t3, TDEF | REF | CVTYPE);
@ -208,7 +209,7 @@ public class CPPASTConditionalExpression extends ASTNode implements IASTConditio
} else if (void2 && void3) { } else if (void2 && void3) {
fType= uqt2; fType= uqt2;
} else { } else {
createProblem(); fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
} }
return; return;
} }
@ -238,10 +239,10 @@ public class CPPASTConditionalExpression extends ASTNode implements IASTConditio
if (cost2.converts() || cost3.converts()) { if (cost2.converts() || cost3.converts()) {
if (cost2.converts()) { if (cost2.converts()) {
if (cost3.converts() || cost2.isAmbiguousUDC()) { if (cost3.converts() || cost2.isAmbiguousUDC()) {
fType= createProblem(); fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
} }
} else if (cost3.isAmbiguousUDC()) { } else if (cost3.isAmbiguousUDC()) {
fType= createProblem(); fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
} }
return; return;
} }
@ -256,7 +257,7 @@ public class CPPASTConditionalExpression extends ASTNode implements IASTConditio
fType= t3; fType= t3;
fValueCategory= vcat3; fValueCategory= vcat3;
} else { } else {
createProblem(); fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
} }
return; return;
} }
@ -266,8 +267,9 @@ public class CPPASTConditionalExpression extends ASTNode implements IASTConditio
ICPPFunction builtin = CPPSemantics.findOverloadedConditionalOperator(expr2, expr3); ICPPFunction builtin = CPPSemantics.findOverloadedConditionalOperator(expr2, expr3);
if (builtin != null) { if (builtin != null) {
fType= ExpressionTypes.typeFromFunctionCall(builtin); fType= ExpressionTypes.typeFromFunctionCall(builtin);
} else {
fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
} }
createProblem();
return; return;
} }
@ -281,7 +283,7 @@ public class CPPASTConditionalExpression extends ASTNode implements IASTConditio
if (fType == null) { if (fType == null) {
fType= Conversions.compositePointerType(t2, t3); fType= Conversions.compositePointerType(t2, t3);
if (fType == null) { if (fType == null) {
createProblem(); fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
} }
} }
} }
@ -345,10 +347,6 @@ public class CPPASTConditionalExpression extends ASTNode implements IASTConditio
return Cost.NO_CONVERSION; return Cost.NO_CONVERSION;
} }
private ProblemBinding createProblem() {
return new ProblemBinding(this, IProblemBinding.SEMANTIC_INVALID_TYPE, this.getRawSignature().toCharArray());
}
private boolean isVoidType(IType t) { private boolean isVoidType(IType t) {
return t instanceof ICPPBasicType && ((ICPPBasicType) t).getKind() == Kind.eVoid; return t instanceof ICPPBasicType && ((ICPPBasicType) t).getKind() == Kind.eVoid;
} }

View file

@ -23,6 +23,7 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression; import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
import org.eclipse.cdt.core.dom.ast.IASTImplicitName; import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
@ -32,6 +33,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
@ -205,7 +207,8 @@ public class CPPASTExpressionList extends ASTNode implements ICPPASTExpressionLi
if (expr != null) if (expr != null)
return expr.getExpressionType(); return expr.getExpressionType();
} }
return null;
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
} }
public ValueCategory getValueCategory() { public ValueCategory getValueCategory() {

View file

@ -34,6 +34,7 @@ import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IFunction; import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
@ -44,6 +45,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CVQualifier; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CVQualifier;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
@ -236,16 +238,15 @@ public class CPPASTFieldReference extends ASTNode implements ICPPASTFieldReferen
return CPPUnknownClass.createUnnamedInstance(); return CPPUnknownClass.createUnnamedInstance();
} }
if (binding instanceof IProblemBinding) { if (binding instanceof IProblemBinding) {
return (IType) binding; return new ProblemType(ISemanticProblem.TYPE_UNRESOLVED_NAME);
} }
// mstodo problem type. return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
return null;
} catch (DOMException e) { } catch (DOMException e) {
return e.getProblem(); return e.getProblem();
} }
} }
public static IType addQualifiersForAccess(ICPPField field, IType fieldType, IType ownerType) throws DOMException { public static IType addQualifiersForAccess(ICPPField field, IType fieldType, IType ownerType) {
CVQualifier cvq1 = SemanticUtil.getCVQualifier(ownerType); CVQualifier cvq1 = SemanticUtil.getCVQualifier(ownerType);
if (field.isMutable()) { if (field.isMutable()) {
// Remove const, add union of volatile. // Remove const, add union of volatile.

View file

@ -29,6 +29,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpressionList; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpressionList;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression;
@ -39,7 +40,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.IToken;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
@ -222,10 +223,10 @@ public class CPPASTFunctionCallExpression extends ASTNode implements
if (owner instanceof ICPPClassType) { if (owner instanceof ICPPClassType) {
return (ICPPClassType) owner; return (ICPPClassType) owner;
} }
return new ProblemBinding(this, IProblemBinding.SEMANTIC_BAD_SCOPE, binding.getNameCharArray()); return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
} }
if (binding instanceof IProblemBinding) { if (binding instanceof IProblemBinding) {
return (IProblemBinding) binding; return new ProblemType(ISemanticProblem.TYPE_UNRESOLVED_NAME);
} }
if (binding instanceof IType) { if (binding instanceof IType) {
return prvalueType((IType) binding); return prvalueType((IType) binding);
@ -240,8 +241,7 @@ public class CPPASTFunctionCallExpression extends ASTNode implements
if (overload != null) { if (overload != null) {
return typeFromFunctionCall(overload); return typeFromFunctionCall(overload);
} }
// mstodo problem type return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
return null;
} }
if (t instanceof IPointerType) { if (t instanceof IPointerType) {
@ -251,8 +251,7 @@ public class CPPASTFunctionCallExpression extends ASTNode implements
return typeFromReturnType(((IFunctionType) t).getReturnType()); return typeFromReturnType(((IFunctionType) t).getReturnType());
} }
// mstodo problem type return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
return null;
} }
public boolean isLValue() { public boolean isLValue() {

View file

@ -29,6 +29,7 @@ import org.eclipse.cdt.core.dom.ast.ICPPASTCompletionContext;
import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IFunction; import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
@ -42,6 +43,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPFunctionSet; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPFunctionSet;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
@ -117,11 +119,10 @@ public class CPPASTIdExpression extends ASTNode implements IASTIdExpression, ICP
} }
try { try {
if (binding instanceof IProblemBinding) { if (binding instanceof IProblemBinding) {
return (IProblemBinding) binding; return new ProblemType(ISemanticProblem.TYPE_UNRESOLVED_NAME);
} }
if (binding instanceof IType || binding instanceof ICPPConstructor) { if (binding instanceof IType || binding instanceof ICPPConstructor) {
// mstodo return problem type return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
return null;
} }
if (binding instanceof IEnumerator) { if (binding instanceof IEnumerator) {
IType type= ((IEnumerator) binding).getType(); IType type= ((IEnumerator) binding).getType();
@ -157,8 +158,7 @@ public class CPPASTIdExpression extends ASTNode implements IASTIdExpression, ICP
} catch (DOMException e) { } catch (DOMException e) {
return e.getProblem(); return e.getProblem();
} }
// mstodo return problem type return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
return null;
} }
/** /**

View file

@ -16,12 +16,13 @@ import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.IBasicType; import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression;
import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.Value; import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
@ -98,8 +99,7 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx
IScope scope = CPPVisitor.getContainingScope(this); IScope scope = CPPVisitor.getContainingScope(this);
IType type= CPPVisitor.getImpliedObjectType(scope); IType type= CPPVisitor.getImpliedObjectType(scope);
if (type == null) { if (type == null) {
// mstodo problem type return new ProblemType(ISemanticProblem.TYPE_UNRESOLVED_NAME);
return null;
} }
return new CPPPointerType(type); return new CPPPointerType(type);
} }
@ -117,7 +117,7 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx
type = new CPPQualifierType(type, true, false); type = new CPPQualifierType(type, true, false);
return new CPPArrayType(type, getStringLiteralSize()); return new CPPArrayType(type, getStringLiteralSize());
} }
return null; return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
} }
public boolean isLValue() { public boolean isLValue() {

View file

@ -31,7 +31,6 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
@ -161,8 +160,15 @@ public class CPPASTNewExpression extends ASTNode implements ICPPASTNewExpression
* @since 5.1 * @since 5.1
*/ */
public boolean isArrayAllocation() { public boolean isArrayAllocation() {
IType t = CPPVisitor.createType(getTypeId()); IASTTypeId typeId= getTypeId();
return t instanceof IArrayType; if (typeId != null) {
IASTDeclarator dtor= typeId.getAbstractDeclarator();
if (dtor != null) {
dtor= ASTQueries.findTypeRelevantDeclarator(dtor);
return dtor instanceof IASTArrayDeclarator;
}
}
return false;
} }
@Override @Override

View file

@ -14,7 +14,9 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTProblem; import org.eclipse.cdt.core.dom.ast.IASTProblem;
import org.eclipse.cdt.core.dom.ast.IASTProblemExpression; import org.eclipse.cdt.core.dom.ast.IASTProblemExpression;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
public class CPPASTProblemExpression extends CPPASTProblemOwner implements IASTProblemExpression { public class CPPASTProblemExpression extends CPPASTProblemOwner implements IASTProblemExpression {
@ -53,7 +55,7 @@ public class CPPASTProblemExpression extends CPPASTProblemOwner implements IASTP
} }
public IType getExpressionType() { public IType getExpressionType() {
return null; return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
} }
public boolean isLValue() { public boolean isLValue() {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2008 IBM Corporation and others. * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -128,9 +128,9 @@ public class CPPASTTemplateId extends CPPASTNameBase implements ICPPASTTemplateI
buf.append(arg.getRawSignature()); buf.append(arg.getRawSignature());
cleanupWhitespace= true; cleanupWhitespace= true;
} }
} else { } else if (arg instanceof IASTTypeId){
IType type= CPPVisitor.createType(arg); IType type= CPPVisitor.createType((IASTTypeId) arg);
if (type == null || type instanceof ISemanticProblem) { if (type instanceof ISemanticProblem) {
buf.append(arg.getRawSignature()); buf.append(arg.getRawSignature());
} else { } else {
buf.append(ASTTypeUtil.getType(type, false)); buf.append(ASTTypeUtil.getType(type, false));

View file

@ -44,6 +44,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
@ -254,7 +255,7 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
// mstodo Type of unknown // mstodo Type of unknown
return CPPUnknownClass.createUnnamedInstance(); return CPPUnknownClass.createUnnamedInstance();
} }
return new ProblemBinding(this, IProblemBinding.SEMANTIC_INVALID_TYPE, this.getRawSignature().toCharArray()); return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
} }
IType typeOfOperand= operand.getExpressionType(); IType typeOfOperand= operand.getExpressionType();

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others. * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -29,18 +29,14 @@ public class CPPArrayType implements IArrayType, ITypeContainer, ISerializableTy
private IASTExpression sizeExpression; private IASTExpression sizeExpression;
private IValue value= Value.NOT_INITIALIZED; private IValue value= Value.NOT_INITIALIZED;
public CPPArrayType(IType type) {
this.type = type;
}
public CPPArrayType(IType type, IValue value) { public CPPArrayType(IType type, IValue value) {
this.type= type;
this.value= value; this.value= value;
setType(type);
} }
public CPPArrayType(IType type, IASTExpression sizeExp) { public CPPArrayType(IType type, IASTExpression sizeExp) {
this.type = type; this.sizeExpression = sizeExp;
this.sizeExpression = sizeExp; setType(type);
} }
public IType getType() { public IType getType() {
@ -48,6 +44,7 @@ public class CPPArrayType implements IArrayType, ITypeContainer, ISerializableTy
} }
public void setType(IType t) { public void setType(IType t) {
assert t != null;
this.type = t; this.type = t;
} }

View file

@ -135,10 +135,7 @@ public class CPPClosureType extends PlatformObject implements ICPPClassType, ICP
if (lambdaDtor != null) { if (lambdaDtor != null) {
IASTTypeId trailingReturnType = lambdaDtor.getTrailingReturnType(); IASTTypeId trailingReturnType = lambdaDtor.getTrailingReturnType();
if (trailingReturnType != null) { if (trailingReturnType != null) {
IType type= CPPVisitor.createType(trailingReturnType); return CPPVisitor.createType(trailingReturnType);
if (type != null)
return type;
return CPPSemantics.VOID_TYPE;
} }
} }
IASTCompoundStatement body = fLambdaExpression.getBody(); IASTCompoundStatement body = fLambdaExpression.getBody();

View file

@ -59,7 +59,7 @@ public class CPPLambdaExpressionParameter extends PlatformObject implements ICPP
IASTNode parent= fDeclaration.getParent(); IASTNode parent= fDeclaration.getParent();
while (parent != null) { while (parent != null) {
if (parent instanceof ICPPASTParameterDeclaration) { if (parent instanceof ICPPASTParameterDeclaration) {
fType= CPPVisitor.createParameterType((ICPPASTParameterDeclaration) parent, false); fType= CPPVisitor.createType((ICPPASTParameterDeclaration) parent, false);
break; break;
} }
parent= parent.getParent(); parent= parent.getParent();

View file

@ -151,7 +151,7 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
IASTNode parent= fDeclarations[0].getParent(); IASTNode parent= fDeclarations[0].getParent();
while (parent != null) { while (parent != null) {
if (parent instanceof ICPPASTParameterDeclaration) { if (parent instanceof ICPPASTParameterDeclaration) {
fType= CPPVisitor.createParameterType((ICPPASTParameterDeclaration) parent, false); fType= CPPVisitor.createType((ICPPASTParameterDeclaration) parent, false);
break; break;
} }
parent= parent.getParent(); parent= parent.getParent();

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009 Wind River Systems, Inc. and others. * Copyright (c) 2009, 2010 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -33,6 +33,7 @@ public class CPPParameterPackType implements ICPPParameterPackType, ITypeContain
} }
public void setType(IType t) { public void setType(IType t) {
assert t != null;
fType= t; fType= t;
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others. * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -30,20 +30,18 @@ public class CPPPointerType implements IPointerType, ITypeContainer, ISerializab
private boolean isConst = false; private boolean isConst = false;
private boolean isVolatile = false; private boolean isVolatile = false;
public CPPPointerType(IType type, IASTPointer operator) {
this.type = type;
this.isConst = operator.isConst();
this.isVolatile = operator.isVolatile();
}
public CPPPointerType(IType type, boolean isConst, boolean isVolatile) { public CPPPointerType(IType type, boolean isConst, boolean isVolatile) {
this.type = type;
this.isConst = isConst; this.isConst = isConst;
this.isVolatile = isVolatile; this.isVolatile = isVolatile;
setType(type);
}
public CPPPointerType(IType type, IASTPointer operator) {
this(type, operator.isConst(), operator.isVolatile());
} }
public CPPPointerType(IType type) { public CPPPointerType(IType type) {
this.type = type; this(type, false, false);
} }
public IType stripQualifiers() { public IType stripQualifiers() {
@ -83,6 +81,7 @@ public class CPPPointerType implements IPointerType, ITypeContainer, ISerializab
} }
public void setType(IType t) { public void setType(IType t) {
assert t != null;
type = t; type = t;
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others. * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -26,9 +26,9 @@ public class CPPQualifierType implements IQualifierType, ITypeContainer, ISerial
private IType type; private IType type;
public CPPQualifierType(IType type, boolean isConst, boolean isVolatile) { public CPPQualifierType(IType type, boolean isConst, boolean isVolatile) {
this.type = type;
this.isConst = isConst; this.isConst = isConst;
this.isVolatile = isVolatile; this.isVolatile = isVolatile;
setType(type);
} }
public boolean isSameType(IType o) { public boolean isSameType(IType o) {
@ -65,6 +65,7 @@ public class CPPQualifierType implements IQualifierType, ITypeContainer, ISerial
} }
public void setType(IType t) { public void setType(IType t) {
assert t != null;
type = t; type = t;
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others. * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -43,6 +43,7 @@ public class CPPReferenceType implements ICPPReferenceType, ITypeContainer, ISer
fIsRValue = fIsRValue && rt.isRValueReference(); fIsRValue = fIsRValue && rt.isRValueReference();
t= rt.getType(); t= rt.getType();
} }
assert t != null;
fType= t; fType= t;
} }

View file

@ -101,7 +101,7 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
IASTNode parent= getPrimaryDeclaration().getParent(); IASTNode parent= getPrimaryDeclaration().getParent();
while (parent != null) { while (parent != null) {
if (parent instanceof ICPPASTParameterDeclaration) { if (parent instanceof ICPPASTParameterDeclaration) {
type= CPPVisitor.createParameterType((ICPPASTParameterDeclaration) parent, true); type= CPPVisitor.createType((ICPPASTParameterDeclaration) parent, true);
break; break;
} }
parent= parent.getParent(); parent= parent.getParent();

View file

@ -2641,7 +2641,7 @@ public class CPPSemantics {
private static IBinding resolveUserDefinedConversion(LookupData data, IFunction[] fns) { private static IBinding resolveUserDefinedConversion(LookupData data, IFunction[] fns) {
ICPPASTConversionName astName= (ICPPASTConversionName) data.astName; ICPPASTConversionName astName= (ICPPASTConversionName) data.astName;
IType t= CPPVisitor.createType(astName.getTypeId()); IType t= CPPVisitor.createType(astName.getTypeId());
if (t == null) { if (t instanceof ISemanticProblem) {
return new ProblemBinding(astName, IProblemBinding.SEMANTIC_INVALID_TYPE, data.getFoundBindings()); return new ProblemBinding(astName, IProblemBinding.SEMANTIC_INVALID_TYPE, data.getFoundBindings());
} }
if (!data.forFunctionDeclaration() || data.forExplicitFunctionSpecialization()) { if (!data.forFunctionDeclaration() || data.forExplicitFunctionSpecialization()) {

View file

@ -37,6 +37,7 @@ import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IArrayType; import org.eclipse.cdt.core.dom.ast.IArrayType;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IEnumeration;
@ -1514,24 +1515,23 @@ public class CPPTemplates {
* @param id the template id containing the template arguments * @param id the template id containing the template arguments
* @return an array of template arguments, currently modeled as IType objects. The * @return an array of template arguments, currently modeled as IType objects. The
* empty IType array is returned if id is <code>null</code> * empty IType array is returned if id is <code>null</code>
* @throws DOMException
*/ */
public static ICPPTemplateArgument[] createTemplateArgumentArray(ICPPASTTemplateId id) throws DOMException { public static ICPPTemplateArgument[] createTemplateArgumentArray(ICPPASTTemplateId id) {
ICPPTemplateArgument[] result= ICPPTemplateArgument.EMPTY_ARGUMENTS; ICPPTemplateArgument[] result= ICPPTemplateArgument.EMPTY_ARGUMENTS;
if (id != null) { if (id != null) {
IASTNode[] params= id.getTemplateArguments(); IASTNode[] args= id.getTemplateArguments();
result = new ICPPTemplateArgument[params.length]; result = new ICPPTemplateArgument[args.length];
for (int i = 0; i < params.length; i++) { for (int i = 0; i < args.length; i++) {
IASTNode param= params[i]; IASTNode arg= args[i];
IType type= CPPVisitor.createType(param); if (arg instanceof IASTTypeId) {
if (type == null) result[i]= new CPPTemplateArgument(CPPVisitor.createType((IASTTypeId) arg));
throw new DOMException(new ProblemBinding(id, IProblemBinding.SEMANTIC_INVALID_TYPE)); } else if (arg instanceof IASTExpression) {
IASTExpression expr= (IASTExpression) arg;
if (param instanceof IASTExpression) { IType type= expr.getExpressionType();
IValue value= Value.create((IASTExpression) param, Value.MAX_RECURSION_DEPTH); IValue value= Value.create((IASTExpression) arg, Value.MAX_RECURSION_DEPTH);
result[i]= new CPPTemplateArgument(value, type); result[i]= new CPPTemplateArgument(value, type);
} else { } else {
result[i]= new CPPTemplateArgument(type); throw new IllegalArgumentException();
} }
} }
} }

View file

@ -82,6 +82,7 @@ import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IQualifierType; import org.eclipse.cdt.core.dom.ast.IQualifierType;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.dom.ast.IVariable;
@ -139,7 +140,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
@ -151,6 +151,7 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.Value; import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTranslationUnit; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTranslationUnit;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArrayType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArrayType;
@ -1264,7 +1265,6 @@ public class CPPVisitor extends ASTQueries {
public CollectDeclarationsAction(IBinding binding) { public CollectDeclarationsAction(IBinding binding) {
binding = CPPTemplates.findDeclarationForSpecialization(binding);
shouldVisitNames = true; shouldVisitNames = true;
this.decls = new IASTName[DEFAULT_LIST_SIZE]; this.decls = new IASTName[DEFAULT_LIST_SIZE];
@ -1411,6 +1411,17 @@ public class CPPVisitor extends ASTQueries {
} }
protected static IBinding unwindBinding(IBinding binding) {
while (true) {
if (binding instanceof ICPPSpecialization) {
binding= ((ICPPSpecialization) binding).getSpecializedBinding();
} else {
break;
}
}
return binding;
}
public static class CollectReferencesAction extends ASTVisitor { public static class CollectReferencesAction extends ASTVisitor {
private static final int DEFAULT_LIST_SIZE = 8; private static final int DEFAULT_LIST_SIZE = 8;
private IASTName[] refs; private IASTName[] refs;
@ -1428,7 +1439,7 @@ public class CPPVisitor extends ASTQueries {
shouldVisitNames = true; shouldVisitNames = true;
this.refs = new IASTName[DEFAULT_LIST_SIZE]; this.refs = new IASTName[DEFAULT_LIST_SIZE];
binding = CPPTemplates.findDeclarationForSpecialization(binding); binding = unwindBinding(binding);
this.bindings = new IBinding[] {binding}; this.bindings = new IBinding[] {binding};
if (binding instanceof ICPPUsingDeclaration) { if (binding instanceof ICPPUsingDeclaration) {
@ -1526,7 +1537,7 @@ public class CPPVisitor extends ASTQueries {
} }
private boolean isReferenceBinding(IBinding nameBinding) { private boolean isReferenceBinding(IBinding nameBinding) {
nameBinding = CPPTemplates.findDeclarationForSpecialization(nameBinding); nameBinding= unwindBinding(nameBinding);
if (nameBinding != null) { if (nameBinding != null) {
for (IBinding binding : bindings) { for (IBinding binding : bindings) {
if (nameBinding.equals(binding)) { if (nameBinding.equals(binding)) {
@ -1590,6 +1601,32 @@ public class CPPVisitor extends ASTQueries {
return new CPPFunctionType(returnType, pTypes, isConst, isVolatile, false); return new CPPFunctionType(returnType, pTypes, isConst, isVolatile, false);
} }
/**
* Creates the type for the given type id.
*/
public static IType createType(IASTTypeId typeid) {
return createType(typeid.getAbstractDeclarator());
}
/**
* Creates the type for a parameter declaration.
*/
public static IType createType(final ICPPASTParameterDeclaration pdecl, boolean forFuncType) {
IType pt;
IASTDeclSpecifier pDeclSpec = pdecl.getDeclSpecifier();
ICPPASTDeclarator pDtor = pdecl.getDeclarator();
pt = createType(pDeclSpec);
if (pDtor != null) {
pt = createType(pt, pDtor);
}
pt= adjustParameterType(pt, forFuncType);
if (pDtor != null && CPPVisitor.findInnermostDeclarator(pDtor).declaresParameterPack()) {
pt= new CPPParameterPackType(pt);
}
return pt;
}
private static IType createType(IType returnType, ICPPASTFunctionDeclarator fnDtor) { private static IType createType(IType returnType, ICPPASTFunctionDeclarator fnDtor) {
IType[] pTypes = createParameterTypes(fnDtor); IType[] pTypes = createParameterTypes(fnDtor);
@ -1613,33 +1650,18 @@ public class CPPVisitor extends ASTQueries {
return type; return type;
} }
/**
* Creates an array of types for the parameters of the given function declarator.
*/
public static IType[] createParameterTypes(ICPPASTFunctionDeclarator fnDtor) { public static IType[] createParameterTypes(ICPPASTFunctionDeclarator fnDtor) {
ICPPASTParameterDeclaration[] params = fnDtor.getParameters(); ICPPASTParameterDeclaration[] params = fnDtor.getParameters();
IType[] pTypes = new IType[params.length]; IType[] pTypes = new IType[params.length];
for (int i = 0; i < params.length; i++) { for (int i = 0; i < params.length; i++) {
pTypes[i]= createParameterType(params[i], true); pTypes[i]= createType(params[i], true);
} }
return pTypes; return pTypes;
} }
/**
* Creates the type for a parameter declaration.
*/
public static IType createParameterType(final ICPPASTParameterDeclaration pdecl, boolean forFuncType) {
IType pt;
IASTDeclSpecifier pDeclSpec = pdecl.getDeclSpecifier();
ICPPASTDeclarator pDtor = pdecl.getDeclarator();
pt = createType(pDeclSpec);
if (pDtor != null) {
pt = createType(pt, pDtor);
}
pt= adjustParameterType(pt, forFuncType);
if (pt != null && CPPVisitor.findInnermostDeclarator(pDtor).declaresParameterPack()) {
pt= new CPPParameterPackType(pt);
}
return pt;
}
/** /**
* Adjusts the parameter type according to 8.3.5-3: * Adjusts the parameter type according to 8.3.5-3:
@ -1693,21 +1715,9 @@ public class CPPVisitor extends ASTQueries {
return type; return type;
} }
public static IType createType(IASTNode node) {
if (node == null)
return null;
if (node instanceof IASTExpression)
return ((IASTExpression) node).getExpressionType();
if (node instanceof IASTTypeId)
return createType(((IASTTypeId) node).getAbstractDeclarator());
if (node instanceof IASTParameterDeclaration)
return createType(((IASTParameterDeclaration) node).getDeclarator());
return null;
}
public static IType createType(IASTDeclarator declarator) { public static IType createType(IASTDeclarator declarator) {
if (declarator == null) if (declarator == null)
return null; return new ProblemType(ISemanticProblem.TYPE_NO_NAME);
declarator= findOutermostDeclarator(declarator); declarator= findOutermostDeclarator(declarator);
IASTNode parent = declarator.getParent(); IASTNode parent = declarator.getParent();
@ -1723,8 +1733,7 @@ public class CPPVisitor extends ASTQueries {
declSpec = typeId.getDeclSpecifier(); declSpec = typeId.getDeclSpecifier();
isPackExpansion= typeId.isPackExpansion(); isPackExpansion= typeId.isPackExpansion();
} else { } else {
assert false; throw new IllegalArgumentException();
return null;
} }
IASTNode initClause= declarator.getInitializer(); IASTNode initClause= declarator.getInitializer();
@ -1748,7 +1757,7 @@ public class CPPVisitor extends ASTQueries {
} else if (parent instanceof IASTCompositeTypeSpecifier && } else if (parent instanceof IASTCompositeTypeSpecifier &&
declSpec.getStorageClass() != IASTDeclSpecifier.sc_static) { declSpec.getStorageClass() != IASTDeclSpecifier.sc_static) {
// Non-static auto-typed class members are not allowed. // Non-static auto-typed class members are not allowed.
return null; return new ProblemType(ISemanticProblem.TYPE_AUTO_FOR_NON_STATIC_FIELD);
} }
return createAutoType(initClause, declSpec, declarator); return createAutoType(initClause, declSpec, declarator);
} }
@ -1767,7 +1776,7 @@ public class CPPVisitor extends ASTQueries {
} }
} }
if (type != null && isPackExpansion) { if (isPackExpansion) {
type= new CPPParameterPackType(type); type= new CPPParameterPackType(type);
} }
return type; return type;
@ -1777,7 +1786,7 @@ public class CPPVisitor extends ASTQueries {
// C++0x: 7.1.6.4 // C++0x: 7.1.6.4
if (!autoTypeDeclSpecs.get().add(declSpec)) { if (!autoTypeDeclSpecs.get().add(declSpec)) {
// Detected a self referring auto type, e.g.: auto x = x; // Detected a self referring auto type, e.g.: auto x = x;
return null; return new ProblemType(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE);
} }
IType type = AutoTypeResolver.AUTO_TYPE; IType type = AutoTypeResolver.AUTO_TYPE;
@ -1788,10 +1797,13 @@ public class CPPVisitor extends ASTQueries {
if (initClause instanceof ICPPASTInitializerList) { if (initClause instanceof ICPPASTInitializerList) {
initializer_list_template = get_initializer_list(declSpec); initializer_list_template = get_initializer_list(declSpec);
if (initializer_list_template == null) { if (initializer_list_template == null) {
return null; return new ProblemType(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE);
} }
type = (IType) CPPTemplates.instantiate(initializer_list_template, type = (IType) CPPTemplates.instantiate(initializer_list_template,
new ICPPTemplateArgument[] { new CPPTemplateArgument(type) }, true); new ICPPTemplateArgument[] { new CPPTemplateArgument(type) }, true);
if (type instanceof IProblemBinding) {
return new ProblemType(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE);
}
} }
type = decorateType(type, declSpec, declarator); type = decorateType(type, declSpec, declarator);
@ -1803,7 +1815,7 @@ public class CPPVisitor extends ASTQueries {
initType = new InitializerListType((ICPPASTInitializerList) initClause); initType = new InitializerListType((ICPPASTInitializerList) initClause);
} }
if (initType == null) { if (initType == null) {
return null; return new ProblemType(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE);
} }
} finally { } finally {
autoTypeDeclSpecs.get().remove(declSpec); autoTypeDeclSpecs.get().remove(declSpec);
@ -1814,7 +1826,7 @@ public class CPPVisitor extends ASTQueries {
Collections.singletonList(valueCat), paramMap); Collections.singletonList(valueCat), paramMap);
ICPPTemplateArgument argument = paramMap.getArgument(0, 0); ICPPTemplateArgument argument = paramMap.getArgument(0, 0);
if (argument == null) { if (argument == null) {
return null; return new ProblemType(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE);
} }
type = argument.getTypeValue(); type = argument.getTypeValue();
if (initClause instanceof ICPPASTInitializerList) { if (initClause instanceof ICPPASTInitializerList) {
@ -1830,7 +1842,8 @@ public class CPPVisitor extends ASTQueries {
private static IType createAutoFunctionType(IASTDeclSpecifier declSpec, ICPPASTFunctionDeclarator declarator) { private static IType createAutoFunctionType(IASTDeclSpecifier declSpec, ICPPASTFunctionDeclarator declarator) {
IASTTypeId id= declarator.getTrailingReturnType(); IASTTypeId id= declarator.getTrailingReturnType();
if (id == null) if (id == null)
return null; return new ProblemType(ISemanticProblem.TYPE_NO_NAME);
IType t= createType(id.getAbstractDeclarator()); IType t= createType(id.getAbstractDeclarator());
t= qualifyType(t, declSpec); t= qualifyType(t, declSpec);
return createType(t, declarator); return createType(t, declarator);
@ -1838,15 +1851,11 @@ public class CPPVisitor extends ASTQueries {
public static IType createType(IASTDeclSpecifier declSpec) { public static IType createType(IASTDeclSpecifier declSpec) {
IType type = getBaseType(declSpec); IType type = getBaseType(declSpec);
if (type == null) {
return null;
}
return qualifyType(type, declSpec); return qualifyType(type, declSpec);
} }
private static IType getBaseType(IASTDeclSpecifier declSpec) { private static IType getBaseType(IASTDeclSpecifier declSpec) {
IType type = null; IASTName name;
IASTName name = null;
if (declSpec instanceof ICPPASTCompositeTypeSpecifier) { if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
name = ((ICPPASTCompositeTypeSpecifier) declSpec).getName(); name = ((ICPPASTCompositeTypeSpecifier) declSpec).getName();
} else if (declSpec instanceof ICPPASTNamedTypeSpecifier) { } else if (declSpec instanceof ICPPASTNamedTypeSpecifier) {
@ -1858,50 +1867,36 @@ public class CPPVisitor extends ASTQueries {
} else if (declSpec instanceof ICPPASTSimpleDeclSpecifier) { } else if (declSpec instanceof ICPPASTSimpleDeclSpecifier) {
ICPPASTSimpleDeclSpecifier spec = (ICPPASTSimpleDeclSpecifier) declSpec; ICPPASTSimpleDeclSpecifier spec = (ICPPASTSimpleDeclSpecifier) declSpec;
// Check for decltype(expr) // Check for decltype(expr)
type = getDeclType(spec); IType type = getDeclType(spec);
if (type == null && spec.getType() != IASTSimpleDeclSpecifier.t_auto) { if (type != null)
type = new CPPBasicType(spec); return type;
} return new CPPBasicType(spec);
} else {
throw new IllegalArgumentException();
} }
if (name != null) { if (name == null)
IBinding binding = name.resolvePreBinding(); return new ProblemType(ISemanticProblem.TYPE_NO_NAME);
if (binding instanceof ICPPConstructor) {
type= ((ICPPConstructor) binding).getClassOwner(); IBinding binding = name.resolvePreBinding();
} else if (binding instanceof IType) { if (!(binding instanceof IProblemBinding)) {
type = (IType) binding; if (binding instanceof ICPPConstructor)
} else if (binding instanceof ICPPTemplateNonTypeParameter) { return ((ICPPConstructor) binding).getClassOwner();
//TODO workaround... is there anything better?
try { if (binding instanceof IType)
type = ((ICPPTemplateNonTypeParameter) binding).getType(); return (IType) binding;
} catch (DOMException e) { }
type = e.getProblem(); return new ProblemType(ISemanticProblem.TYPE_UNRESOLVED_NAME);
}
} else if (binding instanceof IVariable) {
//this is to help with the ambiguity between typeid & idexpression in template arguments
try {
type = ((IVariable) binding).getType();
} catch (DOMException e) {
type = e.getProblem();
}
}
}
return type;
} }
private static IType decorateType(IType type, IASTDeclSpecifier declSpec, IASTDeclarator declarator) { private static IType decorateType(IType type, IASTDeclSpecifier declSpec, IASTDeclarator declarator) {
type = qualifyType(type, declSpec); type = qualifyType(type, declSpec);
type = createType(type, declarator); return createType(type, declarator);
return type;
} }
private static IType qualifyType(IType type, IASTDeclSpecifier declSpec) { private static IType qualifyType(IType type, IASTDeclSpecifier declSpec) {
return SemanticUtil.addQualifiers(type, declSpec.isConst(), declSpec.isVolatile()); return SemanticUtil.addQualifiers(type, declSpec.isConst(), declSpec.isVolatile());
} }
/**
* @param declarator
* @return
*/
private static IType createType(IType baseType, IASTDeclarator declarator) { private static IType createType(IType baseType, IASTDeclarator declarator) {
if (declarator instanceof ICPPASTFunctionDeclarator) if (declarator instanceof ICPPASTFunctionDeclarator)
return createType(baseType, (ICPPASTFunctionDeclarator) declarator); return createType(baseType, (ICPPASTFunctionDeclarator) declarator);

View file

@ -521,7 +521,7 @@ public class LookupData {
ICPPASTParameterDeclaration[] pdecls= functionParameters; ICPPASTParameterDeclaration[] pdecls= functionParameters;
functionArgTypes= new IType[pdecls.length]; functionArgTypes= new IType[pdecls.length];
for (int i = 0; i < pdecls.length; i++) { for (int i = 0; i < pdecls.length; i++) {
functionArgTypes[i] = SemanticUtil.getSimplifiedType(CPPVisitor.createParameterType( functionArgTypes[i] = SemanticUtil.getSimplifiedType(CPPVisitor.createType(
pdecls[i], true)); pdecls[i], true));
} }
} }

View file

@ -73,8 +73,14 @@ public class ParserMessages {
return null; return null;
} }
@SuppressWarnings("nls")
private static String getProblemKey(int id) { private static String getProblemKey(int id) {
switch(id) { switch(id) {
case ISemanticProblem.TYPE_NO_NAME: return "ISemanticProblem.TYPE_NO_NAME";
case ISemanticProblem.TYPE_UNRESOLVED_NAME: return "ISemanticProblem.TYPE_UNRESOLVED_NAME";
case ISemanticProblem.TYPE_AUTO_FOR_NON_STATIC_FIELD: return "ISemanticProblem.TYPE_AUTO_FOR_NON_STATIC_FIELD";
case ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE: return "ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE";
case ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION: return "ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION";
} }
return null; return null;
} }

View file

@ -1,5 +1,5 @@
############################################################################### ###############################################################################
# Copyright (c) 2005, 2009 IBM Corporation and others. # Copyright (c) 2005, 2010 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials # All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0 # are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at # which accompanies this distribution, and is available at
@ -64,3 +64,11 @@ ASTProblemFactory.error.semantic.dom.recursionInResolution=Recursion while looki
ASTProblemFactory.error.semantic.dom.badScope=A scope could not be created to represent the name {0} ASTProblemFactory.error.semantic.dom.badScope=A scope could not be created to represent the name {0}
ASTProblemFactory.error.semantic.dom.memberDeclNotFound=A declaration could not be found for this member definition: {0} ASTProblemFactory.error.semantic.dom.memberDeclNotFound=A declaration could not be found for this member definition: {0}
ASTProblemFactory.error.semantic.dom.invalidTemplateArgs=A template id provides illegal arguments for the instantiation: {0} ASTProblemFactory.error.semantic.dom.invalidTemplateArgs=A template id provides illegal arguments for the instantiation: {0}
ISemanticProblem.TYPE_NO_NAME=Type specification lacks a name
ISemanticProblem.TYPE_UNRESOLVED_NAME=Type depends on an unresolved name
ISemanticProblem.TYPE_AUTO_FOR_NON_STATIC_FIELD=Illegally auto-typed static field
ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE=Failure to determine auto-type
ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION=Failure to determine type of expression

View file

@ -27,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.c.CArrayType; import org.eclipse.cdt.internal.core.dom.parser.c.CArrayType;
import org.eclipse.cdt.internal.core.dom.parser.c.CBasicType; import org.eclipse.cdt.internal.core.dom.parser.c.CBasicType;
import org.eclipse.cdt.internal.core.dom.parser.c.CFunctionType; import org.eclipse.cdt.internal.core.dom.parser.c.CFunctionType;
@ -345,6 +346,8 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
return CFunctionType.unmarshal(firstByte, buffer); return CFunctionType.unmarshal(firstByte, buffer);
case ITypeMarshalBuffer.POINTER: case ITypeMarshalBuffer.POINTER:
return CPointerType.unmarshal(firstByte, buffer); return CPointerType.unmarshal(firstByte, buffer);
case ITypeMarshalBuffer.PROBLEM_TYPE:
return ProblemType.unmarshal(firstByte, buffer);
} }
throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal a type, first byte=" + firstByte)); //$NON-NLS-1$ throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal a type, first byte=" + firstByte)); //$NON-NLS-1$

View file

@ -69,6 +69,7 @@ import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArrayType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArrayType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClosureType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClosureType;
@ -1026,6 +1027,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
return CPPFunctionType.unmarshal(firstByte, buffer); return CPPFunctionType.unmarshal(firstByte, buffer);
case ITypeMarshalBuffer.POINTER: case ITypeMarshalBuffer.POINTER:
return CPPPointerType.unmarshal(firstByte, buffer); return CPPPointerType.unmarshal(firstByte, buffer);
case ITypeMarshalBuffer.PROBLEM_TYPE:
return ProblemType.unmarshal(firstByte, buffer);
case ITypeMarshalBuffer.REFERENCE: case ITypeMarshalBuffer.REFERENCE:
return CPPReferenceType.unmarshal(firstByte, buffer); return CPPReferenceType.unmarshal(firstByte, buffer);
case ITypeMarshalBuffer.PACK_EXPANSION: case ITypeMarshalBuffer.PACK_EXPANSION: