summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-04-16 18:27:27 +0000
committerDouglas Gregor <dgregor@apple.com>2012-04-16 18:27:27 +0000
commit433e05306fa0217598535211103641221b9021ce (patch)
tree3529a26e1b3685172e00a8aabb16dc5d4543d998 /clang/lib/Sema/SemaDecl.cpp
parent505a7c818d9686f8044ce83c6de9e8c234af9f98 (diff)
downloadbcm5719-llvm-433e05306fa0217598535211103641221b9021ce.tar.gz
bcm5719-llvm-433e05306fa0217598535211103641221b9021ce.zip
Implement the last part of C++ [class.mem]p2, delaying the parsing of
exception specifications on member functions until after the closing '}' for the containing class. This allows, for example, a member function to throw an instance of its own class. Fixes PR12564 and a fairly embarassing oversight in our C++98/03 support. llvm-svn: 154844
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 1d4745dcaa6..c7bd72b03e9 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -4471,6 +4471,11 @@ static bool FindOverriddenMethod(const CXXBaseSpecifier *Specifier,
return false;
}
+static bool hasDelayedExceptionSpec(CXXMethodDecl *Method) {
+ const FunctionProtoType *Proto =Method->getType()->getAs<FunctionProtoType>();
+ return Proto && Proto->getExceptionSpecType() == EST_Delayed;
+}
+
/// AddOverriddenMethods - See if a method overrides any in the base classes,
/// and if so, check that it's a valid override and remember it.
bool Sema::AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD) {
@@ -4486,7 +4491,8 @@ bool Sema::AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD) {
if (CXXMethodDecl *OldMD = dyn_cast<CXXMethodDecl>(*I)) {
MD->addOverriddenMethod(OldMD->getCanonicalDecl());
if (!CheckOverridingFunctionReturnType(MD, OldMD) &&
- !CheckOverridingFunctionExceptionSpec(MD, OldMD) &&
+ (hasDelayedExceptionSpec(MD) ||
+ !CheckOverridingFunctionExceptionSpec(MD, OldMD)) &&
!CheckIfOverriddenFunctionIsMarkedFinal(MD, OldMD)) {
AddedAny = true;
}
@@ -7626,7 +7632,7 @@ NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc,
SourceLocation(), SourceLocation(),
SourceLocation(),
EST_None, SourceLocation(),
- 0, 0, 0, 0, Loc, Loc, D),
+ 0, 0, 0, 0, 0, Loc, Loc, D),
DS.getAttributes(),
SourceLocation());
D.SetIdentifier(&II, Loc);
OpenPOWER on IntegriCloud