namespaces and prefix types in context analysis
Martin Stein <[email protected]> Mon, 02 Mar 2015 23:22:58 +0100
| Newsgroups | gmane.emacs.cedet |
|---|---|
| Message-ID | <[email protected]> |
Hi,
trying to figure out how C++ accomplishes computation of prefixe types
for context analysis, I checked the following piece of code. It is
derived from an equivalent f90 code, for which context analysis failed
as well. Here it is:
namespace mystructs
{
struct aaa
{
int xx;
};
struct bbb
{
struct aaa yy;
};
}
struct bbb zz;
int fun()
{
using mystructs;
int uu = zz.!-1-
int vv = zz.yy.!-2-
}
Completion at -1- works fine. Completion at -2- fails, because it cannot
find the type for yy, which seems strange. Is that valid C++ code? As I
said, I encounter the exact same problem with f90. The reason for the
problem, as far as I have dived into the code, is the following.
Context analysis succeeds and has struct aaa and struct bbb in its scope.
Function semantic/analyze.el:semantic-analyze-find-tag-sequence-default
tries to find type definition tags for the sequence (""zz" "yy" ""). It
starts with miniscope=scope and can resolve the type of zz in
semantic/analyze/fcn.el: semantic-analyze-type using this scope, where
it finds the proper type tag.
For the next entry of the sequence the miniscope is reduced to ("struct
aaa yy"), the variables declared as parts of aaa. Naturally, it cannot
find the type definition of aaa in this miniscope. semantic-analyze-type
then tries semanticdb-typecache-find, where it fails. I am not sure why
the db lookup fails (as those type tags are buried in the db), but I
guess it just checks top-level tags and does not dive into components of
those tags. Without the enclosing namespaces, completion works fine.
What I do not quite understand is the setting of slot fullscope of
miniscope in function semantic-analyze-find-tag-sequence-default. (Slot
typecache does not contain anything as well, so I am not sure in which
circumstances this slot comes into play.) Why should I overwrite
fullscope with a set of variable declaration tags, which are of no
apparent (at least to me) use in type analysis?
Without OOP and some other f03/08 goodies, those nested accesses are
quite common in f90 code, so this is somewhat important to me. However,
I will prepare a preliminary f90 parser release, as all other major
things seem to work.
Martin
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/