[PATCH] SemaChecking: return type validation for member functions
dblaikie at gmail.com
dblaikie at gmail.com
Mon Jan 6 11:39:23 PST 2014
Is there any better codepath we could use that would reuse the checking for
non-member functions?
How does this interact with templates?
On Sun Jan 05 2014 at 11:15:36 PM, Saleem Abdulrasool <compnerd at compnerd.org>
wrote:
> Avoid double diagnostics generation for constructors.
>
> Hi rsmith,
>
> http://llvm-reviews.chandlerc.com/D2514
>
> CHANGE SINCE LAST DIFF
> http://llvm-reviews.chandlerc.com/D2514?vs=6361&id=6362#toc
>
> Files:
> lib/Sema/SemaExprCXX.cpp
> test/Analysis/PR18393.cpp
>
> Index: lib/Sema/SemaExprCXX.cpp
> ===================================================================
> --- lib/Sema/SemaExprCXX.cpp
> +++ lib/Sema/SemaExprCXX.cpp
> @@ -4946,6 +4946,13 @@
> bool IsDecltype = ExprEvalContexts.back().IsDecltype;
> CXXDestructorDecl *Destructor = IsDecltype ? 0 : LookupDestructor(RD);
>
> + if (!IsDecltype && RD->isAbstract() && !isa<CXXConstructExpr>(E)) {
> + Diag(E->getExprLoc(), diag::err_abstract_type_in_decl)
> + << Sema::AbstractReturnType << RT->desugar();
> + DiagnoseAbstractType(RD);
> + return Owned(E);
> + }
> +
> if (Destructor) {
> MarkFunctionReferenced(E->getExprLoc(), Destructor);
> CheckDestructorAccess(E->getExprLoc(), Destructor,
> Index: test/Analysis/PR18393.cpp
> ===================================================================
> --- /dev/null
> +++ test/Analysis/PR18393.cpp
> @@ -0,0 +1,26 @@
> +// RUN: %clang_cc1 -fsyntax-only -verify %s
> +// PR18393
> +
> +struct base {
> + virtual void method() = 0;
> + // expected-note at -1 {{unimplemented pure virtual method 'method' in
> 'base'}}
> +};
> +
> +struct derived : base {
> + virtual void method();
> +};
> +
> +struct holder {
> + holder() : d_() {}
> + base get() const { return d_; }
> + const derived d_;
> +};
> +
> +void function(const base &);
> +
> +void test() {
> + holder h;
> + function(h.get());
> + // expected-error at -1 {{return type 'base' is an abstract class}}
> +}
> +
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140106/dd2a7de5/attachment.html>
More information about the cfe-commits
mailing list