diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Parse/ParseTemplate.cpp')
| -rw-r--r-- | contrib/llvm/tools/clang/lib/Parse/ParseTemplate.cpp | 44 | 
1 files changed, 23 insertions, 21 deletions
diff --git a/contrib/llvm/tools/clang/lib/Parse/ParseTemplate.cpp b/contrib/llvm/tools/clang/lib/Parse/ParseTemplate.cpp index 944cd775d52a..56a16b9e0271 100644 --- a/contrib/llvm/tools/clang/lib/Parse/ParseTemplate.cpp +++ b/contrib/llvm/tools/clang/lib/Parse/ParseTemplate.cpp @@ -112,7 +112,7 @@ Parser::ParseTemplateDeclarationOrSpecialization(unsigned Context,      // Parse the '<' template-parameter-list '>'      SourceLocation LAngleLoc, RAngleLoc; -    SmallVector<Decl*, 4> TemplateParams; +    SmallVector<NamedDecl*, 4> TemplateParams;      if (ParseTemplateParameters(CurTemplateDepthTracker.getDepth(),                                  TemplateParams, LAngleLoc, RAngleLoc)) {        // Skip until the semi-colon or a '}'. @@ -197,10 +197,11 @@ Parser::ParseSingleDeclarationAfterTemplate(    MaybeParseCXX11Attributes(prefixAttrs);    if (Tok.is(tok::kw_using)) { -    // FIXME: We should return the DeclGroup to the caller. -    ParseUsingDirectiveOrDeclaration(Context, TemplateInfo, DeclEnd, -                                     prefixAttrs); -    return nullptr; +    auto usingDeclPtr = ParseUsingDirectiveOrDeclaration(Context, TemplateInfo, DeclEnd, +                                                         prefixAttrs); +    if (!usingDeclPtr || !usingDeclPtr.get().isSingleDecl()) +      return nullptr; +    return usingDeclPtr.get().getSingleDecl();    }    // Parse the declaration specifiers, stealing any diagnostics from @@ -329,10 +330,9 @@ Parser::ParseSingleDeclarationAfterTemplate(  /// that enclose this template parameter list.  ///  /// \returns true if an error occurred, false otherwise. -bool Parser::ParseTemplateParameters(unsigned Depth, -                               SmallVectorImpl<Decl*> &TemplateParams, -                                     SourceLocation &LAngleLoc, -                                     SourceLocation &RAngleLoc) { +bool Parser::ParseTemplateParameters( +    unsigned Depth, SmallVectorImpl<NamedDecl *> &TemplateParams, +    SourceLocation &LAngleLoc, SourceLocation &RAngleLoc) {    // Get the template parameter list.    if (!TryConsumeToken(tok::less, LAngleLoc)) {      Diag(Tok.getLocation(), diag::err_expected_less_after) << "template"; @@ -370,9 +370,10 @@ bool Parser::ParseTemplateParameters(unsigned Depth,  ///         template-parameter-list ',' template-parameter  bool  Parser::ParseTemplateParameterList(unsigned Depth, -                             SmallVectorImpl<Decl*> &TemplateParams) { +                             SmallVectorImpl<NamedDecl*> &TemplateParams) {    while (1) { -    if (Decl *TmpParam +     +    if (NamedDecl *TmpParam            = ParseTemplateParameter(Depth, TemplateParams.size())) {        TemplateParams.push_back(TmpParam);      } else { @@ -479,7 +480,7 @@ bool Parser::isStartOfTemplateTypeParameter() {  ///               'class' ...[opt] identifier[opt]  ///         'template' '<' template-parameter-list '>' 'class' identifier[opt]  ///               = id-expression -Decl *Parser::ParseTemplateParameter(unsigned Depth, unsigned Position) { +NamedDecl *Parser::ParseTemplateParameter(unsigned Depth, unsigned Position) {    if (isStartOfTemplateTypeParameter())      return ParseTypeParameter(Depth, Position); @@ -501,7 +502,7 @@ Decl *Parser::ParseTemplateParameter(unsigned Depth, unsigned Position) {  ///         'class' identifier[opt] '=' type-id  ///         'typename' ...[opt][C++0x] identifier[opt]  ///         'typename' identifier[opt] '=' type-id -Decl *Parser::ParseTypeParameter(unsigned Depth, unsigned Position) { +NamedDecl *Parser::ParseTypeParameter(unsigned Depth, unsigned Position) {    assert(Tok.isOneOf(tok::kw_class, tok::kw_typename) &&           "A type-parameter starts with 'class' or 'typename'"); @@ -563,13 +564,13 @@ Decl *Parser::ParseTypeParameter(unsigned Depth, unsigned Position) {  ///       type-parameter-key:  ///         'class'  ///         'typename'       [C++1z] -Decl * +NamedDecl *  Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) {    assert(Tok.is(tok::kw_template) && "Expected 'template' keyword");    // Handle the template <...> part.    SourceLocation TemplateLoc = ConsumeToken(); -  SmallVector<Decl*,8> TemplateParams; +  SmallVector<NamedDecl*,8> TemplateParams;    SourceLocation LAngleLoc, RAngleLoc;    {      ParseScope TemplateParmScope(this, Scope::TemplateParamScope); @@ -589,10 +590,10 @@ Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) {      const Token &Next = Tok.is(tok::kw_struct) ? NextToken() : Tok;      if (Tok.is(tok::kw_typename)) {        Diag(Tok.getLocation(), -           getLangOpts().CPlusPlus1z +           getLangOpts().CPlusPlus17                 ? diag::warn_cxx14_compat_template_template_param_typename                 : diag::ext_template_template_param_typename) -        << (!getLangOpts().CPlusPlus1z +        << (!getLangOpts().CPlusPlus17                  ? FixItHint::CreateReplacement(Tok.getLocation(), "class")                  : FixItHint());      } else if (Next.isOneOf(tok::identifier, tok::comma, tok::greater, @@ -668,7 +669,7 @@ Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) {  ///       template-parameter:  ///         ...  ///         parameter-declaration -Decl * +NamedDecl *  Parser::ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position) {    // Parse the declaration-specifiers (i.e., the type).    // FIXME: The type should probably be restricted in some way... Not all @@ -1023,8 +1024,8 @@ bool Parser::AnnotateTemplateIdToken(TemplateTy Template, TemplateNameKind TNK,              ? OO_None              : TemplateName.OperatorFunctionId.Operator; -    TemplateIdAnnotation *TemplateId = TemplateIdAnnotation::Create(
 -      SS, TemplateKWLoc, TemplateNameLoc, TemplateII, OpKind, Template, TNK,
 +    TemplateIdAnnotation *TemplateId = TemplateIdAnnotation::Create( +      SS, TemplateKWLoc, TemplateNameLoc, TemplateII, OpKind, Template, TNK,        LAngleLoc, RAngleLoc, TemplateArgs, TemplateIds);      Tok.setAnnotationValue(TemplateId); @@ -1380,7 +1381,8 @@ void Parser::ParseLateTemplatedFuncDef(LateParsedTemplate &LPT) {    // Parse the method body. Function body parsing code is similar enough    // to be re-used for method bodies as well. -  ParseScope FnScope(this, Scope::FnScope|Scope::DeclScope); +  ParseScope FnScope(this, Scope::FnScope | Scope::DeclScope | +                               Scope::CompoundStmtScope);    // Recreate the containing function DeclContext.    Sema::ContextRAII FunctionSavedContext(Actions,  | 
