diff options
author | DeLesley Hutchins <delesley@google.com> | 2012-02-16 16:50:43 +0000 |
---|---|---|
committer | DeLesley Hutchins <delesley@google.com> | 2012-02-16 16:50:43 +0000 |
commit | 3fc6e4a7cda90e816cb8213bea927c9067cb6424 (patch) | |
tree | 38059a0c42e6faa08b340afa04f2f015c5ab052f /clang/lib/Parse/Parser.cpp | |
parent | 9bc9bcc2472373ab81a2106e5a04fc6037e19fcc (diff) | |
download | bcm5719-llvm-3fc6e4a7cda90e816cb8213bea927c9067cb6424.tar.gz bcm5719-llvm-3fc6e4a7cda90e816cb8213bea927c9067cb6424.zip |
Allow thread safety attributes on function definitions.
For compatibility with gcc, clang will now parse gcc attributes on
function definitions, but issue a warning if the attribute is not a
thread safety attribute. Warning controlled by -Wgcc-compat.
llvm-svn: 150698
Diffstat (limited to 'clang/lib/Parse/Parser.cpp')
-rw-r--r-- | clang/lib/Parse/Parser.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index 4d8f474514d..c7974369484 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -821,7 +821,8 @@ Parser::ParseDeclarationOrFunctionDefinition(ParsedAttributes &attrs, /// decl-specifier-seq[opt] declarator function-try-block /// Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D, - const ParsedTemplateInfo &TemplateInfo) { + const ParsedTemplateInfo &TemplateInfo, + LateParsedAttrList *LateParsedAttrs) { // Poison the SEH identifiers so they are flagged as illegal in function bodies PoisonSEHIdentifiersRAIIObject PoisonSEHIdentifiers(*this, true); const DeclaratorChunk::FunctionTypeInfo &FTI = D.getFunctionTypeInfo(); @@ -844,7 +845,6 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D, if (FTI.isKNRPrototype()) ParseKNRParamDeclarations(D); - // We should have either an opening brace or, in a C++ constructor, // we may have a colon. if (Tok.isNot(tok::l_brace) && @@ -861,6 +861,19 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D, return 0; } + // Check to make sure that any normal attributes are allowed to be on + // a definition. Late parsed attributes are checked at the end. + if (Tok.isNot(tok::equal)) { + AttributeList *DtorAttrs = D.getAttributes(); + while (DtorAttrs) { + if (!IsThreadSafetyAttribute(DtorAttrs->getName()->getName())) { + Diag(DtorAttrs->getLoc(), diag::warn_attribute_on_function_definition) + << DtorAttrs->getName()->getName(); + } + DtorAttrs = DtorAttrs->getNext(); + } + } + // In delayed template parsing mode, for function template we consume the // tokens and store them for late parsing at the end of the translation unit. if (getLang().DelayedTemplateParsing && @@ -974,6 +987,10 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D, } else Actions.ActOnDefaultCtorInitializers(Res); + // Late attributes are parsed in the same scope as the function body. + if (LateParsedAttrs) + ParseLexedAttributeList(*LateParsedAttrs, Res, false, true); + return ParseFunctionStatementBody(Res, BodyScope); } |