[cfe-commits] r110603 - in /cfe/trunk: include/clang/Basic/DiagnosticParseKinds.td lib/Parse/ParseCXXInlineMethods.cpp test/Parser/cxx-default-args.cpp

Douglas Gregor dgregor at apple.com
Mon Aug 9 15:28:59 PDT 2010


On Aug 9, 2010, at 3:28 PM, Argyrios Kyrtzidis wrote:

> On Aug 9, 2010, at 10:40 PM, Douglas Gregor wrote:
> 
>> 
>> On Aug 9, 2010, at 2:08 PM, Argyrios Kyrtzidis wrote:
>> 
>>> Author: akirtzidis
>>> Date: Mon Aug  9 16:08:13 2010
>>> New Revision: 110603
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=110603&view=rev
>>> Log:
>>> Change warning about incomplete parsing of C++ default arg to error and provide a test case; thanks Doug!
>>> 
>>> Modified:
>>>   cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
>>>   cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
>>>   cfe/trunk/test/Parser/cxx-default-args.cpp
>>> 
>>> Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=110603&r1=110602&r2=110603&view=diff
>>> ==============================================================================
>>> --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
>>> +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Mon Aug  9 16:08:13 2010
>>> @@ -271,8 +271,8 @@
>>>  "expected a class name after '~' to name a destructor">;
>>> def err_destructor_template_id : Error<
>>>  "destructor name %0 does not refer to a template">;
>>> -def warn_default_arg_unparsed : Warning<
>>> -  "parsing of default argument is incomplete">;
>>> +def err_default_arg_unparsed : Error<
>>> +  "unexpected end of default argument expression">;
>>> 
>>> // C++ derived classes
>>> def err_dup_virtual : Error<"duplicate 'virtual' in base specifier">;
>>> 
>>> Modified: cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp?rev=110603&r1=110602&r2=110603&view=diff
>>> ==============================================================================
>>> --- cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp (original)
>>> +++ cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp Mon Aug  9 16:08:13 2010
>>> @@ -145,12 +145,8 @@
>>>        else {
>>>          if (Tok.is(tok::cxx_defaultarg_end))
>>>            ConsumeToken();
>>> -          else {
>>> -            // Warn that there are tokens from the default arg that we left
>>> -            // unparsed. This actually indicates a bug in clang but we avoid
>>> -            // asserting because we want the parser robust.
>>> -            Diag(Tok.getLocation(), diag::warn_default_arg_unparsed);
>>> -          }
>>> +          else
>>> +            Diag(Tok.getLocation(), diag::err_default_arg_unparsed);
>> 
>> Shouldn't we be consuming all of the tokens up to the tok::cxx_defaultarg_end?
> 
> That happens later, all tokens from default arg are consumed:
> 
>         // There could be leftover tokens (e.g. because of an error).
>         // Skip through until we reach the original token position.
>         while (Tok.getLocation() != origLoc && Tok.isNot(tok::eof))
>           ConsumeAnyToken();

Okay, thanks!

	- Doug

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100809/61f0b2a5/attachment.html>


More information about the cfe-commits mailing list