[PATCH] Don't ICE on errorneous destructor in finish_omp_clauses (PR c++/35328)
Jakub Jelinek
jakub@redhat.com
Mon Mar 10 20:27:00 GMT 2008
Hi!
errorneous destructor like the one in the testcase below can
result in build_special_member_call returning NOP_EXPR around
CALL_EXPR (casting to void) similar to what is done when
targetm.cxx.cdtor_returns_this ().
Fixed thusly, regtested on x86_64-linux, committed to trunk.
Will commit to 4.3 soon.
2008-03-10 Jakub Jelinek <jakub@redhat.com>
PR c++/35328
* semantics.c (finish_omp_clauses): Look through NOP_EXPR even
if errorcount.
* g++.dg/gomp/pr35328.C: New test.
--- gcc/cp/semantics.c.jj 2008-03-10 17:11:40.000000000 +0100
+++ gcc/cp/semantics.c 2008-03-10 17:28:14.000000000 +0100
@@ -3661,7 +3661,7 @@ finish_omp_clauses (tree clauses)
complete_ctor_identifier,
t, inner_type, LOOKUP_NORMAL);
- if (targetm.cxx.cdtor_returns_this ())
+ if (targetm.cxx.cdtor_returns_this () || errorcount)
/* Because constructors and destructors return this,
the call will have been cast to "void". Remove the
cast here. We would like to use STRIP_NOPS, but it
@@ -3683,7 +3683,7 @@ finish_omp_clauses (tree clauses)
t = build_special_member_call (t, complete_dtor_identifier,
NULL, inner_type, LOOKUP_NORMAL);
- if (targetm.cxx.cdtor_returns_this ())
+ if (targetm.cxx.cdtor_returns_this () || errorcount)
/* Because constructors and destructors return this,
the call will have been cast to "void". Remove the
cast here. We would like to use STRIP_NOPS, but it
--- gcc/testsuite/g++.dg/gomp/pr35328.C.jj 2008-03-10 17:40:52.000000000 +0100
+++ gcc/testsuite/g++.dg/gomp/pr35328.C 2008-03-10 17:40:19.000000000 +0100
@@ -0,0 +1,31 @@
+// PR c++/35328
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+struct A
+{
+ ~A ()(); // { dg-error "declared as function returning a function" }
+};
+struct B
+{
+ B ()(); // { dg-error "declared as function returning a function" }
+};
+struct C
+{
+ C ();
+ C (const C &)(); // { dg-error "declared as function returning a function" }
+};
+
+void
+foo ()
+{
+ A a;
+ B b;
+ C c;
+ #pragma omp parallel firstprivate (a)
+ ;
+ #pragma omp parallel private (b)
+ ;
+ #pragma omp parallel firstprivate (c)
+ ;
+}
Jakub
More information about the Gcc-patches
mailing list