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 8a548cf..371d8ad 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -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();
diff --git a/test/FixIt/fixit.c b/test/FixIt/fixit.c
index b799fa3..890fb10 100644
--- a/test/FixIt/fixit.c
+++ b/test/FixIt/fixit.c
@@ -38,3 +38,6 @@
int x = y ? 1 4+foobar;
return x;
}
+
+// CHECK: typedef int int_t;
+typedef typedef int int_t;