From 73edd8b28ac415b6fdb7d8c7f8728dc7f8de75d0 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 29 Nov 2010 09:27:29 +0200 Subject: Make container pragmas also work on types in addition to members --- odb/pragma.cxx | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) (limited to 'odb/pragma.cxx') diff --git a/odb/pragma.cxx b/odb/pragma.cxx index 9970376..002a25c 100644 --- a/odb/pragma.cxx +++ b/odb/pragma.cxx @@ -117,12 +117,7 @@ check_decl_type (tree d, string const& name, string const& p, location_t l) p == "id" || p == "auto" || p == "column" || - p == "value_column" || - p == "index_column" || - p == "key_column" || - p == "id_column" || p == "inverse" || - p == "unordered" || p == "transient") { if (tc != FIELD_DECL) @@ -144,11 +139,12 @@ check_decl_type (tree d, string const& name, string const& p, location_t l) } else if (p == "table") { - // Table can be used for both members (container) and types. + // Table can be used for both members (container) and types (container + // or object). // - if (tc != FIELD_DECL && tc != RECORD_TYPE) + if (tc != FIELD_DECL && !TYPE_P (d)) { - error_at (l, "name %qs in db pragma %qs does not refer to a class " + error_at (l, "name %qs in db pragma %qs does not refer to a type " "or data member", name.c_str (), pc); return false; } @@ -176,6 +172,33 @@ check_decl_type (tree d, string const& name, string const& p, location_t l) return false; } } + else if (p == "value_column" || + p == "index_column" || + p == "key_column" || + p == "id_column") + { + // Container columns can be used for both members (container) and + // types (container). + // + if (tc != FIELD_DECL && !TYPE_P (d)) + { + error_at (l, "name %qs in db pragma %qs does not refer to a type " + "or data member", name.c_str (), pc); + return false; + } + } + else if (p == "unordered") + { + // Unordered can be used for both members (container) and + // types (container). + // + if (tc != FIELD_DECL && !TYPE_P (d)) + { + error_at (l, "name %qs in db pragma %qs does not refer to a type " + "or data member", name.c_str (), pc); + return false; + } + } else { error ("unknown db pragma %qs", pc); -- cgit v1.1