summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-02-20 09:23:47 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-02-20 09:23:47 +0000
commit960813e1643ec788707bf18b0cdce4bb142d560a (patch)
tree2b288c4a0e9e8686841868ba4d58f22ec95a3dbe /clang/lib/Sema/SemaDecl.cpp
parentb880909ab5b98baa7d69cf84a8b5c82586c60df5 (diff)
downloadbcm5719-llvm-960813e1643ec788707bf18b0cdce4bb142d560a.tar.gz
bcm5719-llvm-960813e1643ec788707bf18b0cdce4bb142d560a.zip
[MSVC Compat] Implement -EHc semantics
The -EHc flag implicitly adds a nothrow attribute to any extern "C" function when exceptions are enabled. llvm-svn: 261425
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 62cd5c8e3db..a775be9ea25 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -11582,6 +11582,13 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) {
}
}
+ // If C++ exceptions are enabled but we are told extern "C" functions cannot
+ // throw, add an implicit nothrow attribute to any extern "C" function we come
+ // across.
+ if (getLangOpts().CXXExceptions && getLangOpts().ExternCNoUnwind &&
+ FD->isExternC() && !FD->hasAttr<NoThrowAttr>())
+ FD->addAttr(NoThrowAttr::CreateImplicit(Context, FD->getLocation()));
+
IdentifierInfo *Name = FD->getIdentifier();
if (!Name)
return;
OpenPOWER on IntegriCloud