[cfe-commits] r91052 - in /cfe/trunk: lib/Sema/SemaExceptionSpec.cpp test/SemaCXX/exception-spec.cpp
Douglas Gregor
dgregor at apple.com
Thu Dec 10 10:13:53 PST 2009
Author: dgregor
Date: Thu Dec 10 12:13:52 2009
New Revision: 91052
URL: http://llvm.org/viewvc/llvm-project?rev=91052&view=rev
Log:
Implement C++ DR437, which involves exception-specifications that name
a type currently being defined, from Nicola Gigante!
Modified:
cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
cfe/trunk/test/SemaCXX/exception-spec.cpp
Modified: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExceptionSpec.cpp?rev=91052&r1=91051&r2=91052&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExceptionSpec.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExceptionSpec.cpp Thu Dec 10 12:13:52 2009
@@ -35,10 +35,15 @@
/// 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 @@
} 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;
Modified: cfe/trunk/test/SemaCXX/exception-spec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/exception-spec.cpp?rev=91052&r1=91051&r2=91052&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/exception-spec.cpp (original)
+++ cfe/trunk/test/SemaCXX/exception-spec.cpp Thu Dec 10 12:13:52 2009
@@ -186,5 +186,18 @@
void tf() throw(TEx<int>); // expected-error {{implicit instantiation of undefined template}}
-// DR 437, class throws itself. FIXME: See Sema::CheckSpecifiedExceptionType.
-//struct DR437 { void f() throw(DR437); };
+// DR 437, class throws itself.
+struct DR437 {
+ void f() throw(DR437);
+ void g() throw(DR437*);
+ void h() throw(DR437&);
+};
+
+// DR 437 within a nested class
+struct DR437_out {
+ struct DR437_in {
+ void f() throw(DR437_out);
+ void g() throw(DR437_out*);
+ void h() throw(DR437_out&);
+ };
+};
More information about the cfe-commits
mailing list