]> granicus.if.org Git - clang/commitdiff
When complaining about a duplicate declspec, provide a Fix-It that
authorDouglas Gregor <dgregor@apple.com>
Mon, 23 Aug 2010 14:34:43 +0000 (14:34 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 23 Aug 2010 14:34:43 +0000 (14:34 +0000)
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

lib/Parse/ParseDecl.cpp
test/FixIt/fixit.c

index 8a548cf51732393342587714b9a51d548c3ec7cd..371d8ad02e8648e0a2d892146a8b4476ceb0469a 100644 (file)
@@ -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();
index b799fa3b3b884a729353dcbaab88d7bd04ace026..890fb10b41d5c732e8e35ab4a3497803a7f4f7fc 100644 (file)
@@ -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;