Skip to content

[clang] Fix eager skipping on new with unknown type and no new-initializer #110133

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

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
2 changes: 1 addition & 1 deletion clang/lib/Parse/ParseExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3694,7 +3694,7 @@ bool Parser::ParseExpressionList(SmallVectorImpl<Expr *> &Exprs,
SawError = true;
if (FailImmediatelyOnInvalidExpr)
break;
SkipUntil(tok::comma, tok::r_paren, StopBeforeMatch);
SkipUntil(tok::comma, tok::r_paren, StopAtSemi | StopBeforeMatch);
} else {
Exprs.push_back(Expr.get());
}
Expand Down
25 changes: 25 additions & 0 deletions clang/test/AST/new-unknown-type.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// RUN: %clang_cc1 -verify -ast-dump %s | FileCheck %s

extern void foo(Unknown*); // expected-error {{unknown type name 'Unknown'}}

namespace a {
void computeSomething() {
foo(new Unknown()); // expected-error {{unknown type name 'Unknown'}}
foo(new Unknown{}); // expected-error {{unknown type name 'Unknown'}}
foo(new Unknown); // expected-error {{unknown type name 'Unknown'}}
}
} // namespace a

namespace b {
struct Bar{};
} // namespace b

// CHECK: |-NamespaceDecl 0x{{[^ ]*}} <line:5:1, line:11:1> line:5:11 a
// CHECK-NEXT: | `-FunctionDecl 0x{{[^ ]*}} <line:6:3, line:10:3> line:6:8 computeSomething 'void ()'
// CHECK-NEXT: | `-CompoundStmt 0x{{[^ ]*}} <col:27, line:10:3>
// CHECK-NEXT: |-NamespaceDecl 0x{{[^ ]*}} <line:13:1, line:15:1> line:13:11 b
// CHECK-NEXT: | `-CXXRecordDecl 0x{{[^ ]*}} <line:14:3, col:14> col:10 referenced struct Bar definition

static b::Bar bar;
// CHECK: `-VarDecl 0x{{[^ ]*}} <line:23:1, col:15> col:15 bar 'b::Bar' static callinit
// CHECK-NEXT: `-CXXConstructExpr 0x{{[^ ]*}} <col:15> 'b::Bar' 'void () noexcept'
2 changes: 1 addition & 1 deletion clang/test/Parser/colon-colon-parentheses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ int S::(*e; // expected-error{{expected unqualified-id}}
int S::*f;
int g = S::(a); // expected-error {{expected unqualified-id}} expected-error {{use of undeclared identifier 'a'}}
int h = S::(b; // expected-error {{expected unqualified-id}} expected-error {{use of undeclared identifier 'b'}}
);
); // expected-error {{expected unqualified-id}}
int i = S::c;

void foo() {
Expand Down
1 change: 0 additions & 1 deletion clang/test/Parser/cxx-ambig-paren-expr-asan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ int H((int()[)]);
// expected-error@-1 {{expected expression}}
// expected-error@-2 {{expected ']'}}
// expected-note@-3 {{to match this '['}}
// expected-error@-4 {{expected ';' after top level declarator}}
Loading