diff options
Diffstat (limited to 'odb')
-rw-r--r-- | odb/parser.cxx | 39 | ||||
-rw-r--r-- | odb/pragma.cxx | 9 |
2 files changed, 46 insertions, 2 deletions
diff --git a/odb/parser.cxx b/odb/parser.cxx index f620ed5..ad740c4 100644 --- a/odb/parser.cxx +++ b/odb/parser.cxx @@ -100,8 +100,12 @@ private: emit_type_name (tree, bool direct = true); + // // Pragma handling. // + + // Process positioned and named pragmas. + // void process_pragmas (tree, node&, @@ -110,6 +114,11 @@ private: decl_set::const_iterator cur, decl_set::const_iterator end); + // Process named pragmas only. + // + void + process_named_pragmas (tree, node&); + void diagnose_unassoc_pragmas (decl_set const&); @@ -192,6 +201,8 @@ define_fund (tree t) T& node (unit_->new_fund_node<T> (t)); unit_->new_edge<defines> (*scope_, node, name); unit_->insert (t, node); + + process_named_pragmas (t, node); } template <typename T> @@ -1224,6 +1235,8 @@ emit_type (tree t, // qualifier& q (unit_->new_node<qualifier> (file, line, clmn, t, qc, qv, qr)); unit_->new_edge<qualifies> (q, r); + process_named_pragmas (t, q); + return q; } @@ -1357,6 +1370,7 @@ create_type (tree t, << " at " << file << ":" << line << endl; unit_->new_edge<instantiates> (*i_node, *t_node); + process_named_pragmas (t, *i_node); r = i_node; } @@ -1443,6 +1457,7 @@ create_type (tree t, array& a (unit_->new_node<array> (file, line, clmn, t, size)); unit_->insert (t, a); unit_->new_edge<contains> (a, bt); + process_named_pragmas (t, a); r = &a; break; } @@ -1453,6 +1468,7 @@ create_type (tree t, reference& ref (unit_->new_node<reference> (file, line, clmn, t)); unit_->insert (t, ref); unit_->new_edge<references> (ref, bt); + process_named_pragmas (t, ref); r = &ref; break; } @@ -1465,6 +1481,7 @@ create_type (tree t, pointer& p (unit_->new_node<pointer> (file, line, clmn, t)); unit_->insert (t, p); unit_->new_edge<points> (p, bt); + process_named_pragmas (t, p); r = &p; } else @@ -1746,6 +1763,28 @@ process_pragmas (tree t, } void parser::impl:: +process_named_pragmas (tree t, node& node) +{ + pragma_set prags; + + decl_pragmas::const_iterator i (decl_pragmas_.find (t)); + + if (i != decl_pragmas_.end ()) + prags.insert (i->second.begin (), i->second.end ()); + + // Copy the resulting pragma set to context. + // + for (pragma_set::iterator i (prags.begin ()); i != prags.end (); ++i) + { + if (trace) + ts << "\t\t pragma " << i->name << " (" << i->value << ")" + << endl; + + node.set (i->name, i->value); + } +} + +void parser::impl:: diagnose_unassoc_pragmas (decl_set const& decls) { for (decl_set::const_iterator i (decls.begin ()), e (decls.end ()); diff --git a/odb/pragma.cxx b/odb/pragma.cxx index 771e33e..8226495 100644 --- a/odb/pragma.cxx +++ b/odb/pragma.cxx @@ -76,8 +76,13 @@ parse_scoped_name (tree& t, // Get the actual type if this is a TYPE_DECL. // - if (is_type && TREE_CODE (decl) == TYPE_DECL) - decl = TREE_TYPE (decl); + if (is_type) + { + if (TREE_CODE (decl) == TYPE_DECL) + decl = TREE_TYPE (decl); + + decl = TYPE_MAIN_VARIANT (decl); + } return decl; } |