aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDeclCXX.cpp
diff options
context:
space:
mode:
authorFrancois Pichet <pichet2000@gmail.com>2011-04-10 04:58:30 +0000
committerFrancois Pichet <pichet2000@gmail.com>2011-04-10 04:58:30 +0000
commit8cf9049185c72dc453ebb946d39420f3f78dec76 (patch)
treec85a5f7f38d50f56acca23d9e5a44b12d6ab5526 /lib/Sema/SemaDeclCXX.cpp
parent52d6874271829c4f5bb70121fb678c27780ce65a (diff)
Refactor 129240 to merge the old default argument into the new parameter.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129242 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclCXX.cpp')
-rw-r--r--lib/Sema/SemaDeclCXX.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 9dbca64639..01ce75192a 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -288,11 +288,7 @@ bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old) {
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 @@ bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old) {
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);