forked from OSchip/llvm-project
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
This commit is contained in:
parent
4eab4bc23c
commit
80969754b7
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
struct X { X(); virtual ~X(); };
|
|
@ -0,0 +1,2 @@
|
|||
#include "a.h"
|
||||
X *n = new X;
|
|
@ -0,0 +1,4 @@
|
|||
#include "a.h"
|
||||
inline void f() { X x, y(x); }
|
||||
#include "b.h"
|
||||
X x, y(x);
|
|
@ -0,0 +1,3 @@
|
|||
module a { header "a.h" export * }
|
||||
module b { header "b.h" export * }
|
||||
module c { header "c.h" export * }
|
|
@ -0,0 +1,3 @@
|
|||
// RUN: rm -rf %t
|
||||
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/PR21687 -emit-llvm-only %s
|
||||
#include "c.h"
|
Loading…
Reference in New Issue