On 10/29/18 6:15 PM, Marek Polacek wrote:
On Wed, Oct 24, 2018 at 02:55:14PM -0400, Jason Merrill wrote:
On 10/12/18 12:32 PM, Marek Polacek wrote:
+   EXPLICIT_SPECIFIER is used in case the explicit-specifier, if any, has
+   value-dependent expression.  */
  static void
  cp_parser_decl_specifier_seq (cp_parser* parser,
                              cp_parser_flags flags,
                              cp_decl_specifier_seq *decl_specs,
-                             int* declares_class_or_enum)
+                             int* declares_class_or_enum,
+                             tree* explicit_specifier)

Why not add the explicit-specifier to cp_decl_specifier_seq?  They don't
live very long, so making them bigger isn't a concern.  Then other of the
handling could move into grokdeclarator along with the other explicit
handling.

Great -- that simplifies things.

@@ -12822,6 +12844,17 @@ tsubst_function_decl (tree t, tree args, 
tsubst_flags_t complain,
        if (!uses_template_parms (DECL_TI_ARGS (t)))
        return t;
+      /* Handle explicit(dependent-expr).  */
+      if (DECL_HAS_DEPENDENT_EXPLICIT_SPEC_P (t))
+       {
+         tree spec = lookup_explicit_specifier (t);
+         spec = tsubst_copy_and_build (spec, args, complain, in_decl,
+                                       /*function_p=*/false,
+                                       /*i_c_e_p=*/true);
+         spec = build_explicit_specifier (spec, complain);
+         DECL_NONCONVERTING_P (t) = (spec == boolean_true_node);
+       }

This is setting DECL_NONCONVERTING_P on the template, rather than the
instantiation r, which hasn't been created yet at this point; this handling
needs to move further down in the function.

Hmm, interesting that that worked, too.  Anyway, fixed.  Thanks!

It worked for the testcase because that bit was then copied to the instantiation. I'm surprised that converting b0 in explicit13.C worked, though.

+  /* Handle explicit(dependent-expr).  */
+  if (DECL_HAS_DEPENDENT_EXPLICIT_SPEC_P (t))
+    {
+      tree spec = lookup_explicit_specifier (t);
+      spec = tsubst_copy_and_build (spec, args, complain, in_decl,
+                                   /*function_p=*/false,
+                                   /*i_c_e_p=*/true);
+      spec = build_explicit_specifier (spec, complain);
+      DECL_NONCONVERTING_P (r) = (spec == boolean_true_node);
+    }

It still surprises me that you don't need to store the partially instantiated explicit-specifier, but explicit13.C does seem to cover the cases I would expect to break.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

OK.

Jason

Reply via email to