mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 01:15:29 +02:00
Bug 312423: Replace null-types with problem types.
This commit is contained in:
parent
d03bee7bc7
commit
9ed8866605
46 changed files with 274 additions and 211 deletions
|
@ -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.IPointerType;
|
||||
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.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
|
@ -8409,9 +8411,11 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
ICPPVariable t= bh.assertNonProblem("t =", 1);
|
||||
assertEquals("std::initializer_list<double> *", ASTTypeUtil.getType(t.getType()));
|
||||
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);
|
||||
assertNull(y.getType());
|
||||
pt= (IProblemType) y.getType();
|
||||
assertEquals(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE, pt.getID());
|
||||
}
|
||||
|
||||
// auto x = x; // Self referring type.
|
||||
|
@ -8419,7 +8423,8 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
String code= getAboveComment();
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
|
||||
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.
|
||||
|
@ -8428,7 +8433,8 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
String code= getAboveComment();
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* 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.IPointerType;
|
||||
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.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
|
@ -1569,8 +1571,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
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$
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
|
@ -1589,7 +1590,8 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
assertNotNull( p );
|
||||
assertNotNull( p2 );
|
||||
|
||||
assertSame( anA.getType(), p );
|
||||
IProblemType pt= (IProblemType) anA.getType();
|
||||
assertEquals(ISemanticProblem.TYPE_UNRESOLVED_NAME, pt.getID());
|
||||
}
|
||||
|
||||
public void testBug44340() throws Exception {
|
||||
|
|
|
@ -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.IFunctionType;
|
||||
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.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
|
@ -2211,7 +2212,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
tu = TestSourceReader.createIndexBasedAST(index, fCProject, s2);
|
||||
sdecl= (IASTSimpleDeclaration) tu.getDeclarations()[0];
|
||||
var= (IVariable) sdecl.getDeclarators()[0].getName().resolveBinding();
|
||||
assertTrue(var.getType() instanceof IProblemBinding);
|
||||
assertTrue(var.getType() instanceof ISemanticProblem);
|
||||
} finally {
|
||||
index.releaseReadLock();
|
||||
}
|
||||
|
|
|
@ -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.IBinding;
|
||||
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.ITypedef;
|
||||
import org.eclipse.cdt.core.index.IndexFilter;
|
||||
|
@ -85,17 +85,17 @@ public class PDOMCBugsTest extends BaseTestCase {
|
|||
assertEquals(7, bindings.length);
|
||||
Set bnames= new HashSet();
|
||||
for (IBinding binding : bindings) {
|
||||
final String name = binding.getName();
|
||||
bnames.add(name);
|
||||
assertTrue("expected typedef, got "+binding, binding instanceof ITypedef);
|
||||
bnames.add(binding.getName());
|
||||
IType type= SemanticUtil.getUltimateType((IType)binding, false);
|
||||
|
||||
if(binding.getName().equals("J")) {
|
||||
if (name.equals("J")) {
|
||||
// for plain C the second J has to be interpreted as a (useless) parameter name.
|
||||
assertTrue(type instanceof IFunctionType);
|
||||
IFunctionType ft= (IFunctionType) type;
|
||||
assertEquals("int (int)", ASTTypeUtil.getType(ft));
|
||||
} else {
|
||||
assertTrue("expected ITypedef, got "+type, type == null || type instanceof ITypedef || type instanceof IPointerType);
|
||||
assertTrue(type instanceof IProblemType);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,11 @@ package org.eclipse.cdt.core.dom.ast;
|
|||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
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.
|
||||
|
|
|
@ -26,6 +26,7 @@ public interface ITypeMarshalBuffer {
|
|||
final static byte REFERENCE= 6;
|
||||
final static byte POINTER_TO_MEMBER= 7;
|
||||
final static byte PACK_EXPANSION= 8;
|
||||
final static byte PROBLEM_TYPE= 9;
|
||||
static final byte KIND_MASK = 0xf;
|
||||
|
||||
final static int FLAG1 = 0x10;
|
||||
|
|
|
@ -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.IType;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserMessages;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of problem types.
|
||||
*/
|
||||
public class ProblemType implements IProblemType {
|
||||
public class ProblemType implements IProblemType, ISerializableType {
|
||||
private final int fID;
|
||||
|
||||
public ProblemType(int id) {
|
||||
|
@ -45,4 +46,13 @@ public class ProblemType implements IProblemType {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.IASTExpressionStatement;
|
||||
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.gnu.IGNUASTCompoundStatementExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
|
||||
/**
|
||||
* Compound statement for c
|
||||
|
@ -83,7 +85,7 @@ public class CASTCompoundStatementExpression extends ASTNode implements IGNUASTC
|
|||
if (st instanceof IASTExpressionStatement)
|
||||
return ((IASTExpressionStatement)st).getExpression().getExpressionType();
|
||||
}
|
||||
return null;
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
|
||||
public boolean isLValue() {
|
||||
|
|
|
@ -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.IASTExpressionList;
|
||||
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.parser.util.ArrayUtil;
|
||||
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.ProblemType;
|
||||
|
||||
/**
|
||||
* Expression list in C
|
||||
|
@ -100,7 +102,7 @@ public class CASTExpressionList extends ASTNode implements IASTExpressionList,
|
|||
if (expr != null)
|
||||
return expr.getExpressionType();
|
||||
}
|
||||
return null;
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
|
||||
public boolean isLValue() {
|
||||
|
|
|
@ -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.IASTNode;
|
||||
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.IVariable;
|
||||
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.ProblemType;
|
||||
|
||||
/**
|
||||
* Field reference in C.
|
||||
|
@ -141,7 +143,7 @@ public class CASTFieldReference extends ASTNode implements IASTFieldReference, I
|
|||
return e.getProblem();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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.IASTNode;
|
||||
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.internal.core.dom.parser.ASTNode;
|
||||
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.ProblemType;
|
||||
|
||||
/**
|
||||
* Function call expression in C.
|
||||
|
@ -133,7 +135,7 @@ public class CASTFunctionCallExpression extends ASTNode implements
|
|||
type = ((ITypeContainer) type).getType();
|
||||
if (type instanceof IFunctionType)
|
||||
return ((IFunctionType) type).getReturnType();
|
||||
return null;
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
|
||||
public boolean isLValue() {
|
||||
|
|
|
@ -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.IFunction;
|
||||
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.IVariable;
|
||||
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.ProblemType;
|
||||
|
||||
/**
|
||||
* ID Expression in C.
|
||||
|
@ -103,12 +105,12 @@ public class CASTIdExpression extends ASTNode implements IASTIdExpression, IASTC
|
|||
return ((IEnumerator)binding).getType();
|
||||
}
|
||||
if (binding instanceof IProblemBinding) {
|
||||
return (IProblemBinding)binding;
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNRESOLVED_NAME);
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
return e.getProblem();
|
||||
}
|
||||
return null;
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
|
||||
public boolean isLValue() {
|
||||
|
|
|
@ -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.IBasicType;
|
||||
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.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
|
||||
/**
|
||||
* Represents a literal
|
||||
|
@ -97,7 +99,7 @@ public class CASTLiteralExpression extends ASTNode implements IASTLiteralExpress
|
|||
type = new CQualifierType(type, true, false, false);
|
||||
return new CPointerType(type, 0);
|
||||
}
|
||||
return null;
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
|
||||
public boolean isLValue() {
|
||||
|
|
|
@ -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.IASTProblem;
|
||||
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.internal.core.dom.parser.ProblemType;
|
||||
|
||||
public class CASTProblemExpression extends CASTProblemOwner implements IASTProblemExpression {
|
||||
|
||||
|
@ -54,7 +56,7 @@ public class CASTProblemExpression extends CASTProblemOwner implements IASTProbl
|
|||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return null;
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
|
||||
public boolean isLValue() {
|
||||
|
|
|
@ -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.IProblemBinding;
|
||||
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.ITypedef;
|
||||
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.ITypeContainer;
|
||||
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.
|
||||
|
@ -1295,16 +1297,17 @@ public class CVisitor extends ASTQueries {
|
|||
} else if (declSpec instanceof IASTEnumerationSpecifier) {
|
||||
name = ((IASTEnumerationSpecifier)declSpec).getName();
|
||||
} 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();
|
||||
if (binding instanceof IType)
|
||||
if (binding instanceof IType && !(binding instanceof IProblemBinding))
|
||||
return (IType) binding;
|
||||
|
||||
if (binding != null)
|
||||
return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_TYPE, name.toCharArray());
|
||||
return new ProblemBinding(name, IProblemBinding.SEMANTIC_NAME_NOT_FOUND, name.toCharArray());
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNRESOLVED_NAME);
|
||||
}
|
||||
|
||||
public static IType createType(ICASTDeclSpecifier declSpec) {
|
||||
|
@ -1341,7 +1344,7 @@ public class CVisitor extends ASTQueries {
|
|||
}
|
||||
return parmTypes;
|
||||
} else {
|
||||
return null;
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* 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
|
||||
owner.replace(this, fParameterDecl);
|
||||
|
||||
IType t= CPPVisitor.createParameterType(fParameterDecl, true);
|
||||
IType t= CPPVisitor.createType(fParameterDecl, true);
|
||||
if (!(t instanceof ICPPParameterPackType) ||
|
||||
!CPPTemplates.containsParameterPack(((ICPPParameterPackType) t).getType())) {
|
||||
final ICPPASTDeclarator dtor = fParameterDecl.getDeclarator();
|
||||
|
|
|
@ -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.IASTNode;
|
||||
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.cpp.ICPPASTArraySubscriptExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
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.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.Conversions;
|
||||
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();
|
||||
}
|
||||
|
||||
// mstodo return problem type
|
||||
return null;
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
|
||||
public boolean isLValue() {
|
||||
|
|
|
@ -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.IBasicType.Kind;
|
||||
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.IType;
|
||||
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.internal.core.dom.parser.ASTNode;
|
||||
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.CPPVisitor;
|
||||
|
||||
|
@ -337,7 +336,6 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
|
|||
if (type2 instanceof IPointerType) {
|
||||
return type2;
|
||||
}
|
||||
// mstodo problem type
|
||||
break;
|
||||
|
||||
case IASTBinaryExpression.op_minus:
|
||||
|
@ -347,7 +345,6 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
|
|||
}
|
||||
return type1;
|
||||
}
|
||||
// mstodo problem type
|
||||
break;
|
||||
|
||||
case ICPPASTBinaryExpression.op_pmarrow:
|
||||
|
@ -361,7 +358,7 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
|
|||
}
|
||||
return glvalueType(t);
|
||||
}
|
||||
return new ProblemBinding(this, IProblemBinding.SEMANTIC_INVALID_TYPE, getRawSignature().toCharArray());
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
return type1;
|
||||
}
|
||||
|
|
|
@ -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.IASTExpressionStatement;
|
||||
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.gnu.IGNUASTCompoundStatementExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
|
||||
/**
|
||||
* Gnu-extension: ({ ... })
|
||||
|
@ -87,7 +89,7 @@ public class CPPASTCompoundStatementExpression extends ASTNode implements IGNUAS
|
|||
if (st instanceof IASTExpressionStatement)
|
||||
return prvalueType(((IASTExpressionStatement) st).getExpression().getExpressionType());
|
||||
}
|
||||
return null;
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
|
||||
public boolean isLValue() {
|
||||
|
|
|
@ -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.IASTUnaryExpression;
|
||||
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.IType;
|
||||
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.internal.core.dom.parser.ASTNode;
|
||||
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.CVQualifier;
|
||||
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 t3 = expr3.getExpressionType();
|
||||
if (t2 == null || t3 == null)
|
||||
if (t2 == null || t3 == null) {
|
||||
fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
return;
|
||||
}
|
||||
|
||||
final IType uqt2= getNestedType(t2, 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) {
|
||||
fType= uqt2;
|
||||
} else {
|
||||
createProblem();
|
||||
fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -238,10 +239,10 @@ public class CPPASTConditionalExpression extends ASTNode implements IASTConditio
|
|||
if (cost2.converts() || cost3.converts()) {
|
||||
if (cost2.converts()) {
|
||||
if (cost3.converts() || cost2.isAmbiguousUDC()) {
|
||||
fType= createProblem();
|
||||
fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
} else if (cost3.isAmbiguousUDC()) {
|
||||
fType= createProblem();
|
||||
fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -256,7 +257,7 @@ public class CPPASTConditionalExpression extends ASTNode implements IASTConditio
|
|||
fType= t3;
|
||||
fValueCategory= vcat3;
|
||||
} else {
|
||||
createProblem();
|
||||
fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -266,8 +267,9 @@ public class CPPASTConditionalExpression extends ASTNode implements IASTConditio
|
|||
ICPPFunction builtin = CPPSemantics.findOverloadedConditionalOperator(expr2, expr3);
|
||||
if (builtin != null) {
|
||||
fType= ExpressionTypes.typeFromFunctionCall(builtin);
|
||||
} else {
|
||||
fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
createProblem();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -281,7 +283,7 @@ public class CPPASTConditionalExpression extends ASTNode implements IASTConditio
|
|||
if (fType == null) {
|
||||
fType= Conversions.compositePointerType(t2, t3);
|
||||
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;
|
||||
}
|
||||
|
||||
private ProblemBinding createProblem() {
|
||||
return new ProblemBinding(this, IProblemBinding.SEMANTIC_INVALID_TYPE, this.getRawSignature().toCharArray());
|
||||
}
|
||||
|
||||
private boolean isVoidType(IType t) {
|
||||
return t instanceof ICPPBasicType && ((ICPPBasicType) t).getKind() == Kind.eVoid;
|
||||
}
|
||||
|
|
|
@ -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.IASTImplicitName;
|
||||
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.cpp.ICPPASTConstructorChainInitializer;
|
||||
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.internal.core.dom.parser.ASTNode;
|
||||
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;
|
||||
|
||||
|
||||
|
@ -205,7 +207,8 @@ public class CPPASTExpressionList extends ASTNode implements ICPPASTExpressionLi
|
|||
if (expr != null)
|
||||
return expr.getExpressionType();
|
||||
}
|
||||
return null;
|
||||
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
|
||||
public ValueCategory getValueCategory() {
|
||||
|
|
|
@ -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.IPointerType;
|
||||
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.IVariable;
|
||||
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.internal.core.dom.parser.ASTNode;
|
||||
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.CVQualifier;
|
||||
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();
|
||||
}
|
||||
if (binding instanceof IProblemBinding) {
|
||||
return (IType) binding;
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNRESOLVED_NAME);
|
||||
}
|
||||
// mstodo problem type.
|
||||
return null;
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
} catch (DOMException e) {
|
||||
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);
|
||||
if (field.isMutable()) {
|
||||
// Remove const, add union of volatile.
|
||||
|
|
|
@ -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.IPointerType;
|
||||
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.cpp.ICPPASTExpressionList;
|
||||
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.internal.core.dom.parser.ASTNode;
|
||||
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.SemanticUtil;
|
||||
|
||||
|
@ -222,10 +223,10 @@ public class CPPASTFunctionCallExpression extends ASTNode implements
|
|||
if (owner instanceof ICPPClassType) {
|
||||
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) {
|
||||
return (IProblemBinding) binding;
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNRESOLVED_NAME);
|
||||
}
|
||||
if (binding instanceof IType) {
|
||||
return prvalueType((IType) binding);
|
||||
|
@ -240,8 +241,7 @@ public class CPPASTFunctionCallExpression extends ASTNode implements
|
|||
if (overload != null) {
|
||||
return typeFromFunctionCall(overload);
|
||||
}
|
||||
// mstodo problem type
|
||||
return null;
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
|
||||
if (t instanceof IPointerType) {
|
||||
|
@ -251,8 +251,7 @@ public class CPPASTFunctionCallExpression extends ASTNode implements
|
|||
return typeFromReturnType(((IFunctionType) t).getReturnType());
|
||||
}
|
||||
|
||||
// mstodo problem type
|
||||
return null;
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
|
||||
public boolean isLValue() {
|
||||
|
|
|
@ -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.IFunction;
|
||||
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.IVariable;
|
||||
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.parser.util.CharArrayUtils;
|
||||
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.CPPSemantics;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
@ -117,11 +119,10 @@ public class CPPASTIdExpression extends ASTNode implements IASTIdExpression, ICP
|
|||
}
|
||||
try {
|
||||
if (binding instanceof IProblemBinding) {
|
||||
return (IProblemBinding) binding;
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNRESOLVED_NAME);
|
||||
}
|
||||
if (binding instanceof IType || binding instanceof ICPPConstructor) {
|
||||
// mstodo return problem type
|
||||
return null;
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
if (binding instanceof IEnumerator) {
|
||||
IType type= ((IEnumerator) binding).getType();
|
||||
|
@ -157,8 +158,7 @@ public class CPPASTIdExpression extends ASTNode implements IASTIdExpression, ICP
|
|||
} catch (DOMException e) {
|
||||
return e.getProblem();
|
||||
}
|
||||
// mstodo return problem type
|
||||
return null;
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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.Kind;
|
||||
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.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression;
|
||||
|
||||
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.ProblemType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
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);
|
||||
IType type= CPPVisitor.getImpliedObjectType(scope);
|
||||
if (type == null) {
|
||||
// mstodo problem type
|
||||
return null;
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNRESOLVED_NAME);
|
||||
}
|
||||
return new CPPPointerType(type);
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx
|
|||
type = new CPPQualifierType(type, true, false);
|
||||
return new CPPArrayType(type, getStringLiteralSize());
|
||||
}
|
||||
return null;
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
|
||||
public boolean isLValue() {
|
||||
|
|
|
@ -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.ICPPASTNewExpression;
|
||||
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.ASTQueries;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
@ -161,8 +160,15 @@ public class CPPASTNewExpression extends ASTNode implements ICPPASTNewExpression
|
|||
* @since 5.1
|
||||
*/
|
||||
public boolean isArrayAllocation() {
|
||||
IType t = CPPVisitor.createType(getTypeId());
|
||||
return t instanceof IArrayType;
|
||||
IASTTypeId typeId= getTypeId();
|
||||
if (typeId != null) {
|
||||
IASTDeclarator dtor= typeId.getAbstractDeclarator();
|
||||
if (dtor != null) {
|
||||
dtor= ASTQueries.findTypeRelevantDeclarator(dtor);
|
||||
return dtor instanceof IASTArrayDeclarator;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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.IASTProblem;
|
||||
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.internal.core.dom.parser.ProblemType;
|
||||
|
||||
public class CPPASTProblemExpression extends CPPASTProblemOwner implements IASTProblemExpression {
|
||||
|
||||
|
@ -53,7 +55,7 @@ public class CPPASTProblemExpression extends CPPASTProblemOwner implements IASTP
|
|||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return null;
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
|
||||
public boolean isLValue() {
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -128,9 +128,9 @@ public class CPPASTTemplateId extends CPPASTNameBase implements ICPPASTTemplateI
|
|||
buf.append(arg.getRawSignature());
|
||||
cleanupWhitespace= true;
|
||||
}
|
||||
} else {
|
||||
IType type= CPPVisitor.createType(arg);
|
||||
if (type == null || type instanceof ISemanticProblem) {
|
||||
} else if (arg instanceof IASTTypeId){
|
||||
IType type= CPPVisitor.createType((IASTTypeId) arg);
|
||||
if (type instanceof ISemanticProblem) {
|
||||
buf.append(arg.getRawSignature());
|
||||
} else {
|
||||
buf.append(ASTTypeUtil.getType(type, false));
|
||||
|
|
|
@ -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.ITypeContainer;
|
||||
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.CPPVisitor;
|
||||
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
|
||||
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();
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -29,18 +29,14 @@ public class CPPArrayType implements IArrayType, ITypeContainer, ISerializableTy
|
|||
private IASTExpression sizeExpression;
|
||||
private IValue value= Value.NOT_INITIALIZED;
|
||||
|
||||
public CPPArrayType(IType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public CPPArrayType(IType type, IValue value) {
|
||||
this.type= type;
|
||||
this.value= value;
|
||||
setType(type);
|
||||
}
|
||||
|
||||
|
||||
public CPPArrayType(IType type, IASTExpression sizeExp) {
|
||||
this.type = type;
|
||||
this.sizeExpression = sizeExp;
|
||||
this.sizeExpression = sizeExp;
|
||||
setType(type);
|
||||
}
|
||||
|
||||
public IType getType() {
|
||||
|
@ -48,6 +44,7 @@ public class CPPArrayType implements IArrayType, ITypeContainer, ISerializableTy
|
|||
}
|
||||
|
||||
public void setType(IType t) {
|
||||
assert t != null;
|
||||
this.type = t;
|
||||
}
|
||||
|
||||
|
|
|
@ -135,10 +135,7 @@ public class CPPClosureType extends PlatformObject implements ICPPClassType, ICP
|
|||
if (lambdaDtor != null) {
|
||||
IASTTypeId trailingReturnType = lambdaDtor.getTrailingReturnType();
|
||||
if (trailingReturnType != null) {
|
||||
IType type= CPPVisitor.createType(trailingReturnType);
|
||||
if (type != null)
|
||||
return type;
|
||||
return CPPSemantics.VOID_TYPE;
|
||||
return CPPVisitor.createType(trailingReturnType);
|
||||
}
|
||||
}
|
||||
IASTCompoundStatement body = fLambdaExpression.getBody();
|
||||
|
|
|
@ -59,7 +59,7 @@ public class CPPLambdaExpressionParameter extends PlatformObject implements ICPP
|
|||
IASTNode parent= fDeclaration.getParent();
|
||||
while (parent != null) {
|
||||
if (parent instanceof ICPPASTParameterDeclaration) {
|
||||
fType= CPPVisitor.createParameterType((ICPPASTParameterDeclaration) parent, false);
|
||||
fType= CPPVisitor.createType((ICPPASTParameterDeclaration) parent, false);
|
||||
break;
|
||||
}
|
||||
parent= parent.getParent();
|
||||
|
|
|
@ -151,7 +151,7 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
|
|||
IASTNode parent= fDeclarations[0].getParent();
|
||||
while (parent != null) {
|
||||
if (parent instanceof ICPPASTParameterDeclaration) {
|
||||
fType= CPPVisitor.createParameterType((ICPPASTParameterDeclaration) parent, false);
|
||||
fType= CPPVisitor.createType((ICPPASTParameterDeclaration) parent, false);
|
||||
break;
|
||||
}
|
||||
parent= parent.getParent();
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -33,6 +33,7 @@ public class CPPParameterPackType implements ICPPParameterPackType, ITypeContain
|
|||
}
|
||||
|
||||
public void setType(IType t) {
|
||||
assert t != null;
|
||||
fType= t;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* 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 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) {
|
||||
this.type = type;
|
||||
this.isConst = isConst;
|
||||
this.isVolatile = isVolatile;
|
||||
setType(type);
|
||||
}
|
||||
|
||||
public CPPPointerType(IType type, IASTPointer operator) {
|
||||
this(type, operator.isConst(), operator.isVolatile());
|
||||
}
|
||||
|
||||
public CPPPointerType(IType type) {
|
||||
this.type = type;
|
||||
this(type, false, false);
|
||||
}
|
||||
|
||||
public IType stripQualifiers() {
|
||||
|
@ -83,6 +81,7 @@ public class CPPPointerType implements IPointerType, ITypeContainer, ISerializab
|
|||
}
|
||||
|
||||
public void setType(IType t) {
|
||||
assert t != null;
|
||||
type = t;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -26,9 +26,9 @@ public class CPPQualifierType implements IQualifierType, ITypeContainer, ISerial
|
|||
private IType type;
|
||||
|
||||
public CPPQualifierType(IType type, boolean isConst, boolean isVolatile) {
|
||||
this.type = type;
|
||||
this.isConst = isConst;
|
||||
this.isVolatile = isVolatile;
|
||||
setType(type);
|
||||
}
|
||||
|
||||
public boolean isSameType(IType o) {
|
||||
|
@ -65,6 +65,7 @@ public class CPPQualifierType implements IQualifierType, ITypeContainer, ISerial
|
|||
}
|
||||
|
||||
public void setType(IType t) {
|
||||
assert t != null;
|
||||
type = t;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -43,6 +43,7 @@ public class CPPReferenceType implements ICPPReferenceType, ITypeContainer, ISer
|
|||
fIsRValue = fIsRValue && rt.isRValueReference();
|
||||
t= rt.getType();
|
||||
}
|
||||
assert t != null;
|
||||
fType= t;
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
|
|||
IASTNode parent= getPrimaryDeclaration().getParent();
|
||||
while (parent != null) {
|
||||
if (parent instanceof ICPPASTParameterDeclaration) {
|
||||
type= CPPVisitor.createParameterType((ICPPASTParameterDeclaration) parent, true);
|
||||
type= CPPVisitor.createType((ICPPASTParameterDeclaration) parent, true);
|
||||
break;
|
||||
}
|
||||
parent= parent.getParent();
|
||||
|
|
|
@ -2641,7 +2641,7 @@ public class CPPSemantics {
|
|||
private static IBinding resolveUserDefinedConversion(LookupData data, IFunction[] fns) {
|
||||
ICPPASTConversionName astName= (ICPPASTConversionName) data.astName;
|
||||
IType t= CPPVisitor.createType(astName.getTypeId());
|
||||
if (t == null) {
|
||||
if (t instanceof ISemanticProblem) {
|
||||
return new ProblemBinding(astName, IProblemBinding.SEMANTIC_INVALID_TYPE, data.getFoundBindings());
|
||||
}
|
||||
if (!data.forFunctionDeclaration() || data.forExplicitFunctionSpecialization()) {
|
||||
|
|
|
@ -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.IASTNode;
|
||||
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.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||
|
@ -1514,24 +1515,23 @@ public class CPPTemplates {
|
|||
* @param id the template id containing the template arguments
|
||||
* @return an array of template arguments, currently modeled as IType objects. The
|
||||
* 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;
|
||||
if (id != null) {
|
||||
IASTNode[] params= id.getTemplateArguments();
|
||||
result = new ICPPTemplateArgument[params.length];
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
IASTNode param= params[i];
|
||||
IType type= CPPVisitor.createType(param);
|
||||
if (type == null)
|
||||
throw new DOMException(new ProblemBinding(id, IProblemBinding.SEMANTIC_INVALID_TYPE));
|
||||
|
||||
if (param instanceof IASTExpression) {
|
||||
IValue value= Value.create((IASTExpression) param, Value.MAX_RECURSION_DEPTH);
|
||||
IASTNode[] args= id.getTemplateArguments();
|
||||
result = new ICPPTemplateArgument[args.length];
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
IASTNode arg= args[i];
|
||||
if (arg instanceof IASTTypeId) {
|
||||
result[i]= new CPPTemplateArgument(CPPVisitor.createType((IASTTypeId) arg));
|
||||
} else if (arg instanceof IASTExpression) {
|
||||
IASTExpression expr= (IASTExpression) arg;
|
||||
IType type= expr.getExpressionType();
|
||||
IValue value= Value.create((IASTExpression) arg, Value.MAX_RECURSION_DEPTH);
|
||||
result[i]= new CPPTemplateArgument(value, type);
|
||||
} else {
|
||||
result[i]= new CPPTemplateArgument(type);
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.IQualifierType;
|
||||
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.ITypedef;
|
||||
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.ICPPSpecialization;
|
||||
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.ICPPTemplateScope;
|
||||
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.ASTQueries;
|
||||
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.cpp.CPPASTTranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArrayType;
|
||||
|
@ -1264,7 +1265,6 @@ public class CPPVisitor extends ASTQueries {
|
|||
|
||||
|
||||
public CollectDeclarationsAction(IBinding binding) {
|
||||
binding = CPPTemplates.findDeclarationForSpecialization(binding);
|
||||
shouldVisitNames = true;
|
||||
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 {
|
||||
private static final int DEFAULT_LIST_SIZE = 8;
|
||||
private IASTName[] refs;
|
||||
|
@ -1428,7 +1439,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
shouldVisitNames = true;
|
||||
this.refs = new IASTName[DEFAULT_LIST_SIZE];
|
||||
|
||||
binding = CPPTemplates.findDeclarationForSpecialization(binding);
|
||||
binding = unwindBinding(binding);
|
||||
this.bindings = new IBinding[] {binding};
|
||||
|
||||
if (binding instanceof ICPPUsingDeclaration) {
|
||||
|
@ -1526,7 +1537,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
}
|
||||
|
||||
private boolean isReferenceBinding(IBinding nameBinding) {
|
||||
nameBinding = CPPTemplates.findDeclarationForSpecialization(nameBinding);
|
||||
nameBinding= unwindBinding(nameBinding);
|
||||
if (nameBinding != null) {
|
||||
for (IBinding binding : bindings) {
|
||||
if (nameBinding.equals(binding)) {
|
||||
|
@ -1589,7 +1600,33 @@ public class CPPVisitor extends ASTQueries {
|
|||
|
||||
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) {
|
||||
IType[] pTypes = createParameterTypes(fnDtor);
|
||||
|
||||
|
@ -1613,33 +1650,18 @@ public class CPPVisitor extends ASTQueries {
|
|||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array of types for the parameters of the given function declarator.
|
||||
*/
|
||||
public static IType[] createParameterTypes(ICPPASTFunctionDeclarator fnDtor) {
|
||||
ICPPASTParameterDeclaration[] params = fnDtor.getParameters();
|
||||
IType[] pTypes = new IType[params.length];
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
pTypes[i]= createParameterType(params[i], true);
|
||||
pTypes[i]= createType(params[i], true);
|
||||
}
|
||||
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:
|
||||
|
@ -1693,21 +1715,9 @@ public class CPPVisitor extends ASTQueries {
|
|||
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) {
|
||||
if (declarator == null)
|
||||
return null;
|
||||
return new ProblemType(ISemanticProblem.TYPE_NO_NAME);
|
||||
|
||||
declarator= findOutermostDeclarator(declarator);
|
||||
IASTNode parent = declarator.getParent();
|
||||
|
@ -1723,8 +1733,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
declSpec = typeId.getDeclSpecifier();
|
||||
isPackExpansion= typeId.isPackExpansion();
|
||||
} else {
|
||||
assert false;
|
||||
return null;
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
IASTNode initClause= declarator.getInitializer();
|
||||
|
@ -1748,7 +1757,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
} else if (parent instanceof IASTCompositeTypeSpecifier &&
|
||||
declSpec.getStorageClass() != IASTDeclSpecifier.sc_static) {
|
||||
// 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);
|
||||
}
|
||||
|
@ -1767,7 +1776,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
}
|
||||
}
|
||||
|
||||
if (type != null && isPackExpansion) {
|
||||
if (isPackExpansion) {
|
||||
type= new CPPParameterPackType(type);
|
||||
}
|
||||
return type;
|
||||
|
@ -1777,7 +1786,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
// C++0x: 7.1.6.4
|
||||
if (!autoTypeDeclSpecs.get().add(declSpec)) {
|
||||
// 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;
|
||||
|
@ -1788,10 +1797,13 @@ public class CPPVisitor extends ASTQueries {
|
|||
if (initClause instanceof ICPPASTInitializerList) {
|
||||
initializer_list_template = get_initializer_list(declSpec);
|
||||
if (initializer_list_template == null) {
|
||||
return null;
|
||||
return new ProblemType(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE);
|
||||
}
|
||||
type = (IType) CPPTemplates.instantiate(initializer_list_template,
|
||||
new ICPPTemplateArgument[] { new CPPTemplateArgument(type) }, true);
|
||||
if (type instanceof IProblemBinding) {
|
||||
return new ProblemType(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE);
|
||||
}
|
||||
}
|
||||
type = decorateType(type, declSpec, declarator);
|
||||
|
||||
|
@ -1803,7 +1815,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
initType = new InitializerListType((ICPPASTInitializerList) initClause);
|
||||
}
|
||||
if (initType == null) {
|
||||
return null;
|
||||
return new ProblemType(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE);
|
||||
}
|
||||
} finally {
|
||||
autoTypeDeclSpecs.get().remove(declSpec);
|
||||
|
@ -1814,7 +1826,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
Collections.singletonList(valueCat), paramMap);
|
||||
ICPPTemplateArgument argument = paramMap.getArgument(0, 0);
|
||||
if (argument == null) {
|
||||
return null;
|
||||
return new ProblemType(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE);
|
||||
}
|
||||
type = argument.getTypeValue();
|
||||
if (initClause instanceof ICPPASTInitializerList) {
|
||||
|
@ -1830,7 +1842,8 @@ public class CPPVisitor extends ASTQueries {
|
|||
private static IType createAutoFunctionType(IASTDeclSpecifier declSpec, ICPPASTFunctionDeclarator declarator) {
|
||||
IASTTypeId id= declarator.getTrailingReturnType();
|
||||
if (id == null)
|
||||
return null;
|
||||
return new ProblemType(ISemanticProblem.TYPE_NO_NAME);
|
||||
|
||||
IType t= createType(id.getAbstractDeclarator());
|
||||
t= qualifyType(t, declSpec);
|
||||
return createType(t, declarator);
|
||||
|
@ -1838,15 +1851,11 @@ public class CPPVisitor extends ASTQueries {
|
|||
|
||||
public static IType createType(IASTDeclSpecifier declSpec) {
|
||||
IType type = getBaseType(declSpec);
|
||||
if (type == null) {
|
||||
return null;
|
||||
}
|
||||
return qualifyType(type, declSpec);
|
||||
}
|
||||
|
||||
private static IType getBaseType(IASTDeclSpecifier declSpec) {
|
||||
IType type = null;
|
||||
IASTName name = null;
|
||||
IASTName name;
|
||||
if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
|
||||
name = ((ICPPASTCompositeTypeSpecifier) declSpec).getName();
|
||||
} else if (declSpec instanceof ICPPASTNamedTypeSpecifier) {
|
||||
|
@ -1858,50 +1867,36 @@ public class CPPVisitor extends ASTQueries {
|
|||
} else if (declSpec instanceof ICPPASTSimpleDeclSpecifier) {
|
||||
ICPPASTSimpleDeclSpecifier spec = (ICPPASTSimpleDeclSpecifier) declSpec;
|
||||
// Check for decltype(expr)
|
||||
type = getDeclType(spec);
|
||||
if (type == null && spec.getType() != IASTSimpleDeclSpecifier.t_auto) {
|
||||
type = new CPPBasicType(spec);
|
||||
}
|
||||
IType type = getDeclType(spec);
|
||||
if (type != null)
|
||||
return type;
|
||||
return new CPPBasicType(spec);
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (name != null) {
|
||||
IBinding binding = name.resolvePreBinding();
|
||||
if (binding instanceof ICPPConstructor) {
|
||||
type= ((ICPPConstructor) binding).getClassOwner();
|
||||
} else if (binding instanceof IType) {
|
||||
type = (IType) binding;
|
||||
} else if (binding instanceof ICPPTemplateNonTypeParameter) {
|
||||
//TODO workaround... is there anything better?
|
||||
try {
|
||||
type = ((ICPPTemplateNonTypeParameter) binding).getType();
|
||||
} catch (DOMException e) {
|
||||
type = e.getProblem();
|
||||
}
|
||||
} 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;
|
||||
if (name == null)
|
||||
return new ProblemType(ISemanticProblem.TYPE_NO_NAME);
|
||||
|
||||
IBinding binding = name.resolvePreBinding();
|
||||
if (!(binding instanceof IProblemBinding)) {
|
||||
if (binding instanceof ICPPConstructor)
|
||||
return ((ICPPConstructor) binding).getClassOwner();
|
||||
|
||||
if (binding instanceof IType)
|
||||
return (IType) binding;
|
||||
}
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNRESOLVED_NAME);
|
||||
}
|
||||
|
||||
private static IType decorateType(IType type, IASTDeclSpecifier declSpec, IASTDeclarator declarator) {
|
||||
type = qualifyType(type, declSpec);
|
||||
type = createType(type, declarator);
|
||||
return type;
|
||||
return createType(type, declarator);
|
||||
}
|
||||
|
||||
private static IType qualifyType(IType type, IASTDeclSpecifier declSpec) {
|
||||
return SemanticUtil.addQualifiers(type, declSpec.isConst(), declSpec.isVolatile());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param declarator
|
||||
* @return
|
||||
*/
|
||||
private static IType createType(IType baseType, IASTDeclarator declarator) {
|
||||
if (declarator instanceof ICPPASTFunctionDeclarator)
|
||||
return createType(baseType, (ICPPASTFunctionDeclarator) declarator);
|
||||
|
|
|
@ -521,7 +521,7 @@ public class LookupData {
|
|||
ICPPASTParameterDeclaration[] pdecls= functionParameters;
|
||||
functionArgTypes= new IType[pdecls.length];
|
||||
for (int i = 0; i < pdecls.length; i++) {
|
||||
functionArgTypes[i] = SemanticUtil.getSimplifiedType(CPPVisitor.createParameterType(
|
||||
functionArgTypes[i] = SemanticUtil.getSimplifiedType(CPPVisitor.createType(
|
||||
pdecls[i], true));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,8 +73,14 @@ public class ParserMessages {
|
|||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("nls")
|
||||
private static String getProblemKey(int 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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# 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.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}
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -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.index.IIndexBinding;
|
||||
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.CBasicType;
|
||||
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);
|
||||
case ITypeMarshalBuffer.POINTER:
|
||||
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$
|
||||
|
|
|
@ -69,6 +69,7 @@ import org.eclipse.cdt.core.index.IIndexBinding;
|
|||
import org.eclipse.cdt.internal.core.Util;
|
||||
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.ProblemType;
|
||||
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.CPPClosureType;
|
||||
|
@ -1026,6 +1027,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
return CPPFunctionType.unmarshal(firstByte, buffer);
|
||||
case ITypeMarshalBuffer.POINTER:
|
||||
return CPPPointerType.unmarshal(firstByte, buffer);
|
||||
case ITypeMarshalBuffer.PROBLEM_TYPE:
|
||||
return ProblemType.unmarshal(firstByte, buffer);
|
||||
case ITypeMarshalBuffer.REFERENCE:
|
||||
return CPPReferenceType.unmarshal(firstByte, buffer);
|
||||
case ITypeMarshalBuffer.PACK_EXPANSION:
|
||||
|
|
Loading…
Add table
Reference in a new issue