From 5789a4f7c5cee94df29e37fd1c2f7c1d9e883002 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 7 Dec 2010 11:03:33 +0200 Subject: Allow inheritance from transient bases for object and composite value types --- odb/validator.cxx | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) (limited to 'odb/validator.cxx') diff --git a/odb/validator.cxx b/odb/validator.cxx index 73c8f90..87edb21 100644 --- a/odb/validator.cxx +++ b/odb/validator.cxx @@ -84,12 +84,37 @@ namespace virtual void traverse_object (type& c) { - if (c.inherits_begin () != c.inherits_end ()) + for (type::inherits_iterator i (c.inherits_begin ()); + i != c.inherits_end (); + ++i) { - cerr << c.file () << ":" << c.line () << ":" << c.column () << ":" - << " error: object inheritance is not yet supported" << endl; + type& b (i->base ()); - valid_ = false; + if (b.count ("object")) + { + cerr << c.file () << ":" << c.line () << ":" << c.column () << ":" + << " error: object inheritance is not yet supported" << endl; + + valid_ = false; + } + else if (context::comp_value (b)) + { + // @@ Should we use hint here? + // + string name (b.fq_name ()); + + cerr << c.file () << ":" << c.line () << ":" << c.column () << ":" + << " error: base class '" << name << "' is a value type" + << endl; + + cerr << c.file () << ":" << c.line () << ":" << c.column () << ":" + << " info: object types cannot derive from value types" << endl; + + cerr << b.file () << ":" << b.line () << ":" << b.column () << ":" + << " info: class '" << name << "' is defined here" << endl; + + valid_ = false; + } } member_.count_ = 0; @@ -127,19 +152,19 @@ namespace { type& b (i->base ()); - if (!context::comp_value (b)) + if (b.count ("object")) { // @@ Should we use hint here? // string name (b.fq_name ()); cerr << c.file () << ":" << c.line () << ":" << c.column () << ":" - << " error: base class '" << name << "' is not a " - << "composite value type" << endl; + << " error: base class '" << name << "' is an object type" + << endl; cerr << c.file () << ":" << c.line () << ":" << c.column () << ":" - << " info: composite value types can only derive from other " - << "composite value types" << endl; + << " info: composite value types cannot derive from object " + << "types" << endl; cerr << b.file () << ":" << b.line () << ":" << b.column () << ":" << " info: class '" << name << "' is defined here" << endl; -- cgit v1.1