aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@gcc.gnu.org>2003-03-21 02:08:02 -0500
committerJason Merrill <jason@gcc.gnu.org>2003-03-21 02:08:02 -0500
commit742f0efebe4b177253b9df555af6a59ea0c17eb8 (patch)
tree27e2366b724a6c36b540bd88f4ceccdcc1330023
parent963142fcd554cf2ccfab0d85062164fb0da3fb84 (diff)
downloadgcc-742f0efebe4b177253b9df555af6a59ea0c17eb8.zip
gcc-742f0efebe4b177253b9df555af6a59ea0c17eb8.tar.gz
gcc-742f0efebe4b177253b9df555af6a59ea0c17eb8.tar.bz2
re PR c++/7050 (g++ segfaults on: (i ? get_string() : throw))
PR c++/7050 * expr.c (store_expr): Don't attempt to store void-typed trees, just evaluate them for side effects. From-SVN: r64646
-rw-r--r--gcc/testsuite/g++.dg/eh/cond1.C64
1 files changed, 64 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/eh/cond1.C b/gcc/testsuite/g++.dg/eh/cond1.C
new file mode 100644
index 0000000..4f49426
--- /dev/null
+++ b/gcc/testsuite/g++.dg/eh/cond1.C
@@ -0,0 +1,64 @@
+// PR c++/7050
+// { dg-do run }
+
+extern "C" void abort(void);
+
+#define CI(stmt) try { stmt; abort(); } catch (int) { }
+
+struct has_destructor
+{
+ ~has_destructor() { }
+};
+
+struct no_destructor
+{
+};
+
+int PI(int& i) { return i++; }
+
+int main(int argc, char *argv[])
+{
+ (argc+1 ? has_destructor() : throw 0);
+ CI((argc+1 ? throw 0 : has_destructor()));
+ CI((0 ? has_destructor() : throw 0));
+ CI((1 ? throw 0 : has_destructor()));
+ (0 ? throw 0 : has_destructor());
+ (1 ? has_destructor() : throw 0);
+
+ (argc+1 ? no_destructor() : throw 0);
+ CI((argc+1 ? throw 0 : no_destructor()));
+ CI((0 ? no_destructor() : throw 0));
+ CI((1 ? throw 0 : no_destructor()));
+ (0 ? throw 0 : no_destructor());
+ (1 ? no_destructor() : throw 0);
+
+ int i = 1;
+ CI(throw PI(i));
+ if (i != 2) abort();
+
+ (1 ? 0 : throw PI(i));
+ if (i != 2) abort();
+
+ CI(0 ? 0 : throw PI(i));
+ if (i != 3) abort();
+
+ CI(0 ? has_destructor() : throw PI(i));
+ if (i != 4) abort();
+ (argc+1 ? has_destructor() : throw PI(i));
+ if (i != 4) abort();
+
+ i = 1;
+ CI(throw i++);
+ if (i != 2) abort();
+
+ (1 ? 0 : throw i++);
+ if (i != 2) abort();
+
+ CI(0 ? 0 : throw i++);
+ if (i != 3) abort();
+
+ CI(0 ? has_destructor() : throw i++);
+ if (i != 4) abort();
+ (argc+1 ? has_destructor() : throw i++);
+ if (i != 4) abort();
+}