r210304 - PR11306 - Variadic template fix-it suggestion. Recover from misplaced or redundant ellipsis in parameter pack.

Timur Iskhodzhanov timurrrr at google.com
Fri Jun 6 04:16:26 PDT 2014


2014-06-06 6:59 GMT+04:00 Nikola Smiljanic <popizdeh at gmail.com>:

> Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=
> 210304&r1=210303&r2=210304&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseTemplate.cpp Thu Jun  5 21:58:59 2014
> @@ -498,6 +498,11 @@ Decl *Parser::ParseTypeParameter(unsigne
>      return nullptr;
>    }
>
> +  // Recover from misplaced ellipsis.
> +  bool AlreadyHasEllipsis = EllipsisLoc.isValid();
> +  if (TryConsumeToken(tok::ellipsis, EllipsisLoc))
> +    DiagnoseMisplacedEllipsis(EllipsisLoc, NameLoc, AlreadyHasEllipsis,
> true);
> +
>    // Grab a default argument (if available).
>    // Per C++0x [basic.scope.pdecl]p9, we parse the default argument before
>    // we introduce the type parameter into the local scope.
> @@ -507,9 +512,9 @@ Decl *Parser::ParseTypeParameter(unsigne
>      DefaultArg = ParseTypeName(/*Range=*/nullptr,
>                                 Declarator::TemplateTypeArgContext).get();
>
> -  return Actions.ActOnTypeParameter(getCurScope(), TypenameKeyword,
> Ellipsis,
> -                                    EllipsisLoc, KeyLoc, ParamName,
> NameLoc,
> -                                    Depth, Position, EqualLoc,
> DefaultArg);
> +  return Actions.ActOnTypeParameter(getCurScope(), TypenameKeyword,
> EllipsisLoc,
> +                                    KeyLoc, ParamName, NameLoc, Depth,
> Position,
> +                                    EqualLoc, DefaultArg);
>  }
>

FYI
../tools/clang/lib/Parse/ParseTemplate.cpp: In member function
‘clang::Decl* clang::Parser::ParseTypeParameter(unsigned int, unsigned
int)’:
../tools/clang/lib/Parse/ParseTemplate.cpp:476:8: warning: variable
‘Ellipsis’ set but not used [-Wunused-but-set-variable]
   bool Ellipsis = false;
        ^

fixed in r210324.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140606/6a443e2b/attachment.html>


More information about the cfe-commits mailing list