[PATCH] PR20716 - Crash when recovering from type in known dependent base (ms-compatibility)

Nikola Smiljanic popizdeh at gmail.com
Wed Aug 20 18:33:35 PDT 2014


Are you saying you ran the test case without my change and it didn't crash?

Just -cc1 -fms-compatibility -fsyntax-only and you should see it.


On Thu, Aug 21, 2014 at 11:31 AM, David Blaikie <dblaikie at gmail.com> wrote:

> On Wed, Aug 20, 2014 at 5:19 PM, Nikola Smiljanić <popizdeh at gmail.com>
> wrote:
> > Hi rnk,
> >
> > The call to cast crashes because getTemplateDecl returns null for
> TemplateTemplateParmDecls.
> >
> > http://reviews.llvm.org/D4992
> >
> > Files:
> >   lib/Sema/SemaDecl.cpp
> >   test/SemaTemplate/ms-lookup-template-base-classes.cpp
> >
> > Index: lib/Sema/SemaDecl.cpp
> > ===================================================================
> > --- lib/Sema/SemaDecl.cpp
> > +++ lib/Sema/SemaDecl.cpp
> > @@ -150,7 +150,7 @@
> >      if (!TST || !TST->isDependentType())
> >        continue;
> >      auto *TD = TST->getTemplateName().getAsTemplateDecl();
> > -    if (!TD)
> > +       if (!TD || !TD->getTemplatedDecl())
>
> Looks like the indentation might've broken here? (or maybe it's just
> misrendering in the email)
>
> >        continue;
> >      auto *BasePrimaryTemplate =
> cast<CXXRecordDecl>(TD->getTemplatedDecl());
> >      // FIXME: Allow lookup into non-dependent bases of dependent bases,
> possibly
> > Index: test/SemaTemplate/ms-lookup-template-base-classes.cpp
> > ===================================================================
> > --- test/SemaTemplate/ms-lookup-template-base-classes.cpp
> > +++ test/SemaTemplate/ms-lookup-template-base-classes.cpp
> > @@ -460,3 +460,19 @@
> >    int x = f<NameFromBase>();
> >  };
> >  }
> > +
> > +namespace PR20716 {
>
> Test cases that just "don't crash" always seem a bit questionable to
> me - is there some behavior this should be testing for?
>
> > +template <class T>
> > +struct A
> > +{
> > +  void foo() {}
> > +};
> > +
> > +template <template <typename T> class C>
> > +struct B : public C<int>
> > +{
> > +  void bar() {
> > +    foo();
> > +  }
> > +};
> > +}
> >
> > _______________________________________________
> > 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/20140821/d0f276d4/attachment.html>


More information about the cfe-commits mailing list