[C++ PATCH] Fix ICE on variable template access without template args (PR c++/89512)

Jason Merrill jason@redhat.com
Thu Mar 14 02:57:00 GMT 2019


On 3/13/19 6:37 PM, Jakub Jelinek wrote:
> Hi!
> 
> When a variable template (both static data member of some class or at
> namespace level) is accessed without template arguments,
> finish_id_expression_1 handles it through:
>    /* If we didn't find anything, or what we found was a type,
>       then this wasn't really an id-expression.  */
>    if (TREE_CODE (decl) == TEMPLATE_DECL
>        && !DECL_FUNCTION_TEMPLATE_P (decl))
>      {
>        *error_msg = G_("missing template arguments");
>        return error_mark_node;
>      }
> On the following invalid testcase the access is from within a template and
> in that case finish_id_expression{,_1} isn't really called for that, instead
> tsubst_qualified_id just calls finish_qualified_id_expr.
> 
> The ICE is because we pass over a TEMPLATE_DECL to the middle-end (e.g. on
> rhs of an INIT_EXPR etc.).
> 
> The following patch does something similar to what finish_id_expression_1
> does.  Bootstrapped/regtested on x86_64-linux and i686-linux.  Or should it
> be done in tsubst_qualified_id instead (before or after the
> finish_qualified_id_expr call?
> 
> 2019-03-13  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR c++/89512
> 	* semantics.c (finish_qualified_id_expr): Reject variable templates.

OK.

Jason



More information about the Gcc-patches mailing list