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

David Blaikie dblaikie at gmail.com
Wed Aug 20 18:31:36 PDT 2014


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
>




More information about the cfe-commits mailing list