Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++23 extend init-statement to allow alias-declaration #2734

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions cxx-squid/dox/diff-cpp20-cpp23_grammar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,6 @@ postfix-expression:

**A.6 Statements [gram.stmt]**

init-statement:
expression-statement
simple-declaration
alias-declaration

label:
attribute-specifier-seqopt identifier :
attribute-specifier-seqopt case constant-expression :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,8 @@ private static void statements(LexerfulGrammarBuilder b) {
b.rule(initStatement).is(
b.firstOf(
expressionStatement, // C++
simpleDeclaration // C++
simpleDeclaration, // C++
aliasDeclaration // C++23
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,18 @@ void iterationStatement_reallife() {
// CLI extension
.matches("for each(String^% s in arr) { s = i++.ToString(); }")
// C++17 structered bindings
.matches("for (const auto&[key, val] : mymap) { std::cout << key << \": \" << val << std::endl; }");
.matches("for (const auto&[key, val] : mymap) { std::cout << key << \": \" << val << std::endl; }")
// C++23
.matches("for (using T = int; T e : v) ;");
}

@Test
void forInitStatement_reallife() {
setRootRule(CxxGrammarImpl.initStatement);

assertThatParser()
.matches("int i=1;");
.matches("int i=1;")
.matches("using T = int;"); // C++23
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
void sample() {
for (using T = int; T e : v)
/* something */;
}
Loading