mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 01:36:01 +02:00
Cosmetics.
This commit is contained in:
parent
753276a27d
commit
820b901b69
5 changed files with 92 additions and 98 deletions
|
@ -1120,7 +1120,7 @@ public class AST2CPPTests extends AST2TestBase {
|
||||||
// X::f();
|
// X::f();
|
||||||
// X::g();
|
// X::g();
|
||||||
// }
|
// }
|
||||||
public void testUsingDeclaration_1() throws Exception {
|
public void testUsingDeclaration() throws Exception {
|
||||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||||
NameCollector collector = new NameCollector();
|
NameCollector collector = new NameCollector();
|
||||||
tu.accept(collector);
|
tu.accept(collector);
|
||||||
|
@ -1143,6 +1143,39 @@ public class AST2CPPTests extends AST2TestBase {
|
||||||
assertInstances(collector, using_g.getDelegates()[0], 3); // decl + using-decl + ref
|
assertInstances(collector, using_g.getDelegates()[0], 3); // decl + using-decl + ref
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// namespace A {
|
||||||
|
// void f(int);
|
||||||
|
// }
|
||||||
|
// using A::f;
|
||||||
|
// namespace A {
|
||||||
|
// void f(char);
|
||||||
|
// }
|
||||||
|
// void foo() {
|
||||||
|
// f('i');
|
||||||
|
// }
|
||||||
|
// void bar() {
|
||||||
|
// using A::f;
|
||||||
|
// f('c');
|
||||||
|
// }
|
||||||
|
public void testUsingDeclaration_86368() throws Exception {
|
||||||
|
BindingAssertionHelper bh = getAssertionHelper();
|
||||||
|
IFunction f1= bh.assertNonProblem("f(int)", 1);
|
||||||
|
IFunction f2= bh.assertNonProblem("f('i')", 1);
|
||||||
|
assertSame(f1, f2);
|
||||||
|
IFunction g1= bh.assertNonProblem("f(char)", 1);
|
||||||
|
IFunction g2= bh.assertNonProblem("f('c')", 1);
|
||||||
|
assertSame(g1, g2);
|
||||||
|
|
||||||
|
// Alternative binding resolution order.
|
||||||
|
bh = getAssertionHelper();
|
||||||
|
f2= bh.assertNonProblem("f('i')", 1);
|
||||||
|
f1= bh.assertNonProblem("f(int)", 1);
|
||||||
|
assertSame(f1, f2);
|
||||||
|
g2= bh.assertNonProblem("f('c')", 1);
|
||||||
|
g1= bh.assertNonProblem("f(char)", 1);
|
||||||
|
assertSame(g1, g2);
|
||||||
|
}
|
||||||
|
|
||||||
// typedef int Int;
|
// typedef int Int;
|
||||||
// void f(int i);
|
// void f(int i);
|
||||||
// void f(const int);
|
// void f(const int);
|
||||||
|
@ -6839,11 +6872,8 @@ public class AST2CPPTests extends AST2TestBase {
|
||||||
// g(1);
|
// g(1);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
public void testFriendFunctionResolution_86368_1() throws Exception {
|
public void testFriendFunctionResolution_86368() throws Exception {
|
||||||
final String code= getAboveComment();
|
BindingAssertionHelper bh = getAssertionHelper();
|
||||||
parseAndCheckBindings(code);
|
|
||||||
|
|
||||||
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
|
|
||||||
IFunction f1= bh.assertNonProblem("f(int)", 1);
|
IFunction f1= bh.assertNonProblem("f(int)", 1);
|
||||||
IFunction f2= bh.assertNonProblem("f(1)", 1);
|
IFunction f2= bh.assertNonProblem("f(1)", 1);
|
||||||
assertSame(f1, f2);
|
assertSame(f1, f2);
|
||||||
|
@ -6851,7 +6881,8 @@ public class AST2CPPTests extends AST2TestBase {
|
||||||
IFunction g2= bh.assertNonProblem("g(1)", 1);
|
IFunction g2= bh.assertNonProblem("g(1)", 1);
|
||||||
assertSame(g1, g2);
|
assertSame(g1, g2);
|
||||||
|
|
||||||
bh= new BindingAssertionHelper(code, true);
|
// Alternative binding resolution order.
|
||||||
|
bh = getAssertionHelper();
|
||||||
f2= bh.assertNonProblem("f(1)", 1);
|
f2= bh.assertNonProblem("f(1)", 1);
|
||||||
f1= bh.assertNonProblem("f(int)", 1);
|
f1= bh.assertNonProblem("f(int)", 1);
|
||||||
assertSame(f1, f2);
|
assertSame(f1, f2);
|
||||||
|
@ -6860,41 +6891,6 @@ public class AST2CPPTests extends AST2TestBase {
|
||||||
assertSame(g1, g2);
|
assertSame(g1, g2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// namespace A {
|
|
||||||
// void f(int);
|
|
||||||
// }
|
|
||||||
// using A::f;
|
|
||||||
// namespace A {
|
|
||||||
// void f(char); // openReferences fails
|
|
||||||
// }
|
|
||||||
// void foo() {
|
|
||||||
// f('i');
|
|
||||||
// }
|
|
||||||
// void bar() {
|
|
||||||
// using A::f;
|
|
||||||
// f('c');
|
|
||||||
// }
|
|
||||||
public void testFriendFunctionResolution_86368_2() throws Exception {
|
|
||||||
final String code= getAboveComment();
|
|
||||||
parseAndCheckBindings(code);
|
|
||||||
|
|
||||||
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
|
|
||||||
IFunction f1= bh.assertNonProblem("f(int)", 1);
|
|
||||||
IFunction f2= bh.assertNonProblem("f('i')", 1);
|
|
||||||
assertSame(f1, f2);
|
|
||||||
IFunction g1= bh.assertNonProblem("f(char)", 1);
|
|
||||||
IFunction g2= bh.assertNonProblem("f('c')", 1);
|
|
||||||
assertSame(g1, g2);
|
|
||||||
|
|
||||||
bh= new BindingAssertionHelper(code, true);
|
|
||||||
f2= bh.assertNonProblem("f('i')", 1);
|
|
||||||
f1= bh.assertNonProblem("f(int)", 1);
|
|
||||||
assertSame(f1, f2);
|
|
||||||
g2= bh.assertNonProblem("f('c')", 1);
|
|
||||||
g1= bh.assertNonProblem("f(char)", 1);
|
|
||||||
assertSame(g1, g2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// class A {
|
// class A {
|
||||||
// public:
|
// public:
|
||||||
// void foo() const volatile;
|
// void foo() const volatile;
|
||||||
|
@ -10646,7 +10642,6 @@ public class AST2CPPTests extends AST2TestBase {
|
||||||
assertEquals(5, waldo.getInitialValue().numericalValue().longValue());
|
assertEquals(5, waldo.getInitialValue().numericalValue().longValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// constexpr int naive_fibonacci(int x) {
|
// constexpr int naive_fibonacci(int x) {
|
||||||
// return x == 0 ? 0
|
// return x == 0 ? 0
|
||||||
// : x == 1 ? 1
|
// : x == 1 ? 1
|
||||||
|
@ -10664,7 +10659,6 @@ public class AST2CPPTests extends AST2TestBase {
|
||||||
assertNull(waldo.getInitialValue().numericalValue());
|
assertNull(waldo.getInitialValue().numericalValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// constexpr int foo(int a = 42) {
|
// constexpr int foo(int a = 42) {
|
||||||
// return a;
|
// return a;
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -17,19 +17,19 @@ import java.util.Comparator;
|
||||||
*/
|
*/
|
||||||
public class HashTable implements Cloneable {
|
public class HashTable implements Cloneable {
|
||||||
protected static final int minHashSize = 2;
|
protected static final int minHashSize = 2;
|
||||||
|
|
||||||
protected int currEntry = -1;
|
protected int currEntry = -1;
|
||||||
|
protected int[] hashTable;
|
||||||
|
protected int[] nextTable;
|
||||||
|
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return currEntry == -1;
|
return currEntry < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int size() {
|
public final int size() {
|
||||||
return currEntry + 1;
|
return currEntry + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int[] hashTable;
|
|
||||||
protected int[] nextTable;
|
|
||||||
|
|
||||||
public HashTable(int initialSize) {
|
public HashTable(int initialSize) {
|
||||||
int size = 1;
|
int size = 1;
|
||||||
while (size < initialSize)
|
while (size < initialSize)
|
||||||
|
@ -50,7 +50,7 @@ public class HashTable implements Cloneable {
|
||||||
try {
|
try {
|
||||||
newTable = (HashTable) super.clone();
|
newTable = (HashTable) super.clone();
|
||||||
} catch (CloneNotSupportedException e) {
|
} catch (CloneNotSupportedException e) {
|
||||||
//shouldn't happen because object supports clone.
|
// Shouldn't happen because object supports clone.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ public class HashTable implements Cloneable {
|
||||||
public void clear() {
|
public void clear() {
|
||||||
currEntry = -1;
|
currEntry = -1;
|
||||||
|
|
||||||
// clear the table
|
// Clear the table.
|
||||||
if (hashTable == null)
|
if (hashTable == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -83,27 +83,29 @@ public class HashTable implements Cloneable {
|
||||||
nextTable[i] = 0;
|
nextTable[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void rehash() {
|
protected void rehash() {
|
||||||
if (nextTable == null)
|
if (nextTable == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// clear the table (don't call clear() or else the subclasses stuff will be cleared too)
|
// Clear the table (don't call clear() or else the subclasses stuff will be cleared too).
|
||||||
for (int i = 0; i < capacity(); i++) {
|
for (int i = 0; i < capacity(); i++) {
|
||||||
hashTable[2 * i] = 0;
|
hashTable[2 * i] = 0;
|
||||||
hashTable[2 * i + 1] = 0;
|
hashTable[2 * i + 1] = 0;
|
||||||
nextTable[i] = 0;
|
nextTable[i] = 0;
|
||||||
}
|
}
|
||||||
// Need to rehash everything
|
// Need to rehash everything.
|
||||||
for (int i = 0; i <= currEntry; ++i) {
|
for (int i = 0; i <= currEntry; ++i) {
|
||||||
linkIntoHashTable(i, hash(i));
|
linkIntoHashTable(i, hash(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void resize(int size) {
|
protected void resize(int size) {
|
||||||
if (size > minHashSize) {
|
if (size > minHashSize) {
|
||||||
hashTable = new int[size * 2];
|
hashTable = new int[size * 2];
|
||||||
nextTable = new int[size];
|
nextTable = new int[size];
|
||||||
|
|
||||||
// Need to rehash everything
|
// Need to rehash everything.
|
||||||
for (int i = 0; i <= currEntry; ++i) {
|
for (int i = 0; i <= currEntry; ++i) {
|
||||||
linkIntoHashTable(i, hash(i));
|
linkIntoHashTable(i, hash(i));
|
||||||
}
|
}
|
||||||
|
@ -111,7 +113,7 @@ public class HashTable implements Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int hash(int pos) {
|
protected int hash(int pos) {
|
||||||
// return the hash value of the element in the key table
|
// Return the hash value of the element in the key table.
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +124,7 @@ public class HashTable implements Cloneable {
|
||||||
if (hashTable[hash] == 0) {
|
if (hashTable[hash] == 0) {
|
||||||
hashTable[hash] = i + 1;
|
hashTable[hash] = i + 1;
|
||||||
} else {
|
} else {
|
||||||
// need to link
|
// Need to link.
|
||||||
int j = hashTable[hash] - 1;
|
int j = hashTable[hash] - 1;
|
||||||
while (nextTable[j] != 0) {
|
while (nextTable[j] != 0) {
|
||||||
// if (nextTable[j] - 1 == j) {
|
// if (nextTable[j] - 1 == j) {
|
||||||
|
@ -134,7 +136,7 @@ public class HashTable implements Cloneable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final public int capacity() {
|
public final int capacity() {
|
||||||
if (nextTable == null)
|
if (nextTable == null)
|
||||||
return minHashSize;
|
return minHashSize;
|
||||||
return nextTable.length;
|
return nextTable.length;
|
||||||
|
@ -146,11 +148,11 @@ public class HashTable implements Cloneable {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the hash entry
|
// Remove the hash entry.
|
||||||
if (hashTable[hash] == i + 1) {
|
if (hashTable[hash] == i + 1) {
|
||||||
hashTable[hash] = nextTable[i];
|
hashTable[hash] = nextTable[i];
|
||||||
} else {
|
} else {
|
||||||
// find entry pointing to me
|
// Find entry pointing to me.
|
||||||
int j = hashTable[hash] - 1;
|
int j = hashTable[hash] - 1;
|
||||||
while (nextTable[j] != 0 && nextTable[j] != i + 1)
|
while (nextTable[j] != 0 && nextTable[j] != i + 1)
|
||||||
j = nextTable[j] - 1;
|
j = nextTable[j] - 1;
|
||||||
|
@ -158,10 +160,10 @@ public class HashTable implements Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < currEntry) {
|
if (i < currEntry) {
|
||||||
// shift everything over
|
// Shift everything over.
|
||||||
System.arraycopy(nextTable, i + 1, nextTable, i, currEntry - i);
|
System.arraycopy(nextTable, i + 1, nextTable, i, currEntry - i);
|
||||||
|
|
||||||
// adjust hash and next entries for things that moved
|
// Adjust hash and next entries for things that moved.
|
||||||
for (int j = 0; j < hashTable.length; ++j) {
|
for (int j = 0; j < hashTable.length; ++j) {
|
||||||
if (hashTable[j] > i + 1)
|
if (hashTable[j] > i + 1)
|
||||||
--hashTable[j];
|
--hashTable[j];
|
||||||
|
@ -173,18 +175,19 @@ public class HashTable implements Cloneable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// last entry is now free
|
// Last entry is now free.
|
||||||
nextTable[currEntry] = 0;
|
nextTable[currEntry] = 0;
|
||||||
--currEntry;
|
--currEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public void sort(Comparator<Object> c) {
|
public final void sort(Comparator<Object> c) {
|
||||||
if (size() > 1) {
|
if (size() > 1) {
|
||||||
quickSort(c, 0, size() - 1);
|
quickSort(c, 0, size() - 1);
|
||||||
rehash();
|
rehash();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final private void quickSort(Comparator<Object> c, int p, int r) {
|
|
||||||
|
private void quickSort(Comparator<Object> c, int p, int r) {
|
||||||
if (p < r) {
|
if (p < r) {
|
||||||
int q = partition(c, p, r);
|
int q = partition(c, p, r);
|
||||||
if (p < q) quickSort(c, p, q);
|
if (p < q) quickSort(c, p, q);
|
||||||
|
|
|
@ -61,7 +61,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||||
import org.eclipse.core.runtime.PlatformObject;
|
import org.eclipse.core.runtime.PlatformObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binding for c++ function
|
* Binding for C++ function
|
||||||
*/
|
*/
|
||||||
public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInternalFunction {
|
public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInternalFunction {
|
||||||
public static final ICPPFunction UNINITIALIZED_FUNCTION = new CPPFunction(null);
|
public static final ICPPFunction UNINITIALIZED_FUNCTION = new CPPFunction(null);
|
||||||
|
@ -612,10 +612,6 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
||||||
final ICPPParameter p = pars[i];
|
final ICPPParameter p = pars[i];
|
||||||
if (p.hasDefaultValue() || p.isParameterPack()) {
|
if (p.hasDefaultValue() || p.isParameterPack()) {
|
||||||
result--;
|
result--;
|
||||||
// } else {
|
|
||||||
// if (pars.length == 1 && SemanticUtil.isVoidType(p.getType())) {
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -205,7 +205,7 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
|
||||||
int tdeclLen= decls == null ? 0 : decls.length;
|
int tdeclLen= decls == null ? 0 : decls.length;
|
||||||
for (int i= -1; i < tdeclLen; i++) {
|
for (int i= -1; i < tdeclLen; i++) {
|
||||||
IASTDeclarator tdecl;
|
IASTDeclarator tdecl;
|
||||||
if (i == -1) {
|
if (i < 0) {
|
||||||
tdecl= getDeclaratorByName(getDefinition());
|
tdecl= getDeclaratorByName(getDefinition());
|
||||||
if (tdecl == null)
|
if (tdecl == null)
|
||||||
continue;
|
continue;
|
||||||
|
@ -236,7 +236,7 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
|
||||||
int tdeclLen= decls == null ? 0 : decls.length;
|
int tdeclLen= decls == null ? 0 : decls.length;
|
||||||
for (int i= -1; i < tdeclLen && k < updateParams.length; i++) {
|
for (int i= -1; i < tdeclLen && k < updateParams.length; i++) {
|
||||||
IASTDeclarator tdecl;
|
IASTDeclarator tdecl;
|
||||||
if (i == -1) {
|
if (i < 0) {
|
||||||
tdecl= getDeclaratorByName(getDefinition());
|
tdecl= getDeclaratorByName(getDefinition());
|
||||||
if (tdecl == null)
|
if (tdecl == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -708,27 +708,27 @@ public class CPPVisitor extends ASTQueries {
|
||||||
|
|
||||||
IASTName name= declarator.getName().getLastName();
|
IASTName name= declarator.getName().getLastName();
|
||||||
|
|
||||||
// in case the binding was created starting from another name within the declarator.
|
// In case the binding was created starting from another name within the declarator.
|
||||||
IBinding candidate= name.getBinding();
|
IBinding candidate= name.getBinding();
|
||||||
if (candidate != null) {
|
if (candidate != null) {
|
||||||
return candidate;
|
return candidate;
|
||||||
}
|
}
|
||||||
|
|
||||||
// function type
|
// Function type.
|
||||||
if (parent instanceof IASTTypeId)
|
if (parent instanceof IASTTypeId)
|
||||||
return CPPSemantics.resolveBinding(name);
|
return CPPSemantics.resolveBinding(name);
|
||||||
|
|
||||||
// function type for non-type template parameter
|
// Function type for non-type template parameter.
|
||||||
ASTNodeProperty prop = parent.getPropertyInParent();
|
ASTNodeProperty prop = parent.getPropertyInParent();
|
||||||
if (prop == ICPPASTTemplateDeclaration.PARAMETER || prop == ICPPASTTemplatedTypeTemplateParameter.PARAMETER) {
|
if (prop == ICPPASTTemplateDeclaration.PARAMETER || prop == ICPPASTTemplatedTypeTemplateParameter.PARAMETER) {
|
||||||
return CPPTemplates.createBinding((ICPPASTTemplateParameter) parent);
|
return CPPTemplates.createBinding((ICPPASTTemplateParameter) parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// explicit instantiations
|
// Explicit instantiations.
|
||||||
if (prop == ICPPASTExplicitTemplateInstantiation.OWNED_DECLARATION)
|
if (prop == ICPPASTExplicitTemplateInstantiation.OWNED_DECLARATION)
|
||||||
return CPPSemantics.resolveBinding(name);
|
return CPPSemantics.resolveBinding(name);
|
||||||
|
|
||||||
// explicit specializations
|
// Explicit specializations.
|
||||||
ICPPASTTemplateDeclaration tmplDecl= CPPTemplates.getTemplateDeclaration(name);
|
ICPPASTTemplateDeclaration tmplDecl= CPPTemplates.getTemplateDeclaration(name);
|
||||||
if (tmplDecl instanceof ICPPASTTemplateSpecialization) {
|
if (tmplDecl instanceof ICPPASTTemplateSpecialization) {
|
||||||
IBinding b= CPPSemantics.resolveBinding(name);
|
IBinding b= CPPSemantics.resolveBinding(name);
|
||||||
|
@ -740,13 +740,13 @@ public class CPPVisitor extends ASTQueries {
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
// parameter declarations
|
// Parameter declarations.
|
||||||
if (parent instanceof ICPPASTParameterDeclaration) {
|
if (parent instanceof ICPPASTParameterDeclaration) {
|
||||||
ICPPASTParameterDeclaration param = (ICPPASTParameterDeclaration) parent;
|
ICPPASTParameterDeclaration param = (ICPPASTParameterDeclaration) parent;
|
||||||
parent = param.getParent();
|
parent = param.getParent();
|
||||||
if (parent instanceof IASTStandardFunctionDeclarator) {
|
if (parent instanceof IASTStandardFunctionDeclarator) {
|
||||||
IASTStandardFunctionDeclarator fdtor = (IASTStandardFunctionDeclarator) param.getParent();
|
IASTStandardFunctionDeclarator fdtor = (IASTStandardFunctionDeclarator) param.getParent();
|
||||||
// Create parameter bindings only if the declarator declares a function
|
// Create parameter bindings only if the declarator declares a function.
|
||||||
if (findTypeRelevantDeclarator(fdtor) != fdtor)
|
if (findTypeRelevantDeclarator(fdtor) != fdtor)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -771,7 +771,7 @@ public class CPPVisitor extends ASTQueries {
|
||||||
return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_TYPE);
|
return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// function declaration/definition
|
// Function declaration/definition.
|
||||||
IBinding binding= null;
|
IBinding binding= null;
|
||||||
final boolean template= tmplDecl != null;
|
final boolean template= tmplDecl != null;
|
||||||
boolean isFriendDecl= false;
|
boolean isFriendDecl= false;
|
||||||
|
@ -798,7 +798,7 @@ public class CPPVisitor extends ASTQueries {
|
||||||
} else if (parent instanceof IASTSimpleDeclaration) {
|
} else if (parent instanceof IASTSimpleDeclaration) {
|
||||||
IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) parent;
|
IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) parent;
|
||||||
if (simpleDecl.getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_typedef) {
|
if (simpleDecl.getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_typedef) {
|
||||||
// Typedef declaration
|
// Typedef declaration.
|
||||||
if (binding instanceof ICPPInternalBinding && binding instanceof ITypedef && name.isActive()) {
|
if (binding instanceof ICPPInternalBinding && binding instanceof ITypedef && name.isActive()) {
|
||||||
IType t1 = ((ITypedef) binding).getType();
|
IType t1 = ((ITypedef) binding).getType();
|
||||||
IType t2 = createType(declarator);
|
IType t2 = createType(declarator);
|
||||||
|
@ -808,26 +808,27 @@ public class CPPVisitor extends ASTQueries {
|
||||||
}
|
}
|
||||||
return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION);
|
return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION);
|
||||||
}
|
}
|
||||||
// If we don't resolve the target type first, we get a problem binding in case the typedef
|
// If we don't resolve the target type first, we get a problem binding in case
|
||||||
// redeclares the target type, otherwise it is safer to defer the resolution of the target type.
|
// the typedef redeclares the target type, otherwise it is safer to defer
|
||||||
|
// the resolution of the target type.
|
||||||
IType targetType= createType(declarator);
|
IType targetType= createType(declarator);
|
||||||
CPPTypedef td= new CPPTypedef(name);
|
CPPTypedef td= new CPPTypedef(name);
|
||||||
td.setType(targetType);
|
td.setType(targetType);
|
||||||
binding = td;
|
binding = td;
|
||||||
} else if (typeRelevantDtor instanceof IASTFunctionDeclarator) {
|
} else if (typeRelevantDtor instanceof IASTFunctionDeclarator) {
|
||||||
// Function declaration via function declarator
|
// Function declaration via function declarator.
|
||||||
isFunction= true;
|
isFunction= true;
|
||||||
} else {
|
} else {
|
||||||
// Looks like a variable declaration
|
// Looks like a variable declaration.
|
||||||
IType t1 = createType(declarator);
|
IType t1 = createType(declarator);
|
||||||
if (SemanticUtil.getNestedType(t1, TDEF) instanceof IFunctionType) {
|
if (SemanticUtil.getNestedType(t1, TDEF) instanceof IFunctionType) {
|
||||||
// Function declaration via a typedef for a function type
|
// Function declaration via a typedef for a function type
|
||||||
isFunction= true;
|
isFunction= true;
|
||||||
} else if (binding instanceof IParameter) {
|
} else if (binding instanceof IParameter) {
|
||||||
// Variable declaration redeclaring a parameter
|
// Variable declaration redeclaring a parameter.
|
||||||
binding = new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION);
|
binding = new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION);
|
||||||
} else {
|
} else {
|
||||||
// Variable declaration
|
// Variable declaration.
|
||||||
IType t2= null;
|
IType t2= null;
|
||||||
if (binding != null && binding instanceof IVariable && !(binding instanceof IIndexBinding)) {
|
if (binding != null && binding instanceof IVariable && !(binding instanceof IIndexBinding)) {
|
||||||
t2 = ((IVariable) binding).getType();
|
t2 = ((IVariable) binding).getType();
|
||||||
|
|
Loading…
Add table
Reference in a new issue