mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-10 17:55:39 +02:00
Bug 508254 - Variable initializer that references the variable
Change-Id: Ic5b0692db297dead087e4c8479fa0c0f134554da
This commit is contained in:
parent
17ed6bead8
commit
63e6688940
4 changed files with 45 additions and 4 deletions
|
@ -62,7 +62,7 @@ import junit.framework.TestSuite;
|
||||||
* additionally check that the binding obtained has characteristics as
|
* additionally check that the binding obtained has characteristics as
|
||||||
* expected (type,name,etc..)
|
* expected (type,name,etc..)
|
||||||
*/
|
*/
|
||||||
public abstract class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBase {
|
public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBase {
|
||||||
|
|
||||||
public static class SingleProject extends IndexCPPBindingResolutionTest {
|
public static class SingleProject extends IndexCPPBindingResolutionTest {
|
||||||
public SingleProject() { setStrategy(new SinglePDOMTestStrategy(true)); }
|
public SingleProject() { setStrategy(new SinglePDOMTestStrategy(true)); }
|
||||||
|
@ -78,6 +78,11 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
||||||
suite.addTest(SingleProject.suite());
|
suite.addTest(SingleProject.suite());
|
||||||
suite.addTest(ProjectWithDepProj.suite());
|
suite.addTest(ProjectWithDepProj.suite());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IndexCPPBindingResolutionTest() {
|
||||||
|
setStrategy(new SinglePDOMTestStrategy(true));
|
||||||
|
}
|
||||||
|
public static TestSuite suite() { return suite(SingleProject.class); }
|
||||||
|
|
||||||
/* Assertion helpers */
|
/* Assertion helpers */
|
||||||
/* ##################################################################### */
|
/* ##################################################################### */
|
||||||
|
@ -1927,6 +1932,18 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
||||||
public void testNameLookupFromArrayModifier_435075() {
|
public void testNameLookupFromArrayModifier_435075() {
|
||||||
checkBindings();
|
checkBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// struct S {
|
||||||
|
// int* a;
|
||||||
|
// int* b;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// constexpr S waldo = { nullptr, waldo.a };
|
||||||
|
|
||||||
|
// // empty file
|
||||||
|
public void testVariableInitializerThatReferencesVariable_508254() throws Exception {
|
||||||
|
checkBindings();
|
||||||
|
}
|
||||||
|
|
||||||
// class NonVirt {
|
// class NonVirt {
|
||||||
// void m();
|
// void m();
|
||||||
|
|
|
@ -33,7 +33,7 @@ class PDOMCPPField extends PDOMCPPVariable implements ICPPField {
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
protected static final int RECORD_SIZE = FIELD_POSITION_OFFSET + 2;
|
protected static final int RECORD_SIZE = FIELD_POSITION_OFFSET + 2;
|
||||||
|
|
||||||
public PDOMCPPField(PDOMLinkage linkage, PDOMNode parent, ICPPField field, boolean setTypeAndValue)
|
public PDOMCPPField(PDOMCPPLinkage linkage, PDOMNode parent, ICPPField field, boolean setTypeAndValue)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
super(linkage, parent, field, setTypeAndValue);
|
super(linkage, parent, field, setTypeAndValue);
|
||||||
setFieldPosition(field);
|
setFieldPosition(field);
|
||||||
|
|
|
@ -225,6 +225,22 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Binding types
|
// Binding types
|
||||||
|
class ConfigureVariable implements Runnable {
|
||||||
|
private final PDOMCPPVariable fVariable;
|
||||||
|
private final IValue fInitialValue;
|
||||||
|
|
||||||
|
public ConfigureVariable(ICPPVariable original, PDOMCPPVariable variable) {
|
||||||
|
fVariable = variable;
|
||||||
|
fInitialValue = original.getInitialValue();
|
||||||
|
postProcesses.add(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
fVariable.initData(fInitialValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class ConfigureTemplateParameters implements Runnable {
|
class ConfigureTemplateParameters implements Runnable {
|
||||||
private final IPDOMCPPTemplateParameter[] fPersisted;
|
private final IPDOMCPPTemplateParameter[] fPersisted;
|
||||||
private final ICPPTemplateParameter[] fOriginal;
|
private final ICPPTemplateParameter[] fOriginal;
|
||||||
|
|
|
@ -40,7 +40,7 @@ class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
protected static final int RECORD_SIZE = ANNOTATIONS + 1;
|
protected static final int RECORD_SIZE = ANNOTATIONS + 1;
|
||||||
|
|
||||||
public PDOMCPPVariable(PDOMLinkage linkage, PDOMNode parent, ICPPVariable variable, boolean setTypeAndValue)
|
public PDOMCPPVariable(PDOMCPPLinkage linkage, PDOMNode parent, ICPPVariable variable, boolean setTypeAndValue)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
super(linkage, parent, variable.getNameCharArray());
|
super(linkage, parent, variable.getNameCharArray());
|
||||||
|
|
||||||
|
@ -49,7 +49,15 @@ class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
|
||||||
db.putByte(record + ANNOTATIONS, PDOMCPPAnnotations.encodeVariableAnnotations(variable));
|
db.putByte(record + ANNOTATIONS, PDOMCPPAnnotations.encodeVariableAnnotations(variable));
|
||||||
if (setTypeAndValue) {
|
if (setTypeAndValue) {
|
||||||
setType(parent.getLinkage(), variable.getType());
|
setType(parent.getLinkage(), variable.getType());
|
||||||
setValue(variable.getInitialValue());
|
linkage.new ConfigureVariable(variable, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initData(IValue initialValue) {
|
||||||
|
try {
|
||||||
|
setValue(initialValue);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue