summaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExceptionSpec.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-02-07 22:51:16 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-02-07 22:51:16 +0000
commitb7142cbc08de0d7df55b64ead799ad7029967e0d (patch)
tree84da3a769da4febbbde301255f4313f9a9f41ede /lib/Sema/SemaExceptionSpec.cpp
parent17ef7ef24312fca79980f0db621886ebd9e77dfa (diff)
downloadclang-b7142cbc08de0d7df55b64ead799ad7029967e0d.tar.gz
PR16638, DR1552: the exception specification on an implicitly-declared
'operator delete' or 'operator delete[]' is an explicit exception specification. Therefore we should diagnose 'void operator delete(void*)' instead of 'void operator delete(void*) noexcept'. This diagnostic remains an ExtWarn, since in practice people don't always include the exception specification in such a declaration. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201002 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExceptionSpec.cpp')
-rw-r--r--lib/Sema/SemaExceptionSpec.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Sema/SemaExceptionSpec.cpp b/lib/Sema/SemaExceptionSpec.cpp
index 2eee07c0af..1c2a8dbc30 100644
--- a/lib/Sema/SemaExceptionSpec.cpp
+++ b/lib/Sema/SemaExceptionSpec.cpp
@@ -140,10 +140,13 @@ static bool hasImplicitExceptionSpec(FunctionDecl *Decl) {
Decl->getDeclName().getCXXOverloadedOperator() != OO_Array_Delete)
return false;
- // If the user didn't declare the function, its exception specification must
- // be implicit.
+ // For a function that the user didn't declare:
+ // - if this is a destructor, its exception specification is implicit.
+ // - if this is 'operator delete' or 'operator delete[]', the exception
+ // specification is as-if an explicit exception specification was given
+ // (per [basic.stc.dynamic]p2).
if (!Decl->getTypeSourceInfo())
- return true;
+ return isa<CXXDestructorDecl>(Decl);
const FunctionProtoType *Ty =
Decl->getTypeSourceInfo()->getType()->getAs<FunctionProtoType>();