summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-08-26 21:57:33 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-08-26 21:57:33 +0000
commite0dbedd51eac371a1932832cda334d74150cb0b4 (patch)
treee7b0d6934c37dfb3f9a313b0e7c774c572a01f02
parent7cb763e1f0b8d16d7d9e5b4a2a310862f7be36cc (diff)
downloadATCD-e0dbedd51eac371a1932832cda334d74150cb0b4.tar.gz
Mods to check for redefs or case differences in inherited interface
members,
-rw-r--r--TAO/TAO_IDL/ast/ast_interface.cpp122
-rw-r--r--TAO/TAO_IDL/include/ast_interface.h5
-rw-r--r--TAO/TAO_IDL/include/utl_err.h6
-rw-r--r--TAO/TAO_IDL/include/utl_error.h6
-rw-r--r--TAO/TAO_IDL/include/utl_identifier.h3
-rw-r--r--TAO/TAO_IDL/include/utl_string.h3
-rw-r--r--TAO/TAO_IDL/util/utl_err.cpp37
-rw-r--r--TAO/TAO_IDL/util/utl_error.cpp37
-rw-r--r--TAO/TAO_IDL/util/utl_identifier.cpp10
-rw-r--r--TAO/TAO_IDL/util/utl_string.cpp16
10 files changed, 245 insertions, 0 deletions
diff --git a/TAO/TAO_IDL/ast/ast_interface.cpp b/TAO/TAO_IDL/ast/ast_interface.cpp
index 762f4001986..71295c767c3 100644
--- a/TAO/TAO_IDL/ast/ast_interface.cpp
+++ b/TAO/TAO_IDL/ast/ast_interface.cpp
@@ -806,6 +806,128 @@ AST_Interface::compare_names (AST_Interface *that,
return I_TRUE;
}
+void
+AST_Interface::inherited_name_clash ()
+{
+ AST_Decl *my_member, *parent1_member, *parent2_member;
+
+ // Compare our members with those of each parent.
+
+ UTL_ScopeActiveIterator *my_members =
+ new UTL_ScopeActiveIterator (DeclAsScope (this),
+ UTL_Scope::IK_decls);
+
+ while (!(my_members->is_done ()))
+ {
+ my_member = my_members->item ();
+ Identifier *id = my_member->local_name ();
+
+ for (int i = 0; i < this->pd_n_inherits; i ++)
+ {
+ UTL_ScopeActiveIterator *parent_members =
+ new UTL_ScopeActiveIterator (DeclAsScope (pd_inherits[i]),
+ UTL_Scope::IK_decls);
+
+ while (!(parent_members->is_done ()))
+ {
+ parent1_member = parent_members->item ();
+ Identifier *pid = parent1_member->local_name ();
+
+ if (id->compare (pid) == I_TRUE)
+ {
+ idl_global->err ()->error2 (UTL_Error::EIDL_REDEF,
+ my_member,
+ parent1_member);
+ }
+ else if (id->case_compare_quiet (pid) == I_TRUE)
+ {
+ if (idl_global->case_diff_error ())
+ {
+ idl_global->err ()->error2 (UTL_Error::EIDL_NAME_CASE_ERROR,
+ my_member,
+ parent1_member);
+ }
+ else
+ {
+ idl_global->err ()->warning2 (UTL_Error::EIDL_NAME_CASE_WARNING,
+ my_member,
+ parent1_member);
+ }
+ }
+
+ parent_members->next ();
+ }
+
+ delete parent_members;
+ }
+
+ my_members->next ();
+ }
+
+ delete my_members;
+
+ // Now compare members of each parent with each other.
+
+ for (int i = 0; i < this->pd_n_inherits - 1; i++)
+ {
+ UTL_ScopeActiveIterator *parent1_members =
+ new UTL_ScopeActiveIterator (DeclAsScope (pd_inherits[i]),
+ UTL_Scope::IK_decls);
+
+ while (!(parent1_members->is_done ()))
+ {
+ parent1_member = parent1_members->item ();
+ Identifier *pid1 = parent1_member->local_name ();
+
+ for (int j = i + 1; j < this->pd_n_inherits; j++)
+ {
+ UTL_ScopeActiveIterator *parent2_members =
+ new UTL_ScopeActiveIterator (DeclAsScope (pd_inherits[j]),
+ UTL_Scope::IK_decls);
+
+ while (!(parent2_members->is_done ()))
+ {
+ parent2_member = parent2_members->item ();
+ Identifier *pid2 = parent2_member->local_name ();
+
+ if (pid1->compare (pid2) == I_TRUE)
+ {
+ idl_global->err ()->error3 (UTL_Error::EIDL_REDEF,
+ this,
+ parent1_member,
+ parent2_member);
+ }
+ else if (pid1->case_compare_quiet (pid2) == I_TRUE)
+ {
+ if (idl_global->case_diff_error ())
+ {
+ idl_global->err ()->error3 (UTL_Error::EIDL_NAME_CASE_ERROR,
+ this,
+ parent1_member,
+ parent2_member);
+ }
+ else
+ {
+ idl_global->err ()->warning3 (UTL_Error::EIDL_NAME_CASE_WARNING,
+ this,
+ parent1_member,
+ parent2_member);
+ }
+ }
+
+ parent2_members->next ();
+ }
+
+ delete parent2_members;
+ }
+
+ parent1_members->next ();
+ }
+
+ delete parent1_members;
+ }
+}
+
/*
* Narrowing methods
*/
diff --git a/TAO/TAO_IDL/include/ast_interface.h b/TAO/TAO_IDL/include/ast_interface.h
index e49aa173ff2..a2289ad08f7 100644
--- a/TAO/TAO_IDL/include/ast_interface.h
+++ b/TAO/TAO_IDL/include/ast_interface.h
@@ -122,6 +122,11 @@ public:
virtual idl_bool is_abstract_valuetype ();
virtual void set_abstract_valuetype ();
+ // Check if any member's name clashes with a parent's
+ // member's name, or if any parents' members' names
+ // clash with each other.
+ void inherited_name_clash ();
+
// Narrowing
DEF_NARROW_METHODS2(AST_Interface, AST_Type, UTL_Scope);
DEF_NARROW_FROM_DECL(AST_Interface);
diff --git a/TAO/TAO_IDL/include/utl_err.h b/TAO/TAO_IDL/include/utl_err.h
index 87c2f8019a2..5e0ee910603 100644
--- a/TAO/TAO_IDL/include/utl_err.h
+++ b/TAO/TAO_IDL/include/utl_err.h
@@ -126,6 +126,12 @@ public:
void error2(ErrorCode e, AST_Decl *t1, AST_Decl *t2);
void error3(ErrorCode e, AST_Decl *t1, AST_Decl *t2, AST_Decl *t3);
+ // Report warnings with varying numbers of arguments
+ void warning0(ErrorCode e);
+ void warning1(ErrorCode e, AST_Decl *t);
+ void warning2(ErrorCode e, AST_Decl *t1, AST_Decl *t2);
+ void warning3(ErrorCode e, AST_Decl *t1, AST_Decl *t2, AST_Decl *t3);
+
// Report a syntax error in IDL input
void syntax_error(IDL_GlobalData::ParseState ps);
diff --git a/TAO/TAO_IDL/include/utl_error.h b/TAO/TAO_IDL/include/utl_error.h
index 87c2f8019a2..5e0ee910603 100644
--- a/TAO/TAO_IDL/include/utl_error.h
+++ b/TAO/TAO_IDL/include/utl_error.h
@@ -126,6 +126,12 @@ public:
void error2(ErrorCode e, AST_Decl *t1, AST_Decl *t2);
void error3(ErrorCode e, AST_Decl *t1, AST_Decl *t2, AST_Decl *t3);
+ // Report warnings with varying numbers of arguments
+ void warning0(ErrorCode e);
+ void warning1(ErrorCode e, AST_Decl *t);
+ void warning2(ErrorCode e, AST_Decl *t1, AST_Decl *t2);
+ void warning3(ErrorCode e, AST_Decl *t1, AST_Decl *t2, AST_Decl *t3);
+
// Report a syntax error in IDL input
void syntax_error(IDL_GlobalData::ParseState ps);
diff --git a/TAO/TAO_IDL/include/utl_identifier.h b/TAO/TAO_IDL/include/utl_identifier.h
index d889a643f32..95617ebd007 100644
--- a/TAO/TAO_IDL/include/utl_identifier.h
+++ b/TAO/TAO_IDL/include/utl_identifier.h
@@ -103,6 +103,9 @@ public:
long case_compare (Identifier *other);
// also check for case-only difference
+ long case_compare_quiet (Identifier *other);
+ // Like the above but suppressing error or warning I/O
+
// =Dumping
virtual void dump (ostream &o);
diff --git a/TAO/TAO_IDL/include/utl_string.h b/TAO/TAO_IDL/include/utl_string.h
index 568c79f8515..6e4c7d04f82 100644
--- a/TAO/TAO_IDL/include/utl_string.h
+++ b/TAO/TAO_IDL/include/utl_string.h
@@ -116,6 +116,9 @@ public:
virtual long compare (UTL_String *s);
// Compare two String *
+ virtual long compare_quiet (UTL_String *s);
+ // Like the above but without error or warning message output.
+
private:
// Data
char *p_str;
diff --git a/TAO/TAO_IDL/util/utl_err.cpp b/TAO/TAO_IDL/util/utl_err.cpp
index e1d9678b8f3..13cd131282f 100644
--- a/TAO/TAO_IDL/util/utl_err.cpp
+++ b/TAO/TAO_IDL/util/utl_err.cpp
@@ -515,6 +515,43 @@ UTL_Error::error3(UTL_Error::ErrorCode c,
idl_global->set_err_count(idl_global->err_count() + 1);
}
+void
+UTL_Error::warning0 (UTL_Error::ErrorCode c)
+{
+ idl_error_header(c, idl_global->lineno(), idl_global->filename());
+ cerr << "\n";
+}
+
+void
+UTL_Error::warning1 (UTL_Error::ErrorCode c,
+ AST_Decl *d)
+{
+ idl_error_header(c, d->line(), d->file_name());
+ d->name()->dump(cerr); cerr << "\n";
+}
+
+void
+UTL_Error::warning2 (UTL_Error::ErrorCode c,
+ AST_Decl *d1,
+ AST_Decl *d2)
+{
+ idl_error_header(c, d1->line(), d1->file_name());
+ d1->name()->dump(cerr); cerr << ", ";
+ d2->name()->dump(cerr); cerr << "\n";
+}
+
+void
+UTL_Error::warning3 (UTL_Error::ErrorCode c,
+ AST_Decl *d1,
+ AST_Decl *d2,
+ AST_Decl *d3)
+{
+ idl_error_header(c, d1->line(), d1->file_name());
+ d1->name()->dump(cerr); cerr << ", ";
+ d2->name()->dump(cerr); cerr << ", ";
+ d3->name()->dump(cerr); cerr << "\n";
+}
+
// Report a failed coercion attempt
void
UTL_Error::coercion_error(AST_Expression *v, AST_Expression::ExprType t)
diff --git a/TAO/TAO_IDL/util/utl_error.cpp b/TAO/TAO_IDL/util/utl_error.cpp
index e1d9678b8f3..13cd131282f 100644
--- a/TAO/TAO_IDL/util/utl_error.cpp
+++ b/TAO/TAO_IDL/util/utl_error.cpp
@@ -515,6 +515,43 @@ UTL_Error::error3(UTL_Error::ErrorCode c,
idl_global->set_err_count(idl_global->err_count() + 1);
}
+void
+UTL_Error::warning0 (UTL_Error::ErrorCode c)
+{
+ idl_error_header(c, idl_global->lineno(), idl_global->filename());
+ cerr << "\n";
+}
+
+void
+UTL_Error::warning1 (UTL_Error::ErrorCode c,
+ AST_Decl *d)
+{
+ idl_error_header(c, d->line(), d->file_name());
+ d->name()->dump(cerr); cerr << "\n";
+}
+
+void
+UTL_Error::warning2 (UTL_Error::ErrorCode c,
+ AST_Decl *d1,
+ AST_Decl *d2)
+{
+ idl_error_header(c, d1->line(), d1->file_name());
+ d1->name()->dump(cerr); cerr << ", ";
+ d2->name()->dump(cerr); cerr << "\n";
+}
+
+void
+UTL_Error::warning3 (UTL_Error::ErrorCode c,
+ AST_Decl *d1,
+ AST_Decl *d2,
+ AST_Decl *d3)
+{
+ idl_error_header(c, d1->line(), d1->file_name());
+ d1->name()->dump(cerr); cerr << ", ";
+ d2->name()->dump(cerr); cerr << ", ";
+ d3->name()->dump(cerr); cerr << "\n";
+}
+
// Report a failed coercion attempt
void
UTL_Error::coercion_error(AST_Expression *v, AST_Expression::ExprType t)
diff --git a/TAO/TAO_IDL/util/utl_identifier.cpp b/TAO/TAO_IDL/util/utl_identifier.cpp
index f5a9172ae06..1f91f9a199b 100644
--- a/TAO/TAO_IDL/util/utl_identifier.cpp
+++ b/TAO/TAO_IDL/util/utl_identifier.cpp
@@ -122,6 +122,16 @@ Identifier::case_compare (Identifier *o)
return member.compare (&other);
}
+// Report no error if the two identifiers differ only in case.
+long
+Identifier::case_compare_quiet (Identifier *o)
+{
+ UTL_String member (this->pv_string);
+ UTL_String other (o->get_string ());
+
+ return member.compare_quiet (&other);
+}
+
// Dumping
void
diff --git a/TAO/TAO_IDL/util/utl_string.cpp b/TAO/TAO_IDL/util/utl_string.cpp
index 3295a8343be..76b056bb06a 100644
--- a/TAO/TAO_IDL/util/utl_string.cpp
+++ b/TAO/TAO_IDL/util/utl_string.cpp
@@ -194,6 +194,22 @@ UTL_String::compare (UTL_String *s)
return result;
}
+long
+UTL_String::compare_quiet (UTL_String *s)
+{
+ char *s_c_str;
+ long result;
+
+ if (c_str == NULL || s == NULL || (s_c_str = s->get_canonical_rep ()) == NULL)
+ result = I_FALSE;
+ else if (ACE_OS::strcmp (c_str, s_c_str) != 0)
+ result = I_FALSE;
+ else if (ACE_OS::strcmp (p_str, s->get_string ()) != 0)
+ result = I_TRUE;
+
+ return result;
+}
+
// Get the char * from a String
char *
UTL_String::get_string (void)