summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 4a1bbde271d..f7fe506f4ae 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -11635,8 +11635,11 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) {
// 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()));
+ FD->isExternC() && !FD->hasAttr<NoThrowAttr>()) {
+ const auto *FPT = FD->getType()->getAs<FunctionProtoType>();
+ if (!FPT || FPT->getExceptionSpecType() == EST_None)
+ FD->addAttr(NoThrowAttr::CreateImplicit(Context, FD->getLocation()));
+ }
IdentifierInfo *Name = FD->getIdentifier();
if (!Name)
OpenPOWER on IntegriCloud