Extend using declaration to support list of members #13

Closed
shitpoet wants to merge 1 commit from patch-1 into main
shitpoet commented 2026-01-07 22:00:09 +01:00 (Migrated from github.com)

C++17 and up allows a list of members to be imported:

namespace X
{
    using A::g, A::g; // (C++17) OK: double declaration allowed at namespace scope
}

Source - https://en.cppreference.com/w/cpp/language/namespace.html

Currently, the cpp parser behaves inconsistently:

#include <cstdlib>
#include <iostream>

using std::cout, std::endl;
//          ^          ^ variableName
//          ^ namespace
int main() {
    cout << "hello" << endl;
    return 0;
}

Honestly, I don't know how it even parses it at all right now, but I replaced ScopedIdentifier with a new simple comma-separated list ScopedIdentiferList for the UsingDeclaration, and now both member names are recognised as tok-variableNames.

C++17 and up allows a list of members to be imported: ```cpp namespace X { using A::g, A::g; // (C++17) OK: double declaration allowed at namespace scope } ``` Source - https://en.cppreference.com/w/cpp/language/namespace.html Currently, the cpp parser behaves inconsistently: ```cpp #include <cstdlib> #include <iostream> using std::cout, std::endl; // ^ ^ variableName // ^ namespace int main() { cout << "hello" << endl; return 0; } ``` Honestly, I don't know how it even parses it at all right now, but I replaced `ScopedIdentifier` with a new simple comma-separated list `ScopedIdentiferList` for the `UsingDeclaration`, and now both member names are recognised as `tok-variableName`s.
marijnh commented 2026-01-08 09:35:24 +01:00 (Migrated from github.com)

Attached patch fixes this in a more idiomatic way (and without breaking the tests).

Attached patch fixes this in a more idiomatic way (and without breaking the tests).

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lezer/cpp!13
No description provided.