[PATCH] Fix ICE on invalid variable template instantiation (PR c++/72759)

Jason Merrill jason@redhat.com
Thu Aug 4 00:07:00 GMT 2016


OK.

On Wed, Aug 3, 2016 at 8:02 PM, Patrick Palka <patrick@parcs.ath.cx> wrote:
> On Wed, 3 Aug 2016, Jason Merrill wrote:
>
>> Why not check for error_mark_node right after the tsubst_template_args?
>
> No good reason.  This seems to work too.  Does the following look OK
> after bootstrap + regtest?
>
> -- >8 --
>
> gcc/cp/ChangeLog:
>
>         PR c++/72759
>         * pt.c (tsubst_qualified_id): Return error_mark_node if
>         template_args is error_mark_node.
>
> gcc/testsuite/ChangeLog:
>
>         PR c++/72759
>         * g++.dg/cpp1y/pr72759.C: New test.
> ---
>  gcc/cp/pt.c                          |  2 ++
>  gcc/testsuite/g++.dg/cpp1y/pr72759.C | 18 ++++++++++++++++++
>  2 files changed, 20 insertions(+)
>  create mode 100644 gcc/testsuite/g++.dg/cpp1y/pr72759.C
>
> diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
> index a23a05a..7663916 100644
> --- a/gcc/cp/pt.c
> +++ b/gcc/cp/pt.c
> @@ -13826,6 +13826,8 @@ tsubst_qualified_id (tree qualified_id, tree args,
>        if (template_args)
>         template_args = tsubst_template_args (template_args, args,
>                                               complain, in_decl);
> +      if (template_args == error_mark_node)
> +       return error_mark_node;
>        name = TREE_OPERAND (name, 0);
>      }
>    else
> diff --git a/gcc/testsuite/g++.dg/cpp1y/pr72759.C b/gcc/testsuite/g++.dg/cpp1y/pr72759.C
> new file mode 100644
> index 0000000..4af6ea4
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp1y/pr72759.C
> @@ -0,0 +1,18 @@
> +// PR c++/72759
> +// { dg-do compile { target c++14 } }
> +
> +template <typename> struct SpecPerType;
> +class Specializer {
> +  public:  template <bool> static void MbrFnTempl();
> +  template <unsigned> struct A { static void InnerMemberFn(); };
> +  void Trigger() { A<0>::InnerMemberFn; }
> +};
> +template <> struct SpecPerType<Specializer> {
> +  using FnType = void *;
> +  template <bool P>
> +  static constexpr FnType SpecMbrFnPtr = Specializer::MbrFnTempl<P>;
> +};
> +template <unsigned X> void Specializer::A<X>::InnerMemberFn() {
> +  using Spec = SpecPerType<Specializer>;
> +  Spec ErrorSite = Spec::SpecMbrFnPtr<SpecMbrFnPtr>;  // { dg-error "not declared" }
> +}
> --
> 2.9.2.564.g4d4f0b7
>



More information about the Gcc-patches mailing list