From: Jonathan Yong <10walls@gmail.com> Date: Wed, 11 Feb 2026 05:49:57 +0000 (+0000) Subject: Make some C++ tests account for llp64 targets X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a4b0cec47e4a3c0466c9f8ea89e66c9b8f39e85;p=thirdparty%2Fgcc.git Make some C++ tests account for llp64 targets Fix spurious warnings with mingw-w64. gcc/testsuite/ChangeLog: * g++.dg/expr/cast11.C: Cast to intptr_t instead of long. * g++.dg/opt/pr55717.C: Ditto. * g++.dg/warn/Wunused-value-1.C: Ditto. Signed-off-by: Jonathan Yong <10walls@gmail.com> --- diff --git a/gcc/testsuite/g++.dg/expr/cast11.C b/gcc/testsuite/g++.dg/expr/cast11.C index baafebb3c73..77d6e5facc4 100644 --- a/gcc/testsuite/g++.dg/expr/cast11.C +++ b/gcc/testsuite/g++.dg/expr/cast11.C @@ -10,6 +10,8 @@ template void g(T const&&) { } struct B { int i; const char c; } b = {}; +typedef __INTPTR_TYPE__ intptr_t; + void f1() { int i = 0; @@ -19,7 +21,7 @@ void f1() f((long* const)&i); // { dg-warning "5:type qualifiers ignored" } f(static_cast(i)); // { dg-warning "5:type qualifiers ignored" } - f(reinterpret_cast(&i)); // { dg-warning "5:type qualifiers ignored" } + f(reinterpret_cast(&i)); // { dg-warning "5:type qualifiers ignored" } f(static_cast(&i)); // { dg-warning "5:type qualifiers ignored" } f(const_cast(&i)); // { dg-warning "5:type qualifiers ignored" } diff --git a/gcc/testsuite/g++.dg/opt/pr55717.C b/gcc/testsuite/g++.dg/opt/pr55717.C index c03badd258f..688b0ae2fb6 100644 --- a/gcc/testsuite/g++.dg/opt/pr55717.C +++ b/gcc/testsuite/g++.dg/opt/pr55717.C @@ -3,6 +3,7 @@ // { dg-options "-O -g" } typedef unsigned uint32_t __attribute__((mode (__SI__))); +typedef __INTPTR_TYPE__ intptr_t; struct DebugOnly {}; template @@ -95,7 +96,7 @@ struct AllocationSiteKey uint32_t offset : 24; int kind; typedef AllocationSiteKey Lookup; - static unsigned hash (AllocationSiteKey key) { return (long (key.script->code + key.offset)) ^ key.kind; } + static unsigned hash (AllocationSiteKey key) { return (intptr_t (key.script->code + key.offset)) ^ key.kind; } }; void TypeCompartment::sweep (FreeOp *) diff --git a/gcc/testsuite/g++.dg/warn/Wunused-value-1.C b/gcc/testsuite/g++.dg/warn/Wunused-value-1.C index 2ba5587fce0..fe34a8c4ea3 100644 --- a/gcc/testsuite/g++.dg/warn/Wunused-value-1.C +++ b/gcc/testsuite/g++.dg/warn/Wunused-value-1.C @@ -2,11 +2,13 @@ // { dg-do compile { target c++11 } } // { dg-options "-Wunused" } +typedef __INTPTR_TYPE__ intptr_t; + void g () { - (long) new int{}; - long(new int{}); - (long) new int(); - long(new int()); + (intptr_t) new int{}; + intptr_t(new int{}); + (intptr_t) new int(); + intptr_t(new int()); }