[cfe-commits] r129242 - /cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Francois Pichet pichet2000 at gmail.com
Sat Apr 9 21:58:30 PDT 2011


Author: fpichet
Date: Sat Apr  9 23:58:30 2011
New Revision: 129242

URL: http://llvm.org/viewvc/llvm-project?rev=129242&view=rev
Log:
Refactor 129240 to merge the old default argument into the new parameter.

Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=129242&r1=129241&r2=129242&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sat Apr  9 23:58:30 2011
@@ -288,11 +288,7 @@
     ParmVarDecl *NewParam = New->getParamDecl(p);
 
     if (OldParam->hasDefaultArg() && NewParam->hasDefaultArg()) {
-      // 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:
+
       unsigned DiagDefaultParamID =
         diag::err_param_default_argument_redefinition;
 
@@ -302,11 +298,23 @@
       if (getLangOptions().Microsoft) {
         CXXMethodDecl* MD = dyn_cast<CXXMethodDecl>(New);
         if (MD && MD->getParent()->getDescribedClassTemplate()) {
+          // Merge the old default argument into the new parameter.
+          NewParam->setHasInheritedDefaultArg();
+          if (OldParam->hasUninstantiatedDefaultArg())
+            NewParam->setUninstantiatedDefaultArg(
+                                      OldParam->getUninstantiatedDefaultArg());
+          else
+            NewParam->setDefaultArg(OldParam->getInit());
           DiagDefaultParamID = diag::war_param_default_argument_redefinition;
           Invalid = false;
         }
       }
       
+      // 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);





More information about the cfe-commits mailing list