summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-01-30 05:45:05 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-01-30 05:45:05 +0000
commitdebc59d1f360b1f7a041de72c02d76ed131370c6 (patch)
tree6693132ec1fd52975e19332db23028b63f75fa4b /clang/lib/Sema/SemaDecl.cpp
parent457a77739b7c297f40d0e712e8c5ff6cda2aac0f (diff)
downloadbcm5719-llvm-debc59d1f360b1f7a041de72c02d76ed131370c6.tar.gz
bcm5719-llvm-debc59d1f360b1f7a041de72c02d76ed131370c6.zip
Semantic analysis and CodeGen support for C11's _Noreturn. This is modeled as
an attribute for consistency with our other noreturn mechanisms. llvm-svn: 173898
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 2c09c88b201..c94bf5f092f 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1900,6 +1900,11 @@ static void checkNewAttributesAfterDef(Sema &S, Decl *New, const Decl *Old) {
++I;
continue; // regular attr merging will take care of validating this.
}
+ // C's _Noreturn is allowed to be added to a function after it is defined.
+ if (isa<C11NoReturnAttr>(NewAttribute)) {
+ ++I;
+ continue;
+ }
S.Diag(NewAttribute->getLocation(),
diag::warn_attribute_precede_definition);
S.Diag(Def->getLocation(), diag::note_previous_definition);
@@ -5889,6 +5894,11 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
NewFD->setDeclsInPrototypeScope(DeclsInPrototypeScope);
DeclsInPrototypeScope.clear();
+ if (D.getDeclSpec().isNoreturnSpecified())
+ NewFD->addAttr(
+ ::new(Context) C11NoReturnAttr(D.getDeclSpec().getNoreturnSpecLoc(),
+ Context));
+
// Process the non-inheritable attributes on this declaration.
ProcessDeclAttributes(S, NewFD, D,
/*NonInheritable=*/true, /*Inheritable=*/false);
OpenPOWER on IntegriCloud