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.

llvm-svn: 84099
This commit is contained in:
Sebastian Redl 2009-10-14 14:59:48 +00:00
parent 075b21d4dc
commit 7eb5d377d7
3 changed files with 13 additions and 10 deletions

View File

@ -356,7 +356,7 @@ def err_distant_exception_spec : Error<
"exception specifications are not allowed beyond a single level " "exception specifications are not allowed beyond a single level "
"of indirection">; "of indirection">;
def err_incomplete_in_exception_spec : Error< 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">; "in exception specification">;
def err_mismatched_exception_spec : Error< def err_mismatched_exception_spec : Error<
"exception specification in declaration does not match previous declaration">; "exception specification in declaration does not match previous declaration">;

View 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 // C++ 15.4p2: A type denoted in an exception-specification shall not denote
// an incomplete type. // an incomplete type.
// FIXME: This isn't right. This will supress diagnostics from template if (RequireCompleteType(Range.getBegin(), T,
// instantiation and then simply emit the invalid type diagnostic. PDiag(diag::err_incomplete_in_exception_spec) << /*direct*/0 << Range))
if (RequireCompleteType(Range.getBegin(), T, 0)) return true;
return Diag(Range.getBegin(), diag::err_incomplete_in_exception_spec)
<< Range << T << /*direct*/0;
// C++ 15.4p2: A type denoted in an exception-specification shall not denote // 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 // 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 } else
return false; return false;
if (!T->isVoidType() && RequireCompleteType(Range.getBegin(), T, 0)) if (!T->isVoidType() && RequireCompleteType(Range.getBegin(), T,
return Diag(Range.getBegin(), diag::err_incomplete_in_exception_spec) PDiag(diag::err_incomplete_in_exception_spec) << /*direct*/kind << Range))
<< Range << T << /*indirect*/kind; return true;
return false; return false;
} }

View 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 // Pointer to function returning pointer to pointer to function with spec
void (**(*h())())() throw(int); // expected-error {{not allowed beyond a single}} 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 // Exception spec must not have incomplete types, or pointers to them, except
// void. // void.
@ -180,3 +180,8 @@ void mfnptr()
void (Str1::*pfn2)() = &Str1::f; // valid void (Str1::*pfn2)() = &Str1::f; // valid
void (Str1::*pfn3)() throw() = &Str1::f; // expected-error {{not superset}} expected-error {{incompatible type}} 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}}