Context-awareness in Cpp parser
Milian Wolff
mail at milianw.de
Tue May 31 16:27:54 UTC 2011
David Nolden, 31.05.2011:
> 2011/5/31 Milian Wolff <mail at milianw.de>:
> > Hey all, esp. David :)
> >
> > While hacking away at C++0x support, I tripped over the following issue:
> > The parser sometimes seems to ignore some rules / does not take the
> > context into account properly. One case which I'm hit by right now is
> > parseDeclarator. It supports bitfields everywhere, even outside of
> > struct/class contexts.
> >
> > On one hand this can lead to false-positives (the following is accepted
> > as valid by our parser):
> >
> > int main() {
> > int i : 1;
> > return 0;
> > }
> >
> > even though it will not compile. Furthermore it makes me jump through
> > hoops when trying to reuse that function in implementing range-based for
> > (as there the colon has a different meaning).
> >
> > So what would you guys suggest - should I try to add rough context
> > sensitivity?
>
> Yes, I guess there is no other way. You might check the C++
> specification to see where bit-fields are allowed (I guess only in
> class/struct/union member declarations), and then give a "bool
> isClassMember" parameter to parseDeclarator, or something like that.
Probably I'll pick a member variable as the declarator is only called by
helper functions itself and I don't want to pollute the signatures. For now I
did it in a ugly way to get the range-based-for working, only DUChain
integration is missing there for now.
bye
--
Milian Wolff
mail at milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20110531/5a5dfbdd/attachment.sig>
More information about the KDevelop-devel
mailing list