1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Bug 84144 - Occurrence marking for label references.

This commit is contained in:
Thomas Corbat 2014-07-10 13:20:38 +02:00
parent 6dff32c96a
commit f81b783269
3 changed files with 35 additions and 2 deletions

View file

@ -1713,7 +1713,7 @@ public class CPPVisitor extends ASTQueries {
switch (kind) {
case KIND_LABEL:
if (prop == IASTGotoStatement.NAME)
if (prop == IASTGotoStatement.NAME || prop == IASTIdExpression.ID_NAME)
break;
return PROCESS_CONTINUE;

View file

@ -127,3 +127,10 @@ ConstantTemplate<5> c52;
ConstantTemplate<4> c4;
const int c= c5.getNumber(0);
void functionWithLabelReferenceGoto() {
void * labelPointer = &&referencedLabel;
goto *labelPointer;
referencedLabel:
return;
}

View file

@ -533,7 +533,33 @@ public class MarkOccurrenceTest extends BaseUITestCase {
assertOccurrences(0, 0);
assertOccurrencesInWidget();
}
public void testMarkLabelReference() {
try {
fMatch = fFindReplaceDocumentAdapter.find(0, "labelPointer", true, true, true, false);
} catch (BadLocationException e) {
fail();
}
fEditor.selectAndReveal(fMatch.getOffset(), fMatch.getLength());
assertOccurrences(2, 1);
assertOccurrencesInWidget();
}
public void testMarkReferencedLabel() {
try {
fMatch = fFindReplaceDocumentAdapter.find(0, "referencedLabel", true, true, true, false);
} catch (BadLocationException e) {
fail();
}
fEditor.selectAndReveal(fMatch.getOffset(), fMatch.getLength());
assertOccurrences(2, 0);
assertOccurrencesInWidget();
}
private void assertOccurrencesInWidget() {
EditorTestHelper.runEventQueue(100);