diff options
author | Phil Mesnier <mesnierp@objectcomputing.com> | 2021-06-16 10:15:11 -0500 |
---|---|---|
committer | Phil Mesnier <mesnierp@objectcomputing.com> | 2021-06-16 10:15:11 -0500 |
commit | 13c9ee7bba3a02bb9b5a92fbc3699060867e8925 (patch) | |
tree | 29a16d13ea8fa3f3a7073d3f186832cd500ededc /TAO/tests | |
parent | cb579f6b18458bb17117bc953ac6ef3428ca47ea (diff) | |
download | ATCD-13c9ee7bba3a02bb9b5a92fbc3699060867e8925.tar.gz |
applying solution to issue 1550 as found in ace6tao2
Diffstat (limited to 'TAO/tests')
-rw-r--r-- | TAO/tests/IDLv4/annotations/annotation_tests.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/TAO/tests/IDLv4/annotations/annotation_tests.cpp b/TAO/tests/IDLv4/annotations/annotation_tests.cpp index 73b2359c178..35bcc728a83 100644 --- a/TAO/tests/IDLv4/annotations/annotation_tests.cpp +++ b/TAO/tests/IDLv4/annotations/annotation_tests.cpp @@ -4,7 +4,9 @@ #include <ast_porttype.h> #include <ast_eventtype.h> #include <ast_component.h> - +#include <ast_union_branch.h> +#include <ast_union_label.h> +#include <ast_expression.h> #include <string> namespace { @@ -1060,6 +1062,38 @@ annotation_tests () } } catch (Failed const &) {} + /* ------------------------------------------------------------------------- + * Empty union cases aliasing the default case must always be evaluated + * ------------------------------------------------------------------------- + * When the union has an enum discriminator, and one or more empty cases + * acting as an alias to the default case the IDL compiler was failing to + * resolve the ordinal value for these empty labels and this causes trouble + * for at least OpenDDS. + * + * This test is designed to verify that the condition is corrected by + * parsing a specially crafted union and validating the value of the + * label aliasing the default case. + */ + try { + Annotation_Test t ("empty union branch label"); + AST_Union *test_union = t.run ( + "enum disc {A, B, C};\n" + "union empty_union switch (disc) {\n" + "case A: long along;\n" + "case B: short bshort;\n" + "case C:\n" + "default: float cfloat;\n" + "};\n").assert_node<AST_Union>("::empty_union"); + AST_Field **af = 0; + test_union->field(af, 2); + AST_UnionBranch *ub = dynamic_cast<AST_UnionBranch *>(*af); + AST_UnionLabel *ul = ub->label (); + if (ul->label_val()->ev()->u.ulval != 2) + { + t.failed("did not get the correct label value"); + } + } catch (Failed const &) {} + // Done, Print Overall Results Annotation_Test::results (); } |