[cfe-commits] r84099 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExceptionSpec.cpp test/SemaCXX/exception-spec.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Wed Oct 14 07:59:49 PDT 2009


Author: cornedbee
Date: Wed Oct 14 09:59:48 2009
New Revision: 84099

URL: http://llvm.org/viewvc/llvm-project?rev=84099&view=rev
Log:
Use partial diagnostics properly in call to RequireCompleteType. Among other things, this means we get a note on the declaration of the incomplete type when it is used in an exception specification.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
    cfe/trunk/test/SemaCXX/exception-spec.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=84099&r1=84098&r2=84099&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Oct 14 09:59:48 2009
@@ -356,7 +356,7 @@
   "exception specifications are not allowed beyond a single level "
   "of indirection">;
 def err_incomplete_in_exception_spec : Error<
-  "%select{|pointer to |reference to }1incomplete type %0 is not allowed "
+  "%select{|pointer to |reference to }0incomplete type %1 is not allowed "
   "in exception specification">;
 def err_mismatched_exception_spec : Error<
   "exception specification in declaration does not match previous declaration">;

Modified: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExceptionSpec.cpp?rev=84099&r1=84098&r2=84099&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExceptionSpec.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExceptionSpec.cpp Wed Oct 14 09:59:48 2009
@@ -41,11 +41,9 @@
 
   // C++ 15.4p2: A type denoted in an exception-specification shall not denote
   //   an incomplete type.
-  // FIXME: This isn't right. This will supress diagnostics from template
-  // instantiation and then simply emit the invalid type diagnostic.
-  if (RequireCompleteType(Range.getBegin(), T, 0))
-    return Diag(Range.getBegin(), diag::err_incomplete_in_exception_spec)
-      << Range << T << /*direct*/0;
+  if (RequireCompleteType(Range.getBegin(), T,
+      PDiag(diag::err_incomplete_in_exception_spec) << /*direct*/0 << Range))
+    return true;
 
   // C++ 15.4p2: A type denoted in an exception-specification shall not denote
   //   an incomplete type a pointer or reference to an incomplete type, other
@@ -60,9 +58,9 @@
   } else
     return false;
 
-  if (!T->isVoidType() && RequireCompleteType(Range.getBegin(), T, 0))
-    return Diag(Range.getBegin(), diag::err_incomplete_in_exception_spec)
-      << Range << T << /*indirect*/kind;
+  if (!T->isVoidType() && RequireCompleteType(Range.getBegin(), T,
+      PDiag(diag::err_incomplete_in_exception_spec) << /*direct*/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=84099&r1=84098&r2=84099&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/exception-spec.cpp (original)
+++ cfe/trunk/test/SemaCXX/exception-spec.cpp Wed Oct 14 09:59:48 2009
@@ -24,7 +24,7 @@
 // Pointer to function returning pointer to pointer to function with spec
 void (**(*h())())() throw(int); // expected-error {{not allowed beyond a single}}
 
-struct Incomplete;
+struct Incomplete; // expected-note 3 {{forward declaration}}
 
 // Exception spec must not have incomplete types, or pointers to them, except
 // void.
@@ -180,3 +180,8 @@
   void (Str1::*pfn2)() = &Str1::f; // valid
   void (Str1::*pfn3)() throw() = &Str1::f; // expected-error {{not superset}} expected-error {{incompatible type}}
 }
+
+// Don't suppress errors in template instantiation.
+template <typename T> struct TEx; // expected-note {{template is declared here}}
+
+void tf() throw(TEx<int>); // expected-error {{implicit instantiation of undefined template}}





More information about the cfe-commits mailing list