diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-12-10 18:13:52 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-12-10 18:13:52 +0000 |
commit | 0966f358989e2f3900d3a4efaca4c14250f2777b (patch) | |
tree | 0a61aba30b45dd3e46ab11c31dfb405485b920c0 /lib/Sema/SemaExceptionSpec.cpp | |
parent | d87b61f6398bab21176f73818a8d11ca1c3632c8 (diff) |
Implement C++ DR437, which involves exception-specifications that name
a type currently being defined, from Nicola Gigante!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91052 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExceptionSpec.cpp')
-rw-r--r-- | lib/Sema/SemaExceptionSpec.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/Sema/SemaExceptionSpec.cpp b/lib/Sema/SemaExceptionSpec.cpp index 25af0528d8..7e2a98d0bf 100644 --- a/lib/Sema/SemaExceptionSpec.cpp +++ b/lib/Sema/SemaExceptionSpec.cpp @@ -35,10 +35,15 @@ static const FunctionProtoType *GetUnderlyingFunction(QualType T) /// exception specification. Incomplete types, or pointers to incomplete types /// other than void are not allowed. bool Sema::CheckSpecifiedExceptionType(QualType T, const SourceRange &Range) { - // FIXME: This may not correctly work with the fix for core issue 437, - // where a class's own type is considered complete within its body. But - // perhaps RequireCompleteType itself should contain this logic? + // This check (and the similar one below) deals with issue 437, that changes + // C++ 9.2p2 this way: + // Within the class member-specification, the class is regarded as complete + // within function bodies, default arguments, exception-specifications, and + // constructor ctor-initializers (including such things in nested classes). + if (T->isRecordType() && T->getAs<RecordType>()->isBeingDefined()) + return false; + // C++ 15.4p2: A type denoted in an exception-specification shall not denote // an incomplete type. if (RequireCompleteType(Range.getBegin(), T, @@ -58,8 +63,12 @@ bool Sema::CheckSpecifiedExceptionType(QualType T, const SourceRange &Range) { } else return false; + // Again as before + if (T->isRecordType() && T->getAs<RecordType>()->isBeingDefined()) + return false; + if (!T->isVoidType() && RequireCompleteType(Range.getBegin(), T, - PDiag(diag::err_incomplete_in_exception_spec) << /*direct*/kind << Range)) + PDiag(diag::err_incomplete_in_exception_spec) << kind << Range)) return true; return false; |