https://gcc.gnu.org/g:1d577bebe14c506713aee95080b8550a777586ba

commit r12-11254-g1d577bebe14c506713aee95080b8550a777586ba
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Mon Jul 7 09:51:38 2025 +0200

    Revert "c++: Fix a pasto in the PR120471 fix [PR120940]"
    
    This reverts commit ed950a9ed384389ff07ac793b7065abe31bcae3f.

Diff:
---
 gcc/cp/typeck.cc                                  |  2 +-
 gcc/testsuite/g++.dg/parse/pr120940.C             | 18 ------------------
 gcc/testsuite/g++.dg/warn/Wduplicated-branches9.C | 11 -----------
 3 files changed, 1 insertion(+), 30 deletions(-)

diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
index 2f67bb33ff04..19dfaf18928f 100644
--- a/gcc/cp/typeck.cc
+++ b/gcc/cp/typeck.cc
@@ -3814,7 +3814,7 @@ cp_build_array_ref (location_t loc, tree array, tree idx,
       tree op0, op1, op2;
       op0 = TREE_OPERAND (array, 0);
       op1 = TREE_OPERAND (array, 1);
-      op2 = TREE_OPERAND (array, 2);
+      op2 = TREE_OPERAND (array, 1);
       if (TREE_SIDE_EFFECTS (idx) || !tree_invariant_p (idx))
        {
          /* If idx could possibly have some SAVE_EXPRs, turning
diff --git a/gcc/testsuite/g++.dg/parse/pr120940.C 
b/gcc/testsuite/g++.dg/parse/pr120940.C
deleted file mode 100644
index 5da36b2f88a0..000000000000
--- a/gcc/testsuite/g++.dg/parse/pr120940.C
+++ /dev/null
@@ -1,18 +0,0 @@
-// PR c++/120940
-// { dg-do run }
-
-int a[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };
-int b[8] = { 9, 10, 11, 12, 13, 14, 15, 16 };
-
-__attribute__((noipa)) int
-foo (int x, int y)
-{
-  return (x ? a : b)[y];
-}
-
-int
-main ()
-{
-  if (foo (1, 4) != 5 || foo (0, 6) != 15)
-    __builtin_abort ();
-}
diff --git a/gcc/testsuite/g++.dg/warn/Wduplicated-branches9.C 
b/gcc/testsuite/g++.dg/warn/Wduplicated-branches9.C
deleted file mode 100644
index f9fafcd467b4..000000000000
--- a/gcc/testsuite/g++.dg/warn/Wduplicated-branches9.C
+++ /dev/null
@@ -1,11 +0,0 @@
-// PR c++/120940
-// { dg-do compile }
-// { dg-options "-Wduplicated-branches" }
-
-static char a[16][8], b[16][8];
-
-char *
-foo (int x, int y)
-{
-  return (x ? a : b)[y];
-}

Reply via email to