|
@@ -429,12 +429,24 @@ type_trait(int trait, CPPType *type, CPPType *arg) {
|
|
|
CPPExpression CPPExpression::
|
|
CPPExpression CPPExpression::
|
|
|
sizeof_func(CPPType *type) {
|
|
sizeof_func(CPPType *type) {
|
|
|
CPPExpression expr(0);
|
|
CPPExpression expr(0);
|
|
|
- expr._type = T_sizeof;
|
|
|
|
|
|
|
+ expr._type = T_sizeof_type;
|
|
|
expr._u._typecast._to = type;
|
|
expr._u._typecast._to = type;
|
|
|
expr._u._typecast._op1 = nullptr;
|
|
expr._u._typecast._op1 = nullptr;
|
|
|
return expr;
|
|
return expr;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ *
|
|
|
|
|
+ */
|
|
|
|
|
+CPPExpression CPPExpression::
|
|
|
|
|
+sizeof_func(CPPExpression *op1) {
|
|
|
|
|
+ CPPExpression expr(0);
|
|
|
|
|
+ expr._type = T_sizeof_expr;
|
|
|
|
|
+ expr._u._typecast._to = nullptr;
|
|
|
|
|
+ expr._u._typecast._op1 = op1;
|
|
|
|
|
+ return expr;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
*
|
|
*
|
|
|
*/
|
|
*/
|
|
@@ -629,7 +641,8 @@ evaluate() const {
|
|
|
case T_empty_aggregate_init:
|
|
case T_empty_aggregate_init:
|
|
|
case T_new:
|
|
case T_new:
|
|
|
case T_default_new:
|
|
case T_default_new:
|
|
|
- case T_sizeof:
|
|
|
|
|
|
|
+ case T_sizeof_type:
|
|
|
|
|
+ case T_sizeof_expr:
|
|
|
case T_sizeof_ellipsis:
|
|
case T_sizeof_ellipsis:
|
|
|
return Result();
|
|
return Result();
|
|
|
|
|
|
|
@@ -1058,7 +1071,8 @@ determine_type() const {
|
|
|
case T_default_new:
|
|
case T_default_new:
|
|
|
return CPPType::new_type(new CPPPointerType(_u._typecast._to));
|
|
return CPPType::new_type(new CPPPointerType(_u._typecast._to));
|
|
|
|
|
|
|
|
- case T_sizeof:
|
|
|
|
|
|
|
+ case T_sizeof_type:
|
|
|
|
|
+ case T_sizeof_expr:
|
|
|
case T_sizeof_ellipsis:
|
|
case T_sizeof_ellipsis:
|
|
|
case T_alignof:
|
|
case T_alignof:
|
|
|
// Note: this should actually be size_t, but that is defined as a typedef
|
|
// Note: this should actually be size_t, but that is defined as a typedef
|
|
@@ -1334,10 +1348,13 @@ is_fully_specified() const {
|
|
|
case T_default_construct:
|
|
case T_default_construct:
|
|
|
case T_empty_aggregate_init:
|
|
case T_empty_aggregate_init:
|
|
|
case T_default_new:
|
|
case T_default_new:
|
|
|
- case T_sizeof:
|
|
|
|
|
|
|
+ case T_sizeof_type:
|
|
|
case T_alignof:
|
|
case T_alignof:
|
|
|
return _u._typecast._to->is_fully_specified();
|
|
return _u._typecast._to->is_fully_specified();
|
|
|
|
|
|
|
|
|
|
+ case T_sizeof_expr:
|
|
|
|
|
+ return _u._typecast._op1->is_fully_specified();
|
|
|
|
|
+
|
|
|
case T_sizeof_ellipsis:
|
|
case T_sizeof_ellipsis:
|
|
|
return _u._ident->is_fully_specified();
|
|
return _u._ident->is_fully_specified();
|
|
|
|
|
|
|
@@ -1469,7 +1486,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst,
|
|
|
case T_default_construct:
|
|
case T_default_construct:
|
|
|
case T_empty_aggregate_init:
|
|
case T_empty_aggregate_init:
|
|
|
case T_default_new:
|
|
case T_default_new:
|
|
|
- case T_sizeof:
|
|
|
|
|
|
|
+ case T_sizeof_type:
|
|
|
case T_alignof:
|
|
case T_alignof:
|
|
|
rep->_u._typecast._to =
|
|
rep->_u._typecast._to =
|
|
|
_u._typecast._to->substitute_decl(subst, current_scope, global_scope)
|
|
_u._typecast._to->substitute_decl(subst, current_scope, global_scope)
|
|
@@ -1477,6 +1494,13 @@ substitute_decl(CPPDeclaration::SubstDecl &subst,
|
|
|
any_changed = any_changed || (rep->_u._typecast._to != _u._typecast._to);
|
|
any_changed = any_changed || (rep->_u._typecast._to != _u._typecast._to);
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
|
|
+ case T_sizeof_expr:
|
|
|
|
|
+ rep->_u._typecast._op1 =
|
|
|
|
|
+ _u._typecast._op1->substitute_decl(subst, current_scope, global_scope)
|
|
|
|
|
+ ->as_expression();
|
|
|
|
|
+ any_changed = any_changed || (rep->_u._typecast._op1 != _u._typecast._op1);
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
case T_trinary_operation:
|
|
case T_trinary_operation:
|
|
|
rep->_u._op._op3 =
|
|
rep->_u._op._op3 =
|
|
|
_u._op._op3->substitute_decl(subst, current_scope, global_scope)
|
|
_u._op._op3->substitute_decl(subst, current_scope, global_scope)
|
|
@@ -1567,10 +1591,13 @@ is_tbd() const {
|
|
|
case T_new:
|
|
case T_new:
|
|
|
case T_default_construct:
|
|
case T_default_construct:
|
|
|
case T_default_new:
|
|
case T_default_new:
|
|
|
- case T_sizeof:
|
|
|
|
|
|
|
+ case T_sizeof_type:
|
|
|
case T_alignof:
|
|
case T_alignof:
|
|
|
return _u._typecast._to->is_tbd();
|
|
return _u._typecast._to->is_tbd();
|
|
|
|
|
|
|
|
|
|
+ case T_sizeof_expr:
|
|
|
|
|
+ return _u._typecast._op1->is_tbd();
|
|
|
|
|
+
|
|
|
case T_trinary_operation:
|
|
case T_trinary_operation:
|
|
|
if (_u._op._op3->is_tbd()) {
|
|
if (_u._op._op3->is_tbd()) {
|
|
|
return true;
|
|
return true;
|
|
@@ -1807,12 +1834,17 @@ output(std::ostream &out, int indent_level, CPPScope *scope, bool) const {
|
|
|
out << "())";
|
|
out << "())";
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
- case T_sizeof:
|
|
|
|
|
|
|
+ case T_sizeof_type:
|
|
|
out << "sizeof(";
|
|
out << "sizeof(";
|
|
|
_u._typecast._to->output(out, indent_level, scope, false);
|
|
_u._typecast._to->output(out, indent_level, scope, false);
|
|
|
out << ")";
|
|
out << ")";
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
|
|
+ case T_sizeof_expr:
|
|
|
|
|
+ out << "sizeof ";
|
|
|
|
|
+ _u._typecast._op1->output(out, indent_level, scope, false);
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
case T_sizeof_ellipsis:
|
|
case T_sizeof_ellipsis:
|
|
|
out << "sizeof...(";
|
|
out << "sizeof...(";
|
|
|
_u._ident->output(out, scope);
|
|
_u._ident->output(out, scope);
|
|
@@ -2222,10 +2254,13 @@ is_equal(const CPPDeclaration *other) const {
|
|
|
case T_default_construct:
|
|
case T_default_construct:
|
|
|
case T_empty_aggregate_init:
|
|
case T_empty_aggregate_init:
|
|
|
case T_default_new:
|
|
case T_default_new:
|
|
|
- case T_sizeof:
|
|
|
|
|
|
|
+ case T_sizeof_type:
|
|
|
case T_alignof:
|
|
case T_alignof:
|
|
|
return _u._typecast._to == ot->_u._typecast._to;
|
|
return _u._typecast._to == ot->_u._typecast._to;
|
|
|
|
|
|
|
|
|
|
+ case T_sizeof_expr:
|
|
|
|
|
+ return _u._typecast._op1 == ot->_u._typecast._op1;
|
|
|
|
|
+
|
|
|
case T_unary_operation:
|
|
case T_unary_operation:
|
|
|
return *_u._op._op1 == *ot->_u._op._op1;
|
|
return *_u._op._op1 == *ot->_u._op._op1;
|
|
|
|
|
|
|
@@ -2324,10 +2359,13 @@ is_less(const CPPDeclaration *other) const {
|
|
|
case T_default_construct:
|
|
case T_default_construct:
|
|
|
case T_empty_aggregate_init:
|
|
case T_empty_aggregate_init:
|
|
|
case T_default_new:
|
|
case T_default_new:
|
|
|
- case T_sizeof:
|
|
|
|
|
|
|
+ case T_sizeof_type:
|
|
|
case T_alignof:
|
|
case T_alignof:
|
|
|
return _u._typecast._to < ot->_u._typecast._to;
|
|
return _u._typecast._to < ot->_u._typecast._to;
|
|
|
|
|
|
|
|
|
|
+ case T_sizeof_expr:
|
|
|
|
|
+ return _u._typecast._op1 < ot->_u._typecast._op1;
|
|
|
|
|
+
|
|
|
case T_trinary_operation:
|
|
case T_trinary_operation:
|
|
|
if (*_u._op._op3 != *ot->_u._op._op3) {
|
|
if (*_u._op._op3 != *ot->_u._op._op3) {
|
|
|
return *_u._op._op3 < *ot->_u._op._op3;
|
|
return *_u._op._op3 < *ot->_u._op._op3;
|