summaryrefslogtreecommitdiff
path: root/TAO
diff options
context:
space:
mode:
authorOliver Kellogg <okellogg@users.sourceforge.net>2023-01-14 23:33:27 +0100
committerOliver Kellogg <okellogg@users.sourceforge.net>2023-01-14 23:33:27 +0100
commitf790b484f95da51afd080f5cc73209c086476ad2 (patch)
tree70f7566aee382f71257e1ebfa9b0ce87b678c995 /TAO
parent0fd18ea8107aed0274c5e73da15f6f7e18337f8b (diff)
downloadATCD-f790b484f95da51afd080f5cc73209c086476ad2.tar.gz
Address issue #2015 : In TAO/TAO_IDL/ast/ast_field.cpp constructor handle AST_Decl::NT_except.
Diffstat (limited to 'TAO')
-rw-r--r--TAO/TAO_IDL/ast/ast_argument.cpp11
-rw-r--r--TAO/TAO_IDL/ast/ast_field.cpp4
-rw-r--r--TAO/tests/IDL_Test/README4
-rw-r--r--TAO/tests/IDL_Test/exception_misuse1.idl15
-rw-r--r--TAO/tests/IDL_Test/exception_misuse2.idl17
-rwxr-xr-xTAO/tests/IDL_Test/run_test.pl22
6 files changed, 73 insertions, 0 deletions
diff --git a/TAO/TAO_IDL/ast/ast_argument.cpp b/TAO/TAO_IDL/ast/ast_argument.cpp
index 0fbe32d0656..039e5662f23 100644
--- a/TAO/TAO_IDL/ast/ast_argument.cpp
+++ b/TAO/TAO_IDL/ast/ast_argument.cpp
@@ -70,6 +70,11 @@ trademarks or registered trademarks of Sun Microsystems, Inc.
#include "ast_argument.h"
#include "ast_visitor.h"
+#include "ast_type.h"
+
+#include "utl_err.h"
+
+#include "global_extern.h"
// Static functions.
@@ -101,6 +106,12 @@ AST_Argument::AST_Argument (Direction d,
AST_Field (AST_Decl::NT_argument, ft, n),
pd_direction (d)
{
+ AST_Decl::NodeType fnt = ft->node_type ();
+
+ if (fnt == AST_Decl::NT_except)
+ {
+ idl_global->err ()->not_a_type (ft);
+ }
}
AST_Argument::~AST_Argument ()
diff --git a/TAO/TAO_IDL/ast/ast_field.cpp b/TAO/TAO_IDL/ast/ast_field.cpp
index 6b09b061604..bacbf80714c 100644
--- a/TAO/TAO_IDL/ast/ast_field.cpp
+++ b/TAO/TAO_IDL/ast/ast_field.cpp
@@ -115,6 +115,10 @@ AST_Field::AST_Field (AST_Type *ft,
idl_global->err ()->not_a_type (ft);
}
}
+ else if (fnt == AST_Decl::NT_except)
+ {
+ idl_global->err ()->not_a_type (ft);
+ }
}
// To be used when constructing a node of a subclass of AST_Field.
diff --git a/TAO/tests/IDL_Test/README b/TAO/tests/IDL_Test/README
index 386728b4915..ec8321dd999 100644
--- a/TAO/tests/IDL_Test/README
+++ b/TAO/tests/IDL_Test/README
@@ -37,3 +37,7 @@ The rest of the .idl files need only to build cleanly. To test the
client/server functionality of the various IDL types and operations,
see the test suite in ACE_wrappers/TAO/tests/Param_Test.
+There are a few negative tests (e.g. invalid_scoping, keyword_case_diff,
+exception_misuse) where it shall be verified that tao_idl exits with
+an error status. The main.cpp program cannot be used for them because
+it only handles positive tests. To this end, run the script run_test.pl.
diff --git a/TAO/tests/IDL_Test/exception_misuse1.idl b/TAO/tests/IDL_Test/exception_misuse1.idl
new file mode 100644
index 00000000000..0c614127f20
--- /dev/null
+++ b/TAO/tests/IDL_Test/exception_misuse1.idl
@@ -0,0 +1,15 @@
+/**
+ * @file exception_misuse1.idl
+ *
+ * https://github.com/DOCGroup/ACE_TAO/issues/2015
+ *
+ * tao_idl shall reject use of exception for argument of method
+ *
+ */
+interface exception_misuse1 {
+ exception exc_t {
+ string reason;
+ };
+ void doit (in exc_t ex);
+};
+
diff --git a/TAO/tests/IDL_Test/exception_misuse2.idl b/TAO/tests/IDL_Test/exception_misuse2.idl
new file mode 100644
index 00000000000..d5deeeebd22
--- /dev/null
+++ b/TAO/tests/IDL_Test/exception_misuse2.idl
@@ -0,0 +1,17 @@
+/**
+ * @file exception_misuse2.idl
+ *
+ * https://github.com/DOCGroup/ACE_TAO/issues/2015
+ *
+ * tao_idl shall reject use of exception for struct member
+ *
+ */
+module exception_misuse2 {
+ exception exc_t {
+ string reason;
+ };
+ struct mystruct {
+ exc_t ex;
+ };
+};
+
diff --git a/TAO/tests/IDL_Test/run_test.pl b/TAO/tests/IDL_Test/run_test.pl
index 90a7fa9f5d9..4555a81197c 100755
--- a/TAO/tests/IDL_Test/run_test.pl
+++ b/TAO/tests/IDL_Test/run_test.pl
@@ -62,6 +62,20 @@ $test5 = $SV->SpawnWaitKill ($server5->ProcessStartWaitInterval());
open (STDERR, ">&STDOUT");
+my $server6 = PerlACE::TestTarget::create_target (6) || die "Create target 6 failed\n";
+my $input_file6 = $server6->LocalFile ("exception_misuse1.idl");
+
+# Compile the IDL
+$SV = $server6->CreateProcess ("$tao_idl", "$input_file6");
+$test6 = $SV->SpawnWaitKill ($server6->ProcessStartWaitInterval());
+
+my $server7 = PerlACE::TestTarget::create_target (7) || die "Create target 7 failed\n";
+my $input_file7 = $server7->LocalFile ("exception_misuse2.idl");
+
+# Compile the IDL
+$SV = $server7->CreateProcess ("$tao_idl", "$input_file7");
+$test7 = $SV->SpawnWaitKill ($server7->ProcessStartWaitInterval());
+
sub analyze_results {
my $result_file = $_[0];
@@ -107,5 +121,13 @@ if ($match5!= 0) {
print STDERR "ERROR: tao_idl -Cw should have printed warning for $input_file5\n";
$status = 1;
}
+if ($test6 == 0) {
+ print STDERR "ERROR: tao_idl returned $test6 for $input_file6, should have failed!\n";
+ $status = 1;
+}
+if ($test7 == 0) {
+ print STDERR "ERROR: tao_idl returned $test7 for $input_file7, should have failed!\n";
+ $status = 1;
+}
exit $status;