diff mbox series

[committed] Fix ICE in handle_omp_class_iterator (PR c++/92504)

Message ID 20191119090016.GD4650@tucnak
State New
Headers show
Series [committed] Fix ICE in handle_omp_class_iterator (PR c++/92504) | expand

Commit Message

Jakub Jelinek Nov. 19, 2019, 9 a.m. UTC
Hi!

Calling cp_fully_fold (which has been introduced with C++ late folding)
before actually diagnosing invalid arguments of the comparison is
problematic, because as the testcase shows the folding can then ICE before
the invalid code is reported.

Removing the cp_fully_fold call doesn't regress anything, so I've removed
it after doing bootstrap/regtest on x86_64-linux and i686-linux and committed
to trunk.

2019-11-19  Jakub Jelinek  <jakub@redhat.com>

	PR c++/92504
	* semantics.c (handle_omp_for_class_iterator): Don't call
	cp_fully_fold on cond.

	* g++.dg/gomp/pr92504.C: New test.


	Jakub
diff mbox series

Patch

--- gcc/cp/semantics.c.jj	2019-11-11 21:04:24.837962966 +0100
+++ gcc/cp/semantics.c	2019-11-18 19:19:36.921680774 +0100
@@ -8434,7 +8434,6 @@  handle_omp_for_class_iterator (int i, lo
   if (init && EXPR_HAS_LOCATION (init))
     elocus = EXPR_LOCATION (init);
 
-  cond = cp_fully_fold (cond);
   switch (TREE_CODE (cond))
     {
     case GT_EXPR:
--- gcc/testsuite/g++.dg/gomp/pr92504.C.jj	2019-11-18 19:18:45.211452647 +0100
+++ gcc/testsuite/g++.dg/gomp/pr92504.C	2019-11-18 19:19:19.660938426 +0100
@@ -0,0 +1,29 @@ 
+// PR c++/92504
+// { dg-do compile { target c++11 } }
+// { dg-additional-options "-O2" }
+
+namespace std {
+  typedef __SIZE_TYPE__ size_t;
+  typedef __PTRDIFF_TYPE__ ptrdiff_t;
+}
+
+struct A {
+  A ();
+  A (const A &);
+  A & operator++ ();
+  bool operator != (const A &) const;
+  std::ptrdiff_t operator - (const A &);
+  A & operator += (std::size_t);
+  int a;
+  A & begin ();
+  A & end ();				// { dg-message "declared here" }
+};
+
+void
+bar ()
+{
+  A a;
+  #pragma omp for
+  for (auto b = a; b != a.end; ++b)	// { dg-error "invalid use of non-static member function" }
+    ;
+}