summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL/be/be_helper.cpp
diff options
context:
space:
mode:
authorFred Hornsey <hornseyf@objectcomputing.com>2021-06-30 13:51:55 -0500
committerGitHub <noreply@github.com>2021-06-30 13:51:55 -0500
commit48f51b52ee8e8cc1ff6608f1539a7985c65e5acc (patch)
treee48a8d1246f541dbd7077471c4f6b86cb180c5e0 /TAO/TAO_IDL/be/be_helper.cpp
parent4a5a0596c8b261c211a59c945b4f7783df50f132 (diff)
parent354b698dd92c075dc01d36bd01fefd56099ce6a5 (diff)
downloadATCD-48f51b52ee8e8cc1ff6608f1539a7985c65e5acc.tar.gz
Merge pull request #840 from iguessthislldo/igtd/stdint
IDLv4 Explicitly-named Integer Types
Diffstat (limited to 'TAO/TAO_IDL/be/be_helper.cpp')
-rw-r--r--TAO/TAO_IDL/be/be_helper.cpp27
1 files changed, 24 insertions, 3 deletions
diff --git a/TAO/TAO_IDL/be/be_helper.cpp b/TAO/TAO_IDL/be/be_helper.cpp
index 356a5500b5f..5070581c201 100644
--- a/TAO/TAO_IDL/be/be_helper.cpp
+++ b/TAO/TAO_IDL/be/be_helper.cpp
@@ -529,8 +529,23 @@ TAO_OutStream::print (AST_Expression *expr)
break;
case AST_Expression::EV_longlong:
this->TAO_OutStream::print ("ACE_INT64_LITERAL (");
- this->TAO_OutStream::print (ACE_INT64_FORMAT_SPECIFIER_ASCII,
- ev->u.llval);
+ {
+ ACE_CDR::LongLong value = ev->u.llval;
+ /*
+ * It seems that in C/C++ the minus sign and the bare number are parsed
+ * separately for negative integer literals. This can cause compilers
+ * to complain when using the minimum value of a signed integer because
+ * the number without the minus sign is 1 past the max signed value.
+ *
+ * https://stackoverflow.com/questions/65007935
+ *
+ * Apparently the workaround is to write it as `VALUE_PLUS_ONE - 1`.
+ */
+ const bool min_value = value == ACE_INT64_MIN;
+ if (min_value) ++value;
+ TAO_OutStream::print (ACE_INT64_FORMAT_SPECIFIER_ASCII, value);
+ if (min_value) TAO_OutStream::print (" - 1");
+ }
this->TAO_OutStream::print (")");
break;
case AST_Expression::EV_ulonglong:
@@ -596,7 +611,7 @@ TAO_OutStream::print (AST_Expression *expr)
this->TAO_OutStream::print ("L'%lc'", ev->u.wcval);
break;
case AST_Expression::EV_octet:
- this->TAO_OutStream::print ("%d", ev->u.oval);
+ this->TAO_OutStream::print ("0x%02x", ev->u.oval);
break;
case AST_Expression::EV_bool:
this->TAO_OutStream::print ("%s", ev->u.bval ? "true" : "false");
@@ -610,6 +625,12 @@ TAO_OutStream::print (AST_Expression *expr)
case AST_Expression::EV_enum:
this->print (expr->n ());
break;
+ case AST_Expression::EV_int8:
+ this->TAO_OutStream::print ("%d", ev->u.int8val);
+ break;
+ case AST_Expression::EV_uint8:
+ this->TAO_OutStream::print ("%uu", ev->u.uint8val);
+ break;
default:
break;
}