]> granicus.if.org Git - clang/commitdiff
Implement C++ DR437, which involves exception-specifications that name
authorDouglas Gregor <dgregor@apple.com>
Thu, 10 Dec 2009 18:13:52 +0000 (18:13 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 10 Dec 2009 18:13:52 +0000 (18:13 +0000)
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

lib/Sema/SemaExceptionSpec.cpp
test/SemaCXX/exception-spec.cpp

index 25af0528d8b5fd8215cdd09079c0b65f687ad22f..7e2a98d0bf1fa380766462ad3ad1a1ffc70ac87d 100644 (file)
@@ -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;
index 56cc435f7db3aedca1c1cb170be137128eda67fc..efc983322ae5db192dfcabd6c74444566cc6644a 100644 (file)
@@ -186,5 +186,18 @@ template <typename T> struct TEx; // expected-note {{template is declared here}}
 
 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&);
+   }; 
+};