mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 381868: Add parenthesis to support casting of arrays
Change-Id: I9172a5521c02a26d7e4732c9bad5a53a6408cb4b Reviewed-on: https://git.eclipse.org/r/6426 Reviewed-by: Mikhail Khodjaiants <mikhailkhod@googlemail.com> IP-Clean: Mikhail Khodjaiants <mikhailkhod@googlemail.com> Tested-by: Mikhail Khodjaiants <mikhailkhod@googlemail.com>
This commit is contained in:
parent
a2962826c3
commit
73dd6c72e5
1 changed files with 8 additions and 2 deletions
|
@ -1495,13 +1495,19 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions,
|
|||
// cast to array (can be in addition to cast to type)
|
||||
if (castingLength > 0) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("(*("); //$NON-NLS-1$
|
||||
buffer.append("*("); //$NON-NLS-1$
|
||||
buffer.append('(').append(castExpression).append(')');
|
||||
buffer.append('+').append(castingIndex).append(')');
|
||||
buffer.append('@').append(castingLength).append(')');
|
||||
buffer.append('@').append(castingLength);
|
||||
castExpression = buffer.toString();
|
||||
}
|
||||
|
||||
// Surround the entire casted expression with parenthesis in case we are
|
||||
// dealing with an array. Arrays must be parenthesized before they are
|
||||
// subscripted. Note that we can be casting to an array or displaying
|
||||
// as an array, so we must do this all the time.
|
||||
castExpression = String.format("(%s)", castExpression); //$NON-NLS-1$
|
||||
|
||||
return new CastedExpressionDMC((MIExpressionDMC) exprDMC, castExpression, castInfo);
|
||||
} else {
|
||||
assert false;
|
||||
|
|
Loading…
Add table
Reference in a new issue