[cfe-commits] r111807 - in /cfe/trunk: lib/Parse/ParseDecl.cpp test/FixIt/fixit.c

Douglas Gregor dgregor at apple.com
Mon Aug 23 07:34:43 PDT 2010


Author: dgregor
Date: Mon Aug 23 09:34:43 2010
New Revision: 111807

URL: http://llvm.org/viewvc/llvm-project?rev=111807&view=rev
Log:
When complaining about a duplicate declspec, provide a Fix-It that
removes the copy. Patch from Eelis van der Weegen, tweaked/updated by
me.

Modified:
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/test/FixIt/fixit.c

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=111807&r1=111806&r2=111807&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Aug 23 09:34:43 2010
@@ -1405,7 +1405,12 @@
     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();

Modified: cfe/trunk/test/FixIt/fixit.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit.c?rev=111807&r1=111806&r2=111807&view=diff
==============================================================================
--- cfe/trunk/test/FixIt/fixit.c (original)
+++ cfe/trunk/test/FixIt/fixit.c Mon Aug 23 09:34:43 2010
@@ -38,3 +38,6 @@
   int x = y ? 1 4+foobar;
   return x;
 }
+
+// CHECK: typedef int int_t;
+typedef typedef int int_t;





More information about the cfe-commits mailing list