From 8e6bde581d4fb817c7b10d3b2dbaf2b5e0f5dd48 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 18 Oct 2010 16:55:26 +0200 Subject: Check that a type actually classifies something --- xsde/cxx/parser/parser-source.cxx | 42 +++++++++++++++++++------------ xsde/cxx/serializer/serializer-source.cxx | 42 +++++++++++++++++++------------ 2 files changed, 52 insertions(+), 32 deletions(-) (limited to 'xsde/cxx') diff --git a/xsde/cxx/parser/parser-source.cxx b/xsde/cxx/parser/parser-source.cxx index 54d5a05..69f2432 100644 --- a/xsde/cxx/parser/parser-source.cxx +++ b/xsde/cxx/parser/parser-source.cxx @@ -116,16 +116,21 @@ namespace CXX if (!gen) { // The first instance that this anonymous type classifies - // is the prototype for others if any. + // is the prototype for others if any. If this type does + // not classify anything (e.g., it is a base), then we + // don't need to do anything. // - SemanticGraph::Instance& i ( - e.classifies_begin ()->instance ()); - - if (SemanticGraph::Element* e = - dynamic_cast (&i)) + if (e.classifies_begin () != e.classifies_end ()) { - if (e->substitutes_p ()) - gen = true; + SemanticGraph::Instance& i ( + e.classifies_begin ()->instance ()); + + if (SemanticGraph::Element* e = + dynamic_cast (&i)) + { + if (e->substitutes_p ()) + gen = true; + } } } @@ -1293,16 +1298,21 @@ namespace CXX if (!gen) { // The first instance that this anonymous type classifies - // is the prototype for others if any. + // is the prototype for others if any. If this type does + // not classify anything (e.g., it is a base), then we + // don't need to do anything. // - SemanticGraph::Instance& i ( - c.classifies_begin ()->instance ()); - - if (SemanticGraph::Element* e = - dynamic_cast (&i)) + if (c.classifies_begin () != c.classifies_end ()) { - if (e->substitutes_p ()) - gen = true; + SemanticGraph::Instance& i ( + c.classifies_begin ()->instance ()); + + if (SemanticGraph::Element* e = + dynamic_cast (&i)) + { + if (e->substitutes_p ()) + gen = true; + } } } diff --git a/xsde/cxx/serializer/serializer-source.cxx b/xsde/cxx/serializer/serializer-source.cxx index 630d052..a11a221 100644 --- a/xsde/cxx/serializer/serializer-source.cxx +++ b/xsde/cxx/serializer/serializer-source.cxx @@ -446,16 +446,21 @@ namespace CXX if (!gen) { // The first instance that this anonymous type classifies - // is the prototype for others if any. + // is the prototype for others if any. If this type does + // not classify anything (e.g., it is a base), then we + // don't need to do anything. // - SemanticGraph::Instance& i ( - e.classifies_begin ()->instance ()); - - if (SemanticGraph::Element* e = - dynamic_cast (&i)) + if (e.classifies_begin () != e.classifies_end ()) { - if (e->substitutes_p ()) - gen = true; + SemanticGraph::Instance& i ( + e.classifies_begin ()->instance ()); + + if (SemanticGraph::Element* e = + dynamic_cast (&i)) + { + if (e->substitutes_p ()) + gen = true; + } } } @@ -2461,16 +2466,21 @@ namespace CXX if (!gen) { // The first instance that this anonymous type classifies - // is the prototype for others if any. + // is the prototype for others if any. If this type does + // not classify anything (e.g., it is a base), then we + // don't need to do anything. // - SemanticGraph::Instance& i ( - c.classifies_begin ()->instance ()); - - if (SemanticGraph::Element* e = - dynamic_cast (&i)) + if (c.classifies_begin () != c.classifies_end ()) { - if (e->substitutes_p ()) - gen = true; + SemanticGraph::Instance& i ( + c.classifies_begin ()->instance ()); + + if (SemanticGraph::Element* e = + dynamic_cast (&i)) + { + if (e->substitutes_p ()) + gen = true; + } } } -- cgit v1.1