From 883692ebd421c40b44e2c2665e5f54dade5621bc Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 17 Jan 2012 01:04:27 +0000 Subject: [PATCH] Improve diagnostics for dangling '}'. Fixes PR6484. Patch from Jason Switzer! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148270 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticParseKinds.td | 1 + lib/Parse/Parser.cpp | 2 +- test/Parser/objc-quirks.m | 2 +- test/Parser/recovery.c | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td index e4a9fdc3a4..7675a566eb 100644 --- a/include/clang/Basic/DiagnosticParseKinds.td +++ b/include/clang/Basic/DiagnosticParseKinds.td @@ -119,6 +119,7 @@ def err_parse_error : Error<"parse error">; def err_expected_expression : Error<"expected expression">; def err_expected_type : Error<"expected a type">; def err_expected_external_declaration : Error<"expected external declaration">; +def err_extraneous_closing_brace : Error<"extraneous closing brace ('}')">; def err_expected_ident : Error<"expected identifier">; def err_expected_ident_lparen : Error<"expected identifier or '('">; def err_expected_ident_lbrace : Error<"expected identifier or '{'">; diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index e09ee79c8c..db9460bca4 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -552,7 +552,7 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs, // TODO: Invoke action for top-level semicolon. return DeclGroupPtrTy(); case tok::r_brace: - Diag(Tok, diag::err_expected_external_declaration); + Diag(Tok, diag::err_extraneous_closing_brace); ConsumeBrace(); return DeclGroupPtrTy(); case tok::eof: diff --git a/test/Parser/objc-quirks.m b/test/Parser/objc-quirks.m index 72cb1e1d7c..0bdeb464e7 100644 --- a/test/Parser/objc-quirks.m +++ b/test/Parser/objc-quirks.m @@ -7,7 +7,7 @@ int @"s" = 5; // expected-error {{prefix attribute must be}} // rdar://6480479 @interface A // expected-note {{class started here}} }; // expected-error {{missing '@end'}} \ -// expected-error {{expected external declaration}} \ +// expected-error {{extraneous closing brace ('}')}} \ // expected-warning{{extra ';' outside of a function}} diff --git a/test/Parser/recovery.c b/test/Parser/recovery.c index 15fd12b715..3916acfda1 100644 --- a/test/Parser/recovery.c +++ b/test/Parser/recovery.c @@ -16,7 +16,7 @@ static void f (char * (*g) (char **, int), char **p, ...) { // PR3172 -} // expected-error {{expected external declaration}} +} // expected-error {{extraneous closing brace ('}')}} // rdar://6094870 -- 2.40.0