aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-09-19 14:21:30 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-09-19 14:21:30 +0200
commit6c01cad9cbfb6e69121d106226b2c50026f86fa9 (patch)
treeb3225c9b113f52cf63ed13ad7ca2be0693f2bd03
parentab132de5f11e414974cdc0c4b8d85a19792b2e47 (diff)
Use scope and location of db pointer pragma instead of class
-rw-r--r--odb/context.hxx9
-rw-r--r--odb/pragma.cxx20
-rw-r--r--odb/relational/type-processor.cxx65
3 files changed, 63 insertions, 31 deletions
diff --git a/odb/context.hxx b/odb/context.hxx
index 62054a5..1e6ccae 100644
--- a/odb/context.hxx
+++ b/odb/context.hxx
@@ -84,6 +84,15 @@ typedef std::vector<semantics::data_member*> data_member_path;
// Semantic graph context types.
//
+// Object or view pointer.
+//
+struct class_pointer
+{
+ std::string name;
+ tree scope;
+ location_t loc;
+};
+
//
//
struct default_value
diff --git a/odb/pragma.cxx b/odb/pragma.cxx
index e41792a..2fb6d27 100644
--- a/odb/pragma.cxx
+++ b/odb/pragma.cxx
@@ -506,7 +506,7 @@ handle_pragma (cpp_reader* reader,
return;
}
- string v;
+ class_pointer cp;
size_t pb (0);
bool punc (false);
@@ -515,7 +515,7 @@ handle_pragma (cpp_reader* reader,
tt = pragma_lex (&t))
{
if (punc && tt > CPP_LAST_PUNCTUATOR)
- v += ' ';
+ cp.name += ' ';
punc = false;
@@ -530,29 +530,29 @@ handle_pragma (cpp_reader* reader,
{
case CPP_LESS:
{
- v += "< ";
+ cp.name += "< ";
break;
}
case CPP_GREATER:
{
- v += " >";
+ cp.name += " >";
break;
}
case CPP_COMMA:
{
- v += ", ";
+ cp.name += ", ";
break;
}
case CPP_NAME:
{
- v += IDENTIFIER_POINTER (t);
+ cp.name += IDENTIFIER_POINTER (t);
punc = true;
break;
}
default:
{
if (tt <= CPP_LAST_PUNCTUATOR)
- v += cxx_lexer::token_spelling[tt];
+ cp.name += cxx_lexer::token_spelling[tt];
else
{
error () << "unexpected token '" << cxx_lexer::token_spelling[tt]
@@ -570,13 +570,15 @@ handle_pragma (cpp_reader* reader,
return;
}
- if (v.empty ())
+ if (cp.name.empty ())
{
error () << "expected pointer name in db pragma " << p << endl;
return;
}
- val = v;
+ cp.scope = current_scope ();
+ cp.loc = loc;
+ val = cp;
tt = pragma_lex (&t);
}
diff --git a/odb/relational/type-processor.cxx b/odb/relational/type-processor.cxx
index de05735..c6e8d41 100644
--- a/odb/relational/type-processor.cxx
+++ b/odb/relational/type-processor.cxx
@@ -1898,21 +1898,21 @@ namespace relational
void
assign_pointer (type& c)
{
+ location_t loc (0); // Pragma location, or 0 if not used.
+
try
{
string ptr;
string const& name (c.fq_name ());
- tree decl (0); // Resolved template node.
- string decl_name; // User-provided template name.
-
- // Scope in which the pointer pragma was specified.
- //
- tree resolve_scope (c.scope ().tree_node ());
+ tree decl (0); // Resolved template node.
+ string decl_name; // User-provided template name.
+ tree resolve_scope (0); // Scope in which we resolve names.
if (c.count ("pointer"))
{
- string const& p (c.get<string> ("pointer"));
+ class_pointer const& cp (c.get<class_pointer> ("pointer"));
+ string const& p (cp.name);
if (p == "*")
ptr = name + "*";
@@ -1930,7 +1930,7 @@ namespace relational
// This is not a template-id. Resolve it and see if it is a
// template or a type.
//
- decl = resolve_name (p, resolve_scope, true);
+ decl = resolve_name (p, cp.scope, true);
int tc (TREE_CODE (decl));
if (tc == TYPE_DECL)
@@ -1958,14 +1958,18 @@ namespace relational
}
else
{
- cerr << c.file () << ":" << c.line () << ":" << c.column ()
- << ": error: name '" << p << "' specified with "
- << "'#pragma object pointer' does not name a type "
- << "or a template" << endl;
+ error (cp.loc)
+ << "name '" << p << "' specified with db pragma pointer "
+ << "does not name a type or a template" << endl;
throw generation_failed ();
}
}
+
+ // Resolve scope is the scope of the pragma.
+ //
+ resolve_scope = cp.scope;
+ loc = cp.loc;
}
else
{
@@ -1980,6 +1984,10 @@ namespace relational
ptr = p + "< " + name + " >";
decl_name = p;
}
+
+ // Resolve scope is the scope of the class.
+ //
+ resolve_scope = c.scope ().tree_node ();
}
// Check if we are using TR1.
@@ -2012,10 +2020,12 @@ namespace relational
if (TREE_CODE (decl) != TEMPLATE_DECL || !
DECL_CLASS_TEMPLATE_P (decl))
{
- cerr << c.file () << ":" << c.line () << ":" << c.column ()
- << ": error: name '" << decl_name << "' specified with "
- << "'#pragma object pointer' does not name a class "
- << "template" << endl;
+ // This is only checked for the --default-pointer option.
+ //
+ error (c.file (), c.line (), c.column ())
+ << "name '" << decl_name << "' specified with the "
+ << "--default-pointer option does not name a class "
+ << "template" << endl;
throw generation_failed ();
}
@@ -2122,17 +2132,28 @@ namespace relational
}
catch (invalid_name const& ex)
{
- cerr << c.file () << ":" << c.line () << ":" << c.column ()
- << ": error: name '" << ex.name () << "' specified with "
- << "'#pragma object pointer' is invalid" << endl;
+ if (loc != 0)
+ error (loc)
+ << "name '" << ex.name () << "' specified with db pragma "
+ << "pointer is invalid" << endl;
+ else
+ error (c.file (), c.line (), c.column ())
+ << "name '" << ex.name () << "' specified with the "
+ << "--default-pointer option is invalid" << endl;
+
throw generation_failed ();
}
catch (unable_to_resolve const& ex)
{
- cerr << c.file () << ":" << c.line () << ":" << c.column ()
- << ": error: unable to resolve name '" << ex.name ()
- << "' specified with '#pragma object pointer'" << endl;
+ if (loc != 0)
+ error (loc)
+ << "unable to resolve name '" << ex.name () << "' specified "
+ << "with db pragma pointer" << endl;
+ else
+ error (c.file (), c.line (), c.column ())
+ << "unable to resolve name '" << ex.name () << "' specified "
+ << "with the --default-pointer option" << endl;
throw generation_failed ();
}