Hi,
I made some changes to the C parser to try and deal with this. My
parser doesn't know the difference between classes or regular types to
know when it is ok for a variable to have an arg list instead of an
assignment, so it can't seem to figure out the difference between a
function and a variable.
In any case, part of your example now works better than it did before,
so I checked it in.
Eric
On 01/22/2010 09:45 PM, Eric M. Ludlam wrote:
> Hi Sebastian.
>
> This is an interesting example. It appears to be treating the ()
> args to the variable name as a function prototype, which doesn't support
> the , notation. Real compilers know that Toto is a type with a
> constructor when it sees the t1,t2 entries, and can distinguish it from
> a variable. The semantic parser doesn't do any type checking till you
> ask for completions, at which time it has already miscatagorized that text.
>
> The only fix I can think of is to allow the semantic parser to be
> sloppy and allow fcns declared like variables, or variables declared
> like fcns. The second I can imagine causes other kinds of problems.
>
> Perhaps someone one the list has a suggestion on what to do.
>
> Eric
>
> On 01/20/2010 05:37 AM, Sebastien VARRETTE wrote:
>> Hi all,
>>
>> I recently discover that semantic is not able to parse correctly some C++ program that involves templates and multiple initializations.
>> I'm using cedet-1.0pre6 and here is an example.
>>
>> First assume you have any templated class, for instance:
>>
>> template<class T>
>> struct Toto {
>> T n;
>>
>> Toto(): n() {} // default constructor
>> Toto(const T& i): n(i) {} // constructor
>> };
>>
>> Later on, the problem occurs if you create instances of more than one object on the same declaration.
>> More precisely:
>> * the declaration without an explicit call to a constructor work:
>>
>> Toto<int> t1, t2;
>> //t1.<--- invoke semantic-ia-complete-symbol-menu success
>> //t2.<--- invoke semantic-ia-complete-symbol-menu success
>>
>> * the declaration with always explicit call to a constructor seems to work (note: in the more complexe code where I discover the problem, it was not the case for t2 but here it works):
>>
>> Toto<int> t1(0), t2(1);
>> //t1.<--- invoke semantic-ia-complete-symbol-menu success
>> //t2.<--- invoke semantic-ia-complete-symbol-menu success
>>
>> * the declaration with a mixed call fail:
>>
>> Toto<int> t1, t2(1);
>> //t1.<--- invoke semantic-ia-complete-symbol-menu FAILED
>> // error: semantic-analyze-possible-completions-default: Cannot find types for `"t1"'
>> //t2.<--- invoke semantic-ia-complete-symbol-menu FAILED
>> // error: semantic-analyze-possible-completions-default: Cannot find types for `"t2"'
>>
>> I attach the source of the complete example.
>>
>> The problem seems to come from the multiple initialization of the variables meaning it works fine with the following syntax:
>>
>> Toto<int> t1;
>> Toto<int> t2(1);
>> //t1.<--- invoke semantic-ia-complete-symbol-menu success
>> //t2.<--- invoke semantic-ia-complete-symbol-menu success
>>
>>
>> For info, my cedet/semantic configuration is available here: http://github.com/Falkor/emacs-config/blob/master/init-cedet.el
>>
>> Any hint/correction notification is welcome ;)
>>
>> Best regards,
>>
>> --
>> Sebastien Varrette, PhD
>>
>>
>>
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Throughout its 18-year history, RSA Conference consistently attracts the
>> world's best and brightest in the field, creating opportunities for Conference
>> attendees to learn about information security's most important issues through
>> interactions with peers, luminaries and emerging and established companies.
>> http://p.sf.net/sfu/rsaconf-dev2dev
>>
>>
>>
>> _______________________________________________
>> cedet-semantic mailing list
>> cedet-semantic@...
>> https://lists.sourceforge.net/lists/listinfo/cedet-semantic
>
> ------------------------------------------------------------------------------
> Throughout its 18-year history, RSA Conference consistently attracts the
> world's best and brightest in the field, creating opportunities for Conference
> attendees to learn about information security's most important issues through
> interactions with peers, luminaries and emerging and established companies.
> http://p.sf.net/sfu/rsaconf-dev2dev
> _______________________________________________
> cedet-semantic mailing list
> cedet-semantic@...
> https://lists.sourceforge.net/lists/listinfo/cedet-semantic
>
|