libstdc++: Make dg-error pattern more accurate

    Remove useless test variable and use a more accurate dg-error pattern so
    that only the ill-formed expression compilation error is considered.

    libstdc++-v3/ChangeLog:

            * testsuite/23_containers/map/operators/1_neg.cc (test01): Remove test variable
            and use 'no match' dg-error patter.
            * testsuite/23_containers/set/operators/1_neg.cc (test01): Likewise.

Comitted with you as author.

François


On 01/08/2024 09:26, Jonathan Wakely wrote:
On Thu, 1 Aug 2024 at 06:09, François Dumont <frs.dum...@gmail.com> wrote:
Do you want me to take care of those 2 tests ?
Yes please.

You seem to have started something on the review of dg-error patterns in
use.

Here I kept the test variable because I fear to potentially have a
diagnostic about unused returned value.
I thought about that too, but you can't have an unused return value
from a function that doesn't compile. There's no return value, because
itr != mapByName.end() doesn't compile, so there's no function that
gets called, so no return type.

Except in case of regression that would make the expression well-formed and then produce another compilation error. But with your modification of the dg-error pattern this cannot happen anymore so all good.

diff --git a/libstdc++-v3/testsuite/23_containers/map/operators/1_neg.cc 
b/libstdc++-v3/testsuite/23_containers/map/operators/1_neg.cc
index 0eb1eee640b..6ce7b3249d8 100644
--- a/libstdc++-v3/testsuite/23_containers/map/operators/1_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/map/operators/1_neg.cc
@@ -35,6 +35,6 @@ void test01()
   std::map<unsigned, int>::iterator itr(mapByIndex.begin());
 
   // NB: notice, it's not mapByIndex!!
-  bool __attribute__((unused)) test = itr != mapByName.end(); // { dg-error 
"no" }
-  test &= itr == mapByName.end(); // { dg-error "no" }
+  itr != mapByName.end(); // { dg-error "no match" }
+  itr == mapByName.end(); // { dg-error "no match" }
 }
diff --git a/libstdc++-v3/testsuite/23_containers/set/operators/1_neg.cc 
b/libstdc++-v3/testsuite/23_containers/set/operators/1_neg.cc
index 28d08f308e1..b5f69ae920c 100644
--- a/libstdc++-v3/testsuite/23_containers/set/operators/1_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/set/operators/1_neg.cc
@@ -32,6 +32,6 @@ void test01()
   std::set<unsigned int>::iterator itr(setByIndex.begin());
 
   // NB: it's not setByIndex!!
-  bool __attribute__((unused)) test = itr != setByName.end(); // { dg-error 
"no" }
-  test &= itr == setByName.end(); // { dg-error "no" }
+  itr != setByName.end(); // { dg-error "no match" }
+  itr == setByName.end(); // { dg-error "no match" }
 }

Reply via email to