ParseDecl.cpp (206084) | ParseDecl.cpp (206275) |
---|---|
1//===--- ParseDecl.cpp - Declaration 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//===----------------------------------------------------------------------===// --- 320 unchanged lines hidden (view full) --- 329 break; 330 case tok::kw_static_assert: 331 if (Attr.HasAttr) 332 Diag(Attr.Range.getBegin(), diag::err_attributes_not_allowed) 333 << Attr.Range; 334 SingleDecl = ParseStaticAssertDeclaration(DeclEnd); 335 break; 336 default: | 1//===--- ParseDecl.cpp - Declaration 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//===----------------------------------------------------------------------===// --- 320 unchanged lines hidden (view full) --- 329 break; 330 case tok::kw_static_assert: 331 if (Attr.HasAttr) 332 Diag(Attr.Range.getBegin(), diag::err_attributes_not_allowed) 333 << Attr.Range; 334 SingleDecl = ParseStaticAssertDeclaration(DeclEnd); 335 break; 336 default: |
337 return ParseSimpleDeclaration(Context, DeclEnd, Attr.AttrList); | 337 return ParseSimpleDeclaration(Context, DeclEnd, Attr.AttrList, true); |
338 } 339 340 // This routine returns a DeclGroup, if the thing we parsed only contains a 341 // single decl, convert it now. 342 return Actions.ConvertDeclToDeclGroup(SingleDecl); 343} 344 345/// simple-declaration: [C99 6.7: declaration] [C++ 7p1: dcl.dcl] 346/// declaration-specifiers init-declarator-list[opt] ';' 347///[C90/C++]init-declarator-list ';' [TODO] 348/// [OMP] threadprivate-directive [TODO] 349/// 350/// If RequireSemi is false, this does not check for a ';' at the end of the | 338 } 339 340 // This routine returns a DeclGroup, if the thing we parsed only contains a 341 // single decl, convert it now. 342 return Actions.ConvertDeclToDeclGroup(SingleDecl); 343} 344 345/// simple-declaration: [C99 6.7: declaration] [C++ 7p1: dcl.dcl] 346/// declaration-specifiers init-declarator-list[opt] ';' 347///[C90/C++]init-declarator-list ';' [TODO] 348/// [OMP] threadprivate-directive [TODO] 349/// 350/// If RequireSemi is false, this does not check for a ';' at the end of the |
351/// declaration. | 351/// declaration. If it is true, it checks for and eats it. |
352Parser::DeclGroupPtrTy Parser::ParseSimpleDeclaration(unsigned Context, 353 SourceLocation &DeclEnd, | 352Parser::DeclGroupPtrTy Parser::ParseSimpleDeclaration(unsigned Context, 353 SourceLocation &DeclEnd, |
354 AttributeList *Attr) { | 354 AttributeList *Attr, 355 bool RequireSemi) { |
355 // Parse the common declaration-specifiers piece. 356 ParsingDeclSpec DS(*this); 357 if (Attr) 358 DS.AddAttributes(Attr); 359 ParseDeclarationSpecifiers(DS, ParsedTemplateInfo(), AS_none, 360 getDeclSpecContextFromDeclaratorContext(Context)); 361 362 // C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };" 363 // declaration-specifiers init-declarator-list[opt] ';' 364 if (Tok.is(tok::semi)) { | 356 // Parse the common declaration-specifiers piece. 357 ParsingDeclSpec DS(*this); 358 if (Attr) 359 DS.AddAttributes(Attr); 360 ParseDeclarationSpecifiers(DS, ParsedTemplateInfo(), AS_none, 361 getDeclSpecContextFromDeclaratorContext(Context)); 362 363 // C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };" 364 // declaration-specifiers init-declarator-list[opt] ';' 365 if (Tok.is(tok::semi)) { |
365 ConsumeToken(); | 366 if (RequireSemi) ConsumeToken(); |
366 DeclPtrTy TheDecl = Actions.ParsedFreeStandingDeclSpec(CurScope, DS); 367 DS.complete(TheDecl); 368 return Actions.ConvertDeclToDeclGroup(TheDecl); 369 } 370 | 367 DeclPtrTy TheDecl = Actions.ParsedFreeStandingDeclSpec(CurScope, DS); 368 DS.complete(TheDecl); 369 return Actions.ConvertDeclToDeclGroup(TheDecl); 370 } 371 |
371 DeclGroupPtrTy DG = ParseDeclGroup(DS, Context, /*FunctionDefs=*/ false, 372 &DeclEnd); 373 return DG; | 372 return ParseDeclGroup(DS, Context, /*FunctionDefs=*/ false, &DeclEnd); |
374} 375 376/// ParseDeclGroup - Having concluded that this is either a function 377/// definition or a group of object declarations, actually parse the 378/// result. 379Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS, 380 unsigned Context, 381 bool AllowFunctionDefinitions, --- 612 unchanged lines hidden (view full) --- 994 } 995 996 case tok::annot_typename: { 997 if (Tok.getAnnotationValue()) 998 isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec, 999 DiagID, Tok.getAnnotationValue()); 1000 else 1001 DS.SetTypeSpecError(); | 373} 374 375/// ParseDeclGroup - Having concluded that this is either a function 376/// definition or a group of object declarations, actually parse the 377/// result. 378Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS, 379 unsigned Context, 380 bool AllowFunctionDefinitions, --- 612 unchanged lines hidden (view full) --- 993 } 994 995 case tok::annot_typename: { 996 if (Tok.getAnnotationValue()) 997 isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec, 998 DiagID, Tok.getAnnotationValue()); 999 else 1000 DS.SetTypeSpecError(); |
1001 1002 if (isInvalid) 1003 break; 1004 |
|
1002 DS.SetRangeEnd(Tok.getAnnotationEndLoc()); 1003 ConsumeToken(); // The typename 1004 1005 // Objective-C supports syntax of the form 'id<proto1,proto2>' where 'id' 1006 // is a specific typedef and 'itf<proto1,proto2>' where 'itf' is an 1007 // Objective-C interface. If we don't have Objective-C or a '<', this is 1008 // just a normal reference to a typedef name. 1009 if (!Tok.is(tok::less) || !getLang().ObjC1) --- 2374 unchanged lines hidden --- | 1005 DS.SetRangeEnd(Tok.getAnnotationEndLoc()); 1006 ConsumeToken(); // The typename 1007 1008 // Objective-C supports syntax of the form 'id<proto1,proto2>' where 'id' 1009 // is a specific typedef and 'itf<proto1,proto2>' where 'itf' is an 1010 // Objective-C interface. If we don't have Objective-C or a '<', this is 1011 // just a normal reference to a typedef name. 1012 if (!Tok.is(tok::less) || !getLang().ObjC1) --- 2374 unchanged lines hidden --- |