summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-02-29 01:40:36 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-02-29 01:40:36 +0000
commitcd5855e3549eebbf2a22d31b37f36d223c4c7b62 (patch)
tree2e2885e4d9f404f48923f7d0f87ded7ff0c4490a /clang/lib/Sema/SemaDecl.cpp
parent387fccd8dad1ab16f4d7332e8462b88bcbb2b26e (diff)
downloadbcm5719-llvm-cd5855e3549eebbf2a22d31b37f36d223c4c7b62.tar.gz
bcm5719-llvm-cd5855e3549eebbf2a22d31b37f36d223c4c7b62.zip
[clang-cl] /EHc should not effect functions with explicit exception specifications
Functions with an explicit exception specification have their behavior dictated by the specification. The additional /EHc behavior only comes into play if no exception specification is given. llvm-svn: 262198
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-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