[cfe-commits] r83764 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/CMakeLists.txt lib/Sema/Sema.h lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaExceptionSpec.cpp lib/Sema/SemaExprCXX.cpp lib/Sema/SemaType.cpp test/SemaCXX/exception-spec.cpp
Sebastian Redl
sebastian.redl at getdesigned.at
Mon Oct 12 14:05:14 PDT 2009
Douglas Gregor wrote:
>
> On Oct 11, 2009, at 2:03 AM, Sebastian Redl wrote:
>> +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?
>
> My suggestion for this would be to have the parser delay semantic
> analysis of the exception specifications of member functions in the
> same way that we delay parsing of default arguments of the parameters
> of member functions. For example, these checks on the exception
> specialization for a member function declaration could be performed by
> ActOnFinishDelayedCXXMethodDeclaration.
Sounds good. I have to write a test case for it anyway.
>
>> + // 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;
>
> You should be able to use partial diagnostics to get the diagnostic
> you want within RequireCompleteType.
Can partial diagnostics store parameters?
>> + llvm::SmallPtrSet<const Type*, 8> Types;
>
> Should this be a
>
> llvm::SmallPtrSet<CanQualType, 8> Types;
>
> ?
Probably. This code has been lying around on my computer since before
CanQualType was introduced, and I haven't really looked at this new
class yet.
>> +
>> + // Neither contains everything. Do a proper comparison.
>> + for (FunctionProtoType::exception_iterator SubI =
>> Subset->exception_begin(),
>> + SubE = Subset->exception_end(); SubI != SubE; ++SubI) {
>> + // Take one type from the subset.
>> + QualType CanonicalSubT = Context.getCanonicalType(*SubI);
>> + bool SubIsPointer = false;
>> + if (const ReferenceType *RefTy =
>> CanonicalSubT->getAs<ReferenceType>())
>> + CanonicalSubT = RefTy->getPointeeType();
>> + if (const PointerType *PtrTy =
>> CanonicalSubT->getAs<PointerType>()) {
>> + CanonicalSubT = PtrTy->getPointeeType();
>> + SubIsPointer = true;
>> + }
>
> Are there pointer-to-member cases we need to check here?
No. Pointers-to-member don't have implicit hierarchy conversions for
their pointee, so if you decide to throw a pointer-to-member (what a
thing to do), you can only catch it with an exact type match.
Sebastian
More information about the cfe-commits
mailing list