From ab4abe514a617ef530a18d5f71950d082ebd1ac4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 4 Dec 2013 12:20:04 +0200 Subject: Fix bug in wrapped type resolution --- odb/processor.cxx | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/odb/processor.cxx b/odb/processor.cxx index 8eab2d8..89905c2 100644 --- a/odb/processor.cxx +++ b/odb/processor.cxx @@ -938,8 +938,39 @@ namespace // tree type (DECL_ORIGINAL_TYPE (decl)); - semantics::type& wt ( - dynamic_cast (*unit.find (type))); + bool qc (CP_TYPE_CONST_P (type)); + bool qv (CP_TYPE_VOLATILE_P (type)); + bool qr (CP_TYPE_RESTRICT_P (type)); + + type = TYPE_MAIN_VARIANT (type); + semantics::type* wt ( + dynamic_cast (unit.find (type))); + + // Object pointers and wrappers often use the same smart + // pointers so check if the wrapped type is an object. + // + if (object (*wt)) + { + t.set ("wrapper", false); + return false; + } + + if (qc || qv || qr) + { + for (semantics::type::qualified_iterator i (wt->qualified_begin ()); + i != wt->qualified_end (); ++i) + { + semantics::qualifier& q (i->qualifier ()); + + if (q.const_ () == qc && + q.volatile_ () == qv && + q.restrict_ () == qr) + { + wt = &q; + break; + } + } + } // Find the hint. // @@ -955,7 +986,7 @@ namespace decl = TYPE_NAME (ot); } - t.set ("wrapper-type", &wt); + t.set ("wrapper-type", wt); t.set ("wrapper-hint", wh); } catch (operation_failed const&) -- cgit v1.1