diff mbox

[C++] PR 60215

Message ID 53032AFC.8020105@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Feb. 18, 2014, 9:42 a.m. UTC
Hi,

we fixed c++/58647 with:

9672     case COMPONENT_REF:
9673       if (is_overloaded_fn (t))
9674         {
9675           /* We can only get here in checking mode via
9676              build_non_dependent_expr,  because any expression that
9677              calls or takes the address of the function will have
9678              pulled a FUNCTION_DECL out of the COMPONENT_REF.  */
9679           gcc_checking_assert (allow_non_constant);
9680           *non_constant_p = true;
9681           return t;
9682         }


which also added a gcc_checking_assert. In the new issue the assert 
triggers during error recovery and I guess we can simply loosen it a bit 
with || errorcount, the below passes testing.

Thanks,
Paolo.

//////////////////////
/cp
2014-02-18  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/60215
	* semantics.c (cxx_eval_constant_expression, [COMPONENT_REF]):
	During error recovery allow_non_constant may be false.

/testsuite
2014-02-18  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/60215
	* g++.dg/cpp0x/pr60215.C: New.
diff mbox

Patch

Index: cp/semantics.c
===================================================================
--- cp/semantics.c	(revision 207837)
+++ cp/semantics.c	(working copy)
@@ -9676,7 +9677,7 @@  cxx_eval_constant_expression (const constexpr_call
 	     build_non_dependent_expr,  because any expression that
 	     calls or takes the address of the function will have
 	     pulled a FUNCTION_DECL out of the COMPONENT_REF.  */
-	  gcc_checking_assert (allow_non_constant);
+	  gcc_checking_assert (allow_non_constant || errorcount);
 	  *non_constant_p = true;
 	  return t;
 	}
Index: testsuite/g++.dg/cpp0x/pr60215.C
===================================================================
--- testsuite/g++.dg/cpp0x/pr60215.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/pr60215.C	(working copy)
@@ -0,0 +1,8 @@ 
+// PR c++/60215
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+  void foo();
+  int i : foo;  // { dg-error "width" }
+};