blob: ed087e342ae6bb5a9c807284972be51db88a3700 [file] [log] [blame]
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +00001//===--- ParseCXXInlineMethods.cpp - C++ class inline methods parsing------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements parsing for C++ class inline methods.
11//
12//===----------------------------------------------------------------------===//
13
14#include "clang/Parse/Parser.h"
Chandler Carruth3a022472012-12-04 09:13:33 +000015#include "RAIIObjectsForParser.h"
16#include "clang/AST/DeclTemplate.h"
17#include "clang/Parse/ParseDiagnostic.h"
John McCall8b0666c2010-08-20 18:27:03 +000018#include "clang/Sema/DeclSpec.h"
19#include "clang/Sema/Scope.h"
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +000020using namespace clang;
21
John McCalle68672f2013-03-14 05:13:41 +000022/// Get the FunctionDecl for a function or function template decl.
23static FunctionDecl *getFunctionDecl(Decl *D) {
24 if (FunctionDecl *fn = dyn_cast<FunctionDecl>(D))
25 return fn;
26 return cast<FunctionTemplateDecl>(D)->getTemplatedDecl();
27}
28
Sebastian Redla7b98a72009-04-26 20:35:05 +000029/// ParseCXXInlineMethodDef - We parsed and verified that the specified
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +000030/// Declarator is a well formed C++ inline method definition. Now lex its body
31/// and store its tokens for parsing after the C++ class is complete.
Rafael Espindolac2453dd2013-01-08 21:00:12 +000032NamedDecl *Parser::ParseCXXInlineMethodDef(AccessSpecifier AS,
Erik Verbruggenca98f2a2011-10-13 09:41:32 +000033 AttributeList *AccessAttrs,
34 ParsingDeclarator &D,
Douglas Gregor5d1b4e32011-11-07 20:56:01 +000035 const ParsedTemplateInfo &TemplateInfo,
36 const VirtSpecifiers& VS,
37 FunctionDefinitionKind DefinitionKind,
38 ExprResult& Init) {
Abramo Bagnara924a8f32010-12-10 16:29:40 +000039 assert(D.isFunctionDeclarator() && "This isn't a function declarator!");
Alexis Hunt5a7fa252011-05-12 06:15:49 +000040 assert((Tok.is(tok::l_brace) || Tok.is(tok::colon) || Tok.is(tok::kw_try) ||
41 Tok.is(tok::equal)) &&
42 "Current token not a '{', ':', '=', or 'try'!");
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +000043
Benjamin Kramercc4c49d2012-08-23 23:38:35 +000044 MultiTemplateParamsArg TemplateParams(
Alexis Hunt1deb9722010-04-14 23:07:37 +000045 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->data() : 0,
46 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->size() : 0);
47
Rafael Espindolac2453dd2013-01-08 21:00:12 +000048 NamedDecl *FnD;
Douglas Gregor5d1b4e32011-11-07 20:56:01 +000049 D.setFunctionDefinitionKind(DefinitionKind);
John McCall07e91c02009-08-06 02:15:43 +000050 if (D.getDeclSpec().isFriendSpecified())
Kaelyn Uhrain4dc695d2011-10-11 00:28:45 +000051 FnD = Actions.ActOnFriendFunctionDecl(getCurScope(), D,
Benjamin Kramer62b95d82012-08-23 21:35:17 +000052 TemplateParams);
Douglas Gregor728d00b2011-10-10 14:49:18 +000053 else {
Douglas Gregor0be31a22010-07-02 17:43:08 +000054 FnD = Actions.ActOnCXXMemberDeclarator(getCurScope(), AS, D,
Benjamin Kramer62b95d82012-08-23 21:35:17 +000055 TemplateParams, 0,
Richard Smith2b013182012-06-10 03:12:00 +000056 VS, ICIS_NoInit);
Douglas Gregor728d00b2011-10-10 14:49:18 +000057 if (FnD) {
Richard Smithf8a75c32013-08-29 00:47:48 +000058 Actions.ProcessDeclAttributeList(getCurScope(), FnD, AccessAttrs);
Richard Smith74aeef52013-04-26 16:15:35 +000059 bool TypeSpecContainsAuto = D.getDeclSpec().containsPlaceholderType();
Douglas Gregor50cefbf2011-10-17 17:09:53 +000060 if (Init.isUsable())
Larisse Voufo39a1e502013-08-06 01:03:05 +000061 Actions.AddInitializerToDecl(FnD, Init.get(), false,
Douglas Gregor728d00b2011-10-10 14:49:18 +000062 TypeSpecContainsAuto);
63 else
64 Actions.ActOnUninitializedDecl(FnD, TypeSpecContainsAuto);
65 }
Nico Weber24b2a822011-01-28 06:07:34 +000066 }
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +000067
Douglas Gregor433e0532012-04-16 18:27:27 +000068 HandleMemberFunctionDeclDelays(D, FnD);
Eli Friedman3af2a772009-07-22 21:45:50 +000069
John McCallc1465822011-02-14 07:13:47 +000070 D.complete(FnD);
71
Alexis Hunt5a7fa252011-05-12 06:15:49 +000072 if (Tok.is(tok::equal)) {
73 ConsumeToken();
74
Richard Smith1c704732011-11-10 09:08:44 +000075 if (!FnD) {
76 SkipUntil(tok::semi);
77 return 0;
78 }
79
Alexis Hunt5a7fa252011-05-12 06:15:49 +000080 bool Delete = false;
81 SourceLocation KWLoc;
82 if (Tok.is(tok::kw_delete)) {
Richard Smith2bf7fdb2013-01-02 11:42:31 +000083 Diag(Tok, getLangOpts().CPlusPlus11 ?
Richard Smith5d164bc2011-10-15 05:09:34 +000084 diag::warn_cxx98_compat_deleted_function :
Richard Smithe4345902011-12-29 21:57:33 +000085 diag::ext_deleted_function);
Alexis Hunt5a7fa252011-05-12 06:15:49 +000086
87 KWLoc = ConsumeToken();
88 Actions.SetDeclDeleted(FnD, KWLoc);
89 Delete = true;
90 } else if (Tok.is(tok::kw_default)) {
Richard Smith2bf7fdb2013-01-02 11:42:31 +000091 Diag(Tok, getLangOpts().CPlusPlus11 ?
Richard Smith5d164bc2011-10-15 05:09:34 +000092 diag::warn_cxx98_compat_defaulted_function :
Richard Smithe4345902011-12-29 21:57:33 +000093 diag::ext_defaulted_function);
Alexis Hunt5a7fa252011-05-12 06:15:49 +000094
95 KWLoc = ConsumeToken();
96 Actions.SetDeclDefaulted(FnD, KWLoc);
97 } else {
98 llvm_unreachable("function definition after = not 'delete' or 'default'");
99 }
100
101 if (Tok.is(tok::comma)) {
102 Diag(KWLoc, diag::err_default_delete_in_multiple_declaration)
103 << Delete;
104 SkipUntil(tok::semi);
105 } else {
106 ExpectAndConsume(tok::semi, diag::err_expected_semi_after,
107 Delete ? "delete" : "default", tok::semi);
108 }
109
110 return FnD;
111 }
112
Francois Pichet1c229c02011-04-22 22:18:13 +0000113 // In delayed template parsing mode, if we are within a class template
114 // or if we are about to parse function member template then consume
115 // the tokens and store them for parsing at the end of the translation unit.
David Blaikiebbafb8a2012-03-11 07:00:24 +0000116 if (getLangOpts().DelayedTemplateParsing &&
Douglas Gregor1edf5762012-06-28 21:43:01 +0000117 DefinitionKind == FDK_Definition &&
Francois Pichet1c229c02011-04-22 22:18:13 +0000118 ((Actions.CurContext->isDependentContext() ||
119 TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate) &&
Francois Pichet6dc4c162011-11-18 23:47:17 +0000120 !Actions.IsInsideALocalClassWithinATemplateFunction())) {
Francois Pichet1c229c02011-04-22 22:18:13 +0000121
Richard Smithe40f2ba2013-08-07 21:41:30 +0000122 CachedTokens Toks;
123 LexTemplateFunctionForLateParsing(Toks);
Francois Pichet1c229c02011-04-22 22:18:13 +0000124
Richard Smithe40f2ba2013-08-07 21:41:30 +0000125 if (FnD) {
John McCalle68672f2013-03-14 05:13:41 +0000126 FunctionDecl *FD = getFunctionDecl(FnD);
Chandler Carruthbc0f9ae2011-04-25 07:09:43 +0000127 Actions.CheckForFunctionRedefinition(FD);
Richard Smithe40f2ba2013-08-07 21:41:30 +0000128 Actions.MarkAsLateParsedTemplate(FD, FnD, Toks);
Francois Pichet1c229c02011-04-22 22:18:13 +0000129 }
130
131 return FnD;
132 }
133
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000134 // Consume the tokens and store them for later parsing.
135
Douglas Gregorefc46952010-10-12 16:25:54 +0000136 LexedMethod* LM = new LexedMethod(this, FnD);
137 getCurrentClass().LateParsedDeclarations.push_back(LM);
138 LM->TemplateScope = getCurScope()->isTemplateParamScope();
139 CachedTokens &Toks = LM->Toks;
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000140
Sebastian Redla7b98a72009-04-26 20:35:05 +0000141 tok::TokenKind kind = Tok.getKind();
Sebastian Redl0d164012011-09-30 08:32:17 +0000142 // Consume everything up to (and including) the left brace of the
143 // function body.
144 if (ConsumeAndStoreFunctionPrologue(Toks)) {
145 // We didn't find the left-brace we expected after the
Eli Friedman7cd4a9b2012-02-22 04:49:04 +0000146 // constructor initializer; we already printed an error, and it's likely
147 // impossible to recover, so don't try to parse this method later.
Richard Smithcde3fd82013-07-04 00:13:48 +0000148 // Skip over the rest of the decl and back to somewhere that looks
149 // reasonable.
150 SkipMalformedDecl();
Eli Friedman7cd4a9b2012-02-22 04:49:04 +0000151 delete getCurrentClass().LateParsedDeclarations.back();
152 getCurrentClass().LateParsedDeclarations.pop_back();
153 return FnD;
Douglas Gregore8381c02008-11-05 04:29:56 +0000154 } else {
Sebastian Redl0d164012011-09-30 08:32:17 +0000155 // Consume everything up to (and including) the matching right brace.
156 ConsumeAndStoreUntil(tok::r_brace, Toks, /*StopAtSemi=*/false);
Douglas Gregore8381c02008-11-05 04:29:56 +0000157 }
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000158
Sebastian Redla7b98a72009-04-26 20:35:05 +0000159 // If we're in a function-try-block, we need to store all the catch blocks.
160 if (kind == tok::kw_try) {
161 while (Tok.is(tok::kw_catch)) {
Argyrios Kyrtzidis8d7bdba2010-04-23 21:20:12 +0000162 ConsumeAndStoreUntil(tok::l_brace, Toks, /*StopAtSemi=*/false);
163 ConsumeAndStoreUntil(tok::r_brace, Toks, /*StopAtSemi=*/false);
Sebastian Redla7b98a72009-04-26 20:35:05 +0000164 }
165 }
166
Stephen Lin9354fc52013-06-23 07:37:13 +0000167 if (FnD) {
168 // If this is a friend function, mark that it's late-parsed so that
169 // it's still known to be a definition even before we attach the
170 // parsed body. Sema needs to treat friend function definitions
171 // differently during template instantiation, and it's possible for
172 // the containing class to be instantiated before all its member
173 // function definitions are parsed.
174 //
175 // If you remove this, you can remove the code that clears the flag
176 // after parsing the member.
177 if (D.getDeclSpec().isFriendSpecified()) {
178 getFunctionDecl(FnD)->setLateTemplateParsed(true);
179 }
180 } else {
Douglas Gregor6ca64102011-04-14 23:19:27 +0000181 // If semantic analysis could not build a function declaration,
182 // just throw away the late-parsed declaration.
183 delete getCurrentClass().LateParsedDeclarations.back();
184 getCurrentClass().LateParsedDeclarations.pop_back();
185 }
186
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000187 return FnD;
188}
189
Richard Smith938f40b2011-06-11 17:19:42 +0000190/// ParseCXXNonStaticMemberInitializer - We parsed and verified that the
191/// specified Declarator is a well formed C++ non-static data member
192/// declaration. Now lex its initializer and store its tokens for parsing
193/// after the class is complete.
194void Parser::ParseCXXNonStaticMemberInitializer(Decl *VarD) {
195 assert((Tok.is(tok::l_brace) || Tok.is(tok::equal)) &&
196 "Current token not a '{' or '='!");
197
198 LateParsedMemberInitializer *MI =
199 new LateParsedMemberInitializer(this, VarD);
200 getCurrentClass().LateParsedDeclarations.push_back(MI);
201 CachedTokens &Toks = MI->Toks;
202
203 tok::TokenKind kind = Tok.getKind();
204 if (kind == tok::equal) {
205 Toks.push_back(Tok);
Douglas Gregor0cf55e92012-03-08 01:00:17 +0000206 ConsumeToken();
Richard Smith938f40b2011-06-11 17:19:42 +0000207 }
208
209 if (kind == tok::l_brace) {
210 // Begin by storing the '{' token.
211 Toks.push_back(Tok);
212 ConsumeBrace();
213
214 // Consume everything up to (and including) the matching right brace.
215 ConsumeAndStoreUntil(tok::r_brace, Toks, /*StopAtSemi=*/true);
216 } else {
217 // Consume everything up to (but excluding) the comma or semicolon.
218 ConsumeAndStoreUntil(tok::comma, Toks, /*StopAtSemi=*/true,
219 /*ConsumeFinalToken=*/false);
220 }
221
222 // Store an artificial EOF token to ensure that we don't run off the end of
223 // the initializer when we come to parse it.
224 Token Eof;
225 Eof.startToken();
226 Eof.setKind(tok::eof);
227 Eof.setLocation(Tok.getLocation());
228 Toks.push_back(Eof);
229}
230
Douglas Gregorefc46952010-10-12 16:25:54 +0000231Parser::LateParsedDeclaration::~LateParsedDeclaration() {}
232void Parser::LateParsedDeclaration::ParseLexedMethodDeclarations() {}
Richard Smith938f40b2011-06-11 17:19:42 +0000233void Parser::LateParsedDeclaration::ParseLexedMemberInitializers() {}
Douglas Gregorefc46952010-10-12 16:25:54 +0000234void Parser::LateParsedDeclaration::ParseLexedMethodDefs() {}
235
236Parser::LateParsedClass::LateParsedClass(Parser *P, ParsingClass *C)
237 : Self(P), Class(C) {}
238
239Parser::LateParsedClass::~LateParsedClass() {
240 Self->DeallocateParsedClasses(Class);
241}
242
243void Parser::LateParsedClass::ParseLexedMethodDeclarations() {
244 Self->ParseLexedMethodDeclarations(*Class);
245}
246
Richard Smith938f40b2011-06-11 17:19:42 +0000247void Parser::LateParsedClass::ParseLexedMemberInitializers() {
248 Self->ParseLexedMemberInitializers(*Class);
249}
250
Douglas Gregorefc46952010-10-12 16:25:54 +0000251void Parser::LateParsedClass::ParseLexedMethodDefs() {
252 Self->ParseLexedMethodDefs(*Class);
253}
254
255void Parser::LateParsedMethodDeclaration::ParseLexedMethodDeclarations() {
256 Self->ParseLexedMethodDeclaration(*this);
257}
258
259void Parser::LexedMethod::ParseLexedMethodDefs() {
260 Self->ParseLexedMethodDef(*this);
261}
262
Richard Smith938f40b2011-06-11 17:19:42 +0000263void Parser::LateParsedMemberInitializer::ParseLexedMemberInitializers() {
264 Self->ParseLexedMemberInitializer(*this);
265}
266
Douglas Gregor4d87df52008-12-16 21:30:33 +0000267/// ParseLexedMethodDeclarations - We finished parsing the member
268/// specification of a top (non-nested) C++ class. Now go over the
269/// stack of method declarations with some parts for which parsing was
270/// delayed (such as default arguments) and parse them.
Douglas Gregore44a2ad2009-05-27 23:11:45 +0000271void Parser::ParseLexedMethodDeclarations(ParsingClass &Class) {
272 bool HasTemplateScope = !Class.TopLevelClass && Class.TemplateScope;
Douglas Gregorefc46952010-10-12 16:25:54 +0000273 ParseScope ClassTemplateScope(this, Scope::TemplateParamScope, HasTemplateScope);
Richard Smithc8378952013-04-29 11:55:38 +0000274 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
275 if (HasTemplateScope) {
Douglas Gregor0be31a22010-07-02 17:43:08 +0000276 Actions.ActOnReenterTemplateScope(getCurScope(), Class.TagOrTemplate);
Richard Smithc8378952013-04-29 11:55:38 +0000277 ++CurTemplateDepthTracker;
278 }
Douglas Gregore44a2ad2009-05-27 23:11:45 +0000279
John McCall6df5fef2009-12-19 10:49:29 +0000280 // The current scope is still active if we're the top-level class.
281 // Otherwise we'll need to push and enter a new scope.
Douglas Gregore44a2ad2009-05-27 23:11:45 +0000282 bool HasClassScope = !Class.TopLevelClass;
Alexis Hunt1deb9722010-04-14 23:07:37 +0000283 ParseScope ClassScope(this, Scope::ClassScope|Scope::DeclScope,
284 HasClassScope);
John McCall6df5fef2009-12-19 10:49:29 +0000285 if (HasClassScope)
Douglas Gregor0be31a22010-07-02 17:43:08 +0000286 Actions.ActOnStartDelayedMemberDeclarations(getCurScope(), Class.TagOrTemplate);
Douglas Gregore44a2ad2009-05-27 23:11:45 +0000287
Douglas Gregorefc46952010-10-12 16:25:54 +0000288 for (size_t i = 0; i < Class.LateParsedDeclarations.size(); ++i) {
289 Class.LateParsedDeclarations[i]->ParseLexedMethodDeclarations();
Douglas Gregor4d87df52008-12-16 21:30:33 +0000290 }
Douglas Gregore44a2ad2009-05-27 23:11:45 +0000291
John McCall6df5fef2009-12-19 10:49:29 +0000292 if (HasClassScope)
Douglas Gregor0be31a22010-07-02 17:43:08 +0000293 Actions.ActOnFinishDelayedMemberDeclarations(getCurScope(), Class.TagOrTemplate);
Douglas Gregor4d87df52008-12-16 21:30:33 +0000294}
295
Douglas Gregorefc46952010-10-12 16:25:54 +0000296void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
297 // If this is a member template, introduce the template parameter scope.
298 ParseScope TemplateScope(this, Scope::TemplateParamScope, LM.TemplateScope);
Richard Smithc8378952013-04-29 11:55:38 +0000299 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
300 if (LM.TemplateScope) {
Douglas Gregorefc46952010-10-12 16:25:54 +0000301 Actions.ActOnReenterTemplateScope(getCurScope(), LM.Method);
Richard Smithc8378952013-04-29 11:55:38 +0000302 ++CurTemplateDepthTracker;
303 }
Douglas Gregorefc46952010-10-12 16:25:54 +0000304 // Start the delayed C++ method declaration
305 Actions.ActOnStartDelayedCXXMethodDeclaration(getCurScope(), LM.Method);
306
307 // Introduce the parameters into scope and parse their default
308 // arguments.
Richard Smithe233fbf2013-01-28 22:42:45 +0000309 ParseScope PrototypeScope(this, Scope::FunctionPrototypeScope |
310 Scope::FunctionDeclarationScope | Scope::DeclScope);
Douglas Gregorefc46952010-10-12 16:25:54 +0000311 for (unsigned I = 0, N = LM.DefaultArgs.size(); I != N; ++I) {
312 // Introduce the parameter into scope.
Douglas Gregor7fcbd902012-02-21 00:37:24 +0000313 Actions.ActOnDelayedCXXMethodParameter(getCurScope(),
314 LM.DefaultArgs[I].Param);
Douglas Gregorefc46952010-10-12 16:25:54 +0000315
316 if (CachedTokens *Toks = LM.DefaultArgs[I].Toks) {
317 // Save the current token position.
318 SourceLocation origLoc = Tok.getLocation();
319
320 // Parse the default argument from its saved token stream.
321 Toks->push_back(Tok); // So that the current token doesn't get lost
322 PP.EnterTokenStream(&Toks->front(), Toks->size(), true, false);
323
324 // Consume the previously-pushed token.
325 ConsumeAnyToken();
326
327 // Consume the '='.
328 assert(Tok.is(tok::equal) && "Default argument not starting with '='");
329 SourceLocation EqualLoc = ConsumeToken();
330
331 // The argument isn't actually potentially evaluated unless it is
332 // used.
333 EnterExpressionEvaluationContext Eval(Actions,
Douglas Gregor7fcbd902012-02-21 00:37:24 +0000334 Sema::PotentiallyEvaluatedIfUsed,
335 LM.DefaultArgs[I].Param);
Douglas Gregorefc46952010-10-12 16:25:54 +0000336
Sebastian Redldb63af22012-03-14 15:54:00 +0000337 ExprResult DefArgResult;
Richard Smith2bf7fdb2013-01-02 11:42:31 +0000338 if (getLangOpts().CPlusPlus11 && Tok.is(tok::l_brace)) {
Sebastian Redl6db0b1b2012-03-20 21:24:03 +0000339 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
Sebastian Redldb63af22012-03-14 15:54:00 +0000340 DefArgResult = ParseBraceInitializer();
Sebastian Redl6db0b1b2012-03-20 21:24:03 +0000341 } else
Sebastian Redldb63af22012-03-14 15:54:00 +0000342 DefArgResult = ParseAssignmentExpression();
Douglas Gregorefc46952010-10-12 16:25:54 +0000343 if (DefArgResult.isInvalid())
344 Actions.ActOnParamDefaultArgumentError(LM.DefaultArgs[I].Param);
345 else {
346 if (Tok.is(tok::cxx_defaultarg_end))
347 ConsumeToken();
348 else
349 Diag(Tok.getLocation(), diag::err_default_arg_unparsed);
350 Actions.ActOnParamDefaultArgument(LM.DefaultArgs[I].Param, EqualLoc,
351 DefArgResult.take());
352 }
353
354 assert(!PP.getSourceManager().isBeforeInTranslationUnit(origLoc,
355 Tok.getLocation()) &&
356 "ParseAssignmentExpression went over the default arg tokens!");
357 // There could be leftover tokens (e.g. because of an error).
358 // Skip through until we reach the original token position.
359 while (Tok.getLocation() != origLoc && Tok.isNot(tok::eof))
360 ConsumeAnyToken();
361
362 delete Toks;
363 LM.DefaultArgs[I].Toks = 0;
364 }
365 }
Douglas Gregor433e0532012-04-16 18:27:27 +0000366
Douglas Gregorefc46952010-10-12 16:25:54 +0000367 PrototypeScope.Exit();
368
369 // Finish the delayed C++ method declaration.
370 Actions.ActOnFinishDelayedCXXMethodDeclaration(getCurScope(), LM.Method);
371}
372
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000373/// ParseLexedMethodDefs - We finished parsing the member specification of a top
374/// (non-nested) C++ class. Now go over the stack of lexed methods that were
375/// collected during its parsing and parse them all.
Douglas Gregore44a2ad2009-05-27 23:11:45 +0000376void Parser::ParseLexedMethodDefs(ParsingClass &Class) {
377 bool HasTemplateScope = !Class.TopLevelClass && Class.TemplateScope;
Douglas Gregorefc46952010-10-12 16:25:54 +0000378 ParseScope ClassTemplateScope(this, Scope::TemplateParamScope, HasTemplateScope);
Richard Smithc8378952013-04-29 11:55:38 +0000379 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
380 if (HasTemplateScope) {
Douglas Gregor0be31a22010-07-02 17:43:08 +0000381 Actions.ActOnReenterTemplateScope(getCurScope(), Class.TagOrTemplate);
Richard Smithc8378952013-04-29 11:55:38 +0000382 ++CurTemplateDepthTracker;
383 }
Douglas Gregore44a2ad2009-05-27 23:11:45 +0000384 bool HasClassScope = !Class.TopLevelClass;
385 ParseScope ClassScope(this, Scope::ClassScope|Scope::DeclScope,
386 HasClassScope);
387
Douglas Gregorefc46952010-10-12 16:25:54 +0000388 for (size_t i = 0; i < Class.LateParsedDeclarations.size(); ++i) {
389 Class.LateParsedDeclarations[i]->ParseLexedMethodDefs();
390 }
391}
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000392
Douglas Gregorefc46952010-10-12 16:25:54 +0000393void Parser::ParseLexedMethodDef(LexedMethod &LM) {
394 // If this is a member template, introduce the template parameter scope.
395 ParseScope TemplateScope(this, Scope::TemplateParamScope, LM.TemplateScope);
Richard Smithc8378952013-04-29 11:55:38 +0000396 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
397 if (LM.TemplateScope) {
Douglas Gregorefc46952010-10-12 16:25:54 +0000398 Actions.ActOnReenterTemplateScope(getCurScope(), LM.D);
Richard Smithc8378952013-04-29 11:55:38 +0000399 ++CurTemplateDepthTracker;
400 }
Douglas Gregorefc46952010-10-12 16:25:54 +0000401 // Save the current token position.
402 SourceLocation origLoc = Tok.getLocation();
Argyrios Kyrtzidis02041972010-03-31 00:38:09 +0000403
Douglas Gregorefc46952010-10-12 16:25:54 +0000404 assert(!LM.Toks.empty() && "Empty body!");
405 // Append the current token at the end of the new token stream so that it
406 // doesn't get lost.
407 LM.Toks.push_back(Tok);
408 PP.EnterTokenStream(LM.Toks.data(), LM.Toks.size(), true, false);
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000409
Douglas Gregorefc46952010-10-12 16:25:54 +0000410 // Consume the previously pushed token.
Argyrios Kyrtzidisc36633c2013-03-27 23:58:17 +0000411 ConsumeAnyToken(/*ConsumeCodeCompletionTok=*/true);
Douglas Gregorefc46952010-10-12 16:25:54 +0000412 assert((Tok.is(tok::l_brace) || Tok.is(tok::colon) || Tok.is(tok::kw_try))
413 && "Inline method not starting with '{', ':' or 'try'");
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000414
Douglas Gregorefc46952010-10-12 16:25:54 +0000415 // Parse the method body. Function body parsing code is similar enough
416 // to be re-used for method bodies as well.
417 ParseScope FnScope(this, Scope::FnScope|Scope::DeclScope);
418 Actions.ActOnStartOfFunctionDef(getCurScope(), LM.D);
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000419
Douglas Gregorefc46952010-10-12 16:25:54 +0000420 if (Tok.is(tok::kw_try)) {
Douglas Gregora0ff0c32011-03-16 17:05:57 +0000421 ParseFunctionTryBlock(LM.D, FnScope);
Douglas Gregorefc46952010-10-12 16:25:54 +0000422 assert(!PP.getSourceManager().isBeforeInTranslationUnit(origLoc,
423 Tok.getLocation()) &&
424 "ParseFunctionTryBlock went over the cached tokens!");
425 // There could be leftover tokens (e.g. because of an error).
426 // Skip through until we reach the original token position.
427 while (Tok.getLocation() != origLoc && Tok.isNot(tok::eof))
428 ConsumeAnyToken();
429 return;
430 }
431 if (Tok.is(tok::colon)) {
432 ParseConstructorInitializer(LM.D);
433
434 // Error recovery.
435 if (!Tok.is(tok::l_brace)) {
Douglas Gregora0ff0c32011-03-16 17:05:57 +0000436 FnScope.Exit();
Douglas Gregorefc46952010-10-12 16:25:54 +0000437 Actions.ActOnFinishFunctionBody(LM.D, 0);
Matt Beaumont-Gayd0457922011-09-23 22:39:23 +0000438 while (Tok.getLocation() != origLoc && Tok.isNot(tok::eof))
439 ConsumeAnyToken();
Douglas Gregorefc46952010-10-12 16:25:54 +0000440 return;
441 }
442 } else
443 Actions.ActOnDefaultCtorInitializers(LM.D);
444
Richard Smithc8378952013-04-29 11:55:38 +0000445 assert((Actions.getDiagnostics().hasErrorOccurred() ||
446 !isa<FunctionTemplateDecl>(LM.D) ||
447 cast<FunctionTemplateDecl>(LM.D)->getTemplateParameters()->getDepth()
448 < TemplateParameterDepth) &&
449 "TemplateParameterDepth should be greater than the depth of "
450 "current template being instantiated!");
451
Douglas Gregora0ff0c32011-03-16 17:05:57 +0000452 ParseFunctionStatementBody(LM.D, FnScope);
Douglas Gregorefc46952010-10-12 16:25:54 +0000453
John McCalle68672f2013-03-14 05:13:41 +0000454 // Clear the late-template-parsed bit if we set it before.
455 if (LM.D) getFunctionDecl(LM.D)->setLateTemplateParsed(false);
456
Douglas Gregorefc46952010-10-12 16:25:54 +0000457 if (Tok.getLocation() != origLoc) {
458 // Due to parsing error, we either went over the cached tokens or
459 // there are still cached tokens left. If it's the latter case skip the
460 // leftover tokens.
461 // Since this is an uncommon situation that should be avoided, use the
462 // expensive isBeforeInTranslationUnit call.
463 if (PP.getSourceManager().isBeforeInTranslationUnit(Tok.getLocation(),
464 origLoc))
Argyrios Kyrtzidise1224c82010-06-19 19:58:34 +0000465 while (Tok.getLocation() != origLoc && Tok.isNot(tok::eof))
Argyrios Kyrtzidise9b76af2010-06-17 10:52:22 +0000466 ConsumeAnyToken();
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000467 }
468}
469
Richard Smith938f40b2011-06-11 17:19:42 +0000470/// ParseLexedMemberInitializers - We finished parsing the member specification
471/// of a top (non-nested) C++ class. Now go over the stack of lexed data member
472/// initializers that were collected during its parsing and parse them all.
473void Parser::ParseLexedMemberInitializers(ParsingClass &Class) {
474 bool HasTemplateScope = !Class.TopLevelClass && Class.TemplateScope;
475 ParseScope ClassTemplateScope(this, Scope::TemplateParamScope,
476 HasTemplateScope);
Richard Smithc8378952013-04-29 11:55:38 +0000477 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
478 if (HasTemplateScope) {
Richard Smith938f40b2011-06-11 17:19:42 +0000479 Actions.ActOnReenterTemplateScope(getCurScope(), Class.TagOrTemplate);
Richard Smithc8378952013-04-29 11:55:38 +0000480 ++CurTemplateDepthTracker;
481 }
Douglas Gregor3024f072012-04-16 07:05:22 +0000482 // Set or update the scope flags.
Richard Smith938f40b2011-06-11 17:19:42 +0000483 bool AlreadyHasClassScope = Class.TopLevelClass;
Douglas Gregor3024f072012-04-16 07:05:22 +0000484 unsigned ScopeFlags = Scope::ClassScope|Scope::DeclScope;
Richard Smith938f40b2011-06-11 17:19:42 +0000485 ParseScope ClassScope(this, ScopeFlags, !AlreadyHasClassScope);
486 ParseScopeFlags ClassScopeFlags(this, ScopeFlags, AlreadyHasClassScope);
487
488 if (!AlreadyHasClassScope)
489 Actions.ActOnStartDelayedMemberDeclarations(getCurScope(),
490 Class.TagOrTemplate);
491
Benjamin Kramer1d373c62012-05-17 12:01:52 +0000492 if (!Class.LateParsedDeclarations.empty()) {
Douglas Gregor3024f072012-04-16 07:05:22 +0000493 // C++11 [expr.prim.general]p4:
494 // Otherwise, if a member-declarator declares a non-static data member
495 // (9.2) of a class X, the expression this is a prvalue of type "pointer
496 // to X" within the optional brace-or-equal-initializer. It shall not
497 // appear elsewhere in the member-declarator.
498 Sema::CXXThisScopeRAII ThisScope(Actions, Class.TagOrTemplate,
499 /*TypeQuals=*/(unsigned)0);
Richard Smith938f40b2011-06-11 17:19:42 +0000500
Douglas Gregor3024f072012-04-16 07:05:22 +0000501 for (size_t i = 0; i < Class.LateParsedDeclarations.size(); ++i) {
502 Class.LateParsedDeclarations[i]->ParseLexedMemberInitializers();
503 }
504 }
505
Richard Smith938f40b2011-06-11 17:19:42 +0000506 if (!AlreadyHasClassScope)
507 Actions.ActOnFinishDelayedMemberDeclarations(getCurScope(),
508 Class.TagOrTemplate);
509
510 Actions.ActOnFinishDelayedMemberInitializers(Class.TagOrTemplate);
511}
512
513void Parser::ParseLexedMemberInitializer(LateParsedMemberInitializer &MI) {
Richard Smith1a526fd2011-09-29 19:42:27 +0000514 if (!MI.Field || MI.Field->isInvalidDecl())
Richard Smith938f40b2011-06-11 17:19:42 +0000515 return;
516
517 // Append the current token at the end of the new token stream so that it
518 // doesn't get lost.
519 MI.Toks.push_back(Tok);
520 PP.EnterTokenStream(MI.Toks.data(), MI.Toks.size(), true, false);
521
522 // Consume the previously pushed token.
Argyrios Kyrtzidisc36633c2013-03-27 23:58:17 +0000523 ConsumeAnyToken(/*ConsumeCodeCompletionTok=*/true);
Richard Smith938f40b2011-06-11 17:19:42 +0000524
525 SourceLocation EqualLoc;
Richard Smith2b013182012-06-10 03:12:00 +0000526
Douglas Gregor926410d2012-02-21 02:22:07 +0000527 ExprResult Init = ParseCXXMemberInitializer(MI.Field, /*IsFunction=*/false,
528 EqualLoc);
Richard Smith938f40b2011-06-11 17:19:42 +0000529
530 Actions.ActOnCXXInClassMemberInitializer(MI.Field, EqualLoc, Init.release());
531
532 // The next token should be our artificial terminating EOF token.
533 if (Tok.isNot(tok::eof)) {
534 SourceLocation EndLoc = PP.getLocForEndOfToken(PrevTokLocation);
535 if (!EndLoc.isValid())
536 EndLoc = Tok.getLocation();
537 // No fixit; we can't recover as if there were a semicolon here.
538 Diag(EndLoc, diag::err_expected_semi_decl_list);
539
540 // Consume tokens until we hit the artificial EOF.
541 while (Tok.isNot(tok::eof))
542 ConsumeAnyToken();
543 }
544 ConsumeAnyToken();
545}
546
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000547/// ConsumeAndStoreUntil - Consume and store the token at the passed token
Douglas Gregor4d87df52008-12-16 21:30:33 +0000548/// container until the token 'T' is reached (which gets
Mike Stump11289f42009-09-09 15:08:12 +0000549/// consumed/stored too, if ConsumeFinalToken).
Argyrios Kyrtzidis8d7bdba2010-04-23 21:20:12 +0000550/// If StopAtSemi is true, then we will stop early at a ';' character.
Douglas Gregor4d87df52008-12-16 21:30:33 +0000551/// Returns true if token 'T1' or 'T2' was found.
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000552/// NOTE: This is a specialized version of Parser::SkipUntil.
Douglas Gregor4d87df52008-12-16 21:30:33 +0000553bool Parser::ConsumeAndStoreUntil(tok::TokenKind T1, tok::TokenKind T2,
554 CachedTokens &Toks,
Argyrios Kyrtzidis8d7bdba2010-04-23 21:20:12 +0000555 bool StopAtSemi, bool ConsumeFinalToken) {
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000556 // We always want this function to consume at least one token if the first
557 // token isn't T and if not at EOF.
558 bool isFirstTokenConsumed = true;
559 while (1) {
560 // If we found one of the tokens, stop and return true.
Douglas Gregor4d87df52008-12-16 21:30:33 +0000561 if (Tok.is(T1) || Tok.is(T2)) {
562 if (ConsumeFinalToken) {
563 Toks.push_back(Tok);
564 ConsumeAnyToken();
565 }
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000566 return true;
567 }
568
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000569 switch (Tok.getKind()) {
570 case tok::eof:
571 // Ran out of tokens.
572 return false;
573
574 case tok::l_paren:
575 // Recursively consume properly-nested parens.
576 Toks.push_back(Tok);
577 ConsumeParen();
Argyrios Kyrtzidis8d7bdba2010-04-23 21:20:12 +0000578 ConsumeAndStoreUntil(tok::r_paren, Toks, /*StopAtSemi=*/false);
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000579 break;
580 case tok::l_square:
581 // Recursively consume properly-nested square brackets.
582 Toks.push_back(Tok);
583 ConsumeBracket();
Argyrios Kyrtzidis8d7bdba2010-04-23 21:20:12 +0000584 ConsumeAndStoreUntil(tok::r_square, Toks, /*StopAtSemi=*/false);
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000585 break;
586 case tok::l_brace:
587 // Recursively consume properly-nested braces.
588 Toks.push_back(Tok);
589 ConsumeBrace();
Argyrios Kyrtzidis8d7bdba2010-04-23 21:20:12 +0000590 ConsumeAndStoreUntil(tok::r_brace, Toks, /*StopAtSemi=*/false);
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000591 break;
592
593 // Okay, we found a ']' or '}' or ')', which we think should be balanced.
594 // Since the user wasn't looking for this token (if they were, it would
595 // already be handled), this isn't balanced. If there is a LHS token at a
596 // higher level, we will assume that this matches the unbalanced token
597 // and return it. Otherwise, this is a spurious RHS token, which we skip.
598 case tok::r_paren:
599 if (ParenCount && !isFirstTokenConsumed)
600 return false; // Matches something.
601 Toks.push_back(Tok);
602 ConsumeParen();
603 break;
604 case tok::r_square:
605 if (BracketCount && !isFirstTokenConsumed)
606 return false; // Matches something.
607 Toks.push_back(Tok);
608 ConsumeBracket();
609 break;
610 case tok::r_brace:
611 if (BraceCount && !isFirstTokenConsumed)
612 return false; // Matches something.
613 Toks.push_back(Tok);
614 ConsumeBrace();
615 break;
616
Argyrios Kyrtzidis5cec2ae2011-09-04 03:32:15 +0000617 case tok::code_completion:
618 Toks.push_back(Tok);
619 ConsumeCodeCompletionToken();
620 break;
621
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000622 case tok::string_literal:
623 case tok::wide_string_literal:
Douglas Gregorfb65e592011-07-27 05:40:30 +0000624 case tok::utf8_string_literal:
625 case tok::utf16_string_literal:
626 case tok::utf32_string_literal:
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000627 Toks.push_back(Tok);
628 ConsumeStringToken();
629 break;
Argyrios Kyrtzidis8d7bdba2010-04-23 21:20:12 +0000630 case tok::semi:
631 if (StopAtSemi)
632 return false;
633 // FALL THROUGH.
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000634 default:
635 // consume this token.
636 Toks.push_back(Tok);
637 ConsumeToken();
638 break;
639 }
640 isFirstTokenConsumed = false;
641 }
642}
Sebastian Redla74948d2011-09-24 17:48:25 +0000643
644/// \brief Consume tokens and store them in the passed token container until
645/// we've passed the try keyword and constructor initializers and have consumed
Sebastian Redl0d164012011-09-30 08:32:17 +0000646/// the opening brace of the function body. The opening brace will be consumed
647/// if and only if there was no error.
Sebastian Redla74948d2011-09-24 17:48:25 +0000648///
Richard Smithcde3fd82013-07-04 00:13:48 +0000649/// \return True on error.
Sebastian Redl0d164012011-09-30 08:32:17 +0000650bool Parser::ConsumeAndStoreFunctionPrologue(CachedTokens &Toks) {
Sebastian Redla74948d2011-09-24 17:48:25 +0000651 if (Tok.is(tok::kw_try)) {
652 Toks.push_back(Tok);
653 ConsumeToken();
654 }
Richard Smithcde3fd82013-07-04 00:13:48 +0000655
656 if (Tok.isNot(tok::colon)) {
657 // Easy case, just a function body.
658
659 // Grab any remaining garbage to be diagnosed later. We stop when we reach a
660 // brace: an opening one is the function body, while a closing one probably
661 // means we've reached the end of the class.
662 ConsumeAndStoreUntil(tok::l_brace, tok::r_brace, Toks,
663 /*StopAtSemi=*/true,
664 /*ConsumeFinalToken=*/false);
665 if (Tok.isNot(tok::l_brace))
666 return Diag(Tok.getLocation(), diag::err_expected_lbrace);
667
Sebastian Redla74948d2011-09-24 17:48:25 +0000668 Toks.push_back(Tok);
Richard Smithcde3fd82013-07-04 00:13:48 +0000669 ConsumeBrace();
670 return false;
Eli Friedman7cd4a9b2012-02-22 04:49:04 +0000671 }
Sebastian Redl0d164012011-09-30 08:32:17 +0000672
673 Toks.push_back(Tok);
Richard Smithcde3fd82013-07-04 00:13:48 +0000674 ConsumeToken();
675
676 // We can't reliably skip over a mem-initializer-id, because it could be
677 // a template-id involving not-yet-declared names. Given:
678 //
679 // S ( ) : a < b < c > ( e )
680 //
681 // 'e' might be an initializer or part of a template argument, depending
682 // on whether 'b' is a template.
683
684 // Track whether we might be inside a template argument. We can give
685 // significantly better diagnostics if we know that we're not.
686 bool MightBeTemplateArgument = false;
687
688 while (true) {
689 // Skip over the mem-initializer-id, if possible.
690 if (Tok.is(tok::kw_decltype)) {
691 Toks.push_back(Tok);
692 SourceLocation OpenLoc = ConsumeToken();
693 if (Tok.isNot(tok::l_paren))
694 return Diag(Tok.getLocation(), diag::err_expected_lparen_after)
695 << "decltype";
696 Toks.push_back(Tok);
697 ConsumeParen();
698 if (!ConsumeAndStoreUntil(tok::r_paren, Toks, /*StopAtSemi=*/true)) {
699 Diag(Tok.getLocation(), diag::err_expected_rparen);
700 Diag(OpenLoc, diag::note_matching) << "(";
701 return true;
702 }
703 }
704 do {
705 // Walk over a component of a nested-name-specifier.
706 if (Tok.is(tok::coloncolon)) {
707 Toks.push_back(Tok);
708 ConsumeToken();
709
710 if (Tok.is(tok::kw_template)) {
711 Toks.push_back(Tok);
712 ConsumeToken();
713 }
714 }
715
716 if (Tok.is(tok::identifier) || Tok.is(tok::kw_template)) {
717 Toks.push_back(Tok);
718 ConsumeToken();
719 } else if (Tok.is(tok::code_completion)) {
720 Toks.push_back(Tok);
721 ConsumeCodeCompletionToken();
722 // Consume the rest of the initializers permissively.
723 // FIXME: We should be able to perform code-completion here even if
724 // there isn't a subsequent '{' token.
725 MightBeTemplateArgument = true;
726 break;
727 } else {
728 break;
729 }
730 } while (Tok.is(tok::coloncolon));
731
732 if (Tok.is(tok::less))
733 MightBeTemplateArgument = true;
734
735 if (MightBeTemplateArgument) {
736 // We may be inside a template argument list. Grab up to the start of the
737 // next parenthesized initializer or braced-init-list. This *might* be the
738 // initializer, or it might be a subexpression in the template argument
739 // list.
740 // FIXME: Count angle brackets, and clear MightBeTemplateArgument
741 // if all angles are closed.
742 if (!ConsumeAndStoreUntil(tok::l_paren, tok::l_brace, Toks,
743 /*StopAtSemi=*/true,
744 /*ConsumeFinalToken=*/false)) {
745 // We're not just missing the initializer, we're also missing the
746 // function body!
747 return Diag(Tok.getLocation(), diag::err_expected_lbrace);
748 }
749 } else if (Tok.isNot(tok::l_paren) && Tok.isNot(tok::l_brace)) {
750 // We found something weird in a mem-initializer-id.
751 return Diag(Tok.getLocation(), getLangOpts().CPlusPlus11
752 ? diag::err_expected_lparen_or_lbrace
753 : diag::err_expected_lparen);
754 }
755
756 tok::TokenKind kind = Tok.getKind();
757 Toks.push_back(Tok);
758 bool IsLParen = (kind == tok::l_paren);
759 SourceLocation OpenLoc = Tok.getLocation();
760
761 if (IsLParen) {
762 ConsumeParen();
763 } else {
764 assert(kind == tok::l_brace && "Must be left paren or brace here.");
765 ConsumeBrace();
766 // In C++03, this has to be the start of the function body, which
767 // means the initializer is malformed; we'll diagnose it later.
768 if (!getLangOpts().CPlusPlus11)
769 return false;
770 }
771
772 // Grab the initializer (or the subexpression of the template argument).
773 // FIXME: If we support lambdas here, we'll need to set StopAtSemi to false
774 // if we might be inside the braces of a lambda-expression.
775 if (!ConsumeAndStoreUntil(IsLParen ? tok::r_paren : tok::r_brace,
776 Toks, /*StopAtSemi=*/true)) {
777 Diag(Tok, IsLParen ? diag::err_expected_rparen :
778 diag::err_expected_rbrace);
779 Diag(OpenLoc, diag::note_matching) << (IsLParen ? "(" : "{");
780 return true;
781 }
782
783 // Grab pack ellipsis, if present.
784 if (Tok.is(tok::ellipsis)) {
785 Toks.push_back(Tok);
786 ConsumeToken();
787 }
788
789 // If we know we just consumed a mem-initializer, we must have ',' or '{'
790 // next.
791 if (Tok.is(tok::comma)) {
792 Toks.push_back(Tok);
793 ConsumeToken();
794 } else if (Tok.is(tok::l_brace)) {
795 // This is the function body if the ')' or '}' is immediately followed by
796 // a '{'. That cannot happen within a template argument, apart from the
797 // case where a template argument contains a compound literal:
798 //
799 // S ( ) : a < b < c > ( d ) { }
800 // // End of declaration, or still inside the template argument?
801 //
802 // ... and the case where the template argument contains a lambda:
803 //
804 // S ( ) : a < 0 && b < c > ( d ) + [ ] ( ) { return 0; }
805 // ( ) > ( ) { }
806 //
807 // FIXME: Disambiguate these cases. Note that the latter case is probably
808 // going to be made ill-formed by core issue 1607.
809 Toks.push_back(Tok);
810 ConsumeBrace();
811 return false;
812 } else if (!MightBeTemplateArgument) {
813 return Diag(Tok.getLocation(), diag::err_expected_lbrace_or_comma);
814 }
815 }
Sebastian Redla74948d2011-09-24 17:48:25 +0000816}