Bug 297604 - c++ parser fails on "noexcept" c++11 specific keyword
Summary: c++ parser fails on "noexcept" c++11 specific keyword
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Unclassified
Component: Language Support: CPP (old) (show other bugs)
Version: git master
Platform: Archlinux Packages Linux
: NOR normal (vote)
Target Milestone: 4.3.0
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-06 15:39 UTC by Luc
Modified: 2013-03-31 00:45 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Example: code completion not working for std::string variable (27.21 KB, image/png)
2012-04-06 15:39 UTC, Luc
Details
Example 2 - after Ivan patch - still no code completion for std::string (22.38 KB, image/png)
2012-04-06 23:34 UTC, Luc
Details
Example 3 - code completion error: members are shown in global scope (71.06 KB, image/png)
2012-04-06 23:37 UTC, Luc
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Luc 2012-04-06 15:39:43 UTC
Created attachment 70193 [details]
Example: code completion not working for std::string variable

After updating gcc suite to 4.7.0, code completion is not working anymore for some STL classes.
It seems that the new "noexcept" keyword from c++11 is to be blamed.
Comment 1 Ivan Shapovalov 2012-04-06 17:56:41 UTC
Fixed, patch present.
https://git.reviewboard.kde.org/r/104498
Comment 2 Luc 2012-04-06 23:34:27 UTC
Created attachment 70199 [details]
Example 2 - after Ivan patch - still no code completion for std::string
Comment 3 Luc 2012-04-06 23:34:50 UTC
Thanks for quick action! :-)
Unfortunately code completion still not working, maybe there is some other c++11 thingy causing the parser to fail. 
For a quick test (to check if the c++ includes coming with gcc 4.7.0 are indeed creating parsing issues) I replaced /usr/include/c++/4.7.0 with 4.6.3 files -- everything worked great again.
By the way, after your patch Ivan, I observed that all the completion suggestions that should have opened on foo. (in my example) are opening outside of foo., in global scope (check the attached images 2 and 3).
Comment 4 Luc 2012-04-06 23:37:21 UTC
Created attachment 70200 [details]
Example 3 - code completion error: members are shown in global scope
Comment 5 Ivan Shapovalov 2012-04-07 03:53:01 UTC
Another problem seems to be related to "#if __cplusplus" statement in file c++config.h ("/usr/include/c++/4.7.0/{your_architecture}/bits/c++config.h").

I will try to dig into preprocessor implementation and fix it, but a quick&dirty fix could be replacing #if with #ifdef (I've made this replacement somewhat earlier for another reasons).

After replacement (and clearing your DUChain cache), everything should work properly.
Comment 6 Luc 2012-04-07 10:01:16 UTC
Thank you! That was it :-) I confirm it is working again.
I wish I could share a couple of beers with you.
Comment 7 Ivan Shapovalov 2012-04-07 11:56:44 UTC
(In reply to comment #6)
> Thank you! That was it :-) I confirm it is working again.
> I wish I could share a couple of beers with you.

The patch is updated again, now fixing that preprocessor bug.
Please, test it with original c++config.h file.
Comment 8 Milian Wolff 2012-04-07 12:17:08 UTC
Git commit c33000b0280bb329beb46266a4c69235ae38865a by Milian Wolff.
Committed on 07/04/2012 at 14:14.
Pushed by mwolff into branch '4.3'.

c++11 support: handle  noexcept-specification and noexcept-expression in our parser

This is particularly useful with new GCC toolchain version 4.7.0, where these keywords
are frequently used throughout STL.

thanks to Ivan Shapovalov for the patch, I just cleaned it up a bit and added a unit test

REVIEW: 104498

M  +6    -0    languages/cpp/parser/ast.h
M  +22   -5    languages/cpp/parser/codegenerator.cpp
M  +1    -0    languages/cpp/parser/default_visitor.cpp
M  +1    -0    languages/cpp/parser/lexer.cpp
M  +68   -17   languages/cpp/parser/parser.cpp
M  +1    -0    languages/cpp/parser/tests/test_parser.h
M  +11   -1    languages/cpp/parser/tests/test_parser_cpp2011.cpp
M  +2    -0    languages/cpp/parser/tokens.cpp
M  +1    -0    languages/cpp/parser/tokens.h

http://commits.kde.org/kdevelop/c33000b0280bb329beb46266a4c69235ae38865a
Comment 9 Milian Wolff 2012-04-07 13:00:20 UTC
Git commit ab14ac7ce58968d857709572237035ec877e7988 by Milian Wolff.
Committed on 07/04/2012 at 14:57.
Pushed by mwolff into branch '4.3'.

properly handle l, lu, ul integers in our preprocessor

this finally fixes parsing of gcc 4.7 headers

thanks again to Ivan Shapovalov for this patch, which
I cleaned up a bit and added a unit test

the question now: how should ll, ull, llu integers be
handled by a c++11 compliant preprocessor?
REVIEW: 104498

M  +10   -2    languages/cpp/parser/rpp/pp-engine.cpp
M  +11   -1    languages/cpp/parser/tests/test_parser.cpp

http://commits.kde.org/kdevelop/ab14ac7ce58968d857709572237035ec877e7988
Comment 10 Aleix Pol 2013-03-31 00:45:16 UTC
Moving all the bugs from the CPP Parser. It was not well defined the difference between it and C++ Language Support and people kept reporting in both places indistinctively