The g++.dg/DRs/dr2581-?.C tests FAIL on several targets in two ways:
* Both tests FAIL on a couple of targets in the same way:
FAIL: g++.dg/DRs/dr2581-1.C -std=c++11 (test for warnings, line 25)
FAIL: g++.dg/DRs/dr2581-1.C -std=c++17 (test for warnings, line 25)
FAIL: g++.dg/DRs/dr2581-1.C -std=c++20 (test for warnings, line 25)
FAIL: g++.dg/DRs/dr2581-1.C -std=c++23 (test for warnings, line 25)
FAIL: g++.dg/DRs/dr2581-1.C -std=c++26 (test for warnings, line 25)
FAIL: g++.dg/DRs/dr2581-2.C -std=c++11 (test for errors, line 25)
FAIL: g++.dg/DRs/dr2581-2.C -std=c++14 (test for errors, line 25)
FAIL: g++.dg/DRs/dr2581-2.C -std=c++17 (test for errors, line 25)
FAIL: g++.dg/DRs/dr2581-2.C -std=c++20 (test for errors, line 25)
FAIL: g++.dg/DRs/dr2581-2.C -std=c++23 (test for errors, line 25)
FAIL: g++.dg/DRs/dr2581-2.C -std=c++26 (test for errors, line 25)
i.e. the __STDC_ISO_10646__ warning is missing. This happens on
Solaris, FreeBSD, Darwin, and several embedded targets. While
__STDC_ISO_10646__ already exists in C99, it's optional there and
seems to be only defined on Linux/glibc. Thus this patch xfail's this
check on non-Linux.
* Besides, on Solaris only there are more failures for -std=c++11 to
c++26, like
FAIL: g++.dg/DRs/dr2581-2.C -std=c++11 (test for warnings, line 24)
FAIL: g++.dg/DRs/dr2581-2.C -std=c++11 (test for excess errors)
Excess errors:
g++.dg/DRs/dr2581-2.C:24:9: error: '__STDC_VERSION__' redefined
This happens because g++ always predefines __STDC_VERSION__ on
Solaris, so this patch expects an error instead of a warning here.
Tested on i386-pc-solaris2.11, sparc-sun-solaris2.11,
x86_64-apple-darwin25.1.0, and x86_64-pc-linux-gnu.
2025-11-20 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
gcc/testsuite:
* g++.dg/DRs/dr2581-1.C (__STDC_ISO_10646__): xfail on non-Linux.
* g++.dg/DRs/dr2581-2.C: Likewise.
(__STDC_VERSION__): Expect error instead of warning on Solaris.
#undef __STDC__ // { dg-warning "undefining '__STDC__'" }
#undef __STDC_MB_MIGHT_NEQ_WC__ // { dg-warning "undefining '__STDC_MB_MIGHT_NEQ_WC__'" "" { target c++11 } }
#undef __STDC_VERSION__ // { dg-warning "undefining '__STDC_VERSION__'" "" { target c++11 } }
-#undef __STDC_ISO_10646__ // { dg-warning "undefining '__STDC_ISO_10646__'" }
+#undef __STDC_ISO_10646__ // { dg-warning "undefining '__STDC_ISO_10646__'" "" { xfail { ! *-*-linux* } } }
#undef __STDCPP_THREADS__ // { dg-warning "undefining '__STDCPP_THREADS__'" "" { target c++11 } }
#undef __STDCPP_STRICT_POINTER_SAFETY__ // { dg-warning "undefining '__STDCPP_STRICT_POINTER_SAFETY__'" "" { target { c++11 && c++20_down } } }
#undef __cpp_aggregate_bases // { dg-warning "undefining '__cpp_aggregate_bases'" "" { target c++20 } }
#define __TIME__ // { dg-error "'__TIME__' redefined" }
#define __STDC__ // { dg-error "'__STDC__' redefined" }
#define __STDC_MB_MIGHT_NEQ_WC__ // { dg-warning "'__STDC_MB_MIGHT_NEQ_WC__' defined" "" { target c++11 } }
-#define __STDC_VERSION__ // { dg-warning "'__STDC_VERSION__' defined" "" { target c++11 } }
-#define __STDC_ISO_10646__ // { dg-error "'__STDC_ISO_10646__' redefined" }
+#define __STDC_VERSION__ // { dg-warning "'__STDC_VERSION__' defined" "" { target { c++11 && { ! *-*-solaris2* } } } }
+ // { dg-error "'__STDC_VERSION__' redefined" "" { target *-*-solaris2* } .-1 }
+#define __STDC_ISO_10646__ // { dg-error "'__STDC_ISO_10646__' redefined" "" { xfail { ! *-*-linux* } } }
#define __STDCPP_THREADS__ // { dg-message "'__STDCPP_THREADS__' (?:re)?defined" "" { target c++11 } }
#define __STDCPP_STRICT_POINTER_SAFETY__ // { dg-warning "'__STDCPP_STRICT_POINTER_SAFETY__' defined" "" { target { c++11 && c++20_down } } }
#define __cpp_aggregate_bases 201603L // { dg-error "'__cpp_aggregate_bases' redefined" "" { target c++20 } }