]> granicus.if.org Git - clang/commitdiff
Use partial diagnostics properly in call to RequireCompleteType. Among other things...
authorSebastian Redl <sebastian.redl@getdesigned.at>
Wed, 14 Oct 2009 14:59:48 +0000 (14:59 +0000)
committerSebastian Redl <sebastian.redl@getdesigned.at>
Wed, 14 Oct 2009 14:59:48 +0000 (14:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84099 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 5efab50ae38a189ffa7b02517bcea18e9c978874..fc840a2d58bbdedfe3c4e79acd40313fd83c52d0 100644 (file)
@@ -356,7 +356,7 @@ def err_distant_exception_spec : Error<
   "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">;
index 261bebf9553c6393f9c9e2ee042f3deb6c41b637..12d06b4905b364d6f600509e8119b2504df27ba7 100644 (file)
@@ -41,11 +41,9 @@ bool Sema::CheckSpecifiedExceptionType(QualType T, const SourceRange &Range) {
 
   // 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 @@ bool Sema::CheckSpecifiedExceptionType(QualType T, const SourceRange &Range) {
   } 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;
 }
index f55a4494ea4db02ee3dda9df1531dc0463c6f13c..9b2a07d796543f368ec2ee27f344f156425f5920 100644 (file)
@@ -24,7 +24,7 @@ void (**j)() throw(int); // expected-error {{not allowed beyond a single}}
 // 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 mfnptr()
   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}}