r339210 - PR38286: Don't crash when attempting to define a constructor for an
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 7 17:46:24 PDT 2018
Would be good to get this into the Clang 7 release.
On Tue, 7 Aug 2018 at 17:43, Richard Smith via cfe-commits <
cfe-commits at lists.llvm.org> wrote:
> Author: rsmith
> Date: Tue Aug 7 17:42:42 2018
> New Revision: 339210
>
> URL: http://llvm.org/viewvc/llvm-project?rev=339210&view=rev
> Log:
> PR38286: Don't crash when attempting to define a constructor for an
> incomplete class template.
>
> Modified:
> cfe/trunk/lib/Sema/SemaExprCXX.cpp
> cfe/trunk/test/SemaCXX/constructor.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=339210&r1=339209&r2=339210&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Aug 7 17:42:42 2018
> @@ -113,9 +113,15 @@ ParsedType Sema::getConstructorName(Iden
> break;
> }
> }
> - if (!InjectedClassName && CurClass->isInvalidDecl())
> + if (!InjectedClassName) {
> + if (!CurClass->isInvalidDecl()) {
> + // FIXME: RequireCompleteDeclContext doesn't check dependent
> contexts
> + // properly. Work around it here for now.
> + Diag(SS.getLastQualifierNameLoc(),
> + diag::err_incomplete_nested_name_spec) << CurClass <<
> SS.getRange();
> + }
> return ParsedType();
> - assert(InjectedClassName && "couldn't find injected class name");
> + }
>
> QualType T = Context.getTypeDeclType(InjectedClassName);
> DiagnoseUseOfDecl(InjectedClassName, NameLoc);
>
> Modified: cfe/trunk/test/SemaCXX/constructor.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constructor.cpp?rev=339210&r1=339209&r2=339210&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/constructor.cpp (original)
> +++ cfe/trunk/test/SemaCXX/constructor.cpp Tue Aug 7 17:42:42 2018
> @@ -86,3 +86,14 @@ A::S::operator int() { return 1; }
>
> A::S::~S() {}
>
> +namespace PR38286 {
> + // FIXME: It'd be nice to give more consistent diagnostics for these
> cases
> + // (but they're all failing for somewhat different reasons...).
> + template<typename> struct A;
> + template<typename T> A<T>::A() {} // expected-error {{incomplete type
> 'A' named in nested name specifier}}
> + /*FIXME: needed to recover properly from previous error*/;
> + template<typename> struct B;
> + template<typename T> void B<T>::f() {} // expected-error {{out-of-line
> definition of 'f' from class 'B<type-parameter-0-0>'}}
> + template<typename> struct C;
> + template<typename T> C<T>::~C() {} // expected-error {{no type named
> 'C' in 'C<type-parameter-0-0>'}}
> +}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180807/50a9a9ed/attachment.html>
More information about the cfe-commits
mailing list