[cfe-commits] r129240 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDeclCXX.cpp test/SemaCXX/MicrosoftExtensions.cpp

Francois Pichet pichet2000 at gmail.com
Sat Apr 9 22:05:19 PDT 2011


On Sat, Apr 9, 2011 at 11:43 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
> On Sat, Apr 9, 2011 at 8:03 PM, Francois Pichet <pichet2000 at gmail.com> wrote:
>> Author: fpichet
>> Date: Sat Apr  9 22:03:52 2011
>> New Revision: 129240
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=129240&view=rev
>> Log:
>> 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.
>>
>> Modified:
>>    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>>    cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=129240&r1=129239&r2=129240&view=diff
>> ==============================================================================
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat Apr  9 22:03:52 2011
>> @@ -1301,6 +1301,8 @@
>>   "C does not support default arguments">;
>>  def err_param_default_argument_redefinition : Error<
>>   "redefinition of default argument">;
>> +def war_param_default_argument_redefinition : ExtWarn<
>> +  "redefinition of default argument">;
>>  def err_param_default_argument_missing : Error<
>>   "missing default argument on parameter">;
>>  def err_param_default_argument_missing_name : Error<
>>
>> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=129240&r1=129239&r2=129240&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sat Apr  9 22:03:52 2011
>> @@ -293,12 +293,24 @@
>>       // 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);
>
> 1. You're splitting a comment which should be a single unit here.
>
> 2. The default argument for NewParam isn't getting set correctly; look
> at what happens in the non-error case.
>

ok see r129242




More information about the cfe-commits mailing list