PR c++/89420 - ICE with CAST_EXPR in explicit-specifier.
authorMarek Polacek <polacek@redhat.com>
Fri, 22 Feb 2019 19:24:37 +0000 (19:24 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 22 Feb 2019 19:24:37 +0000 (19:24 +0000)
* decl.c (build_explicit_specifier): Don't check
processing_template_decl.  Call instantiation_dependent_expression_p
instead of value_dependent_expression_p.  Call
instantiate_non_dependent_expr_sfinae before
build_converted_constant_expr instead of calling
instantiate_non_dependent_expr after it.  Add
processing_template_decl_sentinel.

* g++.dg/cpp2a/explicit14.C: New test.

From-SVN: r269131

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp2a/explicit14.C [new file with mode: 0644]

index 0858646d19e3280ecf6536810d1b33c39e4336c3..838139196093f233aaead7b5ec54027ba3f0c261 100644 (file)
@@ -1,3 +1,14 @@
+2019-02-22  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/89420 - ICE with CAST_EXPR in explicit-specifier.
+       * decl.c (build_explicit_specifier): Don't check
+       processing_template_decl.  Call instantiation_dependent_expression_p
+       instead of value_dependent_expression_p.  Call
+       instantiate_non_dependent_expr_sfinae before
+       build_converted_constant_expr instead of calling
+       instantiate_non_dependent_expr after it.  Add
+       processing_template_decl_sentinel.
+
 2019-02-22  Thomas Schwinge  <thomas@codesourcery.com>
 
        * parser.c (cp_parser_oacc_simple_clause): Remove parser formal
index 612afbacd270ea78eec324f1afcff352536d0887..c5b5bd3ce08c59521d124509e939b287c88290b1 100644 (file)
@@ -16687,12 +16687,14 @@ require_deduced_type (tree decl, tsubst_flags_t complain)
 tree
 build_explicit_specifier (tree expr, tsubst_flags_t complain)
 {
-  if (processing_template_decl && value_dependent_expression_p (expr))
+  if (instantiation_dependent_expression_p (expr))
     /* Wait for instantiation, tsubst_function_decl will handle it.  */
     return expr;
 
+  expr = instantiate_non_dependent_expr_sfinae (expr, complain);
+  /* Don't let convert_like_real create more template codes.  */
+  processing_template_decl_sentinel s;
   expr = build_converted_constant_expr (boolean_type_node, expr, complain);
-  expr = instantiate_non_dependent_expr (expr);
   expr = cxx_constant_value (expr);
   return expr;
 }
index 555dc4aebfb78fde3c33dbc2f42fb18b95a547d8..9fae9ffa169033f10aeb8241b37461188dc30f4f 100644 (file)
@@ -1,3 +1,8 @@
+2019-02-22  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/89420 - ICE with CAST_EXPR in explicit-specifier.
+       * g++.dg/cpp2a/explicit14.C: New test.
+
 2019-02-22  Matthew Malcomson  <matthew.malcomson@arm.com>
 
        PR target/89324
diff --git a/gcc/testsuite/g++.dg/cpp2a/explicit14.C b/gcc/testsuite/g++.dg/cpp2a/explicit14.C
new file mode 100644 (file)
index 0000000..9c3acc3
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/89420
+// { dg-do compile { target c++2a } }
+
+template<typename>
+struct S {
+  explicit(int(1)) S(int);
+  explicit(int{1}) S(int, int);
+};
+
+S<int> s(1);
+S<int> s2(1, 2);