diff options
| author | Francois Pichet <pichet2000@gmail.com> | 2011-04-10 03:03:52 +0000 |
|---|---|---|
| committer | Francois Pichet <pichet2000@gmail.com> | 2011-04-10 03:03:52 +0000 |
| commit | 53fe2bb29e801224af5c38cef004ed01ca7f029e (patch) | |
| tree | 6af79243e280eb76ffd6d707232688b88c018838 /clang/lib | |
| parent | 87eb515abaed41e915294e37b46670a50583a80c (diff) | |
| download | bcm5719-llvm-53fe2bb29e801224af5c38cef004ed01ca7f029e.tar.gz bcm5719-llvm-53fe2bb29e801224af5c38cef004ed01ca7f029e.zip | |
MSVC accepts that default parameters be redefined for member functions
of template class. The new value is ignored.
This fixes 1 error when parsing MSVC 2010 header files with clang.
llvm-svn: 129240
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 6d50267289a..9dbca64639f 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -293,12 +293,24 @@ bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old) { // 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; + + // MSVC accepts that default parameters be redefined for member functions + // of template class. The new default parameter's value is ignored. + Invalid = true; + if (getLangOptions().Microsoft) { + CXXMethodDecl* MD = dyn_cast<CXXMethodDecl>(New); + if (MD && MD->getParent()->getDescribedClassTemplate()) { + DiagDefaultParamID = diag::war_param_default_argument_redefinition; + Invalid = false; + } + } // int f(int); // void g(int (*fp)(int) = f); // void g(int (*fp)(int) = &f); - Diag(NewParam->getLocation(), - diag::err_param_default_argument_redefinition) + Diag(NewParam->getLocation(), DiagDefaultParamID) << NewParam->getDefaultArgRange(); // Look for the function declaration where the default argument was @@ -313,7 +325,6 @@ bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old) { Diag(OldParam->getLocation(), diag::note_previous_definition) << OldParam->getDefaultArgRange(); - Invalid = true; } else if (OldParam->hasDefaultArg()) { // Merge the old default argument into the new parameter. // It's important to use getInit() here; getDefaultArg() |

