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 | 5b747a169e16e284af8310e4541a1c222f7484c9 (patch) | |
tree | 047d466514ac6840444747ad4e26a49f4c1a5133 /clang/lib/Sema/SemaExceptionSpec.cpp | |
parent | b5b60ea4f9b4f281d1cae41cfc6b0ea4ec2f643b (diff) | |
download | bcm5719-llvm-5b747a169e16e284af8310e4541a1c222f7484c9.tar.gz bcm5719-llvm-5b747a169e16e284af8310e4541a1c222f7484c9.zip |
Implement C++ DR437, which involves exception-specifications that name
a type currently being defined, from Nicola Gigante!
llvm-svn: 91052
Diffstat (limited to 'clang/lib/Sema/SemaExceptionSpec.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExceptionSpec.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaExceptionSpec.cpp b/clang/lib/Sema/SemaExceptionSpec.cpp index 25af0528d8b..7e2a98d0bf1 100644 --- a/clang/lib/Sema/SemaExceptionSpec.cpp +++ b/clang/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; |