make the 'to match this' diagnostic a note.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59921 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2008-11-23 23:17:07 +00:00
Родитель 5f4a6829dc
Коммит 28eb7e992b
14 изменённых файлов: 25 добавлений и 25 удалений

Просмотреть файл

@ -37,6 +37,11 @@ DIAG(note_previous_use, NOTE,
DIAG(note_duplicate_case_prev, NOTE, DIAG(note_duplicate_case_prev, NOTE,
"previous case defined here") "previous case defined here")
/// note_matching - this is used as a continuation of a previous diagnostic,
/// e.g. to specify the '(' when we expected a ')'.
DIAG(note_matching, NOTE,
"to match this '%0'")
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Lexer Diagnostics // Lexer Diagnostics
@ -409,13 +414,6 @@ DIAG(err_expected_selector_for_method, ERROR,
DIAG(err_unexpected_at, ERROR, DIAG(err_unexpected_at, ERROR,
"unexpected '@' in program") "unexpected '@' in program")
/// err_matching - this is used as a continuation of a previous error, e.g. to
/// specify the '(' when we expected a ')'. This should probably be some
/// special sort of diagnostic kind to indicate that it is the second half of
/// the previous diagnostic.
DIAG(err_matching, ERROR,
"to match this '%0'")
/// Objective-C parser diagnostics /// Objective-C parser diagnostics
DIAG(err_unexpected_interface, ERROR, DIAG(err_unexpected_interface, ERROR,
"unexpected interface name '%0': expected expression") "unexpected interface name '%0': expected expression")

Просмотреть файл

@ -137,7 +137,7 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
if (LParenLoc.isValid()) { if (LParenLoc.isValid()) {
if (PeekTok.isNot(tok::r_paren)) { if (PeekTok.isNot(tok::r_paren)) {
PP.Diag(PeekTok.getLocation(), diag::err_pp_missing_rparen); PP.Diag(PeekTok.getLocation(), diag::err_pp_missing_rparen);
PP.Diag(LParenLoc, diag::err_matching) << "("; PP.Diag(LParenLoc, diag::note_matching) << "(";
return true; return true;
} }
// Consume the ). // Consume the ).
@ -261,7 +261,7 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
if (PeekTok.isNot(tok::r_paren)) { if (PeekTok.isNot(tok::r_paren)) {
PP.Diag(PeekTok.getLocation(), diag::err_pp_expected_rparen) PP.Diag(PeekTok.getLocation(), diag::err_pp_expected_rparen)
<< Result.getRange(); << Result.getRange();
PP.Diag(Start, diag::err_matching) << "("; PP.Diag(Start, diag::note_matching) << "(";
return true; return true;
} }
DT.State = DefinedTracker::Unknown; DT.State = DefinedTracker::Unknown;
@ -606,7 +606,7 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec,
if (PeekTok.isNot(tok::colon)) { if (PeekTok.isNot(tok::colon)) {
PP.Diag(PeekTok.getLocation(), diag::err_expected_colon) PP.Diag(PeekTok.getLocation(), diag::err_expected_colon)
<< LHS.getRange(), RHS.getRange(); << LHS.getRange(), RHS.getRange();
PP.Diag(OpLoc, diag::err_matching) << "?"; PP.Diag(OpLoc, diag::note_matching) << "?";
return true; return true;
} }
// Consume the :. // Consume the :.

Просмотреть файл

@ -271,7 +271,7 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, unsigned MinPrec) {
if (Tok.isNot(tok::colon)) { if (Tok.isNot(tok::colon)) {
Diag(Tok, diag::err_expected_colon); Diag(Tok, diag::err_expected_colon);
Diag(OpToken, diag::err_matching) << "?"; Diag(OpToken, diag::note_matching) << "?";
Actions.DeleteExpr(LHS.Val); Actions.DeleteExpr(LHS.Val);
Actions.DeleteExpr(TernaryMiddle.Val); Actions.DeleteExpr(TernaryMiddle.Val);
return ExprResult(true); return ExprResult(true);

Просмотреть файл

@ -199,7 +199,7 @@ Parser::ExprResult Parser::ParseCXXCasts() {
SourceLocation RAngleBracketLoc = Tok.getLocation(); SourceLocation RAngleBracketLoc = Tok.getLocation();
if (ExpectAndConsume(tok::greater, diag::err_expected_greater)) if (ExpectAndConsume(tok::greater, diag::err_expected_greater))
return Diag(LAngleBracketLoc, diag::err_matching) << "<"; return Diag(LAngleBracketLoc, diag::note_matching) << "<";
SourceLocation LParenLoc = Tok.getLocation(), RParenLoc; SourceLocation LParenLoc = Tok.getLocation(), RParenLoc;

Просмотреть файл

@ -733,7 +733,7 @@ Parser::StmtResult Parser::ParseDoStatement() {
ExitScope(); ExitScope();
if (!Body.isInvalid) { if (!Body.isInvalid) {
Diag(Tok, diag::err_expected_while); Diag(Tok, diag::err_expected_while);
Diag(DoLoc, diag::err_matching) << "do"; Diag(DoLoc, diag::note_matching) << "do";
SkipUntil(tok::semi, false, true); SkipUntil(tok::semi, false, true);
} }
return true; return true;

Просмотреть файл

@ -71,7 +71,7 @@ SourceLocation Parser::MatchRHSPunctuation(tok::TokenKind RHSTok,
case tok::greater: LHSName = "<"; DID = diag::err_expected_greater; break; case tok::greater: LHSName = "<"; DID = diag::err_expected_greater; break;
} }
Diag(Tok, DID); Diag(Tok, DID);
Diag(LHSLoc, diag::err_matching) << LHSName; Diag(LHSLoc, diag::note_matching) << LHSName;
SkipUntil(RHSTok); SkipUntil(RHSTok);
return R; return R;
} }

Просмотреть файл

@ -1,7 +1,7 @@
// RUN: clang -fsyntax-only -fno-caret-diagnostics -pedantic %s 2>&1 | grep warning | wc -l | grep 1 && // RUN: clang -fsyntax-only -fno-caret-diagnostics -pedantic %s 2>&1 | grep warning | wc -l | grep 1 &&
// RUN: clang -fsyntax-only -verify -pedantic %s // RUN: clang -fsyntax-only -verify -pedantic %s
char (((( /* expected-error {{to match this '('}} */ char (((( /* expected-note {{to match this '('}} */
*X x ] )))); /* expected-error {{expected ')'}} */ *X x ] )))); /* expected-error {{expected ')'}} */
; // expected-warning {{ISO C does not allow an extra ';' outside of a function}} ; // expected-warning {{ISO C does not allow an extra ';' outside of a function}}

Просмотреть файл

@ -11,7 +11,7 @@ static void test() {
typeof(TInt) anInt; typeof(TInt) anInt;
short TInt eee; // expected-error{{parse error}} short TInt eee; // expected-error{{parse error}}
void ary[7] fff; // expected-error{{array has incomplete element type 'void'}} expected-error{{parse error}} void ary[7] fff; // expected-error{{array has incomplete element type 'void'}} expected-error{{parse error}}
typeof(void ary[7]) anIntError; // expected-error{{expected ')'}} expected-error{{to match this '('}} typeof(void ary[7]) anIntError; // expected-error{{expected ')'}} expected-note {{to match this '('}}
typeof(const int) aci; typeof(const int) aci;
const typeof (*pi) aConstInt; const typeof (*pi) aConstInt;
int xx; int xx;

Просмотреть файл

@ -15,7 +15,7 @@ static void zm_info_pcre(zend_module_entry *zend_module ) { }
static int zm_startup_pcre(int type, int module_number ) { } static int zm_startup_pcre(int type, int module_number ) { }
static int zm_shutdown_pcre(int type, int module_number ) { static int zm_shutdown_pcre(int type, int module_number ) {
zend_function_entry pcre_functions[] = {{ }; // expected-error{{expected '}'}} expected-error{{to match this '{'}} zend_function_entry pcre_functions[] = {{ }; // expected-error{{expected '}'}} expected-note {{to match this '{'}}
zend_module_entry pcre_module_entry = { zend_module_entry pcre_module_entry = {
sizeof(zend_module_entry), 20071006, 0, 0, ((void *)0), ((void *)0), sizeof(zend_module_entry), 20071006, 0, 0, ((void *)0), ((void *)0),
"pcre", pcre_functions, zm_startup_pcre, zm_shutdown_pcre, ((void *)0), "pcre", pcre_functions, zm_startup_pcre, zm_shutdown_pcre, ((void *)0),

Просмотреть файл

@ -72,4 +72,4 @@ void f3() {
} }
// make sure the following doesn't hit any asserts // make sure the following doesn't hit any asserts
void f4(undef::C); // expected-error {{use of undeclared identifier 'undef'}} // expected-error {{expected ')'}} expected-error {{to match this '('}} // expected-error {{variable has incomplete type 'void'}} void f4(undef::C); // expected-error {{use of undeclared identifier 'undef'}} // expected-error {{expected ')'}} expected-note {{to match this '('}} // expected-error {{variable has incomplete type 'void'}}

Просмотреть файл

@ -50,7 +50,7 @@ void bad_deletes()
{ {
delete 0; // expected-error {{cannot delete expression of type 'int'}} delete 0; // expected-error {{cannot delete expression of type 'int'}}
delete [0] (int*)0; // expected-error {{expected ']'}} \ delete [0] (int*)0; // expected-error {{expected ']'}} \
// expected-error {{to match this '['}} // expected-note {{to match this '['}}
delete (void*)0; // expected-error {{cannot delete expression}} delete (void*)0; // expected-error {{cannot delete expression}}
delete (T*)0; // expected-warning {{deleting pointer to incomplete type}} delete (T*)0; // expected-warning {{deleting pointer to incomplete type}}
} }

Просмотреть файл

@ -7,6 +7,6 @@
canBeginSyncingPlanWithId:(bycopy NSString *)planId canBeginSyncingPlanWithId:(bycopy NSString *)planId
syncModes:(bycopy NSArray /* ISDSyncState */ *)syncModes syncModes:(bycopy NSArray /* ISDSyncState */ *)syncModes
entities:(bycopy NSArray /* ISDEntity */ *)entities entities:(bycopy NSArray /* ISDEntity */ *)entities
truthPullers:(bycopy NSDictionary /* NSString -> [NSString] */ *)truthPullers; // expected-error{{expected ')'}} expected-error{{to match this '('}} truthPullers:(bycopy NSDictionary /* NSString -> [NSString] */ *)truthPullers; // expected-error{{expected ')'}} expected-note {{to match this '('}}
@end @end

Просмотреть файл

@ -50,14 +50,16 @@ typedef signed char BOOL;
// test parser recovery: rdar://6254579 // test parser recovery: rdar://6254579
@property (readonly getter=isAwesome) // expected-error {{error: expected ')'}} \ @property ( // expected-note {{to match this '('}}
// expected-error {{to match this '('}} readonly getter=isAwesome) // expected-error {{error: expected ')'}}
int _awesome; int _awesome;
@property (readonlyx) // expected-error {{unknown property attribute 'readonlyx'}} @property (readonlyx) // expected-error {{unknown property attribute 'readonlyx'}}
int _awesome2; int _awesome2;
@property (+) // expected-error {{error: expected ')'}} \ @property ( // expected-note {{to match this '('}}
// expected-error {{to match this '('}} +) // expected-error {{error: expected ')'}}
int _awesome3; int _awesome3;
@end @end

Просмотреть файл

@ -6,7 +6,7 @@
@end @end
void foo(id x) { void foo(id x) {
bar((short<SomeProtocol>)x); // expected-error {{expected ')'}} expected-error {{to match this '('}} bar((short<SomeProtocol>)x); // expected-error {{expected ')'}} expected-note {{to match this '('}}
bar((<SomeProtocol>)x); // expected-warning {{protocol qualifiers without 'id' is archaic}} bar((<SomeProtocol>)x); // expected-warning {{protocol qualifiers without 'id' is archaic}}
[(<SomeProtocol>)x bar]; // expected-warning {{protocol qualifiers without 'id' is archaic}} [(<SomeProtocol>)x bar]; // expected-warning {{protocol qualifiers without 'id' is archaic}}