re PR c++/84333 (ICE with ternary operator in template function)
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 13 Feb 2018 21:23:22 +0000 (21:23 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 13 Feb 2018 21:23:22 +0000 (21:23 +0000)
/cp
2018-02-13  Paolo Carlini  <paolo.carlini@oracle.com>

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  <paolo.carlini@oracle.com>

PR c++/84333
* g++.dg/template/sizeof16.C: New.
* g++.dg/template/sizeof17.C: Likewise.

From-SVN: r257638

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/sizeof16.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/sizeof17.C [new file with mode: 0644]

index 7c52edeeab6deca814e2b4776f8c67cb9b1b8a8f..84fb9094d908d32c594376da73efb48fe29e8acd 100644 (file)
@@ -1,3 +1,9 @@
+2018-02-13  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       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  <jason@redhat.com>
 
        PR c++/84080 - ICE with return type deduction and specialization.
index 15b723ad2b090c111f49c62a8111e704392673f8..7176e4afa1507a0e5a45de7931c10e19b299a2a0 100644 (file)
@@ -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
index e0edbe57b56655ab7491651bf1399aba5b3fa1c7..f22c21afb76b4410e21a078b6911f6123102019a 100644 (file)
@@ -1,3 +1,9 @@
+2018-02-13  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/84333
+       * g++.dg/template/sizeof16.C: New.
+       * g++.dg/template/sizeof17.C: Likewise.
+
 2018-02-13  Janus Weil  <janus@gcc.gnu.org>
 
        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 (file)
index 0000000..084bb21
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/84333
+// { dg-options -Wno-pedantic }
+
+template<typename> 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 (file)
index 0000000..2d5892d
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/84333
+// { dg-options -Wno-pedantic }
+
+template<typename T> int foo()
+{
+  return sizeof(T) > 1 ? : 1;
+}