summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2007-05-25 19:10:53 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2007-05-25 19:10:53 +0000
commitda7c7196a29568971d48d6c0812252832a1cdd24 (patch)
treefb1cfcf4b641776b5c143bc6f22d7a6b7e278eb5
parent0c681311177471fe18379e2af9bc02e41b1b83c3 (diff)
downloadATCD-da7c7196a29568971d48d6c0812252832a1cdd24.tar.gz
ChangeLogTag: Fri May 25 18:49:12 UTC 2007 Jeff Parsons <j.parsons@vanderbilt.edu>
-rw-r--r--TAO/ChangeLog14
-rw-r--r--TAO/TAO_IDL/ast/ast_expression.cpp103
-rw-r--r--TAO/tests/IDL_Test/constants.idl3
3 files changed, 83 insertions, 37 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index 280f3758478..ac576a091be 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,17 @@
+Fri May 25 18:49:12 UTC 2007 Jeff Parsons <j.parsons@vanderbilt.edu>
+
+ * TAO_IDL/ast/ast_expression.cpp:
+
+ Fixed a bug in parsing of octet constants where the rhs
+ has an infix operator. Thanks to Lother Werzinger
+ <lothar at tradescape dot biz> for reporting the
+ problem. This fix closes [BUGID:2944].
+
+ * tests/IDL_Test/constants.idl:
+
+ Added some of items in the example IDL submitted by
+ Lothar to our test suite of problem IDL declarations.
+
Fri May 25 18:02:30 UTC 2007 Scott Harris <harris_s@ociweb.com>
* TAO_IDL/include/idl_global.h:
diff --git a/TAO/TAO_IDL/ast/ast_expression.cpp b/TAO/TAO_IDL/ast/ast_expression.cpp
index 164a806a9a5..bb1921533f3 100644
--- a/TAO/TAO_IDL/ast/ast_expression.cpp
+++ b/TAO/TAO_IDL/ast/ast_expression.cpp
@@ -2065,7 +2065,7 @@ AST_Expression::eval_bit_op (AST_Expression::EvalKind ek)
retval->et = EV_ulonglong;
switch (this->pd_ec)
- {
+ {
case EC_or:
retval->u.ullval =
this->pd_v1->ev ()->u.ullval | this->pd_v2->ev ()->u.ullval;
@@ -2088,7 +2088,7 @@ AST_Expression::eval_bit_op (AST_Expression::EvalKind ek)
break;
default:
return 0;
- }
+ }
}
else if (ek == EK_longlong)
{
@@ -2097,30 +2097,30 @@ AST_Expression::eval_bit_op (AST_Expression::EvalKind ek)
retval->et = EV_longlong;
switch (this->pd_ec)
- {
- case EC_or:
- retval->u.llval =
- this->pd_v1->ev ()->u.llval | this->pd_v2->ev ()->u.llval;
- break;
- case EC_xor:
- retval->u.llval =
- this->pd_v1->ev ()->u.llval ^ this->pd_v2->ev ()->u.llval;
- break;
- case EC_and:
- retval->u.llval =
- this->pd_v1->ev ()->u.llval & this->pd_v2->ev ()->u.llval;
- break;
- case EC_left:
- retval->u.llval =
- this->pd_v1->ev ()->u.llval << this->pd_v2->ev ()->u.llval;
- break;
- case EC_right:
- retval->u.llval =
- this->pd_v1->ev ()->u.llval >> this->pd_v2->ev ()->u.llval;
- break;
- default:
- return 0;
- }
+ {
+ case EC_or:
+ retval->u.llval =
+ this->pd_v1->ev ()->u.llval | this->pd_v2->ev ()->u.llval;
+ break;
+ case EC_xor:
+ retval->u.llval =
+ this->pd_v1->ev ()->u.llval ^ this->pd_v2->ev ()->u.llval;
+ break;
+ case EC_and:
+ retval->u.llval =
+ this->pd_v1->ev ()->u.llval & this->pd_v2->ev ()->u.llval;
+ break;
+ case EC_left:
+ retval->u.llval =
+ this->pd_v1->ev ()->u.llval << this->pd_v2->ev ()->u.llval;
+ break;
+ case EC_right:
+ retval->u.llval =
+ this->pd_v1->ev ()->u.llval >> this->pd_v2->ev ()->u.llval;
+ break;
+ default:
+ return 0;
+ }
}
else
#endif
@@ -2131,7 +2131,7 @@ AST_Expression::eval_bit_op (AST_Expression::EvalKind ek)
retval->et = EV_ulong;
switch (this->pd_ec)
- {
+ {
case EC_or:
retval->u.ulval =
this->pd_v1->ev ()->u.ulval | this->pd_v2->ev ()->u.ulval;
@@ -2154,7 +2154,7 @@ AST_Expression::eval_bit_op (AST_Expression::EvalKind ek)
break;
default:
return 0;
- }
+ }
}
else if (ek == EK_long)
{
@@ -2163,7 +2163,7 @@ AST_Expression::eval_bit_op (AST_Expression::EvalKind ek)
retval->et = EV_long;
switch (this->pd_ec)
- {
+ {
case EC_or:
retval->u.lval =
this->pd_v1->ev ()->u.lval | this->pd_v2->ev ()->u.lval;
@@ -2186,7 +2186,7 @@ AST_Expression::eval_bit_op (AST_Expression::EvalKind ek)
break;
default:
return 0;
- }
+ }
}
else if (ek == EK_bool)
{
@@ -2220,6 +2220,42 @@ AST_Expression::eval_bit_op (AST_Expression::EvalKind ek)
return 0;
}
}
+ else if (ek == EK_octet)
+ {
+ this->pd_v1->set_ev (this->pd_v1->coerce (EV_octet));
+ this->pd_v2->set_ev (this->pd_v2->coerce (EV_octet));
+ retval->et = EV_octet;
+
+ switch (this->pd_ec)
+ {
+ case EC_or:
+ retval->u.oval =
+ this->pd_v1->ev ()->u.oval | this->pd_v2->ev ()->u.oval;
+ break;
+ case EC_xor:
+ retval->u.oval =
+ this->pd_v1->ev ()->u.oval ^ this->pd_v2->ev ()->u.oval;
+ break;
+ case EC_and:
+ retval->u.oval =
+ this->pd_v1->ev ()->u.oval & this->pd_v2->ev ()->u.oval;
+ break;
+ case EC_left:
+ // This is the only operation that can cause overflow even if
+ // both operands are in range, so we set the ExprType to a
+ // large type and catch the octet overflow, if any, later.
+ retval->et = EV_ulong;
+ retval->u.ulval =
+ this->pd_v1->ev ()->u.ulval << this->pd_v2->ev ()->u.ulval;
+ break;
+ case EC_right:
+ retval->u.ulval =
+ this->pd_v1->ev ()->u.ulval >> this->pd_v2->ev ()->u.ulval;
+ break;
+ default:
+ return 0;
+ }
+ }
else
{
return 0;
@@ -2607,13 +2643,6 @@ AST_Expression::eval_internal (AST_Expression::EvalKind ek)
ek);
}
- if (ek == EK_bool || ek == EK_octet)
- {
- // Operators may be used only with integer or floating point types.
- idl_global->err ()->illegal_infix ();
- return 0;
- }
-
// OK, must evaluate operator.
switch (this->pd_ec)
{
diff --git a/TAO/tests/IDL_Test/constants.idl b/TAO/tests/IDL_Test/constants.idl
index 732baa4eb26..1ee602e8074 100644
--- a/TAO/tests/IDL_Test/constants.idl
+++ b/TAO/tests/IDL_Test/constants.idl
@@ -79,6 +79,9 @@ const unsigned long div1 = 99 / 12;
const unsigned short stuff = ~0;
const unsigned long day = ~0;
const unsigned long drink = 1000000000 << 2;
+const unsigned long c_l1 = (1 << 1);
+const octet c_o11 = 10 + c_l1;
+const octet c_o3 = (1 << 3);
// An enum of one type cannot be assigned to an constant of another
// enum type, but it's ok if one is a typedef of the other.