summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTReaderDecl.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-03-10 02:00:53 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-03-10 02:00:53 +0000
commit80969754b73ceeeb350354eb97a67027c21862b6 (patch)
treea685594a551a36df0dea0de6ca546c4b0835568b /clang/lib/Serialization/ASTReaderDecl.cpp
parent4eab4bc23c2b5582b3754421d045eeef1bce0016 (diff)
downloadbcm5719-llvm-80969754b73ceeeb350354eb97a67027c21862b6.tar.gz
bcm5719-llvm-80969754b73ceeeb350354eb97a67027c21862b6.zip
PR21687: when adding a redeclaration of a function with an implicit exception
specification, update all prior declarations if the new one has an explicit exception specification and the prior ones don't. Patch by Vassil Vassilev! Some minor tweaking and test case by me. llvm-svn: 231738
Diffstat (limited to 'clang/lib/Serialization/ASTReaderDecl.cpp')
-rw-r--r--clang/lib/Serialization/ASTReaderDecl.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index 2a01d853c7c..9a382c1659d 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -2833,14 +2833,23 @@ void ASTDeclReader::attachPreviousDeclImpl(ASTReader &Reader,
// If this declaration has an unresolved exception specification but the
// previous declaration had a resolved one, resolve the exception
- // specification now.
+ // specification now. If this declaration has a resolved exception
+ // specification but the previous declarations did not, apply our exception
+ // specification to all prior ones now.
auto *FPT = FD->getType()->getAs<FunctionProtoType>();
auto *PrevFPT = PrevFD->getType()->getAs<FunctionProtoType>();
- if (FPT && PrevFPT &&
- isUnresolvedExceptionSpec(FPT->getExceptionSpecType()) &&
- !isUnresolvedExceptionSpec(PrevFPT->getExceptionSpecType())) {
- Reader.Context.adjustExceptionSpec(
- FD, PrevFPT->getExtProtoInfo().ExceptionSpec);
+ if (FPT && PrevFPT) {
+ bool WasUnresolved = isUnresolvedExceptionSpec(FPT->getExceptionSpecType());
+ bool IsUnresolved = isUnresolvedExceptionSpec(PrevFPT->getExceptionSpecType());
+ if (WasUnresolved && !IsUnresolved) {
+ Reader.Context.adjustExceptionSpec(
+ FD, PrevFPT->getExtProtoInfo().ExceptionSpec);
+ } else if (!WasUnresolved && IsUnresolved) {
+ FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
+ for (FunctionDecl *PrevFDToUpdate = PrevFD; PrevFDToUpdate;
+ PrevFDToUpdate = PrevFDToUpdate->getPreviousDecl())
+ Reader.Context.adjustExceptionSpec(PrevFDToUpdate, EPI.ExceptionSpec);
+ }
}
}
}
OpenPOWER on IntegriCloud