Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2019-04-04 03:22:22 +0000
committerNathan Ridge2019-04-05 02:48:03 +0000
commit26e9f5e78702f89bf86612c5698edd6373a561fb (patch)
tree9fc6a65a22ce5f2a7ad146c1cb4039b760a30642
parent682a4e69fcfd61cad2e15991a4c48db8816bbd79 (diff)
downloadorg.eclipse.cdt-26e9f5e78702f89bf86612c5698edd6373a561fb.tar.gz
org.eclipse.cdt-26e9f5e78702f89bf86612c5698edd6373a561fb.tar.xz
org.eclipse.cdt-26e9f5e78702f89bf86612c5698edd6373a561fb.zip
Bug 545756 - Handle the case where CPPVisitor.get_SIZE_T() returns a typedef
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java
index e08dce34c8..7d91bdeea9 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java
@@ -160,10 +160,18 @@ public class EvalUnaryTypeID extends CPPDependentEvaluation {
case op_sizeof:
case op_sizeofParameterPack:
case op_alignof:
- CPPBasicType t = (CPPBasicType) CPPVisitor.get_SIZE_T().clone();
- if (getValue().numberValue() != null)
- t.setAssociatedNumericalValue(getValue().numberValue().longValue());
- return t;
+ IType result = (IType) CPPVisitor.get_SIZE_T().clone();
+ IType simplifiedResult = SemanticUtil.getSimplifiedType(result);
+ if (simplifiedResult instanceof CPPBasicType) {
+ CPPBasicType t = (CPPBasicType) simplifiedResult;
+ IValue value = getValue();
+ if (value != null && value.numberValue() != null) {
+ t.setAssociatedNumericalValue(value.numberValue().longValue());
+ }
+ // We're still returning 'result', which is now modified.
+ // This preserves the 'size_t' typedef.
+ }
+ return result;
case op_typeid:
return CPPVisitor.get_type_info();
case op_has_nothrow_copy:

Back to the top