From: Paolo Carlini Date: Tue, 13 Feb 2018 21:23:22 +0000 (+0000) Subject: re PR c++/84333 (ICE with ternary operator in template function) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3a9ad4c190409ee4a9d20ad4f4d1349302e90da7;p=gcc.git re PR c++/84333 (ICE with ternary operator in template function) /cp 2018-02-13 Paolo Carlini PR c++/84333 * call.c (build_conditional_expr_1): Use cp_save_expr instead of save_expr for the G++ extension. /testsuite 2018-02-13 Paolo Carlini PR c++/84333 * g++.dg/template/sizeof16.C: New. * g++.dg/template/sizeof17.C: Likewise. From-SVN: r257638 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7c52edeeab6..84fb9094d90 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-02-13 Paolo Carlini + + PR c++/84333 + * call.c (build_conditional_expr_1): Use cp_save_expr instead of + save_expr for the G++ extension. + 2018-02-13 Jason Merrill PR c++/84080 - ICE with return type deduction and specialization. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 15b723ad2b0..7176e4afa15 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4805,7 +4805,7 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3, if (lvalue_p (arg1)) arg2 = arg1 = cp_stabilize_reference (arg1); else - arg2 = arg1 = save_expr (arg1); + arg2 = arg1 = cp_save_expr (arg1); } /* If something has already gone wrong, just pass that fact up the diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e0edbe57b56..f22c21afb76 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-02-13 Paolo Carlini + + PR c++/84333 + * g++.dg/template/sizeof16.C: New. + * g++.dg/template/sizeof17.C: Likewise. + 2018-02-13 Janus Weil PR fortran/84313 diff --git a/gcc/testsuite/g++.dg/template/sizeof16.C b/gcc/testsuite/g++.dg/template/sizeof16.C new file mode 100644 index 00000000000..084bb2185c7 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/sizeof16.C @@ -0,0 +1,7 @@ +// PR c++/84333 +// { dg-options -Wno-pedantic } + +template int foo() +{ + return sizeof(int) > 1 ? : 1; +} diff --git a/gcc/testsuite/g++.dg/template/sizeof17.C b/gcc/testsuite/g++.dg/template/sizeof17.C new file mode 100644 index 00000000000..2d5892d2c8b --- /dev/null +++ b/gcc/testsuite/g++.dg/template/sizeof17.C @@ -0,0 +1,7 @@ +// PR c++/84333 +// { dg-options -Wno-pedantic } + +template int foo() +{ + return sizeof(T) > 1 ? : 1; +}