Bug 580935 - [C++20] Parser fails with designated initializers
Summary: [C++20] Parser fails with designated initializers
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-parser (show other bugs)
Version: 10.7.0   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL: https://en.cppreference.com/w/cpp/lan...
Whiteboard:
Keywords:
Depends on:
Blocks: cxx20
  Show dependency tree
 
Reported: 2022-10-20 05:35 EDT by NightStrike CLA
Modified: 2022-10-20 16:15 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description NightStrike CLA 2022-10-20 05:35:13 EDT
Consider the code:

struct S { int x; } s { .x = 4 };

vs:

struct S { int x; } s { 4 };


The first produces a red line under 's', the second works fine.  Both are valid.
Comment 1 NightStrike CLA 2022-10-20 05:40:23 EDT
Interestingly, this works:

struct S { int x; } = { .x = 4 };

(ie, assign instead of universal init)
Comment 2 Jonah Graham CLA 2022-10-20 09:54:27 EDT
Thanks @NightStrike for the bug report. 

Is this a C++20 extension? That is what it looks like on[1]:

T object { .des1 = arg1 , .des2 { arg2 } ... };	(4)	(since C++20)

If so, I have added it to the backlog of C++20 stuff that is missing. At the moment there is no one actively looking at C++ language support in CDT. If you are interested in working on this and providing a patch please let me know.

[1] https://en.cppreference.com/w/cpp/language/aggregate_initialization
Comment 3 NightStrike CLA 2022-10-20 16:07:43 EDT
Correct.  While it was an extension supported by the major compilers for a long time, it only recently made it into the language proper.

I'm sorry to hear about the developer need.  I would think that c++ language support is a critical component of a c++ IDE.  Sadly, I don't have the technical ability to provide a patch for this.  I used to engage with Nathan Ridge on parser issues.  Maybe he's available?
Comment 4 Nathan Ridge CLA 2022-10-20 16:15:25 EDT
(In reply to NightStrike   from comment #3)
> I used to engage with Nathan
> Ridge on parser issues.  Maybe he's available?

I moved on to clangd (https://clangd.llvm.org/) a few years ago. (I use it with the VSCode client but there are various other editor integrations for it.)

Keeping a separate C++ parser implementation maintained in Eclipse CDT with new C++ language features just wasn't scalable. clangd is built on clang's parser, and gets access to new C++ features as soon as they're implemented in clang.

I've also recently become aware of the CDT.cloud project (https://cdt-cloud.io/), which aims to develop an IDE similar to Eclipse CDT (e.g. suited for toolchain vendors to customize into their own toolchain-specific products) using clangd to provide language support.