llvm-project/clang/test/Parser/cxx-ambig-paren-expr-asan.cpp
Alejandro Álvarez Ayllón 4bd81c5738
[Clang] Fix eager skipping in ParseExpressionList() (#110133)
i.e., in a call like `function(new Unknown);` the parser should skip only until the
semicolon.

Before this change, everything was skipped until a balanced closing
parenthesis or brace was found. This strategy can cause completely bogus
ASTs. For instance, in the case of the test `new-unknown-type.cpp`,
`struct Bar` would end nested under the namespace `a::b`.
2024-10-02 01:54:29 +02:00

9 lines
314 B
C++

// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
// This syntax error used to cause use-after free due to token local buffer
// in ParseCXXAmbiguousParenExpression.
int H((int()[)]);
// expected-error@-1 {{expected expression}}
// expected-error@-2 {{expected ']'}}
// expected-note@-3 {{to match this '['}}