rsmith added inline comments.
================
Comment at: lib/Sema/SemaDecl.cpp:7447-7450
@@ -7446,1 +7446,6 @@
+ if (const FunctionProtoType *FPT = R->getAs<FunctionProtoType>()) {
+ if (FPT->hasExceptionSpec()) {
+ auto LocBeg = D.getFunctionTypeInfo().getExceptionSpecLocBeg();
+ auto LocEnd = D.getFunctionTypeInfo().getExceptionSpecLocEnd();
+ Diag(LocBeg, diag::err_function_concept_exception_spec)
----------------
nwilson wrote:
> rsmith wrote:
> > This will assert if there isn't a `FunctionTypeInfo` for the declaration,
> > which can theoretically happen if it's declared via an (ill-formed today)
> > `typedef`. (It also might not provide a source range if the exception
> > specification is implicit, for instance because the function template is a
> > destructor or deallocation function, but passing an empty SourceRange to
> > the FixItHint should just result it in being ignored.)
> Hmm, I'm not sure if we'd run into that case because I don't believe we can
> have a `concept` specified as a typedef (check is yet to be added) and a
> check exists for being in a non-namespace scope. Do you think a check should
> still be added verifying that the FunctionTypeInfo exists?
Yes, you should check that a `FunctionTypeInfo` exists (`isFunctionDeclarator`)
rather than assuming that it does. The testcase would look something like this:
typedef int Fn() noexcept;
template<typename T> concept Fn C;
I think we'll discard the `noexcept` early at the moment, but that's not
something you should be subtly relying on here (especially given that
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4533.html is looming
on the horizon). Something like:
SourceRange Range;
if (D.isFunctionDeclarator())
Range = D.getFunctionTypeInfo().getExceptionSpecRange();
... should handle this safely.
http://reviews.llvm.org/D11789
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits