]> granicus.if.org Git - clang/commitdiff
Remove broken fix-it when a default function argument has been
authorDouglas Gregor <dgregor@apple.com>
Wed, 13 Jan 2010 00:12:48 +0000 (00:12 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 13 Jan 2010 00:12:48 +0000 (00:12 +0000)
redefined. There's a FIXME with an apology about why we don't try to
do better here. Fixes <rdar://problem/7513023>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93274 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp

index 0cd70026477d1b89fbeb8cbf711af607d4103700..ffd10c89f0f8780d593c9a9893a424417be024cd 100644 (file)
@@ -270,18 +270,18 @@ bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old) {
     ParmVarDecl *NewParam = New->getParamDecl(p);
 
     if (OldParam->hasDefaultArg() && NewParam->hasDefaultArg()) {
-      // FIXME: If the parameter doesn't have an identifier then the location
-      // points to the '=' which means that the fixit hint won't remove any
-      // extra spaces between the type and the '='.
-      SourceLocation Begin = NewParam->getLocation();
-      if (NewParam->getIdentifier())
-        Begin = PP.getLocForEndOfToken(Begin);
-        
+      // FIXME: If we knew where the '=' was, we could easily provide a fix-it 
+      // hint here. Alternatively, we could walk the type-source information
+      // for NewParam to find the last source location in the type... but it
+      // isn't worth the effort right now. This is the kind of test case that
+      // is hard to get right:
+      
+      //   int f(int);
+      //   void g(int (*fp)(int) = f);
+      //   void g(int (*fp)(int) = &f);
       Diag(NewParam->getLocation(),
            diag::err_param_default_argument_redefinition)
-        << NewParam->getDefaultArgRange()
-        << CodeModificationHint::CreateRemoval(SourceRange(Begin,
-                                                        NewParam->getLocEnd()));
+        << NewParam->getDefaultArgRange();
       
       // Look for the function declaration where the default argument was
       // actually written, which may be a declaration prior to Old.