Bug 490359 - [C++17] (N4230) Nested namespace definitions
Summary: [C++17] (N4230) Nested namespace definitions
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-parser (show other bugs)
Version: 9.0.0   Edit
Hardware: PC Windows 7
: P3 normal with 4 votes (vote)
Target Milestone: 9.4.2   Edit
Assignee: Nathan Ridge CLA
QA Contact: Markus Schorn CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 490407
  Show dependency tree
 
Reported: 2016-03-24 05:15 EDT by Julien Lavergne CLA
Modified: 2018-02-04 16:11 EST (History)
10 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Julien Lavergne CLA 2016-03-24 05:15:02 EDT
Hi,


I am committing this improvement request despite nothing is settled yet for C++17.
The feature is supported by GCC 6 and thus CDT should not produce any warning for the following code:


namespace x::y <--- Syntax error
{
}
Comment 1 Peter Levine CLA 2016-06-11 20:35:39 EDT
AFAIK, nested namespace definitions were officially adopted into the upcoming C++17 standard back in November 2014.  I would really like CDT to support this.
Comment 2 Harald Achitz CLA 2017-09-04 04:35:12 EDT
anything new with this issue? 
I just wanted today switch to C++1z in out project, just because of the nested namespaces.
with the compiles we use this works, 

but than I hade to notice that eclipse does not support this and reports synztx errors.

This is not good, and this issue is already 1 year old
Comment 3 Nathan Ridge CLA 2017-09-04 20:30:27 EDT
(In reply to Harald Achitz from comment #2)
> This is not good, and this issue is already 1 year old

There are much older features that are still not supported, like C++14 init-captures or most C11 features.

It takes someone to do the work of implementing these. I spend most of what little spare time I have working on CDT, but I'm barely staying on top of regressions from previous changes. Help / contributions are welcome.
Comment 4 Harald Achitz CLA 2017-09-05 04:10:04 EDT
It seems that are too less development resources for CDT.
When I look around at how many companies I have seen eclipse CDT in use, and than read that resources for implementing features are missing, this makes me sad.
Comment 5 Kamil Rojewski CLA 2017-11-15 04:09:10 EST
This is actually a quite important feature, since CDT fails to parse any code inside nested namespaces, turning it essentially into a plain text editor.
Comment 6 Nathan Ridge CLA 2017-11-15 15:48:52 EST
I would be willing to mentor someone who is interested in contributing a fix for this.
Comment 7 Joshua Newcomb CLA 2017-12-02 12:08:48 EST
I heard some time back that there was a project working to incorperate the Clang AST into eclipse CDT in order to resolve problems like this one, is that still going on?
Comment 8 Nathan Ridge CLA 2017-12-02 13:21:16 EST
(In reply to Joshua Newcomb from comment #7)
> I heard some time back that there was a project working to incorperate the
> Clang AST into eclipse CDT in order to resolve problems like this one, is
> that still going on?

Yes, bug 511851. But it's a long term project, I wouldn't expect the results of that to be usable any time soon.
Comment 9 Manish Boyat CLA 2018-01-15 22:51:02 EST
Is there an ETA for this issue. I am not able to use eclipse at all as our existing codebase is using the new nested namespace feature everywhere and I will be forced to use a different IDE just to get away from this issue.
Will be quite a sad end to my tenure as an eclipse CDT user.
Comment 10 Manish Boyat CLA 2018-01-15 22:52:34 EST
Or if there is a workaround then it will help too as it might temporarily give me some time to wait for a final improvement in CDT as currently it is completely unusable for me
Comment 11 Nathan Ridge CLA 2018-01-16 00:37:31 EST
Workaround:

#ifdef __CDT_PARSER__
  namespace x { namespace y {
#else
  namespace x::y {
#endif

Of course, at that point you may as well just use the longer form unconditionally.

You could also consider contributing a patch to CDT to accept the short form.
Comment 12 Manish Boyat CLA 2018-01-16 04:31:12 EST
thanks a lot for the information
I'll have to impose this change to everyone in the team in order for me to use eclipse. I guess it is not the most viable option for me. Any clue if there is a time line for anyone to pick it up in near future?
Comment 13 Manish Boyat CLA 2018-01-16 19:39:36 EST
(In reply to Kamil Rojewski from comment #5)
> This is actually a quite important feature, since CDT fails to parse any
> code inside nested namespaces, turning it essentially into a plain text
> editor.

did you find any workaround for this issue? I cannot just sk the whole team to not use the feature till eclipse comes up with a patch :-( any help appreciated.
Comment 14 Eclipse Genie CLA 2018-01-22 00:57:57 EST
New Gerrit change created: https://git.eclipse.org/r/115779
Comment 15 Nathan Ridge CLA 2018-01-22 01:01:25 EST
I had a look it this; it ended up being quite straightforward to add support for this to the parser.

We don't explicitly represent in the AST whether the nested form of a namespace definition was used or the regular form, although an AST consumer could probably deduce it by observing that the start offset of a namespace definition node is the same as the start offset of its enclosing namespace definition node (which wouldn't happen with the regular form).

In any case, parsing and name resolution should work correctly with this change.
Comment 16 Harald Achitz CLA 2018-01-22 03:52:53 EST
great! looking forward seeing this update in upstream
Comment 17 Manish Boyat CLA 2018-01-23 03:23:41 EST
Thanks a lot for the same...I look forward to see the changes
Comment 18 Vittorio Romeo CLA 2018-01-25 08:14:07 EST
Thanks for the patch - is it possible to apply it to an existing installation of Eclipse somehow? This bug is forcing us to revert all "C++17 nested namespace" changes, as the IDE becomes unusable with them...
Comment 19 Nathan Ridge CLA 2018-01-25 17:16:00 EST
(In reply to Vittorio Romeo from comment #18)
> Thanks for the patch - is it possible to apply it to an existing
> installation of Eclipse somehow? This bug is forcing us to revert all "C++17
> nested namespace" changes, as the IDE becomes unusable with them...

I will commit the patch today, and it should then make it into the next CDT nightly build. You can install a nightly build into an existing installation.
Comment 21 Nathan Ridge CLA 2018-01-25 18:20:27 EST
Ok, committed now. Should be in the next nightly build.

Nightly builds can be installed via this update site:

http://download.eclipse.org/tools/cdt/builds/master/nightly/
Comment 22 Nathan Ridge CLA 2018-01-25 18:20:43 EST
Fixed for CDT 9.5.
Comment 23 Eclipse Genie CLA 2018-02-04 15:07:34 EST
New Gerrit change created: https://git.eclipse.org/r/116684
Comment 25 Nathan Ridge CLA 2018-02-04 16:11:38 EST
Fixed for 9.4.2 as well.