Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2012-05-31 01:25:21 +0000
committerSergey Prigogin2012-05-31 01:28:50 +0000
commit2776e06605754d52ce75effaf237edbbedddda73 (patch)
tree52ca1e5f8d856bbb5eb5006ea35689322baf1059 /core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java
parent3604f812ced75a313a8de08387e338a335771cd9 (diff)
downloadorg.eclipse.cdt-2776e06605754d52ce75effaf237edbbedddda73.tar.gz
org.eclipse.cdt-2776e06605754d52ce75effaf237edbbedddda73.tar.xz
org.eclipse.cdt-2776e06605754d52ce75effaf237edbbedddda73.zip
Bug 380498 - typedef is expanded during refactoring
Diffstat (limited to 'core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java28
1 files changed, 17 insertions, 11 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java
index 0c98534b635..a6a29f4401c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java
@@ -9,6 +9,7 @@
* John Camelon (IBM) - Initial API and implementation
* Mike Kucera (IBM)
* Markus Schorn (Wind River Systems)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@@ -16,6 +17,7 @@ import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.glvalueType;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.prvalueType;
+import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.restoreTypedefs;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromFunctionCall;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromFunctionCall;
@@ -40,7 +42,6 @@ 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;
-
public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpression, IASTAmbiguityParent {
private int op;
private IASTExpression operand1;
@@ -313,21 +314,26 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
}
private IType createExpressionType() {
+ IType originalType1 = operand1.getExpressionType();
+ IType originalType2 = operand2 instanceof IASTExpression ?
+ ((IASTExpression) operand2).getExpressionType() : null;
+
// Check for overloaded operator.
ICPPFunction o= getOverload();
if (o != null) {
- return typeFromFunctionCall(o);
+ IType type = typeFromFunctionCall(o);
+ return restoreTypedefs(type, originalType1, originalType2);
}
final int op = getOperator();
- IType type1 = prvalueType(operand1.getExpressionType());
+ IType type1 = prvalueType(originalType1);
if (type1 instanceof ISemanticProblem) {
return type1;
}
-
+
IType type2 = null;
- if (operand2 instanceof IASTExpression) {
- type2= prvalueType(((IASTExpression) operand2).getExpressionType());
+ if (originalType2 != null) {
+ type2= prvalueType(originalType2);
if (type2 instanceof ISemanticProblem) {
return type2;
}
@@ -335,7 +341,7 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
IType type= CPPArithmeticConversion.convertCppOperandTypes(op, type1, type2);
if (type != null) {
- return type;
+ return restoreTypedefs(type, originalType1, originalType2);
}
switch (op) {
@@ -351,10 +357,10 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
case IASTBinaryExpression.op_plus:
if (type1 instanceof IPointerType) {
- return type1;
+ return restoreTypedefs(type1, originalType1);
}
if (type2 instanceof IPointerType) {
- return type2;
+ return restoreTypedefs(type2, originalType2);
}
break;
@@ -363,7 +369,7 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
if (type2 instanceof IPointerType) {
return CPPVisitor.getPointerDiffType(this);
}
- return type1;
+ return restoreTypedefs(type1, originalType1);
}
break;
@@ -380,6 +386,6 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
}
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
}
- return type1;
+ return restoreTypedefs(type1, originalType1);
}
}

Back to the top