From: Douglas Gregor Date: Mon, 23 Aug 2010 14:34:43 +0000 (+0000) Subject: When complaining about a duplicate declspec, provide a Fix-It that X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ae2fb144fef905a860a49e8066fb28521447f7c9;p=clang When complaining about a duplicate declspec, provide a Fix-It that removes the copy. Patch from Eelis van der Weegen, tweaked/updated by me. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111807 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 8a548cf517..371d8ad02e 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -1405,7 +1405,12 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, if (isInvalid) { assert(PrevSpec && "Method did not return previous specifier!"); assert(DiagID); - Diag(Tok, DiagID) << PrevSpec; + + if (DiagID == diag::ext_duplicate_declspec) + Diag(Tok, DiagID) + << PrevSpec << FixItHint::CreateRemoval(Tok.getLocation()); + else + Diag(Tok, DiagID) << PrevSpec; } DS.SetRangeEnd(Tok.getLocation()); ConsumeToken(); diff --git a/test/FixIt/fixit.c b/test/FixIt/fixit.c index b799fa3b3b..890fb10b41 100644 --- a/test/FixIt/fixit.c +++ b/test/FixIt/fixit.c @@ -38,3 +38,6 @@ int test_cond(int y, int fooBar) { int x = y ? 1 4+foobar; return x; } + +// CHECK: typedef int int_t; +typedef typedef int int_t;