diff mbox

[C++] PR 70266

Message ID bc33b247-d7bb-1660-a4c7-1ab0c50fe8cb@oracle.com
State New
Headers show

Commit Message

Paolo Carlini March 3, 2017, 10:26 a.m. UTC
Hi,

one more case of OVERLOAD filtering to cxx_eval_constant_expression and 
causing an ICE.

In order to have a proper diagnostic early enough I think that in 
build_must_not_throw_expr we want to use 
perform_implicit_conversion_flags on the condition before calling 
cxx_constant_value for it. That would be also analogous to the code we 
already have in build_noexcept_spec, for example. Tested x86_64-linux.

Thanks, Paolo.

//////////////////////
/cp
2017-03-03  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/70266
	* except.c (build_must_not_throw_expr): Perform the implicit
	conversions on the condition.

/testsuite
2017-03-03  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/70266
	* g++.dg/tm/pr70266.C: New.

Comments

Jason Merrill March 3, 2017, 11:36 a.m. UTC | #1
OK.

On Fri, Mar 3, 2017 at 12:26 AM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> Hi,
>
> one more case of OVERLOAD filtering to cxx_eval_constant_expression and
> causing an ICE.
>
> In order to have a proper diagnostic early enough I think that in
> build_must_not_throw_expr we want to use perform_implicit_conversion_flags
> on the condition before calling cxx_constant_value for it. That would be
> also analogous to the code we already have in build_noexcept_spec, for
> example. Tested x86_64-linux.
>
> Thanks, Paolo.
>
> //////////////////////
>
diff mbox

Patch

Index: cp/except.c
===================================================================
--- cp/except.c	(revision 245836)
+++ cp/except.c	(working copy)
@@ -268,6 +268,9 @@  build_must_not_throw_expr (tree body, tree cond)
 
   if (cond && !value_dependent_expression_p (cond))
     {
+      cond = perform_implicit_conversion_flags (boolean_type_node, cond,
+						tf_warning_or_error,
+						LOOKUP_NORMAL);
       cond = cxx_constant_value (cond);
       if (integer_zerop (cond))
 	return body;
Index: testsuite/g++.dg/tm/pr70266.C
===================================================================
--- testsuite/g++.dg/tm/pr70266.C	(revision 0)
+++ testsuite/g++.dg/tm/pr70266.C	(working copy)
@@ -0,0 +1,8 @@ 
+// { dg-do compile { target c++11 } }
+// { dg-options "-fgnu-tm" }
+
+template < typename T > 
+int foo (int x, T t)
+{
+  return __transaction_atomic noexcept (foo) (1);  // { dg-error "cannot resolve" }
+}