diff options
Diffstat (limited to 'gcc/testsuite')
394 files changed, 19038 insertions, 432 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f7893e54ba7..1527b4498c9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,1331 @@ +2019-11-21 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/91355 + * g++.dg/torture/pr91355.C: New test. + + Backported from mainline + 2019-11-20 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/90840 + * gcc.c-torture/compile/pr90840.c: New test. + + PR target/90867 + * gcc.target/i386/pr90867.c: New test. + + PR c/90898 + * gcc.dg/pr90898.c: New test. + + 2019-11-19 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/91450 + * gcc.c-torture/execute/pr91450-1.c: New test. + * gcc.c-torture/execute/pr91450-2.c: New test. + + 2019-11-08 Jakub Jelinek <jakub@redhat.com> + + PR c++/92384 + * g++.dg/torture/pr92384.C: New test. + + 2019-10-31 Jakub Jelinek <jakub@redhat.com> + + PR preprocessor/92296 + * c-c++-common/cpp/pr92296-1.c: New test. + * c-c++-common/cpp/pr92296-2.c: New test. + + 2019-10-29 Jakub Jelinek <jakub@redhat.com> + + PR c++/92201 + * g++.dg/other/pr92201.C: New test. + + 2019-10-17 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/92056 + * gcc.c-torture/compile/pr92056.c: New test. + + 2019-10-04 Jakub Jelinek <jakub@redhat.com> + + PR c++/91974 + * g++.dg/cpp1z/eval-order5.C: New test. + + 2019-09-07 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/91665 + * gcc.dg/vect/pr91665.c: New test. + + 2019-09-05 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/91001 + PR middle-end/91105 + PR middle-end/91106 + * gcc.c-torture/compile/pr91001.c: New test. + + 2019-09-01 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/91623 + * gcc.target/i386/pr91623.c: New test. + + 2019-08-09 Jakub Jelinek <jakub@redhat.com> + + PR c/91401 + * c-c++-common/gomp/pr91401-1.c: New test. + * c-c++-common/gomp/pr91401-2.c: New test. + +2019-11-20 Peter Bergner <bergner@linux.ibm.com> + + Backport from mainline + 2019-11-13 David Edelsohn <dje.gcc@gmail.com> + + * gcc.target/powerpc/pr92090.c: Limit -mbig to powerpc64le-*-*. + * gcc.target/powerpc/pr92090-2.c: Likewise. + + 2019-11-07 Peter Bergner <bergner@linux.ibm.com> + + PR other/92090 + * gcc.target/powerpc/pr92090-2.c: New test. + + 2019-11-07 Peter Bergner <bergner@linux.ibm.com> + + PR other/92090 + * gcc.target/powerpc/pr92090.c: New test. + +2019-11-08 Eric Botcazou <ebotcazou@adacore.com> + + * gcc.c-torture/compile/20191108-1.c: New test. + * gcc.target/sparc/overflow-1.c: Add -fno-pie to the options. + * gcc.target/sparc/overflow-2.c: Likewise. + * gcc.target/sparc/overflow-3.c: Likewise. + * gcc.target/sparc/overflow-4.c: Likewise. + * gcc.target/sparc/overflow-5.c: Likewise. + +2019-11-05 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-06-20 Iain Sandoe <iain@sandoe.co.uk> + + * obj-c++.dg/stubify-1.mm: Adjust options and scan-asm checks. + * obj-c++.dg/stubify-2.mm: Likewise. + * objc.dg/stubify-1.m: Likewise. + * objc.dg/stubify-2.m: Likewise. + +2019-11-03 Iain Sandoe <iain@sandoe.co.uk> + + PR c++/79274 + * g++.dg/tls/pr77285-2.C: XFAIL test for Darwin. + +2019-11-02 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline + 2019-06-13 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.dg/pr90760.c: Require alias support. + +2019-11-01 Delia Burduv <Delia.Burduv@arm.com> + + Backport from trunk + 2019-02-20 Andre Vieira <andre.simoesdiasvieira@arm.com> + + PR target/86487 + * gcc.target/arm/pr86487.c: New. + +2019-10-31 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-10-22 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.dg/Wnonnull.c: Provide prototypes for strlen and memcpy. + Use __SIZE_TYPE__ instead of size_t. + + Backport from mainline. + 2019-10-19 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.dg/Wnonnull.c: Add attributed function declarations for + memcpy and strlen for Darwin. + +2019-10-31 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-10-13 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.target/i386/indirect-thunk-1.c: Allow 'l' or 'L' in + indirection label prefix, for Darwin. + * gcc.target/i386/indirect-thunk-2.c: Likewise. + * gcc.target/i386/indirect-thunk-3.c: Likewise. + * gcc.target/i386/indirect-thunk-4.c: Likewise. + * gcc.target/i386/indirect-thunk-attr-1.c: Likewise. + * gcc.target/i386/indirect-thunk-attr-2.c: Likewise. + * gcc.target/i386/indirect-thunk-attr-3.c: Likewise. + * gcc.target/i386/indirect-thunk-attr-4.c: Likewise. + * gcc.target/i386/indirect-thunk-attr-5.c: Likewise. + * gcc.target/i386/indirect-thunk-attr-6.c: Likewise. + * gcc.target/i386/indirect-thunk-extern-1.c: Likewise. + * gcc.target/i386/indirect-thunk-extern-2.c: Likewise. + * gcc.target/i386/indirect-thunk-extern-3.c: Likewise. + * gcc.target/i386/indirect-thunk-extern-4.c: Likewise. + * gcc.target/i386/indirect-thunk-inline-1.c: Likewise. + * gcc.target/i386/indirect-thunk-inline-2.c: Likewise. + * gcc.target/i386/indirect-thunk-inline-3.c: Likewise. + * gcc.target/i386/indirect-thunk-inline-4.c: Likewise. + * gcc.target/i386/pr32219-2.c: Likewise. + * gcc.target/i386/pr32219-3.c: Likewise. + * gcc.target/i386/pr32219-4.c: Likewise. + * gcc.target/i386/pr32219-7.c: Likewise. + * gcc.target/i386/pr32219-8.c: Likewise. + * gcc.target/i386/ret-thunk-14.c: Likewise. + * gcc.target/i386/ret-thunk-15.c: Likewise. + * gcc.target/i386/ret-thunk-9.c: Likewise. + +2019-10-31 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-08-13 Iain Sandoe <iain@sandoe.co.uk> + + * obj-c++.dg/stubify-1.mm: Rename symbol stub option. + * obj-c++.dg/stubify-2.mm: Likewise. + * objc.dg/stubify-1.m: Likewise. + * objc.dg/stubify-2.m: Likewise. + +2019-10-31 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-05-15 Iain Sandoe <iain@sandoe.co.uk> + + * lib/target-supports.exp + (check_effective_target_powerpc_p8vector_ok): No support for Darwin. + (check_effective_target_powerpc_p9vector_ok): Likewise. + (check_effective_target_powerpc_float128_sw_ok): Likewise. + (check_effective_target_powerpc_float128_hw_ok): Likewise. + (check_effective_target_powerpc_vsx_ok): Likewise. + * gcc.target/powerpc/bfp/bfp.exp: Don't try to run this for Darwin. + * gcc.target/powerpc/dfp/dfp.exp: Likewise. + +2019-10-30 Dragan Mladjenovic <dmladjenovic@wavecomp.com> + + Backport from mainline + 2019-07-09 Dragan Mladjenovic <dmladjenovic@wavecomp.com> + + * gcc.target/mips/cfgcleanup-jalr1.c: New test. + * gcc.target/mips/cfgcleanup-jalr2.c: New test. + * gcc.target/mips/cfgcleanup-jalr3.c: New test. + +2019-10-28 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.c-torture/compile/pr72802.c: Skip for Darwin. + +2019-10-28 Jiufu Guo <guojiufu@linux.ibm.com> + + Backport from mainline + PR target/70010 + * gcc.target/powerpc/pr70010.c: Add -Wno-psabi and -mvsx. + +2019-10-28 Peter Bergner <bergner@linux.ibm.com> + Jiufu Guo <guojiufu@linux.ibm.com> + + PR target/70010 + * gcc.target/powerpc/pr70010.c: New test. + * gcc.target/powerpc/pr70010-1.c: New test. + * gcc.target/powerpc/pr70010-3.c: New test. + * gcc.target/powerpc/pr70010-4.c: New test. + +2019-10-27 Paul Thomas <pault@gcc.gnu.org> + + Backport from mainline + PR fortran/86248 + * gfortran.dg/char_result_19.f90 : New test. + * gfortran.dg/char_result_mod_19.f90 : Module for the new test. + +2019-10-25 Richard Earnshaw <rearnsha@arm.com> + + Backport from mainline + 2019-05-08 Mihail Ionescu <mihail.ionescu@arm.com> + Richard Earnshaw <rearnsha@arm.com> + PR target/88167 + * gcc.target/arm/pr88167-1.c: New test. + * gcc.target/arm/pr88167-2.c: New test. + +2019-10-23 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2019-10-17 Richard Biener <rguenther@suse.de> + + PR debug/91887 + * g++.dg/debug/dwarf2/pr91887.C: New testcase. + + 2019-09-19 Richard Biener <rguenther@suse.de> + + PR tree-optimization/91812 + * gcc.dg/torture/pr91812.c: New testcase. + +2019-10-23 Eric Botcazou <ebotcazou@adacore.com> + + * gcc.c-torture/execute/20191023-1.c: New test. + +2019-10-18 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/69455 + * gfortran.dg/pr69455_1.f90: New test. + * gfortran.dg/pr69455_2.f90: Ditto. + +2019-10-17 Bill Schmidt <wschmidt@linux.ibm.com> + + Backport from mainline + 2019-10-15 Bill Schmidt <wschmidt@linux.ibm.com> + + PR target/92093 + * gcc.target/powerpc/pr91275.c: Fix type and endian issues. + +2019-10-14 Will Schmidt <will_schmidt@vnet.ibm.com> + + Backport from trunk. + 2019-09-26 Will Schmidt <will_schmidt@vnet.ibm.com> + + * gcc.target/powerpc/pure-builtin-redundant-load.c: New. + +2019-10-10 Uroš Bizjak <ubizjak@gmail.com> + + PR target/92022 + * g++.dg/pr92022.C: New test. + +2019-10-07 Thomas Koenig <tkoenig@gcc.gnu.org> + + Backport from trunk + PR fortran/84487 + * gfortran.dg/typebound_call_22.f03: xfail. + +2019-10-07 Bill Schmidt <wschmidt@linux.ibm.com> + + Backport from mainline + 2019-10-01 Bill Schmidt <wschmdit@linux.ibm.com> + + PR target/91275 + * gcc.target/powerpc/pr91275.c: New. + +2019-10-01 Kyrylo Tkachov <kyrylo.tkachov@arm.com> + + Backport from mainline + 2019-09-24 Kyrylo Tkachov <kyrylo.tkachov@arm.com> + + * gcc.target/aarch64/nosplit-di-const-volatile_1.c: New test. + +2019-10-01 Eric Botcazou <ebotcazou@adacore.com> + + * gcc.dg/pr91854.c: New test. + +2019-09-28 Paul Thomas <pault@gcc.gnu.org> + + Backport from mainline + PR fortran/91588 + * gfortran.dg/associate_49.f90 : New test. + +2019-09-25 Kyrylo Tkachov <kyrylo.tkachov@arm.com> + + Backport from mainline + 2019-08-22 Kyrylo Tkachov <kyrylo.tkachov@arm.com> + + * gcc.target/arm/acle/crc_hf_1.c: New test. + +2019-09-20 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-05-11 Iain Sandoe <iain@sandoe.co.uk> + + PR testsuite/81058 + * gcc.target/i386/avx512bw-vpmovswb-1.c: Use regular data section + for variables on Darwin, rather than common. + * gcc.target/i386/avx512bw-vpmovuswb-1.c: Likewise. + * gcc.target/i386/avx512bw-vpmovwb-1.c: Likewise. + +2019-09-18 Thomas Koenig <tkoenig@gcc.gnu.org> + + Backport from trunk + PR fortran/91550 + * gfortran.dg/do_subscript_6.f90: New test. + +2019-09-15 Thomas Koenig <tkoenig@gcc.gnu.org> + + Backport from trunk + PR fortran/91557 + * gfortran.dg/warn_unused_dummy_argument_5.f90: New test. + +2019-09-11 Eric Botcazou <ebotcazou@adacore.com> + + * gcc.target/sparc/20161111-1.c: XFAIL redundant zero-extension test. + +2019-09-09 Jakub Jelinek <jakub@redhat.com> + + PR target/87853 + * gcc.target/i386/pr87853.c: New test. + + PR target/91704 + * gcc.target/i386/pr91704.c: New test. + +2019-09-05 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/91660 + * gfortran.dg/pdt_4.f03: Fix invalid code. + * gfortran.dg/pr91660_1.f90: New test. + * gfortran.dg/pr91660_2.f90: Ditto. + +2019-09-04 Wilco Dijkstra <wdijkstr@arm.com> + + Backport from mainline + 2019-08-13 Wilco Dijkstra <wdijkstr@arm.com> + + PR target/81800 + * gcc.target/aarch64/no-inline-lrint_3.c: New test. + +2019-09-02 Richard Biener <rguenther@suse.de> + + PR testsuite/91619 + * gcc.dg/vect/pr81740-2.c: Restrict to vect_hw_misalign. + +2019-09-01 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-06-15 Iain Sandoe <iain@sandoe.co.uk> + + PR objc/90709 + * obj-c++.dg/proto-lossage-7.mm: Use proxy headers. + * obj-c++.dg/strings/const-cfstring-2.mm: Likewise. + * obj-c++.dg/strings/const-cfstring-5.mm: Likewise + * obj-c++.dg/strings/const-str-12.mm: Likewise. + * obj-c++.dg/syntax-error-1.mm: Likewise. + * obj-c++.dg/torture/strings/const-cfstring-1.mm: Likewise. + * obj-c++.dg/torture/strings/const-str-10.mm: Likewise. + * obj-c++.dg/torture/strings/const-str-11.mm: Likewise. + * obj-c++.dg/torture/strings/const-str-9.mm: Likewise. + * obj-c++.dg/cxx-ivars-3.mm: Skip on later Darwin, where the 10.4 API + in no longer supported, also on m64 where there's no meaning to it. + * obj-c++.dg/isa-field-1.mm: Suppress unwanted warning, add comment why. + * obj-c++.dg/objc-gc-3.mm: Skip for Darwin > 16, the API use is an error + there. + * obj-c++.dg/qual-types-1.mm: Prune a spurious l64 warning. + * obj-c++.dg/stubify-1.mm: Tidy up after better compiler warnings. + * obj-c++.dg/stubify-2.mm: Likewise. + * obj-c++.dg/try-catch-1.mm: Likewise. + * obj-c++.dg/try-catch-3.mm: Likewise. + + Backport from mainline. + 2019-06-15 Iain Sandoe <iain@sandoe.co.uk> + + PR objc/90709 + * objc.dg/encode-7-next-64bit.m: Use proxy headers. + * objc.dg/image-info.m: Likewise. + * objc.dg/method-6.m: Likewise. + * objc.dg/no-extra-load.m: Likewise. + * objc.dg/objc-foreach-4.m: Likewise. + * objc.dg/objc-foreach-5.m: Likewise. + * objc.dg/proto-lossage-7.m: Likewise. + * objc.dg/strings/const-cfstring-2.m: Likewise. + * objc.dg/strings/const-cfstring-5.m: Likewise. + * objc.dg/strings/const-str-12b.m: Likewise. + * objc.dg/symtab-1.m: Likewise. + * objc.dg/torture/strings/const-cfstring-1.m: Likewise. + * objc.dg/torture/strings/const-str-10.m: Likewise. + * objc.dg/torture/strings/const-str-11.m: Likewise. + * objc.dg/torture/strings/const-str-9.m: Likewise. + * objc.dg/zero-link-1.m: Likewise. + * objc.dg/zero-link-2.m: Likewise. + * objc.dg/zero-link-3.m: Likewise. + * objc.dg/isa-field-1.m: Suppress unwanted warning, add comment why. + * objc.dg/headers.m: XFAIL for Darwin14-19. + * objc.dg/objc-gc-4.m: Skip for Darwin > 16, the API use is an error + there. + + Backport from mainline. + 2019-06-15 Iain Sandoe <iain@sandoe.co.uk> + + PR objc/90709 + * objc-obj-c++-shared/CF-CFString.h: New. + * objc-obj-c++-shared/F-NSArray.h: New. + * objc-obj-c++-shared/F-NSAutoreleasePool.h: New. + * objc-obj-c++-shared/F-NSObject.h: New. + * objc-obj-c++-shared/F-NSString.h: New. + * objc-obj-c++-shared/F-NSValue.h: New. + * objc-obj-c++-shared/GNUStep/CoreFoundation/CFArray.h: New. + * objc-obj-c++-shared/GNUStep/CoreFoundation/CFAvailability.h: New. + * objc-obj-c++-shared/GNUStep/CoreFoundation/CFBase.h: New. + * objc-obj-c++-shared/GNUStep/CoreFoundation/CFCharacterSet.h: New. + * objc-obj-c++-shared/GNUStep/CoreFoundation/CFData.h: New. + * objc-obj-c++-shared/GNUStep/CoreFoundation/CFDictionary.h: New. + * objc-obj-c++-shared/GNUStep/CoreFoundation/CFLocale.h: New. + * objc-obj-c++-shared/GNUStep/CoreFoundation/CFString.h: New. + * objc-obj-c++-shared/GNUStep/Foundation/NSArray.h: New. + * objc-obj-c++-shared/GNUStep/Foundation/NSAutoreleasePool.h: New. + * objc-obj-c++-shared/GNUStep/Foundation/NSDate.h: New. + * objc-obj-c++-shared/GNUStep/Foundation/NSEnumerator.h: New. + * objc-obj-c++-shared/GNUStep/Foundation/NSGeometry.h: New. + * objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h: New. + * objc-obj-c++-shared/GNUStep/Foundation/NSObject.h: New. + * objc-obj-c++-shared/GNUStep/Foundation/NSRange.h: New. + * objc-obj-c++-shared/GNUStep/Foundation/NSString.h: New. + * objc-obj-c++-shared/GNUStep/Foundation/NSValue.h: New. + * objc-obj-c++-shared/GNUStep/Foundation/NSZone.h: New. + * objc-obj-c++-shared/GNUStep/GNUstepBase/GNUstep.h: New. + * objc-obj-c++-shared/GNUStep/GNUstepBase/GSBlocks.h: New. + * objc-obj-c++-shared/GNUStep/GNUstepBase/GSConfig.h: New. + * objc-obj-c++-shared/GNUStep/GNUstepBase/GSObjCRuntime.h: New. + * objc-obj-c++-shared/GNUStep/GNUstepBase/GSVersionMacros.h: New. + * objc-obj-c++-shared/GNUStep/GNUstepBase/NSArray+GNUstepBase.h: New. + * objc-obj-c++-shared/GNUStep/GNUstepBase/NSMutableString+GNUstepBase.h: + New. + * objc-obj-c++-shared/GNUStep/GNUstepBase/NSNumber+GNUstepBase.h: New. + * objc-obj-c++-shared/GNUStep/GNUstepBase/NSObject+GNUstepBase.h: New. + * objc-obj-c++-shared/GNUStep/GNUstepBase/NSString+GNUstepBase.h: New. + +2019-09-01 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-07-27 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.target/powerpc/bmi2-bzhi64-1a.c: Add options to enable altivec + and vsx. + +2019-09-01 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-07-25 Iain Sandoe <iain@sandoe.co.uk> + + PR gcov-profile/91087 + * g++.dg/gcov/pr16855.C: Xfail the count lines for the DTORs and the + "final" line for the failure summaries. Adjust source layout so that + dejagnu xfail expressions work. + +2019-09-01 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-07-13 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.target/powerpc/stabs-attrib-vect-darwin.c: Require stabs + support. + +2019-09-01 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-06-24 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.target/powerpc/safe-indirect-jump-1.c: Skip for Darwin. + * gcc.target/powerpc/safe-indirect-jump-7.c: Likewise. + +2019-09-01 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-04-15 Dominique d'Humieres <dominiq@gcc.gnu.org> + + PR tree-optimization/90020 + * gcc.dg/torture/pr90020.c: Add linker options for darwin. + +2019-09-01 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-05-10 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.target/x86_64/abi/avx512f/abi-avx512f.exp: Darwin is + now tested. + * gcc.target/x86_64/abi/avx512f/asm-support-darwin.s: New. + +2019-09-01 Eric Botcazou <ebotcazou@adacore.com> + + * gcc.c-torture/execute/20190901-1.c: New test. + +2019-08-31 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-06-24 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.target/powerpc/spec-barr-1.c: Adjust scan assembler regex + to recognise Darwin's register names. + +2019-08-31 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-06-24 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.dg/cpp/isysroot-1.c: Use <example.h> as the test header. + * gcc.dg/cpp/usr/include/stdio.h: Rename... + * gcc.dg/cpp/usr/include/example.h: ... to this. + +2019-08-31 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-06-23 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.target/powerpc/builtins-2.c: Require VSX hardware support. + +2019-08-31 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-06-23 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.target/powerpc/pr80125.c (foo): Use an unsigned char + vector explicitly for the vec_perm. + +2019-08-31 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-06-23 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.target/powerpc/pr71785.c: For Darwin, make test non-PIC, + expect the out-of-line GPR restore, and test specifically for + absence of branches to local labels. + +2019-08-31 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-06-22 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.target/powerpc/pr64205.c: Require effective target dfp. + * gcc.target/powerpc/pr79909.c: Likewise. + +2019-08-31 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-06-22 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.target/powerpc/darwin-bool-1.c: Suppress the pedantic + warning about _Bool. + +2019-08-31 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-06-13 Iain Sandoe <iain@sandoe.co.uk> + + * g++.dg/pr71694.C: Use non-PIC codegen for Darwin m32. + +2019-08-31 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-06-13 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.dg/darwin-minversion-1.c: Use compile rather than link/run. + * gcc.dg/darwin-minversion-2.c: Likewise. + +2019-08-31 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-06-11 Iain Sandoe <iain@sandoe.co.uk> + + PR testsuite/65364 + * gcc.dg/uninit-19.c (fn1): Adjust target condition for Darwin. + (fn2): Likewise. + +2019-08-31 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-06-06 Iain Sandoe <iain@sandoe.co.uk> + + * g++.dg/cpp0x/alignas4.C: Amend test to check for zerofill syntax + on Darwin. + +2019-08-31 Segher Boessenkool <segher@kernel.crashing.org> + + PR target/91481 + * gcc.target/powerpc/darn-3.c: Fix testcase. + +2019-08-30 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-06-01 Iain Sandoe <iain@sandoe.co.uk> + + PR target/90698 + * gcc.target/i386/pr49866.c: XFAIL for Darwin. + * gcc.target/i386/pr63538.c: Likewise. + * gcc.target/i386/pr61599-1.c: Skip for Darwin. + +2019-08-30 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-05-31 Iain Sandoe <iain@sandoe.co.uk> + + * g++.dg/cpp0x/pr84497.C: Require alias support. + +2019-08-30 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-05-30 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.target/i386/stack-prot-sym.c: Require native TLS support. + +2019-08-30 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-05-27 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.target/i386/pr22076.c: Adjust options to + match codegen expected by the scan-asms. + +2019-08-30 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-05-26 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.target/i386/pr39013-1.c: Adjust scan-asms for PIE to + account for PIC code on Darwin. + * gcc.target/i386/pr39013-2.c: Likewise. + * gcc.target/i386/pr64317.c: Likewise. + +2019-08-30 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-05-25 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.target/i386/pr59874-3.c: Use the spelling of popcnt + expected for Darwin. + +2019-08-30 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-05-25 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.target/i386/pr82659-3.c: Require alias support. + +2019-08-30 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-05-24 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.target/i386/pconfig-1.c: Scan for the string in the generated + code, not in comments or miscellaneous directives. + * gcc.target/i386/wbinvd-1.c: Likewise. + * gcc.target/i386/wbnoinvd-1.c: Likewise. + * gcc.target/i386/pr66819-3.c: Specifically, check that there is no + call to "bar". + * gcc.target/i386/pr66819-4.c: Likewise. + * gcc.target/i386/pr82662.c + +2019-08-30 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-05-24 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.target/i386/pr67985-2.c: Adjust label checks for + Darwin. + * gcc.target/i386/pr77881.c: Likewise. + +2019-08-30 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-05-24 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.target/i386/pr70738-7.c: Likewise. + * gcc.target/i386/pr24414.c: Likewise. + +2019-08-30 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-05-23 Iain Sandoe <iain@sandoe.co.uk> + + PR rtl-optimisation/64895 + * gcc.target/i386/fuse-caller-save-rec.c: Remove XFAILs. + * gcc.target/i386/fuse-caller-save.c: Likewise. + * gcc.target/i386/fuse-caller-save-xmm.c: Adjust tests for + PIC cases, remove XFAILs. + +2019-08-30 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2019-07-08 Richard Biener <rguenther@suse.de> + + PR tree-optimization/91108 + * gcc.dg/tree-ssa/pr91091-1.c: New testcase. + * gcc.dg/tree-ssa/ssa-fre-78.c: Likewise. + +2019-08-30 Segher Boessenkool <segher@kernel.crashing.org> + + Backport from trunk + 2019-08-23 Segher Boessenkool <segher@kernel.crashing.org> + + PR target/91481 + * gcc.target/powerpc/darn-3.c: New testcase. + +2019-08-30 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2018-12-04 Richard Biener <rguenther@suse.de> + + PR tree-optimization/88315 + * gcc.dg/vect/slp-reduc-sad.c: Adjust to provide non-trivial + initial value. + +2019-08-30 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2019-06-18 Richard Biener <rguenther@suse.de> + + PR debug/90900 + * gcc.dg/gomp/pr90900.c: New testcase. + + 2019-04-29 Richard Biener <rguenther@suse.de> + + PR tree-optimization/90278 + * gcc.dg/torture/pr90278.c: New testcase. + + 2019-04-25 Richard Biener <rguenther@suse.de> + + PR middle-end/90194 + * g++.dg/torture/pr90194.C: New testcase. + +2019-08-30 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2019-07-31 Richard Biener <rguenther@suse.de> + + PR tree-optimization/91293 + * gcc.dg/vect/pr91293-1.c: New testcase. + * gcc.dg/vect/pr91293-2.c: Likewise. + * gcc.dg/vect/pr91293-3.c: Likewise. + + 2019-07-31 Richard Biener <rguenther@suse.de> + + PR tree-optimization/91280 + * g++.dg/torture/pr91280.C: New testcase. + + 2019-07-19 Richard Biener <rguenther@suse.de> + + PR tree-optimization/91200 + * gcc.dg/torture/pr91200.c: New testcase. + + 2019-07-15 Richard Biener <rguenther@suse.de> + + PR middle-end/91162 + * gcc.dg/autopar/pr91162.c: New testcase. + + 2019-07-11 Richard Biener <rguenther@suse.de> + + PR middle-end/91131 + * gcc.target/i386/pr91131.c: New testcase. + + 2019-07-10 Richard Biener <rguenther@suse.de> + + PR tree-optimization/91126 + * gcc.dg/torture/pr91126.c: New testcase. + +2019-08-30 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2019-05-06 Richard Biener <rguenther@suse.de> + + PR tree-optimization/90328 + * gcc.dg/torture/pr90328.c: New testcase. + + 2019-02-22 Richard Biener <rguenther@suse.de> + + PR middle-end/87609 + * gcc.dg/torture/restrict-7.c: New testcase. + +2019-08-30 Bin Cheng <bin.linux@linux.alibaba.com> + + Backport from mainline + 2019-07-18 Bin Cheng <bin.linux@linux.alibaba.com> + + PR tree-optimization/91137 + * gcc.c-torture/execute/pr91137.c: New test. + +2019-08-30 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2019-04-08 Richard Biener <rguenther@suse.de> + + PR tree-optimization/90006 + * gcc.dg/vect/bb-slp-pr90006.c: New testcase. + + 2019-04-01 Bin Cheng <bin.cheng@linux.alibaba.com> + + PR tree-optimization/89725 + * gcc.dg/tree-ssa/pr89725.c: New test. + + 2019-03-26 Bin Cheng <bin.cheng@linux.alibaba.com> + + PR tree-optimization/81740 + * gcc.dg/vect/pr81740-1.c: New testcase. + * gcc.dg/vect/pr81740-2.c: Likewise. + +2019-08-30 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2019-04-11 Richard Biener <rguenther@suse.de> + + PR tree-optimization/90020 + * gcc.dg/torture/pr90020.c: New testcase. + +2019-08-29 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-05-22 Iain Sandoe <iain@sandoe.co.uk> + + PR testsuite/27221 + * g++.dg/ext/alignof2.C: XFAIL for 32bit Darwin. + +2019-08-29 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-05-21 Iain Sandoe <iain@sandoe.co.uk> + + PR testsuite/67958 + * gcc.target/i386/pr32219-1.c: Adjust scan-asms for Darwin, comment + the differences. + * gcc.target/i386/pr32219-2.c: Likewise. + * gcc.target/i386/pr32219-3.c: Likewise. + * gcc.target/i386/pr32219-4.c: Likewise. + * gcc.target/i386/pr32219-5.c: Likewise. + * gcc.target/i386/pr32219-6.c: Likewise. + * gcc.target/i386/pr32219-7.c: Likewise. + * gcc.target/i386/pr32219-8.c: Likewise. + +2019-08-29 Jakub Jelinek <jakub@redhat.com> + + Backported from mainline + 2019-07-30 Jakub Jelinek <jakub@redhat.com> + + PR target/91150 + * gcc.target/i386/avx512bw-pr91150.c: New test. + + 2019-07-04 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/78884 + * gcc.dg/gomp/pr78884.c: New test. + + PR rtl-optimization/90756 + * gcc.dg/pr90756.c: New test. + + 2019-06-25 Jakub Jelinek <jakub@redhat.com> + + PR sanitizer/90954 + * c-c++-common/gomp/pr90954.c: New test. + + 2019-06-21 Jakub Jelinek <jakub@redhat.com> + + PR c++/90950 + * g++.dg/gomp/lastprivate-1.C: New test. + + 2019-06-12 Jakub Jelinek <jakub@redhat.com> + + PR c/90760 + * gcc.dg/pr90760.c: New test. + + 2019-06-05 Jakub Jelinek <jakub@redhat.com> + + PR debug/90733 + * gcc.dg/pr90733.c: New test. + + 2019-05-10 Jakub Jelinek <jakub@redhat.com> + + PR pch/90326 + * g++.dg/pch/pr90326.C: New test. + * g++.dg/pch/pr90326.Hs: New file. + + 2019-04-19 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/90139 + * gcc.c-torture/compile/pr90139.c: New test. + +2019-08-28 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-05-21 Iain Sandoe <iain@sandoe.co.uk> + + PR target/63891 + * gcc.dg/darwin-weakimport-3.c: Adjust options and explain + the reasons. + +2019-08-28 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-05-20 Iain Sandoe <iain@sandoe.co.uk> + + PR testsuite/58321 + * gcc.target/i386/memcpy-strategy-3.c: Adjust count for Darwin and + add a comment as to the reason for the difference. + * gcc.target/i386/memset-strategy-1.c: Likewise. + +2019-08-28 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-05-18 Iain Sandoe <iain@sandoe.co.uk> + + * objc.dg/instancetype-0.m: New. + +2019-08-25 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-06-13 Iain Sandoe <iain@sandoe.co.uk> + + * gcc.dg/darwin-minversion-link.c: New test. + +2019-08-23 Mihailo Stojanovic <mistojanovic@wavecomp.com> + + * gcc.target/mips/get-fcsr-3.c: New test. + +2019-08-20 Eric Botcazou <ebotcazou@adacore.com> + + * gcc.c-torture/execute/20190820-1.c: New test. + +2019-08-15 Jonathan Wakely <jwakely@redhat.com> + + Backport from mainline. + 2019-08-14 Jonathan Wakely <jwakely@redhat.com> + + PR c++/91436 + * g++.dg/lookup/missing-std-include-5.C: Limit test to C++14 and up. + * g++.dg/lookup/missing-std-include-6.C: Don't check make_unique in + test that runs for C++11. + * g++.dg/lookup/missing-std-include-8.C: Check make_unique here. + +2019-08-14 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-05-02 Iain Sandoe <iain@sandoe.co.uk> + + * g++.dg/ext/instantiate2.C: Remove special-casing for Darwin. + +2013-08-13 Thomas Koenig <tkoenig@gcc.gnu.org> + + Backport from trunk + PR fortran/90563 + * gfortran.dg/do_subscript_5.f90: New test. + +2019-08-05 Kito Cheng <kito.cheng@sifive.com> + + Backport from mainline + 2019-08-05 Kito Cheng <kito.cheng@sifive.com> + + * gcc.target/riscv/promote-type-for-libcall.c: New. + +2019-08-02 Thomas Koenig <tkoenig@gcc.gnu.org> + Paul Thomas <pault@gcc.gnu.org> + + Backport from trunk + PR fortran/90786 + PR fortran/90813 + * gfortran.dg/proc_ptr_51.f90: New test. + +2019-07-22 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2019-07-22 Martin Liska <mliska@suse.cz> + + PR driver/91172 + * gcc.dg/pr91172.c: New test. + +2019-07-21 Richard Sandiford <richard.sandiford@arm.com> + + Backport from mainline + 2019-07-18 Richard Sandiford <richard.sandiford@arm.com> + + * c-c++-common/pr53633-2.c: New test. + +2019-07-16 Wilco Dijkstra <wdijkstr@arm.com> + + Backport from mainline + PR target/89222 + * gcc.target/arm/pr89222.c: Add new test. + +2019-07-16 Wilco Dijkstra <wdijkstr@arm.com> + + Backport from mainline + 2019-02-04 Wilco Dijkstra <wdijkstr@arm.com> + PR target/89190 + * gcc.target/arm/pr89190.c: New test. + +2019-07-15 Andreas Krebbel <krebbel@linux.ibm.com> + + Backport from mainline + 2019-07-01 Andreas Krebbel <krebbel@linux.ibm.com> + + * gcc.target/s390/vector/vec-shift-2.c: New test. + +2019-07-12 Wilco Dijkstra <wdijkstr@arm.com> + + PR testsuite/78529 + * gcc.c-torture/execute/builtins/builtins.exp: Add -fno-ipa-ra. + +2019-07-07 Paul Thomas <pault@gcc.gnu.org> + + Backport from trunk + PR fortran/91077 + * gfortran.dg/pointer_array_11.f90 : New test. + +2019-07-04 Chenghua Xu <paul.hua.gm@gmail.com> + + Backported from mainline. + * gcc.target/mips/mips-fmadd.c: Rename to ... + * gcc.target/mips/mips-fmadd-o32.c: ... Here; add abi=32. + * gcc.target/mips/mips-fmadd-n64.c: New. + +2019-07-04 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2019-07-03 Martin Liska <mliska@suse.cz> + + PR middle-end/90899 + * gcc.target/i386/pr90899.c: New test. + +2019-06-29 Eric Botcazou <ebotcazou@adacore.com> + + * gnat.dg/specs/array5.ads: New test. + * gnat.dg/specs/array5_pkg1.ads: New helper. + * gnat.dg/specs/array5_pkg2.ads: Likewise. + * gnat.dg/specs/array5_pkg2-g.ads: Likewise. + +2019-06-21 Jeff Law <law@redhat.com> + + Backport fom mainline + 2019-06-21 Jeff Law <law@redhat.com> + + PR tree-optimization/90949 + * gcc.c-torture/execute/pr90949.c: New test. + +2019-06-21 Thomas Koenig <tkoenig@gcc.gnu.org> + + Backport from trunk + PR fortran/90937 + * gfortran.dg/external_procedure_4.f90: New test. + +2019-06-16 Jeff Law <law@redhat.com> + + Backported from mainline + 2019-05-31 Dragan Mladjenovic <dmladjenovic@wavecomp.com> + * gcc.target/mips/msa-fmadd.c: New. + +2019-06-12 Thomas Koenig <tkoenig@gcc.gnu.org> + Tomáš Trnka <trnka@scm.com> + + Backport from trunk + PR fortran/90744 + * gfortran.dg/deferred_character_33.f90: New test. + * gfortran.dg/deferred_character_33a.f90: New test. + +2019-06-11 Jakub Jelinek <jakub@redhat.com> + + PR c++/90810 + * g++.dg/ext/vector37.C: New test. + +2019-06-10 Paul Thomas <pault@gcc.gnu.org> + + Backport from trunk + PR fortran/90498 + * gfortran.dg/associate_48.f90 : New test. + +2019-06-09 Paul Thomas <pault@gcc.gnu.org> + + Backport from trunk + PR fortran/57284 + * gfortran.dg/assign_10.f90: Bump up counts of "atmp". + * gfortran.dg/transpose_optimization_2.f90: Ditto + +2019-06-09 Paul Thomas <pault@gcc.gnu.org> + + Backport from trunk + PR fortran/57284 + * gfortran.dg/class_70.f03 + +2019-06-07 John David Anglin <danglin@gcc.gnu.org> + + * lib/scanasm.exp (dg-function-on-line): Add pattern for hppa*-*-linux*. + +2019-06-07 Iain Sandoe <iain@sandoe.co.uk> + + PR target/82920 + * gcc.target/i386/indirect-thunk-bnd-1.c: Adjust scan-asms for Darwin, + do not use -fno-pic on Darwin. + * gcc.target/i386/indirect-thunk-bnd-2.c: Likewise. + * gcc.target/i386/ret-thunk-25.c: Skip for Darwin, which has a + different ABI for returning this category of complex value. + +2019-06-07 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-05-15 Iain Sandoe <iain@sandoe.co.uk> + + PR target/82920 + * g++.dg/cet-notrack-1.C: Adjust scan assembler for Darwin. + * gcc.target/i386/cet-notrack-5a.c: Likewise. + * gcc.target/i386/cet-notrack-5b.c: Likewise. + * gcc.target/i386/cet-notrack-6b.c: Likewise. + * gcc.target/i386/cet-notrack-icf-1.c: Likewise. + * gcc.target/i386/cet-notrack-icf-2.c: Likewise. + * gcc.target/i386/cet-notrack-icf-3.c: Likewise. + * gcc.target/i386/cet-notrack-icf-4.c: Likewise. + * gcc.target/i386/cet-sjlj-3.c: Likewise. + * gcc.target/i386/cet-sjlj-5.c: Likewise. + +2019-06-07 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-05-14 Iain Sandoe <iain@sandoe.co.uk> + + PR target/82920 + * gcc.target/i386/cet-sjlj-6b.c: Require effective target x32. + * gcc.target/i386/pr52146.c: Likewise. + * gcc.target/i386/pr52698.c: Likewise. + * gcc.target/i386/pr52857-1.c: Likewise. + * gcc.target/i386/pr52857-2.c: Likewise. + * gcc.target/i386/pr52876.c: Likewise. + * gcc.target/i386/pr53698.c: Likewise. + * gcc.target/i386/pr54157.c: Likewise. + * gcc.target/i386/pr55049-1.c: Likewise. + * gcc.target/i386/pr55093.c: Likewise. + * gcc.target/i386/pr55116-1.c: Likewise. + * gcc.target/i386/pr55116-2.c: Likewise. + * gcc.target/i386/pr55597.c: Likewise. + * gcc.target/i386/pr59929.c: Likewise. + * gcc.target/i386/pr66470.c: Likewise. + +2019-06-07 Iain Sandoe <iain@sandoe.co.uk> + + Backport from mainline. + 2019-05-12 Iain Sandoe <iain@sandoe.co.uk> + Dominique d'Humieres <dominiq@gcc.gnu.org> + + PR target/82920 + * gcc.target/i386/indirect-thunk-1.c: Adjust scan-asms for Darwin, + do not use -fno-pic on Darwin. + * gcc.target/i386/indirect-thunk-2.c: Likewise. + * gcc.target/i386/indirect-thunk-3.c: Likewise. + * gcc.target/i386/indirect-thunk-4.c: Likewise. + * gcc.target/i386/indirect-thunk-7.c: Likewise. + * gcc.target/i386/indirect-thunk-attr-1.c: Likewise. + * gcc.target/i386/indirect-thunk-attr-2.c: Likewise. + * gcc.target/i386/indirect-thunk-attr-3.c: Likewise. + * gcc.target/i386/indirect-thunk-attr-4.c: Likewise. + * gcc.target/i386/indirect-thunk-attr-5.c: Likewise. + * gcc.target/i386/indirect-thunk-attr-6.c: Likewise. + * gcc.target/i386/indirect-thunk-attr-7.c: Likewise. + * gcc.target/i386/indirect-thunk-attr-8.c: Likewise. + * gcc.target/i386/indirect-thunk-extern-1.c: Likewise. + * gcc.target/i386/indirect-thunk-extern-2.c: Likewise. + * gcc.target/i386/indirect-thunk-extern-3.c: Likewise. + * gcc.target/i386/indirect-thunk-extern-4.c: Likewise. + * gcc.target/i386/indirect-thunk-extern-7.c: Likewise. + * gcc.target/i386/indirect-thunk-inline-1.c: Likewise. + * gcc.target/i386/indirect-thunk-inline-2.c: Likewise. + * gcc.target/i386/indirect-thunk-inline-3.c: Likewise. + * gcc.target/i386/indirect-thunk-inline-4.c: Likewise. + * gcc.target/i386/indirect-thunk-inline-7.c: Likewise. + * gcc.target/i386/indirect-thunk-register-1.c: Likewise. + * gcc.target/i386/indirect-thunk-register-2.c: Likewise. + * gcc.target/i386/indirect-thunk-register-3.c: Likewise. + * gcc.target/i386/indirect-thunk-register-4.c: Likewise. + * gcc.target/i386/ret-thunk-1.c: Likewise. + * gcc.target/i386/ret-thunk-10.c: Likewise. + * gcc.target/i386/ret-thunk-11.c: Likewise. + * gcc.target/i386/ret-thunk-12.c: Likewise. + * gcc.target/i386/ret-thunk-13.c: Likewise. + * gcc.target/i386/ret-thunk-14.c: Likewise. + * gcc.target/i386/ret-thunk-15.c: Likewise. + * gcc.target/i386/ret-thunk-16.c: Likewise. + * gcc.target/i386/ret-thunk-2.c: Likewise. + * gcc.target/i386/ret-thunk-22.c: Likewise. + * gcc.target/i386/ret-thunk-23.c: Likewise. + * gcc.target/i386/ret-thunk-24.c: Likewise. + * gcc.target/i386/ret-thunk-3.c: Likewise. + * gcc.target/i386/ret-thunk-4.c: Likewise. + * gcc.target/i386/ret-thunk-5.c: Likewise. + * gcc.target/i386/ret-thunk-6.c: Likewise. + * gcc.target/i386/ret-thunk-7.c: Likewise. + * gcc.target/i386/ret-thunk-8.c: Likewise. + * gcc.target/i386/ret-thunk-9.c: Likewise. + +2019-05-28 Eric Botcazou <ebotcazou@adacore.com> + + * gnat.dg/opt79.ad[sb]: New test. + +2019-05-27 Eric Botcazou <ebotcazou@adacore.com> + + * gnat.dg/specs/array4.ads: New test. + +2019-05-27 Eric Botcazou <ebotcazou@adacore.com> + + * gnat.dg/unchecked_convert13.adb: New test. + +2019-05-24 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2019-05-23 Martin Liska <mliska@suse.cz> + + PR sanitizer/90570 + * g++.dg/asan/pr90570.C: New test. + +2019-05-23 Eric Botcazou <ebotcazou@adacore.com> + + * gnat.dg/opt78.ad[sb]: New test. + +2019-05-23 Uroš Bizjak <ubizjak@gmail.com> + + Backported from mainline + 2019-05-21 Uroš Bizjak <ubizjak@gmail.com> + + PR target/90547 + * gcc.target/i386/pr90547.c: New test. + +2019-05-22 Eric Botcazou <ebotcazou@adacore.com> + + * g++.dg/tls/pr85400.C: New test. + +2019-05-20 Jeff Law <law@redhat.com> + + Backported from mainline + 2019-05-17 Dragan Mladjenovic <dmladjenovic@wavecomp.com> + + * g++.dg/eh/o32-fp.C: New. + * gcc.target/mips/dwarfregtable-1.c: New. + * gcc.target/mips/dwarfregtable-2.c: New. + * gcc.target/mips/dwarfregtable-3.c: New. + * gcc.target/mips/dwarfregtable-4.c: New. + * gcc.target/mips/dwarfregtable.h: New. + +2019-05-20 Jonathan Wakely <jwakely@redhat.com> + + Backported from mainline + 2019-05-20 Jonathan Wakely <jwakely@redhat.com> + + PR c++/90532 Ensure __is_constructible(T[]) is false + * g++.dg/ext/90532.C: New test. + +2019-05-16 Kelvin Nilsen <kelvin@gcc.gnu.org> + + Backport from mainline. + 2019-05-07 Kelvin Nilsen <kelvin@gcc.gnu.org> + + PR target/89765 + * gcc.target/powerpc/pr89765-mc.c: New test. + * gcc.target/powerpc/vsx-builtin-10c.c: New test. + * gcc.target/powerpc/vsx-builtin-10d.c: New test. + * gcc.target/powerpc/vsx-builtin-11c.c: New test. + * gcc.target/powerpc/vsx-builtin-11d.c: New test. + * gcc.target/powerpc/vsx-builtin-12c.c: New test. + * gcc.target/powerpc/vsx-builtin-12d.c: New test. + * gcc.target/powerpc/vsx-builtin-13c.c: New test. + * gcc.target/powerpc/vsx-builtin-13d.c: New test. + * gcc.target/powerpc/vsx-builtin-14c.c: New test. + * gcc.target/powerpc/vsx-builtin-14d.c: New test. + * gcc.target/powerpc/vsx-builtin-15c.c: New test. + * gcc.target/powerpc/vsx-builtin-15d.c: New test. + * gcc.target/powerpc/vsx-builtin-16c.c: New test. + * gcc.target/powerpc/vsx-builtin-16d.c: New test. + * gcc.target/powerpc/vsx-builtin-17c.c: New test. + * gcc.target/powerpc/vsx-builtin-17d.c: New test. + * gcc.target/powerpc/vsx-builtin-18c.c: New test. + * gcc.target/powerpc/vsx-builtin-18d.c: New test. + * gcc.target/powerpc/vsx-builtin-19c.c: New test. + * gcc.target/powerpc/vsx-builtin-19d.c: New test. + * gcc.target/powerpc/vsx-builtin-20c.c: New test. + * gcc.target/powerpc/vsx-builtin-20d.c: New test. + * gcc.target/powerpc/vsx-builtin-9c.c: New test. + * gcc.target/powerpc/vsx-builtin-9d.c: New test. + +2019-05-08 Kelvin Nilsen <kelvin@gcc.gnu.org> + + Backport from mainline. + 2019-05-06 Kelvin Nilsen <kelvin@gcc.gnu.org> + + PR target/89424 + * gcc.target/powerpc/pr89424-0.c: New test. + * gcc.target/powerpc/vsx-builtin-13a.c: Define macro PR89424 to + enable testing of newly patched capability. + * gcc.target/powerpc/vsx-builtin-13b.c: Likewise. + * gcc.target/powerpc/vsx-builtin-20a.c: Likewise. + * gcc.target/powerpc/vsx-builtin-20b.c: Likewise. + 2019-05-06 Richard Biener <rguenther@suse.de> PR bootstrap/90359 diff --git a/gcc/testsuite/c-c++-common/cpp/pr92296-1.c b/gcc/testsuite/c-c++-common/cpp/pr92296-1.c new file mode 100644 index 00000000000..4bd69c8be87 --- /dev/null +++ b/gcc/testsuite/c-c++-common/cpp/pr92296-1.c @@ -0,0 +1,32 @@ +/* PR preprocessor/92296 */ +/* { dg-do preprocess } */ + +#pragma push_macro("__TIMESTAMP__") +#pragma pop_macro("__TIMESTAMP__") + +#pragma push_macro("__TIME__") +#pragma pop_macro("__TIME__") + +#pragma push_macro("__DATE__") +#pragma pop_macro("__DATE__") + +#pragma push_macro("__FILE__") +#pragma pop_macro("__FILE__") + +#pragma push_macro("__BASE_FILE__") +#pragma pop_macro("__BASE_FILE__") + +#pragma push_macro("__LINE__") +#pragma pop_macro("__LINE__") + +#pragma push_macro("__INCLUDE_LEVEL__") +#pragma pop_macro("__INCLUDE_LEVEL__") + +#pragma push_macro("__COUNTER__") +#pragma pop_macro("__COUNTER__") + +#pragma push_macro("__has_attribute") +#pragma pop_macro("__has_attribute") + +#pragma push_macro("__has_cpp_attribute") +#pragma pop_macro("__has_cpp_attribute") diff --git a/gcc/testsuite/c-c++-common/cpp/pr92296-2.c b/gcc/testsuite/c-c++-common/cpp/pr92296-2.c new file mode 100644 index 00000000000..15362a4bdc3 --- /dev/null +++ b/gcc/testsuite/c-c++-common/cpp/pr92296-2.c @@ -0,0 +1,73 @@ +/* PR preprocessor/92296 */ +/* { dg-do preprocess } */ +/* { dg-options "-Wno-builtin-macro-redefined" } */ + +#pragma push_macro("__TIMESTAMP__") +#undef __TIMESTAMP__ +#define __TIMESTAMP__ "Thu Oct 31 12:00:00 2019" +timestamp1 = __TIMESTAMP__ +#pragma pop_macro("__TIMESTAMP__") +timestamp2 = __TIMESTAMP__ + +#pragma push_macro("__TIME__") +#undef __TIME__ +#define __TIME__ "12:00:00" +time1 = __TIME__ +#pragma pop_macro("__TIME__") +time2 = __TIME__ + +#pragma push_macro("__DATE__") +#undef __DATE__ +#define __DATE__ "Oct 31 2019" +date1 = __DATE__ +#pragma pop_macro("__DATE__") +date2 = __DATE__ + +#pragma push_macro("__FILE__") +#undef __FILE__ +#define __FILE__ "pr92296-3.c" +file1 = __FILE__ /* { dg-final { scan-file pr92296-2.i "file1 = \"pr92296-3.c\"" } } */ +#pragma pop_macro("__FILE__") +file2 = __FILE__ /* { dg-final { scan-file-not pr92296-2.i "file2 = \"pr92296-3.c\"" } } */ + +#pragma push_macro("__BASE_FILE__") +#undef __BASE_FILE__ +#define __BASE_FILE__ "pr92296-4.c" +filebase1 = __BASE_FILE__ /* { dg-final { scan-file pr92296-2.i "filebase1 = \"pr92296-4.c\"" } } */ +#pragma pop_macro("__BASE_FILE__") +filebase2 = __BASE_FILE__ /* { dg-final { scan-file-not pr92296-2.i "filebase2 = \"pr92296-4.c\"" } } */ + +#pragma push_macro("__LINE__") +#undef __LINE__ /* { dg-warning "undefining" } */ +#define __LINE__ 142 +line1 = __LINE__ /* { dg-final { scan-file pr92296-2.i "line1 = 142" } } */ +#pragma pop_macro("__LINE__") +line2 = __LINE__ /* { dg-final { scan-file pr92296-2.i "line2 = 45" } } */ + +#pragma push_macro("__INCLUDE_LEVEL__") +#undef __INCLUDE_LEVEL__ /* { dg-warning "undefining" } */ +#define __INCLUDE_LEVEL__ 42 +includelevel1 = __INCLUDE_LEVEL__ /* { dg-final { scan-file pr92296-2.i "includelevel1 = 42" } } */ +#pragma pop_macro("__INCLUDE_LEVEL__") +includelevel2 = __INCLUDE_LEVEL__ /* { dg-final { scan-file pr92296-2.i "includelevel2 = 0" } } */ + +#pragma push_macro("__COUNTER__") +#undef __COUNTER__ /* { dg-warning "undefining" } */ +#define __COUNTER__ 172 +counter1 = __COUNTER__ /* { dg-final { scan-file pr92296-2.i "counter1 = 172" } } */ +#pragma pop_macro("__COUNTER__") +counter2 = __COUNTER__ /* { dg-final { scan-file-not pr92296-2.i "counter2 = 172" } } */ + +#pragma push_macro("__has_attribute") +#undef __has_attribute /* { dg-warning "undefining" } */ +#define __has_attribute(x) 0 +hasattr1 = __has_attribute(noreturn) /* { dg-final { scan-file pr92296-2.i "hasattr1 = 0" } } */ +#pragma pop_macro("__has_attribute") +hasattr2 = __has_attribute(noreturn) /* { dg-final { scan-file-not pr92296-2.i "hasattr2 = 0" } } */ + +#pragma push_macro("__has_cpp_attribute") +#undef __has_cpp_attribute /* { dg-warning "undefining" } */ +#define __has_cpp_attribute(x) 0 +hasattrcpp1 = __has_cpp_attribute(noreturn) /* { dg-final { scan-file pr92296-2.i "hasattrcpp1 = 0" } } */ +#pragma pop_macro("__has_cpp_attribute") +hasattrcpp2 = __has_cpp_attribute(noreturn) /* { dg-final { scan-file-not pr92296-2.i "hasattrcpp2 = 0" } } */ diff --git a/gcc/testsuite/c-c++-common/gomp/pr90954.c b/gcc/testsuite/c-c++-common/gomp/pr90954.c new file mode 100644 index 00000000000..cc3a6e9e52a --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr90954.c @@ -0,0 +1,27 @@ +/* PR sanitizer/90954 */ +/* { dg-do compile } */ +/* { dg-options "-fopenmp -fsanitize=undefined" } */ + +float v; +int i; + +void +foo (float x, float y) +{ + #pragma omp atomic + v += x / y; +} + +void +bar (int x, int y) +{ + #pragma omp atomic + i += x / y; +} + +void +baz (int x, int y) +{ + #pragma omp atomic + i *= (x << y); +} diff --git a/gcc/testsuite/c-c++-common/gomp/pr91401-1.c b/gcc/testsuite/c-c++-common/gomp/pr91401-1.c new file mode 100644 index 00000000000..f588bf6f16c --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr91401-1.c @@ -0,0 +1,10 @@ +/* PR c/91401 */ + +void +foo (void) +{ + int i; + #pragma omp distribute parallel for schedule (static) dist_schedule (static) + for (i = 0; i < 64; i++) + ; +} diff --git a/gcc/testsuite/c-c++-common/gomp/pr91401-2.c b/gcc/testsuite/c-c++-common/gomp/pr91401-2.c new file mode 100644 index 00000000000..f537e66e27c --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr91401-2.c @@ -0,0 +1,15 @@ +#pragma omp declare target +void f0 (void); + +void +f1 (void) +{ + int i; + #pragma omp distribute dist_schedule(static) dist_schedule(static) /* { dg-warning "too many 'dist_schedule' clauses" } */ + for (i = 0; i < 8; ++i) + f0 (); + #pragma omp distribute dist_schedule(static,2) dist_schedule(static,4) /* { dg-warning "too many 'dist_schedule' clauses" } */ + for (i = 0; i < 8; ++i) + f0 (); +} +#pragma omp end declare target diff --git a/gcc/testsuite/c-c++-common/pr53633-2.c b/gcc/testsuite/c-c++-common/pr53633-2.c new file mode 100644 index 00000000000..c26cb10cc83 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr53633-2.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target naked_functions } */ +/* { dg-options "-O2 -Wall" } */ +/* Check that we do not get warnings about missing return statements + or bogus looking noreturn functions. */ +static int __attribute__((naked)) +foo (void) +{ + __asm__ (""); +} + +static int __attribute__((naked,noreturn)) +bar (void) +{ + __asm__ (""); +} + +int foo_caller (void) { return foo (); } +int bar_caller (void) { return bar (); } diff --git a/gcc/testsuite/g++.dg/asan/pr90570.C b/gcc/testsuite/g++.dg/asan/pr90570.C new file mode 100644 index 00000000000..c2366905516 --- /dev/null +++ b/gcc/testsuite/g++.dg/asan/pr90570.C @@ -0,0 +1,18 @@ +/* PR sanitizer/90570 */ +/* { dg-do run } */ + +#include <vector> + +struct stru +{ + std::vector<int> v{1,2,3,4}; + int i{5}; +}; + +int main() +{ + stru s1; + stru s2; + + return 0; +} diff --git a/gcc/testsuite/g++.dg/cet-notrack-1.C b/gcc/testsuite/g++.dg/cet-notrack-1.C index eab0946d477..ee98fd43d58 100644 --- a/gcc/testsuite/g++.dg/cet-notrack-1.C +++ b/gcc/testsuite/g++.dg/cet-notrack-1.C @@ -1,7 +1,7 @@ /* { dg-do compile { target i?86-*-* x86_64-*-* } } */ /* { dg-options "-fcf-protection" } */ /* { dg-final { scan-assembler "endbr32|endbr64" } } */ -/* { dg-final { scan-assembler-times "\tcall\[ \t]+puts" 2 } } */ +/* { dg-final { scan-assembler-times "\tcall\[ \t]+_?puts" 2 } } */ /* { dg-final { scan-assembler-times "notrack call\[ \t]+" 1 } } */ #include <stdio.h> diff --git a/gcc/testsuite/g++.dg/concepts/no-bool1.C b/gcc/testsuite/g++.dg/concepts/no-bool1.C new file mode 100644 index 00000000000..be9b73a0689 --- /dev/null +++ b/gcc/testsuite/g++.dg/concepts/no-bool1.C @@ -0,0 +1,4 @@ +// { dg-do compile { target c++14 } } +// { dg-additional-options -fconcepts } + +template <class T> concept True = true; diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas4.C b/gcc/testsuite/g++.dg/cpp0x/alignas4.C index b66fa651bc2..1ef48707586 100644 --- a/gcc/testsuite/g++.dg/cpp0x/alignas4.C +++ b/gcc/testsuite/g++.dg/cpp0x/alignas4.C @@ -1,7 +1,13 @@ // PR c++/59012 // { dg-do compile { target c++11 } } // { dg-final { scan-assembler "align 8" { target { { i?86-*-* x86_64-*-* } && { { ! ia32 } && { ! *-*-darwin* } } } } } } -// { dg-final { scan-assembler "align 4" { target ia32 } } } +// { dg-final { scan-assembler "align 4" { target { ia32 && { ! *-*-darwin* } } } } } + +// Darwin produces aligned .zerofill directives for these. +// { dg-final { scan-assembler {zerofill[^\n\r]+_a,4,2} { target { ilp32 && *-*-darwin* } } } } +// { dg-final { scan-assembler {zerofill[^\n\r]+_a,8,3} { target { lp64 && *-*-darwin* } } } } +// { dg-final { scan-assembler {zerofill[^\n\r]+_a2,4,2} { target { ilp32 && *-*-darwin* } } } } +// { dg-final { scan-assembler {zerofill[^\n\r]+_a2,8,3} { target { lp64 && *-*-darwin* } } } } template <class... T> struct A diff --git a/gcc/testsuite/g++.dg/cpp0x/pr84497.C b/gcc/testsuite/g++.dg/cpp0x/pr84497.C index cb9d233bf71..ea7cea47a81 100644 --- a/gcc/testsuite/g++.dg/cpp0x/pr84497.C +++ b/gcc/testsuite/g++.dg/cpp0x/pr84497.C @@ -1,6 +1,7 @@ // PR 84497 mismatch with thread constructor fn weakness // { dg-do compile { target c++11 } } // { dg-require-weak "" } +// { dg-require-alias "" } struct Base { diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction58.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction58.C new file mode 100644 index 00000000000..82c3f83710f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction58.C @@ -0,0 +1,16 @@ +// PR c++/86098 +// { dg-additional-options -std=c++17 } + +template <class _Res> class future; +template <class T> T&& declval(); + +template<template <class...> class T> +struct construct_deduced { + template <class... AN> + using deduced_t = decltype(T{declval<AN>()...}); + template<class... AN> + deduced_t<AN...> operator()(AN&&... an) const; +}; + +template<class T> +future<T> future_from(T singleSender); diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp50.C b/gcc/testsuite/g++.dg/cpp1z/decomp50.C new file mode 100644 index 00000000000..5400a826948 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/decomp50.C @@ -0,0 +1,51 @@ +// PR c++/92106 - ICE with structured bindings and -Wreturn-local-addr. +// { dg-do compile { target c++17 } } + +template <typename> struct B; +template <typename _Tp> struct B<_Tp *> { typedef _Tp& reference; }; +struct C { + template <typename _Up> using rebind = _Up *; +}; +template <typename _Iterator, typename> class D { +public: + typename B<_Iterator>::reference operator*(); + void operator++(); +}; + +template <typename _Iterator, typename _Container> +bool operator!=(D<_Iterator, _Container>, D<_Iterator, _Container>); +template <typename _Tp> class F { +public: + typedef _Tp value_type; +}; + +template <typename _Alloc> struct G { + template <typename _Tp> struct H { using type = C::rebind<_Tp>; }; + using const_pointer = typename H<typename _Alloc::value_type>::type; +}; +template <typename _Tp, typename _Alloc = F<_Tp>> class I { + typedef D<typename G<_Alloc>::const_pointer, int> const_iterator; + +public: + const_iterator begin(); + const_iterator end(); +}; + +struct A { + struct J { + int name; + int value; + }; + I<J> members; + template <typename Key> const int *find(Key) { + for (const auto &[name, value] : members) + // See <https://gcc.gnu.org/ml/gcc-patches/2019-10/msg01107.html> + // for why we don't warn here. + return &value; // { dg-bogus "address of local variable" } + return nullptr; + } +}; +int main() { + A a; + a.find(""); +} diff --git a/gcc/testsuite/g++.dg/cpp1z/eval-order5.C b/gcc/testsuite/g++.dg/cpp1z/eval-order5.C new file mode 100644 index 00000000000..a8f06ed421a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/eval-order5.C @@ -0,0 +1,31 @@ +// PR c++/91974 +// { dg-do run } +// { dg-options "-fstrong-eval-order" } + +extern "C" void abort (); + +bool ok = false; + +void +foo (int x) +{ + if (x != 0) + abort (); + ok = true; +} + +void +bar (int) +{ + abort (); +} + +int +main () +{ + typedef void (*T) (int); + T fn = foo; + fn ((fn = bar, 0)); + if (fn != bar || !ok) + abort (); +} diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/pr91887.C b/gcc/testsuite/g++.dg/debug/dwarf2/pr91887.C new file mode 100644 index 00000000000..6cd99cc9bb8 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/pr91887.C @@ -0,0 +1,12 @@ +// { dg-do compile } +// { dg-require-effective-target c++11 } +// { dg-options "-g -fdebug-types-section" } +class A { +public: + A(); + template <typename U> A(U); +}; +template <class> struct B { typedef A type; }; +template <class R, typename... Args> +int Bind(R(Args...), typename B<Args>::type...) { return 0; } +void KeepBufferRefs(A, A) { A a, b(Bind(KeepBufferRefs, a, b)); } diff --git a/gcc/testsuite/g++.dg/eh/o32-fp.C b/gcc/testsuite/g++.dg/eh/o32-fp.C new file mode 100644 index 00000000000..08fa51bc203 --- /dev/null +++ b/gcc/testsuite/g++.dg/eh/o32-fp.C @@ -0,0 +1,47 @@ +// Test whether call saved float are restored properly for O32 ABI +// { dg-do run { target { { { mips*-*-linux* } && hard_float } && { ! mips64 } } } } +// { dg-options "-O2" } + +void __attribute__((noinline)) +bar (void) +{ + throw 1; +} + +void __attribute__((noinline)) +foo (void) +{ + register double f20 __asm__ ("f20") = 0.0; + register double f22 __asm__ ("f22") = 0.0; + register double f24 __asm__ ("f24") = 0.0; + register double f26 __asm__ ("f26") = 0.0; + register double f28 __asm__ ("f28") = 0.0; + register double f30 __asm__ ("f30") = 0.0; + __asm__ __volatile__("":"+f"(f20),"+f"(f22),"+f"(f24),"+f"(f26),"+f"(f30)); + bar (); +} + +int +main (void) +{ + register double f20 __asm__ ("f20") = 12.0; + register double f22 __asm__ ("f22") = 13.0; + register double f24 __asm__ ("f24") = 14.0; + register double f26 __asm__ ("f26") = 15.0; + register double f28 __asm__ ("f28") = 16.0; + register double f30 __asm__ ("f30") = 17.0; + + try + { + foo (); + } + catch (...) + { + __asm__ ("":"+f"(f20),"+f"(f22),"+f"(f24),"+f"(f26),"+f"(f30)); + } + + if (f20 != 12.0 || f22 != 13.0 || f24 != 14.0 + || f26 != 15.0 || f28 != 16.0 || f30 != 17.0) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/g++.dg/ext/90532.C b/gcc/testsuite/g++.dg/ext/90532.C new file mode 100644 index 00000000000..acdc4e2b07e --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/90532.C @@ -0,0 +1,27 @@ +// { dg-do compile { target c++11 } } +// PR c++/90532 +static_assert( !__is_constructible(int[]), "" ); +static_assert( !__is_constructible(int[], int), "" ); +static_assert( !__is_constructible(int[], int[]), "" ); +static_assert( !__is_trivially_constructible(int[]), "" ); +static_assert( !__is_trivially_constructible(int[], int), "" ); +static_assert( !__is_trivially_constructible(int[], int[]), "" ); +static_assert( !__is_trivially_constructible(int[], int(&)[]), "" ); +static_assert( !__is_trivially_constructible(int[], void), "" ); +struct A { }; +static_assert( !__is_constructible(A[]), "" ); +static_assert( !__is_constructible(A[], const A&), "" ); +static_assert( !__is_constructible(A[], const A[]), "" ); +static_assert( !__is_trivially_constructible(A[]), "" ); +static_assert( !__is_trivially_constructible(A[], const A&), "" ); +static_assert( !__is_trivially_constructible(A[], const A[]), "" ); +static_assert( !__is_trivially_constructible(A[], A(&)[]), "" ); +static_assert( !__is_trivially_constructible(A[], void), "" ); +struct B { B(); }; +static_assert( !__is_constructible(B[]), "" ); +static_assert( !__is_constructible(B[], const B&), "" ); +static_assert( !__is_trivially_constructible(B[]), "" ); +static_assert( !__is_trivially_constructible(B[], const B&), "" ); +static_assert( !__is_trivially_constructible(B[], const B[]), "" ); +static_assert( !__is_trivially_constructible(B[], B(&)[]), "" ); +static_assert( !__is_trivially_constructible(B[], void), "" ); diff --git a/gcc/testsuite/g++.dg/ext/alignof2.C b/gcc/testsuite/g++.dg/ext/alignof2.C index 22175902f83..bd56cf627a4 100644 --- a/gcc/testsuite/g++.dg/ext/alignof2.C +++ b/gcc/testsuite/g++.dg/ext/alignof2.C @@ -3,7 +3,7 @@ // wrong for some fields. // { dg-do run } -// { dg-xfail-run-if "AIX ABI increases struct alignment for first member double" { powerpc-ibm-aix* } } +// { dg-xfail-run-if "AIX/Darwin ABI increases struct alignment for first member double" { powerpc-ibm-aix* || { ilp32 && powerpc-*-darwin* } } } extern "C" void abort(); diff --git a/gcc/testsuite/g++.dg/ext/instantiate2.C b/gcc/testsuite/g++.dg/ext/instantiate2.C index a6292892b38..97ef45c874d 100644 --- a/gcc/testsuite/g++.dg/ext/instantiate2.C +++ b/gcc/testsuite/g++.dg/ext/instantiate2.C @@ -8,8 +8,7 @@ template <class T> struct A { template <class T> T A<T>::t = 0; static template struct A<int>; -// { dg-final { scan-assembler "\n_?_ZN1AIiE1tE(:|\n|\t)" { target { ! *-*-darwin* } } } } -// { dg-final { scan-assembler ".zerofill __DATA,__pu_bss2,__ZN1AIiE1tE" { target *-*-darwin* } } } +// { dg-final { scan-assembler "\n_?_ZN1AIiE1tE(:|\n|\t)" } } void test_int() { A<int>::t = 42; } // { dg-final { scan-assembler-not "\n_?_ZN1AIcE1tE(:|\n|\t)" } } diff --git a/gcc/testsuite/g++.dg/ext/vector37.C b/gcc/testsuite/g++.dg/ext/vector37.C new file mode 100644 index 00000000000..a7baf8d33f9 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/vector37.C @@ -0,0 +1,29 @@ +// PR c++/90810 +// { dg-do run } + +void +foo (float x, float y) +{ + typedef float __attribute__ ((__vector_size__ (4 * sizeof (float)), __may_alias__)) V; + const V a = { x, x, x, x }, b = { y, y, y, y }; + const V c = a / b; + if (c[0] != 6.0f || c[1] != 6.0f || c[2] != 6.0f || c[3] != 6.0f) + __builtin_abort (); +} + +void +bar (float y) +{ + typedef float __attribute__ ((__vector_size__ (4 * sizeof (float)), __may_alias__)) V; + const V a = { 7.0f, 8.0f, 9.0f, 10.0f }, b = { 1.0f, 2.0f, 3.0f, y }; + const V c = a / b; + if (c[0] != 7.0f || c[1] != 4.0f || c[2] != 3.0f || c[3] != 5.0f) + __builtin_abort (); +} + +int +main () +{ + foo (12.0f, 2.0f); + bar (2.0f); +} diff --git a/gcc/testsuite/g++.dg/gcov/pr16855.C b/gcc/testsuite/g++.dg/gcov/pr16855.C index d7aa8a4f72c..a68b05cb571 100644 --- a/gcc/testsuite/g++.dg/gcov/pr16855.C +++ b/gcc/testsuite/g++.dg/gcov/pr16855.C @@ -1,6 +1,8 @@ /* { dg-options "-fprofile-arcs -ftest-coverage" } */ /* { dg-do run { target native } } */ +/* See PR91087 for information on Darwin xfails. */ + #include <stdlib.h> #include <stdio.h> @@ -18,7 +20,9 @@ class Test { public: Test (void) { fprintf (stderr, "In Test::Test\n"); /* count(1) */ } - ~Test (void) { fprintf (stderr, "In Test::~Test\n"); /* count(1) */ } + ~Test (void) { + fprintf (stderr, "In Test::~Test\n"); /* count(1) { xfail *-*-darwin* } */ + } } T1; void @@ -42,7 +46,7 @@ static void __attribute__ ((constructor)) ctor_default () static void __attribute__ ((destructor)) dtor_default () { - fprintf (stderr, "in destructor(())\n"); /* count(1) */ + fprintf (stderr, "in destructor(())\n"); /* count(1) { xfail *-*-darwin* } */ } -/* { dg-final { run-gcov branches { -b pr16855.C } } } */ +/* { dg-final { run-gcov branches { -b pr16855.C } { xfail *-*-darwin* } } } */ diff --git a/gcc/testsuite/g++.dg/gomp/lastprivate-1.C b/gcc/testsuite/g++.dg/gomp/lastprivate-1.C new file mode 100644 index 00000000000..ce25e1a6b90 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/lastprivate-1.C @@ -0,0 +1,16 @@ +// PR c++/90950 +// { dg-do compile } + +template <typename T> +T +foo (void) +{ + T y = 0; + T &x = y; + #pragma omp parallel for lastprivate (x) + for (int i = 0; i < 8; ++i) + x = i; + return x; +} + +int a = foo<int> (); diff --git a/gcc/testsuite/g++.dg/lookup/missing-std-include-5.C b/gcc/testsuite/g++.dg/lookup/missing-std-include-5.C index fe880a6263b..3ec9abd9316 100644 --- a/gcc/testsuite/g++.dg/lookup/missing-std-include-5.C +++ b/gcc/testsuite/g++.dg/lookup/missing-std-include-5.C @@ -1,2 +1,3 @@ +// { dg-do compile { target c++14 } } using namespace std::complex_literals; // { dg-error "" } // { dg-message "#include <complex>" "" { target *-*-* } .-1 } diff --git a/gcc/testsuite/g++.dg/lookup/missing-std-include-6.C b/gcc/testsuite/g++.dg/lookup/missing-std-include-6.C index d9eeb4284e8..a8f27473e6d 100644 --- a/gcc/testsuite/g++.dg/lookup/missing-std-include-6.C +++ b/gcc/testsuite/g++.dg/lookup/missing-std-include-6.C @@ -11,15 +11,6 @@ void test_make_shared () // { dg-error "expected primary-expression before '\\)' token" "" { target *-*-* } .-3 } } -template<class T> -void test_make_unique () -{ - auto p = std::make_unique<T>(); // { dg-error "'make_unique' is not a member of 'std'" } - // { dg-message "'#include <memory>'" "" { target *-*-* } .-1 } - // { dg-error "expected primary-expression before '>' token" "" { target *-*-* } .-2 } - // { dg-error "expected primary-expression before '\\)' token" "" { target *-*-* } .-3 } -} - std::shared_ptr<int> test_shared_ptr; // { dg-error "'shared_ptr' in namespace 'std' does not name a template type" } // { dg-message "'#include <memory>'" "" { target *-*-* } .-1 } diff --git a/gcc/testsuite/g++.dg/lookup/missing-std-include-8.C b/gcc/testsuite/g++.dg/lookup/missing-std-include-8.C index 68b208299f2..73532c82968 100644 --- a/gcc/testsuite/g++.dg/lookup/missing-std-include-8.C +++ b/gcc/testsuite/g++.dg/lookup/missing-std-include-8.C @@ -13,6 +13,15 @@ void test_make_shared () // { dg-error "expected primary-expression before '\\)' token" "" { target *-*-* } .-3 } } +template<class T> +void test_make_unique () +{ + std::make_unique<T>(); // { dg-error "'make_unique' is not a member of 'std'" } + // { dg-message "'std::make_unique' is only available from C\\+\\+14 onwards" "" { target *-*-* } .-1 } + // { dg-error "expected primary-expression before '>' token" "" { target *-*-* } .-2 } + // { dg-error "expected primary-expression before '\\)' token" "" { target *-*-* } .-3 } +} + void test_array () { std::array a; // { dg-error "'array' is not a member of 'std'" } diff --git a/gcc/testsuite/g++.dg/other/pr92201.C b/gcc/testsuite/g++.dg/other/pr92201.C new file mode 100644 index 00000000000..15ba1a12525 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr92201.C @@ -0,0 +1,7 @@ +// PR c++/92201 + +int +foo (void (*p) ()) +{ + return (*reinterpret_cast<int (*)()> (p)) (); +} diff --git a/gcc/testsuite/g++.dg/pch/pr90326.C b/gcc/testsuite/g++.dg/pch/pr90326.C new file mode 100644 index 00000000000..6b4c5e1c730 --- /dev/null +++ b/gcc/testsuite/g++.dg/pch/pr90326.C @@ -0,0 +1,9 @@ +#include "pr90326.H" + +int main() +{ + float f = __FLT_MAX__; + if (f == 0.0) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/g++.dg/pch/pr90326.Hs b/gcc/testsuite/g++.dg/pch/pr90326.Hs new file mode 100644 index 00000000000..8b1a393741c --- /dev/null +++ b/gcc/testsuite/g++.dg/pch/pr90326.Hs @@ -0,0 +1 @@ +// empty diff --git a/gcc/testsuite/g++.dg/pr71694.C b/gcc/testsuite/g++.dg/pr71694.C index 0a8baf230bf..5b59f879fbf 100644 --- a/gcc/testsuite/g++.dg/pr71694.C +++ b/gcc/testsuite/g++.dg/pr71694.C @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O2 -fno-store-merging" } */ +/* { dg-additional-options "-fno-common -mdynamic-no-pic" { target { ia32 && { x86_64-*-darwin* i?86-*-darwin* } } } } */ struct B { B() {} diff --git a/gcc/testsuite/g++.dg/pr91173.C b/gcc/testsuite/g++.dg/pr91173.C new file mode 100644 index 00000000000..b8fb41ba0cd --- /dev/null +++ b/gcc/testsuite/g++.dg/pr91173.C @@ -0,0 +1,45 @@ +class a { + int b; + void *c; + +public: + bool aa(); + int &ab() { + if (aa()) { + void *d(c); + return static_cast<int *>(d)[b]; + } + return *(int *)0; + } +}; +typedef enum {E} e; +class f : public a { + int g; + +public: + int ac() { + if (g) + return 1; + return ac(); + } +}; +int *ad; +struct h { + static int ae(e, int *m) { + f ag; + int *ah; + while (!0) { + ad = &ag.ab(); + ah = ad + ag.ac(); + while (ad < ah) + *m = *ad++; + } + } +}; +template <class, class> +void i(int *, int *, int, int *, e n, int *o) { + h::ae(n, o); +} +int aq, ar, as, at, au; +void aw() { i<int, bool>(&aq, &ar, as, &at, (e)0, &au); } + diff --git a/gcc/testsuite/g++.dg/pr92022.C b/gcc/testsuite/g++.dg/pr92022.C new file mode 100644 index 00000000000..066d984ffc5 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr92022.C @@ -0,0 +1,13 @@ +// { dg-do compile { target alpha*-*-* } } +// { dg-options "-O1 -g -fno-var-tracking -mcpu=ev4 -mieee" } + +struct a { + a(long); +}; +long b; +void c() { + a d(1); + double e = b; + for (; b;) + d = e; +} diff --git a/gcc/testsuite/g++.dg/tls/pr77285-2.C b/gcc/testsuite/g++.dg/tls/pr77285-2.C index bac273a4d68..459ecc6555d 100644 --- a/gcc/testsuite/g++.dg/tls/pr77285-2.C +++ b/gcc/testsuite/g++.dg/tls/pr77285-2.C @@ -3,7 +3,7 @@ // { dg-require-effective-target tls } // { dg-final { scan-assembler "_Z4var1B3tag" } } // { dg-final { scan-assembler "_Z4var2B3tag" } } -// { dg-final { scan-assembler "_ZTH4var1B3tag" } } +// { dg-final { scan-assembler "_ZTH4var1B3tag" { xfail *-*-darwin* } } } // { dg-final { scan-assembler "_ZTW4var1B3tag" } } struct __attribute__((abi_tag("tag"))) X { ~X () {} int i = 0; }; diff --git a/gcc/testsuite/g++.dg/tls/pr85400.C b/gcc/testsuite/g++.dg/tls/pr85400.C new file mode 100644 index 00000000000..f8d1bceaca5 --- /dev/null +++ b/gcc/testsuite/g++.dg/tls/pr85400.C @@ -0,0 +1,24 @@ +// PR c++/85400 +// Testcase by Brian Vandenberg <phantall@gmail.com> + +// { dg-do link { target c++11 } } +// { dg-require-effective-target fpic } +// { dg-require-effective-target shared } +// { dg-require-effective-target tls } +// { dg-options "-shared -fPIC -O" } +// { dg-add-options tls } + +struct Test +{ + int blah (int y) + { + thread_local int mything = 3; + mything = y > 0 ? y : mything; + return mything; + } +}; + +int stuff (Test& test, int y) +{ + return test.blah(y); +} diff --git a/gcc/testsuite/g++.dg/torture/pr90194.C b/gcc/testsuite/g++.dg/torture/pr90194.C new file mode 100644 index 00000000000..f0c3a77db8a --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr90194.C @@ -0,0 +1,18 @@ +// { dg-do compile } +// { dg-additional-options "-g" } + +struct cb { + int yr; +}; + +void * +operator new (__SIZE_TYPE__, void *nq) +{ + return nq; +} + +void +af (int xn) +{ + new (&xn) cb { }; +} diff --git a/gcc/testsuite/g++.dg/torture/pr91280.C b/gcc/testsuite/g++.dg/torture/pr91280.C new file mode 100644 index 00000000000..063bef836f9 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr91280.C @@ -0,0 +1,223 @@ +// { dg-do compile } + +enum { Aligned, RowMajor }; +enum { ReadOnlyAccessors }; +template <typename> struct K { + enum { value }; +}; +template <typename> struct traits; +template <typename T> struct traits<const T> : traits<T> {}; +struct A { + enum { has_write_access, value }; +}; +template <typename, int n> class array { +public: + int operator[](unsigned long p1) { return values[p1]; } + int values[n]; +}; +template <typename> struct I; +template <typename, int, template <class> class = I> class M; +template <typename, int, int, typename> class J; +template <typename, int> class N; +template <typename, typename> class D; +template <typename, typename, typename, typename> class TensorContractionOp; +template <long, typename> class TensorChippingOp; +class C; +template <typename DenseIndex, int NumDims> +struct K<array<DenseIndex, NumDims>> { + static const long value = NumDims; +}; +template <typename Scalar_, int NumIndices_, int Options_, typename IndexType_> +struct traits<J<Scalar_, NumIndices_, Options_, IndexType_>> { + typedef IndexType_ Index; +}; +template <typename PlainObjectType, int Options_, + template <class> class MakePointer_> +struct traits<M<PlainObjectType, Options_, MakePointer_>> + : traits<PlainObjectType> {}; +template <typename T> struct B { typedef T type; }; +template <typename Derived> class N<Derived, ReadOnlyAccessors> { +public: + typedef typename traits<Derived>::Index Index; + D<int, Derived> m_fn1(); + template <typename OtherDerived, typename Dimensions> + TensorContractionOp<Dimensions, Derived, const OtherDerived, int> + m_fn2(OtherDerived, Dimensions); + template <Index> TensorChippingOp<1, Derived> m_fn3(Index); +}; +template <typename Derived, int = A::value> +class N : public N<Derived, ReadOnlyAccessors> { +public: + template <typename DeviceType> C m_fn4(DeviceType); +}; +template <typename, typename> struct TensorEvaluator; +template <typename UnaryOp, typename ArgType, typename Device> +struct TensorEvaluator<const D<UnaryOp, ArgType>, Device> { + TensorEvaluator(D<UnaryOp, ArgType>, Device); +}; +template <typename, typename> class D { +public: + typedef typename B<D>::type Nested; +}; +template <typename Indices_, typename LeftArgType_, typename RightArgType_, + typename OutputKernelType_, typename Device_> +struct traits< + TensorEvaluator<const TensorContractionOp<Indices_, LeftArgType_, + RightArgType_, OutputKernelType_>, + Device_>> { + typedef Indices_ Indices; + typedef LeftArgType_ LeftArgType; + typedef RightArgType_ RightArgType; + typedef OutputKernelType_ OutputKernelType; + typedef Device_ Device; +}; +template <typename, typename LhsXprType, typename RhsXprType, typename> +class TensorContractionOp { +public: + typedef typename B<TensorContractionOp>::type Nested; + typename LhsXprType::Nested m_fn5(); + typename RhsXprType::Nested m_fn6(); +}; +template <typename Derived> struct TensorContractionEvaluatorBase { + typedef typename traits<Derived>::LeftArgType LeftArgType; + typedef typename traits<Derived>::RightArgType RightArgType; + typedef typename traits<Derived>::Device Device; + TensorContractionEvaluatorBase( + TensorContractionOp<typename traits<Derived>::Indices, LeftArgType, + RightArgType, + typename traits<Derived>::OutputKernelType> + p1, + Device p2) + : m_leftImpl(p1.m_fn6(), p2), m_rightImpl(p1.m_fn5(), p2) { + long nocontract_idx; + for (int i;; i++) { + bool contracting; + if (contracting) { + if (nocontract_idx < K<int>::value) + m_j_size = m_j_strides[nocontract_idx]; + nocontract_idx++; + } + } + } + array<long, 1> m_j_strides; + long m_j_size; + TensorEvaluator<RightArgType, Device> m_leftImpl; + TensorEvaluator<LeftArgType, Device> m_rightImpl; +}; +template <typename Indices, typename LeftArgType, typename RightArgType, + typename OutputKernelType, typename Device> +struct TensorEvaluator< + const TensorContractionOp<Indices, LeftArgType, RightArgType, + OutputKernelType>, + Device> + : TensorContractionEvaluatorBase<TensorEvaluator< + const TensorContractionOp<Indices, LeftArgType, RightArgType, + OutputKernelType>, + Device>> { + typedef TensorEvaluator Self; + typedef TensorContractionEvaluatorBase<Self> Base; + TensorEvaluator( + TensorContractionOp<Indices, LeftArgType, RightArgType, OutputKernelType> + p1, + Device p2) + : Base(p1, p2) {} +}; +template <long DimId, typename XprType> +struct traits<TensorChippingOp<DimId, XprType>> : traits<XprType> {}; +template <long, typename XprType> +class TensorChippingOp : public N<TensorChippingOp<1, XprType>> { +public: + typedef typename B<TensorChippingOp>::type Nested; +}; +template <long DimId, typename ArgType, typename Device> +struct TensorEvaluator<const TensorChippingOp<DimId, ArgType>, Device> { + static const int NumInputDims = K<typename ArgType::Dimensions>::value; + array<long, NumInputDims> m_dimensions; +}; +template <long DimId, typename ArgType, typename Device> +struct TensorEvaluator<TensorChippingOp<DimId, ArgType>, Device> + : TensorEvaluator<const TensorChippingOp<1, ArgType>, Device> { + TensorEvaluator(TensorChippingOp<DimId, ArgType>, Device); +}; +template <typename, typename RhsXprType> class TensorAssignOp { +public: + TensorAssignOp(TensorChippingOp<0, const M<J<int, 3, 1, int>, 1>>, + RhsXprType); + TensorChippingOp<0, const M<J<int, 3, 1, int>, 1>> m_fn7(); + typename RhsXprType::Nested m_fn8(); +}; +template <typename LeftArgType, typename RightArgType, typename Device> +struct TensorEvaluator<const TensorAssignOp<LeftArgType, RightArgType>, + Device> { + TensorEvaluator(TensorAssignOp<LeftArgType, RightArgType> p1, Device p2) + : m_leftImpl(p1.m_fn7(), p2), m_rightImpl(p1.m_fn8(), p2) {} + TensorEvaluator<LeftArgType, Device> m_leftImpl; + TensorEvaluator<RightArgType, Device> m_rightImpl; +}; +template <typename Expression> class F { +public: + static void m_fn9(Expression p1) { + int device; + TensorEvaluator<Expression, int>(p1, device); + } +}; +class C { +public: + void + operator=(TensorContractionOp<array<int, 1>, + TensorChippingOp<1, M<J<float, 3, 1, int>, 0>>, + const D<int, M<J<float, 3, 1, int>, 0>>, int> + p1) { + TensorAssignOp< + TensorChippingOp<0, const M<J<int, 3, 1, int>, 1>>, + const TensorContractionOp< + array<int, 1>, TensorChippingOp<1, M<J<float, 3, 1, int>, 0>>, + const D<int, M<J<float, 3, 1, int>, 0>>, int>> + assign(m_expression, p1); + F<const TensorAssignOp< + TensorChippingOp<0, const M<J<int, 3, 1, int>, 1>>, + const TensorContractionOp< + array<int, 1>, TensorChippingOp<1, M<J<float, 3, 1, int>, 0>>, + const D<int, M<J<float, 3, 1, int>, 0>>, int>>>::m_fn9(assign); + } + TensorChippingOp<0, const M<J<int, 3, 1, int>, 1>> m_expression; +}; +template <typename, int NumIndices_, int, typename> class J { +public: + typedef array<long, NumIndices_> Dimensions; +}; +template <typename PlainObjectType, int Options_, template <class> class> +class M : public N<M<PlainObjectType, Options_>> { +public: + typedef typename PlainObjectType::Dimensions Dimensions; +}; +template <int NDIMS> struct TTypes { + typedef M<J<float, NDIMS, RowMajor, int>, Aligned> ConstTensor; +}; +class L { +public: + template <typename, long NDIMS> typename TTypes<NDIMS>::ConstTensor m_fn10(); +}; +class H { +public: + H(int *); +}; +class G { +public: + G(H *(int *)); +}; +int Run_d; +class O : H { +public: + int BatchMatMul_context; + O() : H(&BatchMatMul_context) { + L out, in_y, in_x; + auto Tx = in_x.m_fn10<float, 3>(), Ty = in_y.m_fn10<float, 3>(), + Tz = out.m_fn10<float, 3>(), z = Tz; + array<int, 1> contract_pairs; + auto x = Tx.m_fn3<0>(0); + auto y = Ty.m_fn1(); + z.m_fn4(Run_d) = x.m_fn2(y, contract_pairs); + } +}; +G registrar__body__0__object([](int *) -> H * { O(); return 0; }); diff --git a/gcc/testsuite/g++.dg/torture/pr91355.C b/gcc/testsuite/g++.dg/torture/pr91355.C new file mode 100644 index 00000000000..7a385dc5bdd --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr91355.C @@ -0,0 +1,28 @@ +// PR tree-optimization/91355 +// { dg-do run } +// { dg-options "-std=c++14" } + +unsigned int d = 0; + +struct S { + S () { d++; } + S (const S &) { d++; } + ~S () { d--; } +}; + +void +foo (int i) throw (int) // { dg-warning "dynamic exception specifications are deprecated" } +{ + if (i == 0) + throw 3; + S d; + throw 3; +} + +int +main () +{ + try { foo (1); } catch (...) {} + if (d) + __builtin_abort (); +} diff --git a/gcc/testsuite/g++.dg/torture/pr92384.C b/gcc/testsuite/g++.dg/torture/pr92384.C new file mode 100644 index 00000000000..049a45a0154 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr92384.C @@ -0,0 +1,38 @@ +// PR c++/92384 +// { dg-do run } + +struct S {}; +struct T : public S { S a, b, c, d, e, f, g, h, i, j, k, l, m; }; +struct U { long long a, b, c; }; + +U +foo (S, S, S, T, T, T, U g) +{ + return g; +} + +__attribute__((noipa)) bool +bar (S a, S b, S c, T d, T e, T f, U g, void **h) +{ + h[0] = (void *) &a; + h[1] = (void *) &b; + h[2] = (void *) &c; + h[3] = (void *) &d; + h[4] = (void *) &e; + h[5] = (void *) &f; + h[6] = (void *) &g; + asm volatile ("" : : "r" (h) : "memory"); + return (h[0] != h[1] && h[1] != h[2] && h[2] != h[3] + && h[3] != h[4] && h[4] != h[5] && h[5] != h[6]); +} + +int +main () +{ + S a; + T b; + U c = { 1, 2, 3 }; + void *d[7]; + if (!bar (a, a, a, b, b, b, c, d)) + __builtin_abort (); +} diff --git a/gcc/testsuite/g++.dg/tree-ssa/tail-call-1.C b/gcc/testsuite/g++.dg/tree-ssa/tail-call-1.C new file mode 100644 index 00000000000..c67af6e41c7 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/tail-call-1.C @@ -0,0 +1,11 @@ +// PR c++/82081 +// { dg-do compile { target c++11 } } +// { dg-additional-options "-O2 -fdump-tree-optimized" } +// { dg-final { scan-tree-dump-not "tail call" "optimized" } } + +int g(int) ; + +int f() noexcept { + int i = 42, j = 43; + return g(i+j); +} diff --git a/gcc/testsuite/gcc.c-torture/compile/20191108-1.c b/gcc/testsuite/gcc.c-torture/compile/20191108-1.c new file mode 100644 index 00000000000..7929751bb06 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20191108-1.c @@ -0,0 +1,14 @@ +/* PR target/92095 */ +/* Testcase by Sergei Trofimovich <slyfox@inbox.ru> */ + +typedef union { + double a; + int b[2]; +} c; + +double d(int e) +{ + c f; + (&f)->b[0] = 15728640; + return e ? -(&f)->a : (&f)->a; +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr72802.c b/gcc/testsuite/gcc.c-torture/compile/pr72802.c index b9e1ab31580..1e19577194e 100644 --- a/gcc/testsuite/gcc.c-torture/compile/pr72802.c +++ b/gcc/testsuite/gcc.c-torture/compile/pr72802.c @@ -1,3 +1,4 @@ +/* { dg-skip-if "see PR trail" { *-*-darwin* } } */ static a[]; static b, h, m, n, o, p, q, t, u, v, t5, t6, t16, t17, t18, t25; c; diff --git a/gcc/testsuite/gcc.c-torture/compile/pr90139.c b/gcc/testsuite/gcc.c-torture/compile/pr90139.c new file mode 100644 index 00000000000..f3d99f04c86 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr90139.c @@ -0,0 +1,20 @@ +/* PR middle-end/90139 */ + +typedef float __attribute__((vector_size (sizeof (float)))) V; +void bar (int, V *); +int l; + +void +foo (void) +{ + V n, b, o; + while (1) + switch (l) + { + case 0: + o = n; + n = b; + b = o; + bar (1, &o); + } +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr90840.c b/gcc/testsuite/gcc.c-torture/compile/pr90840.c new file mode 100644 index 00000000000..94a6f3f4baf --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr90840.c @@ -0,0 +1,19 @@ +/* PR middle-end/90840 */ +struct S { long long a; int b; }; +struct S foo (void); +struct __attribute__((packed)) T { long long a; char b; }; +struct T baz (void); + +void +bar (void) +{ + _Complex long double c; + *(struct S *) &c = foo (); +} + +void +qux (void) +{ + _Complex long double c; + *(struct T *) &c = baz (); +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr91001.c b/gcc/testsuite/gcc.c-torture/compile/pr91001.c new file mode 100644 index 00000000000..4b6a017c860 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr91001.c @@ -0,0 +1,31 @@ +/* PR middle-end/91001 */ +/* PR middle-end/91105 */ +/* PR middle-end/91106 */ + +struct __attribute__((packed)) S { short b; char c; }; +struct T { short b, c, d; }; +struct __attribute__((packed)) R { int b; char c; }; +union __attribute__((aligned(128), transparent_union)) U { struct S c; } u; +union __attribute__((aligned(32), transparent_union)) V { struct T c; } v; +union __attribute__((aligned(32), transparent_union)) W { struct R c; } w; +void foo (union U); +void bar (union V); +void baz (union W); + +void +qux (void) +{ + foo (u); +} + +void +quux (void) +{ + bar (v); +} + +void +corge (void) +{ + baz (w); +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr92056.c b/gcc/testsuite/gcc.c-torture/compile/pr92056.c new file mode 100644 index 00000000000..d04da763e15 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr92056.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/92056 */ + +const char *d; + +void +foo (int c, char *e, const char *a, const char *b) +{ + switch (c) + { + case 33: + for (;; d++) + if (__builtin_strcmp (b ? : "", d)) + return; + break; + case 4: + __builtin_sprintf (e, a); + } +} diff --git a/gcc/testsuite/gcc.c-torture/execute/20190820-1.c b/gcc/testsuite/gcc.c-torture/execute/20190820-1.c new file mode 100644 index 00000000000..6a06eff7571 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20190820-1.c @@ -0,0 +1,111 @@ +/* PR rtl-optimization/91347 */
+/* Reported by John David Anglin <danglin@gcc.gnu.org> */
+
+typedef unsigned short __u16;
+typedef __signed__ int __s32;
+typedef unsigned int __u32;
+typedef __signed__ long long __s64;
+typedef unsigned long long __u64;
+typedef __u16 u16;
+typedef __s32 s32;
+typedef __u32 u32;
+typedef __u64 u64;
+typedef _Bool bool;
+typedef s32 int32_t;
+typedef u32 uint32_t;
+typedef u64 uint64_t;
+
+char hex_asc_upper[16];
+u16 decpair[100];
+
+static __attribute__ ((noipa)) void
+put_dec_full4 (char *buf, unsigned r)
+{
+ unsigned q;
+ q = (r * 0x147b) >> 19;
+ *((u16 *)buf) = decpair[r - 100*q];
+ buf += 2;
+ *((u16 *)buf) = decpair[q];
+}
+
+static __attribute__ ((noipa)) unsigned
+put_dec_helper4 (char *buf, unsigned x)
+{
+ uint32_t q = (x * (uint64_t)0x346DC5D7) >> 43;
+ put_dec_full4(buf, x - q * 10000);
+ return q;
+}
+
+static __attribute__ ((noipa)) char *
+put_dec (char *buf, unsigned long long n)
+{
+ uint32_t d3, d2, d1, q, h;
+ d1 = ((uint32_t)n >> 16);
+ h = (n >> 32);
+ d2 = (h ) & 0xffff;
+ d3 = (h >> 16);
+ q = 656 * d3 + 7296 * d2 + 5536 * d1 + ((uint32_t)n & 0xffff);
+ q = put_dec_helper4(buf, q);
+ q += 7671 * d3 + 9496 * d2 + 6 * d1;
+ q = put_dec_helper4(buf+4, q);
+ q += 4749 * d3 + 42 * d2;
+ q = put_dec_helper4(buf+8, q);
+ return buf;
+}
+
+struct printf_spec {
+ unsigned int type:8;
+ signed int field_width:24;
+ unsigned int flags:8;
+ unsigned int base:8;
+ signed int precision:16;
+} __attribute__((__packed__));
+
+static __attribute__ ((noipa)) char *
+number (char *buf, char *end, unsigned long long num, struct printf_spec spec)
+{
+
+ char tmp[3 * sizeof(num)] __attribute__((__aligned__(2)));
+ char sign;
+ char locase;
+ int need_pfx = ((spec.flags & 64) && spec.base != 10);
+ int i;
+ bool is_zero = num == 0LL;
+ int field_width = spec.field_width;
+ int precision = spec.precision;
+
+ i = 0;
+ if (num < spec.base)
+ tmp[i++] = hex_asc_upper[num] | locase;
+ else if (spec.base != 10) {
+ int mask = spec.base - 1;
+ int shift = 3;
+ if (spec.base == 16)
+ shift = 4;
+ else
+ __builtin_abort ();
+ do {
+ tmp[i++] = (hex_asc_upper[((unsigned char)num) & mask] | locase);
+ num >>= shift;
+ } while (num);
+ } else {
+ i = put_dec(tmp, num) - tmp;
+ }
+ return buf;
+}
+
+static __attribute__ ((noipa)) char *
+pointer_string (char *buf, char *end, const void *ptr, struct printf_spec spec)
+{
+ spec.base = 16;
+ spec.flags = 0;
+ return number(buf, end, 100, spec);
+}
+
+int
+main (void)
+{
+ struct printf_spec spec;
+ char *s = pointer_string (0, 0, 0, spec);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/20190901-1.c b/gcc/testsuite/gcc.c-torture/execute/20190901-1.c new file mode 100644 index 00000000000..c78715ef2c1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20190901-1.c @@ -0,0 +1,36 @@ +/* PR target/91472 */ +/* Reported by John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> */ + +typedef unsigned int gmp_uint_least32_t; + +union ieee_double_extract +{ + struct + { + gmp_uint_least32_t sig:1; + gmp_uint_least32_t exp:11; + gmp_uint_least32_t manh:20; + gmp_uint_least32_t manl:32; + } s; + double d; +}; + +double __attribute__((noipa)) +tests_infinity_d (void) +{ + union ieee_double_extract x; + x.s.exp = 2047; + x.s.manl = 0; + x.s.manh = 0; + x.s.sig = 0; + return x.d; +} + +int +main (void) +{ + double x = tests_infinity_d (); + if (x == 0.0) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/20191023-1.c b/gcc/testsuite/gcc.c-torture/execute/20191023-1.c new file mode 100644 index 00000000000..3811ebca151 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20191023-1.c @@ -0,0 +1,73 @@ +/* PR tree-optimization/92131 */ +/* Testcase by Armin Rigo <arigo@tunes.org> */ + +long b, c, d, e, f, i; +char g, h, j, k; +int *aa; + +static void error (void) __attribute__((noipa)); +static void error (void) { __builtin_abort(); } + +static void see_me_here (void) __attribute__((noipa)); +static void see_me_here (void) {} + +static void aaa (void) __attribute__((noipa)); +static void aaa (void) {} + +static void a (void) __attribute__((noipa)); +static void a (void) { + long am, ao; + if (aa == 0) { + aaa(); + if (j) + goto ay; + } + return; +ay: + aaa(); + if (k) { + aaa(); + goto az; + } + return; +az: + if (i) + if (g) + if (h) + if (e) + goto bd; + return; +bd: + am = 0; + while (am < e) { + switch (c) { + case 8: + goto bh; + case 4: + return; + } + bh: + if (am >= 0) + b = -am; + ao = am + b; + f = ao & 7; + if (f == 0) + see_me_here(); + if (ao >= 0) + am++; + else + error(); + } +} + +int main (void) +{ + j++; + k++; + i++; + g++; + h++; + e = 1; + a(); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp b/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp index 9f0b24ad4ee..e8297e15f18 100644 --- a/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp @@ -37,7 +37,7 @@ load_lib c-torture.exp torture-init set-torture-options $C_TORTURE_OPTIONS {{}} $LTO_TORTURE_OPTIONS -set additional_flags "-fno-tree-loop-distribute-patterns -fno-tracer" +set additional_flags "-fno-tree-loop-distribute-patterns -fno-tracer -fno-ipa-ra" if [istarget "powerpc-*-darwin*"] { lappend additional_flags "-Wl,-multiply_defined,suppress" } diff --git a/gcc/testsuite/gcc.c-torture/execute/pr90949.c b/gcc/testsuite/gcc.c-torture/execute/pr90949.c new file mode 100644 index 00000000000..8c2ae3972d4 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr90949.c @@ -0,0 +1,42 @@ +void __attribute__ ((noipa, noinline)) my_puts (const char *str) { } + +void __attribute__ ((noipa, noinline)) my_free (void *p) { } + + +struct Node +{ + struct Node *child; +}; + +struct Node space[2] = { }; + +struct Node * __attribute__ ((noipa, noinline)) my_malloc (int bytes) +{ + return &space[0]; +} + +void +walk (struct Node *module, int cleanup) +{ + if (module == 0) + { + return; + } + if (!cleanup) + { + my_puts ("No cleanup"); + } + walk (module->child, cleanup); + if (cleanup) + { + my_free (module); + } +} + +int +main () +{ + struct Node *node = my_malloc (sizeof (struct Node)); + node->child = 0; + walk (node, 1); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr91137.c b/gcc/testsuite/gcc.c-torture/execute/pr91137.c new file mode 100644 index 00000000000..aa6bb6ca021 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr91137.c @@ -0,0 +1,34 @@ +long long a; +unsigned b; +int c[70]; +int d[70][70]; +int e; + +__attribute__ ((noinline)) void f(long long *g, int p2) { + *g = p2; +} + +__attribute__ ((noinline)) void fn2() { + for (int j = 0; j < 70; j++) { + for (int i = 0; i < 70; i++) { + if (b) + c[i] = 0; + for (int l = 0; l < 70; l++) + d[i][1] = d[l][i]; + } + for (int k = 0; k < 70; k++) + e = c[0]; + } +} + +int main() { + b = 5; + for (int j = 0; j < 70; ++j) + c[j] = 2075593088; + fn2(); + f(&a, e); + if (a) + __builtin_abort(); + return 0; +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/pr91450-1.c b/gcc/testsuite/gcc.c-torture/execute/pr91450-1.c new file mode 100644 index 00000000000..9aafc5f791a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr91450-1.c @@ -0,0 +1,88 @@ +/* PR middle-end/91450 */ + +__attribute__((noipa)) unsigned long long +foo (int a, int b) +{ + unsigned long long r; + if (!__builtin_mul_overflow (a, b, &r)) + __builtin_abort (); + return r; +} + +__attribute__((noipa)) unsigned long long +bar (int a, int b) +{ + unsigned long long r; + if (a >= 0) + return 0; + if (!__builtin_mul_overflow (a, b, &r)) + __builtin_abort (); + return r; +} + +__attribute__((noipa)) unsigned long long +baz (int a, int b) +{ + unsigned long long r; + if (b >= 0) + return 0; + if (!__builtin_mul_overflow (a, b, &r)) + __builtin_abort (); + return r; +} + +__attribute__((noipa)) unsigned long long +qux (int a, int b) +{ + unsigned long long r; + if (a >= 0) + return 0; + if (b < 0) + return 0; + if (!__builtin_mul_overflow (a, b, &r)) + __builtin_abort (); + return r; +} + +__attribute__((noipa)) unsigned long long +quux (int a, int b) +{ + unsigned long long r; + if (a < 0) + return 0; + if (b >= 0) + return 0; + if (!__builtin_mul_overflow (a, b, &r)) + __builtin_abort (); + return r; +} + +int +main () +{ + if (foo (-4, 2) != -8ULL) + __builtin_abort (); + if (foo (2, -4) != -8ULL) + __builtin_abort (); + if (bar (-4, 2) != -8ULL) + __builtin_abort (); + if (baz (2, -4) != -8ULL) + __builtin_abort (); + if (qux (-4, 2) != -8ULL) + __builtin_abort (); + if (quux (2, -4) != -8ULL) + __builtin_abort (); + if (foo (-2, 1) != -2ULL) + __builtin_abort (); + if (foo (1, -2) != -2ULL) + __builtin_abort (); + if (bar (-2, 1) != -2ULL) + __builtin_abort (); + if (baz (1, -2) != -2ULL) + __builtin_abort (); + if (qux (-2, 1) != -2ULL) + __builtin_abort (); + if (quux (1, -2) != -2ULL) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr91450-2.c b/gcc/testsuite/gcc.c-torture/execute/pr91450-2.c new file mode 100644 index 00000000000..bfaabbb5ac6 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr91450-2.c @@ -0,0 +1,76 @@ +/* PR middle-end/91450 */ + +__attribute__((noipa)) void +foo (int a, int b) +{ + unsigned long long r; + if (__builtin_mul_overflow (a, b, &r)) + __builtin_abort (); + if (r != 0) + __builtin_abort (); +} + +__attribute__((noipa)) void +bar (int a, int b) +{ + unsigned long long r; + if (a >= 0) + return; + if (__builtin_mul_overflow (a, b, &r)) + __builtin_abort (); + if (r != 0) + __builtin_abort (); +} + +__attribute__((noipa)) void +baz (int a, int b) +{ + unsigned long long r; + if (b >= 0) + return; + if (__builtin_mul_overflow (a, b, &r)) + __builtin_abort (); + if (r != 0) + __builtin_abort (); +} + +__attribute__((noipa)) void +qux (int a, int b) +{ + unsigned long long r; + if (a >= 0) + return; + if (b < 0) + return; + if (__builtin_mul_overflow (a, b, &r)) + __builtin_abort (); + if (r != 0) + __builtin_abort (); +} + +__attribute__((noipa)) void +quux (int a, int b) +{ + unsigned long long r; + if (a < 0) + return; + if (b >= 0) + return; + if (__builtin_mul_overflow (a, b, &r)) + __builtin_abort (); + if (r != 0) + __builtin_abort (); +} + +int +main () +{ + foo (-4, 0); + foo (0, -4); + foo (0, 0); + bar (-4, 0); + baz (0, -4); + qux (-4, 0); + quux (0, -4); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/Wnonnull.c b/gcc/testsuite/gcc.dg/Wnonnull.c index be89a5a755c..0ed06aabe68 100644 --- a/gcc/testsuite/gcc.dg/Wnonnull.c +++ b/gcc/testsuite/gcc.dg/Wnonnull.c @@ -2,7 +2,10 @@ { dg-do compile } { dg-options "-O2 -Wall" } */ -#include <string.h> +extern __SIZE_TYPE__ strlen (const char *__s) + __attribute ((pure)) __attribute ((nonnull (1))); +extern void *memcpy (void *__restrict __dest, const void *__restrict __src, + __SIZE_TYPE__ __n) __attribute ((nonnull (1, 2))); char buf[100]; @@ -14,9 +17,9 @@ struct Test __attribute ((nonnull (1, 2))) inline char* -my_strcpy (char *restrict dst, const char *restrict src, size_t size) +my_strcpy (char *restrict dst, const char *restrict src, __SIZE_TYPE__ size) { - size_t len = strlen (src); /* { dg-warning "argument 1 null where non-null expected" } */ + __SIZE_TYPE__ len = strlen (src); /* { dg-warning "argument 1 null where non-null expected" } */ if (len < size) memcpy (dst, src, len + 1); /* { dg-warning "argument 2 null where non-null expected" } */ else diff --git a/gcc/testsuite/gcc.dg/autopar/pr91162.c b/gcc/testsuite/gcc.dg/autopar/pr91162.c new file mode 100644 index 00000000000..ff243e4c1c0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/autopar/pr91162.c @@ -0,0 +1,25 @@ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O -ftree-parallelize-loops=2 -fno-tree-dominator-opts --param parloops-min-per-thread=30" } */ + +void +zf (__int128 ct) +{ + __int128 *rk = &ct; + + if (0) + { + int jj; + +t9: + for (jj = 0; jj < 60; ++jj) + { + } + + __builtin_unreachable (); + } + + while (*rk < 1) + ++*rk; + + goto t9; +} diff --git a/gcc/testsuite/gcc.dg/cpp/isysroot-1.c b/gcc/testsuite/gcc.dg/cpp/isysroot-1.c index 7263ce41544..4c54f9e218a 100644 --- a/gcc/testsuite/gcc.dg/cpp/isysroot-1.c +++ b/gcc/testsuite/gcc.dg/cpp/isysroot-1.c @@ -1,10 +1,17 @@ /* { dg-options "-isysroot ${srcdir}/gcc.dg/cpp" } */ /* { dg-do compile { target *-*-darwin* } } */ -#include <stdio.h> +/* For the test to succeed there needs to be some header that is to be found + in the 'expected' place i.e. <sysroot>/usr/include/. It's important that + it is not the name of a header for which fixincludes have been applied, + since such headers will be found in the gcc include-fixed dir and, in + general, reference additional headers. The dummy sysroot will prevent the + additional headers from being found, resulting in a failed test. So use + a header name we don't expect to see. */ +#include <example.h> int main() { - /* Special stdio.h supplies function foo. */ + /* Special example.h supplies function foo. */ void (*x)(void) = foo; return 0; } diff --git a/gcc/testsuite/gcc.dg/cpp/usr/include/stdio.h b/gcc/testsuite/gcc.dg/cpp/usr/include/example.h index c674e89f7ef..c674e89f7ef 100644 --- a/gcc/testsuite/gcc.dg/cpp/usr/include/stdio.h +++ b/gcc/testsuite/gcc.dg/cpp/usr/include/example.h diff --git a/gcc/testsuite/gcc.dg/darwin-minversion-1.c b/gcc/testsuite/gcc.dg/darwin-minversion-1.c index ee6493a3119..5f8524fbcb8 100644 --- a/gcc/testsuite/gcc.dg/darwin-minversion-1.c +++ b/gcc/testsuite/gcc.dg/darwin-minversion-1.c @@ -1,6 +1,6 @@ /* Basic test for -mmacosx-version-min switch on Darwin. */ /* { dg-options "-mmacosx-version-min=10.5" } */ -/* { dg-do run { target *-*-darwin* } } */ +/* { dg-do compile { target *-*-darwin* } } */ int main () diff --git a/gcc/testsuite/gcc.dg/darwin-minversion-2.c b/gcc/testsuite/gcc.dg/darwin-minversion-2.c index 46fab671b95..3dbbca6f4c5 100644 --- a/gcc/testsuite/gcc.dg/darwin-minversion-2.c +++ b/gcc/testsuite/gcc.dg/darwin-minversion-2.c @@ -1,6 +1,6 @@ /* Basic test for -mmacosx-version-min switch on Darwin. */ /* { dg-options "-mmacosx-version-min=10.1 -mmacosx-version-min=10.5" } */ -/* { dg-do run { target *-*-darwin* } } */ +/* { dg-do compile { target *-*-darwin* } } */ int main () diff --git a/gcc/testsuite/gcc.dg/darwin-minversion-link.c b/gcc/testsuite/gcc.dg/darwin-minversion-link.c new file mode 100644 index 00000000000..0a80048ba35 --- /dev/null +++ b/gcc/testsuite/gcc.dg/darwin-minversion-link.c @@ -0,0 +1,26 @@ +/* Test that we can handle leading-zeros on mmacosx-version-min for invocations + including linking (so that spec processing works). To make sure that any + necessary target libs are present we make this specific to the target version + being built. */ +/* { dg-do link { target *-*-darwin* } } */ +/* { dg-additional-options "-mmacosx-version-min=010.04.11 -DCHECK=1049" { target *-*-darwin8* } } */ +/* { dg-additional-options "-mmacosx-version-min=010.05.08 -DCHECK=1058" { target *-*-darwin9* } } */ +/* { dg-additional-options "-mmacosx-version-min=010.06.08 -DCHECK=1068" { target *-*-darwin10* } } */ +/* { dg-additional-options "-mmacosx-version-min=010.07.05 -DCHECK=1075" { target *-*-darwin11* } } */ +/* { dg-additional-options "-mmacosx-version-min=010.08.05 -DCHECK=1085" { target *-*-darwin12* } } */ +/* { dg-additional-options "-mmacosx-version-min=010.09.05 -DCHECK=1095" { target *-*-darwin13* } } */ +/* { dg-additional-options "-mmacosx-version-min=010.010.03 -DCHECK=101003" { target *-*-darwin14* } } */ +/* { dg-additional-options "-mmacosx-version-min=010.011.06 -DCHECK=101106" { target *-*-darwin15* } } */ +/* { dg-additional-options "-mmacosx-version-min=010.012.06 -DCHECK=101206" { target *-*-darwin16* } } */ +/* { dg-additional-options "-mmacosx-version-min=010.013.06 -DCHECK=101306" { target *-*-darwin17* } } */ +/* This next test covers 10.18 and (currently unreleased) 10.19 for now. */ +/* { dg-additional-options "-mmacosx-version-min=010.014.05 -DCHECK=101405" { target *-*-darwin1[89]* } } */ + +int +main () +{ +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != CHECK + fail me; +#endif + return 0; +} diff --git a/gcc/testsuite/gcc.dg/darwin-weakimport-3.c b/gcc/testsuite/gcc.dg/darwin-weakimport-3.c index 77ab980b12d..a15b5b0e7cb 100644 --- a/gcc/testsuite/gcc.dg/darwin-weakimport-3.c +++ b/gcc/testsuite/gcc.dg/darwin-weakimport-3.c @@ -1,5 +1,20 @@ /* { dg-do compile { target *-*-darwin* } } */ -/* { dg-options "-fno-asynchronous-unwind-tables" } */ + +/* Here we want to test if "foo" gets placed into a coalesced + section (it should not). + + However, for i386, and PIC code we have a "get_pc thunk" that + is (correctly) placed in a coalesced section when using an older + linker - also unwind tables are emitted into coalesced. + + With modern linkers this is moot, since even weak symbols + are emitted into the regular sections. + + To avoid the unwind tables -fno-asynchronous-unwind-tables. + To ensure that we emit code for an older linker -mtarget-linker + To avoid the get_pc thunk optimise at least O1. */ + +/* { dg-options "-fno-asynchronous-unwind-tables -O1 -mtarget-linker 85.2" } */ /* { dg-require-weak "" } */ /* { dg-final { scan-assembler-not "coalesced" } } */ diff --git a/gcc/testsuite/gcc.dg/gomp/pr78884.c b/gcc/testsuite/gcc.dg/gomp/pr78884.c new file mode 100644 index 00000000000..3e03df55867 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/pr78884.c @@ -0,0 +1,16 @@ +/* PR middle-end/78884 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fopenmp" } */ + +void bar (int *); + +void +foo (int n) +{ +#pragma omp simd + for (int i = 0; i < 1024; i++) + { + int vla[n]; + bar (vla); + } +} diff --git a/gcc/testsuite/gcc.dg/gomp/pr90900.c b/gcc/testsuite/gcc.dg/gomp/pr90900.c new file mode 100644 index 00000000000..d4c5d7d5bef --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/pr90900.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fopenmp -g" } */ + +void f (int a) +{ + void *x = &&lab; +#pragma omp parallel + if (a) + { lab: __builtin_unreachable(); } + x; +} diff --git a/gcc/testsuite/gcc.dg/pr90733.c b/gcc/testsuite/gcc.dg/pr90733.c new file mode 100644 index 00000000000..7d2a7fb559a --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr90733.c @@ -0,0 +1,22 @@ +/* PR debug/90733 */ +/* { dg-do compile } */ +/* { dg-options "-g -O2 -w" } */ + +struct S { unsigned a : 1; }; +union U { struct S b; _Complex unsigned c; }; + +union U +foo (union U d) +{ + union U e = d; + return e; +} + +int +bar (void) +{ + union U x, y; + x.c = x.b.a; + y = foo (x); + return x.c != y.c; +} diff --git a/gcc/testsuite/gcc.dg/pr90756.c b/gcc/testsuite/gcc.dg/pr90756.c new file mode 100644 index 00000000000..3507aa29e70 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr90756.c @@ -0,0 +1,26 @@ +/* PR rtl-optimization/90756 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wno-psabi" } */ +/* { dg-additional-options "-mno-sse" { target ia32 } } */ + +typedef float B __attribute__((vector_size(4 * sizeof (float)))); +typedef unsigned long long C __attribute__((vector_size(4 * sizeof (long long)))); +typedef short D __attribute__((vector_size(4 * sizeof (short)))); +B z; +void foo (C); +C bar (D); +B baz (); +D qux (B); + +void +quux (int x) +{ + B n = z, b = z; + while (1) + switch (x) + { + case 0: n = baz (); /* FALLTHRU */ + case 1: { B o = n; n = b; b = o; } /* FALLTHRU */ + case 2: { D u = qux (b); C v = bar (u); foo (v); } + } +} diff --git a/gcc/testsuite/gcc.dg/pr90760.c b/gcc/testsuite/gcc.dg/pr90760.c new file mode 100644 index 00000000000..6092a4e98cb --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr90760.c @@ -0,0 +1,9 @@ +/* PR c/90760 */ +/* { dg-do compile } */ +/* { dg-require-alias "" } */ +/* { dg-require-named-sections "" } */ + +void bar (void) {} +void foo (void) __attribute__ ((alias ("bar"))); /* { dg-error "section of alias 'foo' must match section of its target" } */ +void foo (void) __attribute__ ((section ("baz"))); +void qux (void) __attribute__ ((alias ("bar"), section ("baz"))); /* { dg-error "section of alias 'qux' must match section of its target" } */ diff --git a/gcc/testsuite/gcc.dg/pr90898.c b/gcc/testsuite/gcc.dg/pr90898.c new file mode 100644 index 00000000000..e992ea34cd9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr90898.c @@ -0,0 +1,16 @@ +/* PR c/90898 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void *p; +int bar (void); +void baz (int *); + +void +foo (void) +{ + p = __builtin_stack_save (); + int a[(bar (), 2)]; + baz (a); + __builtin_stack_restore (p); +} diff --git a/gcc/testsuite/gcc.dg/pr91854.c b/gcc/testsuite/gcc.dg/pr91854.c new file mode 100644 index 00000000000..fbf33a58890 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr91854.c @@ -0,0 +1,55 @@ +/* PR target/91854 */ +/* Testcase by Sergei Trofimovich <slyfox@inbox.ru> */ +/* { dg-do assemble } */ +/* { dg-options "-O2 -Wno-int-conversion" } */ +/* { dg-additional-options "-fPIE -mcpu=niagara4" { target sparc*-*-* } } */ + +typedef struct { + long a; +} __attribute__((packed)) c; +void *e, *f; +int i, j, ab, k, l, m, o; +inline int g(int p) { + if (__builtin_expect(p, 1)) { + const int aa = ((c *)e)->a ^ ((c *)f)->a; + if (aa) + f = sizeof(long); + return f; + } +} +void d(); +int am (); +inline int n(char p, int u) { + int q, r, ac = i; + short b = m; + while (r && u) { + if (l) { + if (k) { + void *h = i; + if (__builtin_expect(p, 1)) { + const int aa = ((c *)e)->a ^ ((c *)h)->a; + if (aa) + h = sizeof(long); + q = h; + } + } + ab = q; + char s; + if (s) { + char t = l = g(t); + } + } + if (j && b) + if (ac) + d(); + } +} +void v() { + const int al = am(); + if (al) + n(am, v); +an: + n(am, v); + if (o) + goto an; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr90020.c b/gcc/testsuite/gcc.dg/torture/pr90020.c new file mode 100644 index 00000000000..1748243852a --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr90020.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ +/* { dg-require-weak "" } */ +/* { dg-additional-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } } */ +/* { dg-additional-options "-Wl,-flat_namespace" { target *-*-darwin[89]* } } */ + +void __attribute__((noinline,noclone)) +check (int i) +{ + if (i == 0) + __builtin_exit (0); +} + +int i; +extern int x __attribute__((weak)); + +int main(int argc, char **argv) +{ + if (argc) + { + check (i); + return x; + } + else + { + check (i); + return x-1; + } + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr90278.c b/gcc/testsuite/gcc.dg/torture/pr90278.c new file mode 100644 index 00000000000..617246a6d4c --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr90278.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fexceptions -fnon-call-exceptions" } */ + +double +hc (void) +{ + double dp = 0.0; + double ek[1]; + + ek[0] = 1.0 / dp < 0.0; + + return ek[0]; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr90328.c b/gcc/testsuite/gcc.dg/torture/pr90328.c new file mode 100644 index 00000000000..a70f3dd425e --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr90328.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ + +void g(int*__restrict x, int*y) +{ + *x = *y; +} + +void __attribute__((noipa)) f(int* a,int* b) +{ + for(int i=0;i<1024;++i) + g(a+i,b+i); +} + +int main() +{ + int x[1025]; + for (int i = 0; i < 1025; ++i) + x[i] = i+1; + f(x+1, x); + for (int i = 0; i < 1025; ++i) + if (x[i] != 1) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr91126.c b/gcc/testsuite/gcc.dg/torture/pr91126.c new file mode 100644 index 00000000000..8e34815b9a7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr91126.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ + +struct S +{ + __INT32_TYPE__ a : 24; + __INT32_TYPE__ b : 8; +} s; + +int +main() +{ + s.a = 0xfefefe; + s.b = 0xfe; + unsigned char c; + c = ((unsigned char *)&s)[0]; + if (c != 0xfe) + __builtin_abort (); + c = ((unsigned char *)&s)[1]; + if (c != 0xfe) + __builtin_abort (); + c = ((unsigned char *)&s)[2]; + if (c != 0xfe) + __builtin_abort (); + c = ((unsigned char *)&s)[3]; + if (c != 0xfe) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr91200.c b/gcc/testsuite/gcc.dg/torture/pr91200.c new file mode 100644 index 00000000000..09db9e142c7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr91200.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ + +int printf (const char *, ...); + +char a; +int b, c, **d; + +int main () +{ + int f = -128, *g, *h[2] = {0, 0}, i; + printf("0"); + if (a) + { + while (f > a) { + int *j = &i; + *j |= 0; + } + h[i] = &c; + } + if (h[1]) + { + int **k = &g; + *k = &f; + while (i) + { + int **l[] = {&g}; + } + int **m = &g; + *d = *m = &b; + } + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr91812.c b/gcc/testsuite/gcc.dg/torture/pr91812.c new file mode 100644 index 00000000000..ebc67a01e33 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr91812.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */ +/* { dg-options "-fdump-tree-optimized-blocks" } */ + +unsigned register1; +unsigned register2; + +void busy_wait_for_register (int x) +{ + volatile unsigned* ptr; + switch(x) { + case 0x1111: + ptr = ®ister1; + break; + + case 0x2222: + ptr = ®ister2; + break; + + default: + return; + } + while (*ptr) {} +} + +/* { dg-final { scan-tree-dump "loop depth 1" "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/torture/restrict-7.c b/gcc/testsuite/gcc.dg/torture/restrict-7.c new file mode 100644 index 00000000000..107371098b3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/restrict-7.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ + +extern void abort (void); + +static inline __attribute__((always_inline)) void +copy(int *restrict a, int *restrict b) +{ + *b = *a; + *a = 7; +} + +void __attribute__((noinline)) +floppy(int mat[static 2], unsigned idxs[static 3]) +{ + for (int i = 0; i < 3; i++) + copy(&mat[i%2], &mat[idxs[i]]); +} + +int main() +{ + int mat[2] = {10, 20}; + unsigned idxs[3] = {1, 0, 1}; + floppy(mat, idxs); + if (mat[0] != 7 || mat[1] != 10) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr89725.c b/gcc/testsuite/gcc.dg/tree-ssa/pr89725.c new file mode 100644 index 00000000000..ad826d90b86 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr89725.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -floop-interchange -fno-tree-dce" } */ +int abs (int); +int find_sad_16x16(int *intra_mode) +{ + int current_intra_sad_2,best_intra_sad2; + int M1[16][16],M0[4][4][4][4],M3[4],M4[4][4]; + int i,j,k; + int ii,jj; + int up_avail, left_avail, left_up_avail; + for (i=0;i<17;i++) + if (left_up_avail) + { + for (jj=0;jj<4;jj++) + for (ii=0;ii<4;ii++) + for (j=0;j<4;j++) + for (i=0;i<4;i++) + { + M0[i][ii][2][jj]=M3[0]-M3[1]; + M0[i][ii][1][jj]=M3[2]+M3[3]; + current_intra_sad_2 += abs(M0[i][ii][j][jj]); + } + + if(current_intra_sad_2 < best_intra_sad2) + best_intra_sad2=current_intra_sad_2; + } + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr91091-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr91091-1.c new file mode 100644 index 00000000000..2ee75d9804a --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr91091-1.c @@ -0,0 +1,23 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -fno-strict-aliasing" } */ + +struct s { int x; } __attribute__((packed)); +struct t { int x; }; + +void __attribute__((noinline,noipa)) +swap(struct s* p, struct t* q) +{ + p->x = q->x; + q->x = p->x; +} + +int main() +{ + struct t a[2]; + a[0].x = 0x12345678; + a[1].x = 0x98765432; + swap ((struct s *)((char *)a + 1), a); + if (a[0].x != 0x12345678) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-78.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-78.c new file mode 100644 index 00000000000..4ad232ea123 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-78.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -fstrict-aliasing" } */ + +union U { + struct A { int : 2; int x : 8; } a; + struct B { int : 6; int x : 8; } b; +}; + +int __attribute__((noipa)) +foo (union U *p, union U *q) +{ + p->a.x = 1; + q->b.x = 1; + return p->a.x; +} + +int +main() +{ + union U x; + if (foo (&x, &x) != x.a.x) + __builtin_abort (); + return 0; +} + +/* We support arbitrary punning through unions when it happens through + the union type and thus p == q is valid here. */ diff --git a/gcc/testsuite/gcc.dg/uninit-19.c b/gcc/testsuite/gcc.dg/uninit-19.c index 094dc0eb73d..553991e4dd9 100644 --- a/gcc/testsuite/gcc.dg/uninit-19.c +++ b/gcc/testsuite/gcc.dg/uninit-19.c @@ -12,7 +12,7 @@ fn1 (int p1, float *f1, float *f2, float *f3, unsigned char *c1, float *f4, { if (p1 & 8) b[3] = p10[a]; - /* { dg-warning "may be used uninitialized" "" { target { { nonpic } || { hppa*64*-*-* } } } .-1 } */ + /* { dg-warning "may be used uninitialized" "" { target { { nonpic } || { hppa*64*-*-* *-*-darwin* } } } .-1 } */ } void @@ -22,5 +22,5 @@ fn2 () if (l & 6) n = &c + m; fn1 (l, &d, &e, &g, &i, &h, &k, n); - /* { dg-warning "may be used uninitialized" "" { target { ! { { nonpic } || { hppa*64*-*-* } } } } .-1 } */ + /* { dg-warning "may be used uninitialized" "" { target { ! { { nonpic } || { hppa*64*-*-* *-*-darwin* } } } } .-1 } */ } diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr90006.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr90006.c new file mode 100644 index 00000000000..104d3fb89b0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr90006.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fno-math-errno" } */ +/* { dg-additional-options "-march=x86-64" { target x86_64-*-* i?86-*-* } } */ + +long int lrint(double x); + +int a, b; +union c { + int d; +}; + +int e() +{ + int f, g, h; + long i, j, k; + double l, m = b = lrint(0.3127); + a = b >> 16 >> 8 & 255; + ((union c *)e)->d = a; + k = m; + h = k >> 16 >> 8 & 255; + ((union c *)(e + 4))->d = h; + j = lrint(l); + g = j >> 16 >> 8 & 255; + ((union c *)(e + 8))->d = g; + i = lrint(0.292); + f = i >> 16 >> 8 & 255; + ((union c *)(e + 12))->d = f; + return 0; +} + +/* { dg-final { scan-tree-dump "basic block vectorized" "slp2" { target { { x86_64-*-* i?86-*-* } && ilp32 } } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/pr81740-1.c b/gcc/testsuite/gcc.dg/vect/pr81740-1.c new file mode 100644 index 00000000000..d2226fcdbee --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr81740-1.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ +/* { dg-require-effective-target vect_int } */ + +#include "tree-vect.h" + +int a[8][10] = { [2][5] = 4 }, c; + +int +main () +{ + short b; + int i, d; + check_vect (); + for (b = 4; b >= 0; b--) + for (c = 0; c <= 6; c++) + a[c + 1][b + 2] = a[c][b + 1]; + for (i = 0; i < 8; i++) + for (d = 0; d < 10; d++) + if (a[i][d] != (i == 3 && d == 6) * 4) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/pr81740-2.c b/gcc/testsuite/gcc.dg/vect/pr81740-2.c new file mode 100644 index 00000000000..6bb8371aacb --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr81740-2.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_hw_misalign } */ + +#include "tree-vect.h" + +int a[8][10] = { [2][5] = 4 }, c; + +int +main () +{ + short b; + int i, d; + check_vect (); + for (b = 4; b >= 0; b--) + for (c = 6; c >= 0; c--) + a[c + 1][b + 2] = a[c][b + 1]; + for (i = 0; i < 8; i++) + for (d = 0; d < 10; d++) + if (a[i][d] != (i == 3 && d == 6) * 4) + __builtin_abort (); + return 0; +} + +/* { dg-final { scan-tree-dump "OUTER LOOP VECTORIZED" "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/pr91293-1.c b/gcc/testsuite/gcc.dg/vect/pr91293-1.c new file mode 100644 index 00000000000..dc321f5726f --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr91293-1.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse4.1" { target { sse4_runtime } } } */ + +long long a; +unsigned b, c; +int d = 62; +void e(long long *f, int p2) { *f = p2; } +int main() +{ + for (int g = 2; g <= d; g++) + { + b += g + 4; + c += 5 - g; + } + e(&a, b); + if (a != 2196) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/pr91293-2.c b/gcc/testsuite/gcc.dg/vect/pr91293-2.c new file mode 100644 index 00000000000..b9354bbd5e8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr91293-2.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse4.1" { target { sse4_runtime } } } */ + +long long a; +unsigned b, c; +int d = 62; +void e(long long *f, int p2) { *f = p2; } +int main() +{ + for (int g = 2; g <= d; g++) + { + c += 5 - g; + b += g + 4; + } + e(&a, b); + if (a != 2196) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/pr91293-3.c b/gcc/testsuite/gcc.dg/vect/pr91293-3.c new file mode 100644 index 00000000000..c35bc3481cb --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr91293-3.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-additional-options "-msse4.1" { target { sse4_runtime } } } */ + +long long a; +unsigned b, c; +int d = 62; +void e(long long *f, int p2) { *f = p2; } +int xx = 5, yy = 4; +int main() +{ + for (int g = 2; g <= d; g++) + { + c += xx - g; + b += yy + g; + } + e(&a, b); + if (a != 2196) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/pr91665.c b/gcc/testsuite/gcc.dg/vect/pr91665.c new file mode 100644 index 00000000000..6b69ea030b1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr91665.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/91665 */ +/* { dg-do compile } */ +/* { dg-additional-options "-Ofast" } */ + +short int v; + +void +foo (short int x, short int y) +{ + short int *p = &v; + + x = 1; + while (x != 0) + x += ++y || (*p = x); +} diff --git a/gcc/testsuite/gcc.dg/vect/slp-reduc-sad.c b/gcc/testsuite/gcc.dg/vect/slp-reduc-sad.c index d921c7cd65d..5f7a3e09f60 100644 --- a/gcc/testsuite/gcc.dg/vect/slp-reduc-sad.c +++ b/gcc/testsuite/gcc.dg/vect/slp-reduc-sad.c @@ -12,7 +12,7 @@ extern void abort (void); int __attribute__((noinline,noclone)) foo (uint8_t *pix1, uint8_t *pix2, int i_stride_pix2) { - int i_sum = 0; + int i_sum = 5; for( int y = 0; y < 16; y++ ) { i_sum += abs ( pix1[0] - pix2[0] ); @@ -52,7 +52,7 @@ main () __asm__ volatile (""); } - if (foo (X, Y, 16) != 32512) + if (foo (X, Y, 16) != 32512 + 5) abort (); return 0; diff --git a/gcc/testsuite/gcc.target/aarch64/no-inline-lrint_3.c b/gcc/testsuite/gcc.target/aarch64/no-inline-lrint_3.c new file mode 100644 index 00000000000..ca772cb999e --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/no-inline-lrint_3.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target ilp32 } */ +/* { dg-options "-O3 -fno-math-errno -fno-fp-int-builtin-inexact" } */ + +#define TEST(name, float_type, int_type, fn) void f_##name (float_type x) \ +{ \ + volatile int_type b = __builtin_##fn (x); \ +} + +TEST (dld, double, long, lrint) +TEST (flf, float , long, lrintf) + +TEST (did, double, int, lrint) +TEST (fif, float , int, lrintf) + +/* { dg-final { scan-assembler-times "fcvtzs\tw\[0-9\]+, \[d,s\]\[0-9\]+" 2 } } */ +/* { dg-final { scan-assembler-times "bl\tlrint" 2 } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/nosplit-di-const-volatile_1.c b/gcc/testsuite/gcc.target/aarch64/nosplit-di-const-volatile_1.c new file mode 100644 index 00000000000..da5975ad165 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/nosplit-di-const-volatile_1.c @@ -0,0 +1,15 @@ +/* Check that storing the 64-bit immediate to a volatile location is done + with a single store. */ + +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef unsigned long long u64; + +void bar (u64 *x) +{ + *(volatile u64 *)x = 0xabcdef10abcdef10ULL; +} + +/* { dg-final { scan-assembler-times "str\tx..?, .*" 1 } } */ +/* { dg-final { scan-assembler-not "str\tw..?, .*" } } */ diff --git a/gcc/testsuite/gcc.target/arm/acle/crc_hf_1.c b/gcc/testsuite/gcc.target/arm/acle/crc_hf_1.c new file mode 100644 index 00000000000..e6cbfc0b33e --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/crc_hf_1.c @@ -0,0 +1,14 @@ +/* Test that using an Armv8-a hard-float target doesn't + break CRC intrinsics. */ + +/* { dg-do compile } */ +/* { dg-require-effective-target arm_hard_vfp_ok } */ +/* { dg-options "-mfloat-abi=hard -march=armv8-a+simd+crc" } */ + +#include <arm_acle.h> + +uint32_t +foo (uint32_t a, uint32_t b) +{ + return __crc32cw (a, b); +} diff --git a/gcc/testsuite/gcc.target/arm/pr86487.c b/gcc/testsuite/gcc.target/arm/pr86487.c new file mode 100644 index 00000000000..1c1db7852d9 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pr86487.c @@ -0,0 +1,10 @@ +/* { dg-skip-if "" { *-*-* } { "-march=armv[0-6]*" "-mthumb" } { "" } } */ +/* { dg-require-effective-target arm_neon_hw } */ +/* { dg-options "-O1 -mbig-endian" } */ +/* { dg-add-options arm_neon } */ +int a, b, c, d; +long long fn1(long long p2) { return p2 == 0 ? -1 : -1 % p2; } +void fn2(long long p1, short p2, long p3) { + b = fn1((d || 6) & a); + c = b | p3; +} diff --git a/gcc/testsuite/gcc.target/arm/pr88167-1.c b/gcc/testsuite/gcc.target/arm/pr88167-1.c new file mode 100644 index 00000000000..517a86d6e4b --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pr88167-1.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target arm_thumb1_ok } */ +/* { dg-options "-O2 -mthumb" } */ + +void *retaddr; + +void foo (void) { + retaddr = __builtin_return_address (0); + + /* Used for enforcing registers stacking. */ + asm volatile ("" : : : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", + "r8", "r9", "r10", "r11", "r12"); +} + +/* { dg-final { scan-assembler-not "mov\tlr," } } */ diff --git a/gcc/testsuite/gcc.target/arm/pr88167-2.c b/gcc/testsuite/gcc.target/arm/pr88167-2.c new file mode 100644 index 00000000000..6a303345eb9 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pr88167-2.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-skip-if "" { ! { arm_thumb1 } } } */ + +int __attribute__((noclone, noinline)) +foo (int a, long long b) { + /* Used for enforcing registers stacking. */ + asm volatile ("" : : : "r0", "r1", "r2", "r3", + "r8", "r9", "r10", "r11", "r12"); + return (int) b; +} + +int main () +{ + if (foo (1, 0x1000000000000003LL) != 3) + __builtin_abort (); + __builtin_exit (0); +} diff --git a/gcc/testsuite/gcc.target/arm/pr89190.c b/gcc/testsuite/gcc.target/arm/pr89190.c new file mode 100644 index 00000000000..e622d7081ed --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pr89190.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target arm_arch_v8m_base_ok } */ +/* { dg-options "-O2" } */ +/* { dg-add-options arm_arch_v8m_base } */ + +long long a; +int b, c; +int d(int e, int f) { return e << f; } +void g() { + long long h; + char i = d(b >= 7, 2); + c = i == 0 ?: 1 / i; + h = c && a ?: c + a; + b = h; +} diff --git a/gcc/testsuite/gcc.target/arm/pr89222.c b/gcc/testsuite/gcc.target/arm/pr89222.c new file mode 100644 index 00000000000..d26d7df1754 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pr89222.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void g (void); + +void f1 (int x) +{ + if (x != (int) g + 3) + return; + g(); +} + +void (*a2)(void); + +void f2 (void) +{ + a2 = &g + 3; +} + +typedef void (*__sighandler_t)(int); +void handler (int); + +void f3 (int x) +{ + __sighandler_t h = &handler; + if (h != (__sighandler_t) 2 && h != (__sighandler_t) 1) + h (x); +} + +/* { dg-final { scan-assembler-times {add(?:s)?\tr[0-9]+, r[0-9]+, #3} 2 } } */ +/* { dg-final { scan-assembler-not {.word\tg\+3} } } */ +/* { dg-final { scan-assembler-not {.word\thandler-1} } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-pr91150.c b/gcc/testsuite/gcc.target/i386/avx512bw-pr91150.c new file mode 100644 index 00000000000..8c6862265cb --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512bw-pr91150.c @@ -0,0 +1,37 @@ +/* PR target/91150 */ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512bw" } */ +/* { dg-require-effective-target avx512bw } */ + +#include "avx512bw-check.h" + +typedef unsigned char V __attribute__((vector_size (64))); + +__attribute__((noipa)) void +foo (V *x, V *y, V *z) +{ + *x = __builtin_shuffle (*y, *z, (V) { 0, 1, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, + 80, 81, 82, 83, 84, 85, 86, 87, + 88, 89, 90, 91, 92, 93, 94, 95, + 96, 97, 98, 99, 100, 101, 102, 103, + 104, 105, 106, 107, 108, 109, 110, 111, + 112, 113, 114, 115, 116, 117, 118, 119, + 120, 121, 122, 123, 124, 125, 126, 127 }); +} + +static void +avx512bw_test (void) +{ + union U { unsigned char a[64]; V v; } a, b, c; + int i; + for (i = 0; i < 64; i++) + { + b.a[i] = i + 1; + c.a[i] = i + 65; + } + foo (&a.v, &b.v, &c.v); + for (i = 0; i < 64; i++) + if (a.a[i] != (i < 16 ? i + 1 : i + 65)) + __builtin_abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-vpmovswb-1.c b/gcc/testsuite/gcc.target/i386/avx512bw-vpmovswb-1.c index 6bb87d25f4d..9d470c62b9e 100644 --- a/gcc/testsuite/gcc.target/i386/avx512bw-vpmovswb-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512bw-vpmovswb-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-mavx512bw -mavx512vl -O2" } */ +/* { dg-additional-options "-fno-common" { target *-*-darwin* } } */ /* { dg-final { scan-assembler-times "vpmovswb\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpmovswb\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpmovswb\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}{z}(?:\n|\[ \\t\]+#)" 1 } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-vpmovuswb-1.c b/gcc/testsuite/gcc.target/i386/avx512bw-vpmovuswb-1.c index 7825e46a944..da51198ffe1 100644 --- a/gcc/testsuite/gcc.target/i386/avx512bw-vpmovuswb-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512bw-vpmovuswb-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-mavx512bw -mavx512vl -O2" } */ +/* { dg-additional-options "-fno-common" { target *-*-darwin* } } */ /* { dg-final { scan-assembler-times "vpmovuswb\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpmovuswb\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpmovuswb\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}{z}(?:\n|\[ \\t\]+#)" 1 } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-vpmovwb-1.c b/gcc/testsuite/gcc.target/i386/avx512bw-vpmovwb-1.c index a1ad551392b..e67da87b33d 100644 --- a/gcc/testsuite/gcc.target/i386/avx512bw-vpmovwb-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512bw-vpmovwb-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-mavx512bw -mavx512vl -O2" } */ +/* { dg-additional-options "-fno-common" { target *-*-darwin* } } */ /* { dg-final { scan-assembler-times "vpmovwb\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpmovwb\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpmovwb\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}{z}(?:\n|\[ \\t\]+#)" 1 } } */ diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-5a.c b/gcc/testsuite/gcc.target/i386/cet-notrack-5a.c index 50fe0db7d0c..3856507fb71 100644 --- a/gcc/testsuite/gcc.target/i386/cet-notrack-5a.c +++ b/gcc/testsuite/gcc.target/i386/cet-notrack-5a.c @@ -2,7 +2,8 @@ /* { dg-options "-O -fcf-protection" } */ /* { dg-final { scan-assembler-times "endbr32" 1 { target ia32 } } } */ /* { dg-final { scan-assembler-times "endbr64" 1 { target { ! ia32 } } } } */ -/* { dg-final { scan-assembler-not "\tcall\[ \t]+" } } */ +/* { dg-final { scan-assembler-not "\tcall\[ \t]+" { target { { ! ia32 } || { ! *-*-darwin* } } } } } */ +/* { dg-final { scan-assembler-times "\tcall\[ \t]+" 1 { target { ia32 && *-*-darwin* } } } } */ /* { dg-final { scan-assembler-times "notrack call\[ \t]+" 1 } } */ int (*fptr) (int) __attribute__ ((nocf_check)); diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-5b.c b/gcc/testsuite/gcc.target/i386/cet-notrack-5b.c index 222ff62d670..332737c13ae 100644 --- a/gcc/testsuite/gcc.target/i386/cet-notrack-5b.c +++ b/gcc/testsuite/gcc.target/i386/cet-notrack-5b.c @@ -3,7 +3,8 @@ /* { dg-options "-O -fcf-protection" } */ /* { dg-final { scan-assembler-times "endbr32" 1 { target ia32 } } } */ /* { dg-final { scan-assembler-times "endbr64" 1 { target { ! ia32 } } } } */ -/* { dg-final { scan-assembler-times "\tcall\[ \t]+" 1 } } */ +/* { dg-final { scan-assembler-times "\tcall\[ \t]+" 1 { target { { ! ia32 } || { ! *-*-darwin* } } } } } */ +/* { dg-final { scan-assembler-times "\tcall\[ \t]+" 2 { target { ia32 && *-*-darwin* } } } } */ /* { dg-final { scan-assembler-times "notrack call\[ \t]+" 1 } } */ int (*fptr) (int) __attribute__ ((nocf_check)); diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-6b.c b/gcc/testsuite/gcc.target/i386/cet-notrack-6b.c index f27088c7283..041ba318d77 100644 --- a/gcc/testsuite/gcc.target/i386/cet-notrack-6b.c +++ b/gcc/testsuite/gcc.target/i386/cet-notrack-6b.c @@ -2,7 +2,8 @@ /* { dg-options "-O0 -fcf-protection" } */ /* { dg-final { scan-assembler-times "endbr32" 1 { target ia32 } } } */ /* { dg-final { scan-assembler-times "endbr64" 1 { target { ! ia32 } } } } */ -/* { dg-final { scan-assembler-not "\tcall\[ \t]+" } } */ +/* { dg-final { scan-assembler-not "\tcall\[ \t]+" { target { { ! ia32 } || { ! *-*-darwin* } } } } } */ +/* { dg-final { scan-assembler-times "\tcall\[ \t]+" 1 { target { ia32 && *-*-darwin* } } } } */ /* { dg-final { scan-assembler-times "notrack call\[ \t]+" 1 } } */ int foo (int arg); diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-icf-1.c b/gcc/testsuite/gcc.target/i386/cet-notrack-icf-1.c index 0bddf54862a..a601ed3f6c4 100644 --- a/gcc/testsuite/gcc.target/i386/cet-notrack-icf-1.c +++ b/gcc/testsuite/gcc.target/i386/cet-notrack-icf-1.c @@ -3,8 +3,8 @@ /* { dg-options "-O2 -fcf-protection=none" } */ /* { dg-final { scan-assembler-not "endbr" } } */ /* { dg-final { scan-assembler-not "fn3:" } } */ -/* { dg-final { scan-assembler "set\[ \t]+fn2,fn1" } } */ -/* { dg-final { scan-assembler "set\[ \t]+fn3,fn1" } } */ +/* { dg-final { scan-assembler "set\[ \t]+fn2,fn1" { target { ! *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "set\[ \t]+fn3,fn1" { target { ! *-*-darwin* } } } } */ static __attribute__((noinline)) int fn1 (int x) diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-icf-2.c b/gcc/testsuite/gcc.target/i386/cet-notrack-icf-2.c index 08132a3e7ac..f15594d1f0b 100644 --- a/gcc/testsuite/gcc.target/i386/cet-notrack-icf-2.c +++ b/gcc/testsuite/gcc.target/i386/cet-notrack-icf-2.c @@ -3,7 +3,7 @@ /* { dg-options "-O2 -fcf-protection" } */ /* { dg-final { scan-assembler "endbr" } } */ /* { dg-final { scan-assembler "fn3:" } } */ -/* { dg-final { scan-assembler "set\[ \t]+fn2,fn1" } } */ +/* { dg-final { scan-assembler "set\[ \t]+fn2,fn1" { target { ! *-*-darwin* } } } } */ static __attribute__((noinline)) int fn1 (int x) diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-icf-3.c b/gcc/testsuite/gcc.target/i386/cet-notrack-icf-3.c index ed2d53ac5ef..a733789aa25 100644 --- a/gcc/testsuite/gcc.target/i386/cet-notrack-icf-3.c +++ b/gcc/testsuite/gcc.target/i386/cet-notrack-icf-3.c @@ -3,8 +3,8 @@ /* { dg-options "-O2 -fcf-protection=none" } */ /* { dg-final { scan-assembler-not "endbr" } } */ /* { dg-final { scan-assembler-not "fn2:" } } */ -/* { dg-final { scan-assembler "set\[ \t]+fn2,fn1" } } */ -/* { dg-final { scan-assembler "set\[ \t]+fn3,fn1" } } */ +/* { dg-final { scan-assembler "set\[ \t]+fn2,fn1" { target { ! *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "set\[ \t]+fn3,fn1" { target { ! *-*-darwin* } } } } */ int (*foo)(int); diff --git a/gcc/testsuite/gcc.target/i386/cet-notrack-icf-4.c b/gcc/testsuite/gcc.target/i386/cet-notrack-icf-4.c index b5f07876b52..7d646662a4e 100644 --- a/gcc/testsuite/gcc.target/i386/cet-notrack-icf-4.c +++ b/gcc/testsuite/gcc.target/i386/cet-notrack-icf-4.c @@ -3,7 +3,7 @@ /* { dg-options "-O2 -fcf-protection" } */ /* { dg-final { scan-assembler "endbr" } } */ /* { dg-final { scan-assembler "fn2:" } } */ -/* { dg-final { scan-assembler "set\[ \t]+fn3,fn1" } } */ +/* { dg-final { scan-assembler "set\[ \t]+fn3,fn1" { target { ! *-*-darwin* } } } } */ int (*foo)(int); diff --git a/gcc/testsuite/gcc.target/i386/cet-sjlj-3.c b/gcc/testsuite/gcc.target/i386/cet-sjlj-3.c index 25117cc0c9f..e2653dbb2c5 100644 --- a/gcc/testsuite/gcc.target/i386/cet-sjlj-3.c +++ b/gcc/testsuite/gcc.target/i386/cet-sjlj-3.c @@ -3,7 +3,7 @@ /* { dg-final { scan-assembler-times "endbr32" 4 { target ia32 } } } */ /* { dg-final { scan-assembler-times "endbr64" 4 { target { ! ia32 } } } } */ /* { dg-final { scan-assembler-times "call _?setjmp" 1 } } */ -/* { dg-final { scan-assembler-times "call longjmp" 1 } } */ +/* { dg-final { scan-assembler-times "call _?longjmp" 1 } } */ #include <stdio.h> #include <setjmp.h> diff --git a/gcc/testsuite/gcc.target/i386/cet-sjlj-5.c b/gcc/testsuite/gcc.target/i386/cet-sjlj-5.c index 1b624327d0f..8470f9cbf88 100644 --- a/gcc/testsuite/gcc.target/i386/cet-sjlj-5.c +++ b/gcc/testsuite/gcc.target/i386/cet-sjlj-5.c @@ -3,7 +3,7 @@ /* { dg-final { scan-assembler-times "endbr32" 2 { target ia32 } } } */ /* { dg-final { scan-assembler-times "endbr64" 2 { target { ! ia32 } } } } */ /* { dg-final { scan-assembler-times "call _?setjmp" 1 } } */ -/* { dg-final { scan-assembler-times "call longjmp" 1 } } */ +/* { dg-final { scan-assembler-times "call _?longjmp" 1 } } */ #include <stdio.h> #include <setjmp.h> diff --git a/gcc/testsuite/gcc.target/i386/cet-sjlj-6b.c b/gcc/testsuite/gcc.target/i386/cet-sjlj-6b.c index 6ec4b834bfb..b2376e710df 100644 --- a/gcc/testsuite/gcc.target/i386/cet-sjlj-6b.c +++ b/gcc/testsuite/gcc.target/i386/cet-sjlj-6b.c @@ -1,4 +1,5 @@ /* { dg-do compile { target { ! ia32 } } } */ +/* { dg-require-effective-target maybe_x32 } */ /* { dg-options "-O -maddress-mode=long -fcf-protection -mx32" } */ /* { dg-final { scan-assembler-times "endbr64" 2 } } */ /* { dg-final { scan-assembler-times "movq\t.*buf\\+16" 1 } } */ diff --git a/gcc/testsuite/gcc.target/i386/fuse-caller-save-rec.c b/gcc/testsuite/gcc.target/i386/fuse-caller-save-rec.c index 7abcf91e26d..e8d4efb260e 100644 --- a/gcc/testsuite/gcc.target/i386/fuse-caller-save-rec.c +++ b/gcc/testsuite/gcc.target/i386/fuse-caller-save-rec.c @@ -18,14 +18,12 @@ foo (int y) return y + bar (y); } -/* For !nonpic && ia32 xfails, see PR64895. */ - /* Check that no registers are saved/restored. */ -/* { dg-final { scan-assembler-not "push" { xfail { { ! nonpic } && ia32 } } } } */ -/* { dg-final { scan-assembler-not "pop" { xfail { { ! nonpic } && ia32 } } } } */ +/* { dg-final { scan-assembler-not "push" } } */ +/* { dg-final { scan-assembler-not "pop" } } */ /* Check that addition uses dx. */ -/* { dg-final { scan-assembler-times "addl\t%\[re\]?dx, %\[re\]?ax" 1 { xfail { { ! nonpic } && ia32 } } } } */ +/* { dg-final { scan-assembler-times "addl\t%\[re\]?dx, %\[re\]?ax" 1 } } */ /* Verify that bar is self-recursive. */ /* { dg-final { scan-assembler-times "call\t_?bar" 2 } } */ diff --git a/gcc/testsuite/gcc.target/i386/fuse-caller-save-xmm.c b/gcc/testsuite/gcc.target/i386/fuse-caller-save-xmm.c index c2d0544d665..4deff93c1e8 100644 --- a/gcc/testsuite/gcc.target/i386/fuse-caller-save-xmm.c +++ b/gcc/testsuite/gcc.target/i386/fuse-caller-save-xmm.c @@ -15,13 +15,19 @@ foo (v2df y) return y + bar (y); } -/* For !nonpic && ia32 xfails, see PR64895. */ - /* Check presence of all insns on xmm registers. These checks are expected to pass with both -fipa-ra and -fno-ipa-ra. */ -/* { dg-final { scan-assembler-times "addpd\t\\.?LC0.*, %xmm0" 1 } } */ -/* { dg-final { scan-assembler-times "addpd\t%xmm1, %xmm0" 1 { xfail { { ! nonpic } && ia32 } } } } */ -/* { dg-final { scan-assembler-times "movapd\t%xmm0, %xmm1" 1 { xfail { { ! nonpic } && ia32 } } } } */ + +/* Darwin local constant symbol is "lC0", ELF targets ".LC0" */ +/* { dg-final { scan-assembler-times {addpd\t\.?[Ll]C0.*, %xmm0} 1 { target { { ! ia32 } || nonpic } } } } */ +/* { dg-final { scan-assembler-times {movapd\t\.?[Ll]C0.*, %xmm1} 1 { target { ia32 && { ! nonpic } } } } } */ + +/* We happen to get this for both cases, but in different positions. */ +/* { dg-final { scan-assembler-times "addpd\t%xmm1, %xmm0" 1 } } */ + +/* { dg-final { scan-assembler-times "movapd\t%xmm0, %xmm1" 1 { target { { ! ia32 } || nonpic } } } } */ +/* { dg-final { scan-assembler-times "movapd\t%xmm0, %xmm2" 1 { target { ia32 && { ! nonpic } } } } } */ +/* { dg-final { scan-assembler-times "addpd\t%xmm2, %xmm0" 1 { target { ia32 && { ! nonpic } } } } } */ /* Check absence of save/restore of xmm1 register. */ /* { dg-final { scan-assembler-not "movaps\t%xmm1, \\(%\[re\]?sp\\)" } } */ diff --git a/gcc/testsuite/gcc.target/i386/fuse-caller-save.c b/gcc/testsuite/gcc.target/i386/fuse-caller-save.c index 4b8e68d90f5..c0e8bf443d0 100644 --- a/gcc/testsuite/gcc.target/i386/fuse-caller-save.c +++ b/gcc/testsuite/gcc.target/i386/fuse-caller-save.c @@ -16,11 +16,9 @@ foo (int y) return y + bar (y); } -/* For !nonpic && ia32 xfails, see PR64895. */ - /* Check that no registers are saved/restored. */ -/* { dg-final { scan-assembler-not "push" { xfail { { ! nonpic } && ia32 } } } } */ -/* { dg-final { scan-assembler-not "pop" { xfail { { ! nonpic } && ia32 } } } } */ +/* { dg-final { scan-assembler-not "push" } } */ +/* { dg-final { scan-assembler-not "pop" } } */ /* PR61605. If the first argument register and the return register differ, then bar leaves the first argument register intact. That means in foo that the @@ -31,4 +29,4 @@ foo (int y) /* { dg-final { scan-assembler-not "movl" { target { ! ia32 } } } } */ /* Check that addition uses di (in case of no copy) or dx (in case of copy). */ -/* { dg-final { scan-assembler-times "addl\t%\[re\]?d\[ix\], %\[re\]?ax" 1 { xfail { { ! nonpic } && ia32 } } } } */ +/* { dg-final { scan-assembler-times "addl\t%\[re\]?d\[ix\], %\[re\]?ax" 1 } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c index 6e94d2c4865..e2914a8333c 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk" } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ typedef void (*dispatch_t)(long offset); @@ -11,9 +12,11 @@ male_indirect_jump (long offset) dispatch(offset); } -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*dispatch" { target *-*-linux* } } } */ +/* { dg-final { scan-assembler {movq[ \t]*_dispatch} { target { lp64 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {movl[ \t]*[Ll]_dispatch\$non_lazy_ptr-L[0-9]+\$pb} { target { ia32 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "jmp\[ \t\]*_?__x86_indirect_thunk_(r|e)ax" } } */ +/* { dg-final { scan-assembler {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler {call[ \t]*\.?LIND} } } */ /* { dg-final { scan-assembler {\tpause} } } */ /* { dg-final { scan-assembler {\tlfence} } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c index 3c467078964..d2b7c74b143 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ typedef void (*dispatch_t)(long offset); @@ -11,9 +12,11 @@ male_indirect_jump (long offset) dispatch[offset](offset); } -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*dispatch" { target *-*-linux* } } } */ +/* { dg-final { scan-assembler {movq[ \t]*_dispatch} { target { lp64 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {movl[ \t]*[Ll]_dispatch\$non_lazy_ptr-L[0-9]+\$pb} { target { ia32 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "jmp\[ \t\]*_?__x86_indirect_thunk_(r|e)ax" } } */ +/* { dg-final { scan-assembler {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler {call[ \t]*\.?LIND} } } */ /* { dg-final { scan-assembler {\tpause} } } */ /* { dg-final { scan-assembler {\tlfence} } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c index e4c9b885d50..129fb2125f0 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ typedef void (*dispatch_t)(long offset); @@ -12,9 +13,11 @@ male_indirect_jump (long offset) return 0; } -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*dispatch" { target *-*-linux* } } } */ +/* { dg-final { scan-assembler {movq[ \t]*_dispatch} { target { lp64 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {movl[ \t]*[Ll]_dispatch\$non_lazy_ptr-L[0-9]+\$pb} { target { ia32 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "call\[ \t\]*_?__x86_indirect_thunk_(r|e)ax" } } */ +/* { dg-final { scan-assembler {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler {call[ \t]*\.?LIND} } } */ /* { dg-final { scan-assembler {\tpause} } } */ /* { dg-final { scan-assembler {\tlfence} } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c index b22554ae282..01996fb029f 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ typedef void (*dispatch_t)(long offset); @@ -12,9 +13,11 @@ male_indirect_jump (long offset) return 0; } -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*dispatch" { target *-*-linux* } } } */ +/* { dg-final { scan-assembler {movq[ \t]*_dispatch} { target { lp64 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {movl[ \t]*[Ll]_dispatch\$non_lazy_ptr-L[0-9]+\$pb} { target { ia32 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "call\[ \t\]*_?__x86_indirect_thunk_(r|e)ax" } } */ +/* { dg-final { scan-assembler {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler {call[ \t]*\.?LIND} } } */ /* { dg-final { scan-assembler {\tpause} } } */ /* { dg-final { scan-assembler {\tlfence} } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c index 53868f46558..6f2eec85122 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic -fjump-tables" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fjump-tables" } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ void func0 (void); void func1 (void); @@ -36,8 +37,10 @@ bar (int i) } /* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*\.L\[0-9\]+\\(,%" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler {leaq[ \t]*L[0-9]+\(%rip\)} { target { lp64 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {addl[ \t]*L[0-9]+-L[0-9]+\$pb} { target { ia32 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "jmp\[ \t\]*_?__x86_indirect_thunk_(r|e)ax" } } */ +/* { dg-final { scan-assembler {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler {call[ \t]*\.?LIND} } } */ /* { dg-final { scan-assembler {\tpause} } } */ /* { dg-final { scan-assembler {\tlfence} } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c index 7106407b83d..1493e18243b 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ typedef void (*dispatch_t)(long offset); @@ -14,9 +15,11 @@ male_indirect_jump (long offset) dispatch(offset); } -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*dispatch" { target *-*-linux* } } } */ +/* { dg-final { scan-assembler {movq[ \t]*_dispatch} { target { lp64 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {movl[ \t]*[Ll]_dispatch\$non_lazy_ptr-L[0-9]+\$pb} { target { ia32 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "jmp\[ \t\]*_?__x86_indirect_thunk_(r|e)ax" } } */ +/* { dg-final { scan-assembler {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler {call[ \t]*\.?LIND} } } */ /* { dg-final { scan-assembler {\tpause} } } */ /* { dg-final { scan-assembler {\tlfence} } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c index 27c7e5b029b..3ddd4980b69 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ typedef void (*dispatch_t)(long offset); @@ -12,9 +13,11 @@ male_indirect_jump (long offset) dispatch[offset](offset); } -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*dispatch" { target *-*-linux* } } } */ +/* { dg-final { scan-assembler {movq[ \t]*_dispatch} { target { lp64 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {movl[ \t]*[Ll]_dispatch\$non_lazy_ptr-L[0-9]+\$pb} { target { ia32 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "jmp\[ \t\]*_?__x86_indirect_thunk_(r|e)ax" } } */ +/* { dg-final { scan-assembler {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler {call[ \t]*\.?LIND} } } */ /* { dg-final { scan-assembler {\tpause} } } */ /* { dg-final { scan-assembler {\tlfence} } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c index 89a2bac8403..43d5f95b4fb 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ typedef void (*dispatch_t)(long offset); @@ -14,9 +15,11 @@ male_indirect_jump (long offset) return 0; } -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 2 } } */ -/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 2 } } */ +/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*dispatch" { target *-*-linux* } } } */ +/* { dg-final { scan-assembler {movq[ \t]*_dispatch} { target { lp64 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {movl[ \t]*[Ll]_dispatch\$non_lazy_ptr-L[0-9]+\$pb} { target { ia32 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler-times {jmp[ \t]*\.?LIND} 2 } } */ +/* { dg-final { scan-assembler-times {call[ \t]*\.?LIND} 2 } } */ /* { dg-final { scan-assembler {\tpause} } } */ /* { dg-final { scan-assembler {\tlfence} } } */ -/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ +/* { dg-final { scan-assembler-not "_?__x86_indirect_thunk" } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c index 3eb83c3779a..bf62636c63c 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ typedef void (*dispatch_t)(long offset); @@ -13,9 +14,11 @@ male_indirect_jump (long offset) return 0; } -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 2 } } */ -/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 2 } } */ +/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*dispatch" { target *-*-linux* } } } */ +/* { dg-final { scan-assembler {movq[ \t]*_dispatch} { target { lp64 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {movl[ \t]*[Ll]_dispatch\$non_lazy_ptr-L[0-9]+\$pb} { target { ia32 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler-times {jmp[ \t]*\.?LIND} 2 } } */ +/* { dg-final { scan-assembler-times {call[ \t]*\.?LIND} 2 } } */ /* { dg-final { scan-assembler {\tpause} } } */ /* { dg-final { scan-assembler {\tlfence} } } */ -/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ +/* { dg-final { scan-assembler-not "_?__x86_indirect_thunk" } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c index 0098dd1133d..27ba82932e4 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ typedef void (*dispatch_t)(long offset); @@ -14,8 +15,10 @@ male_indirect_jump (long offset) return 0; } -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ +/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*dispatch" { target *-*-linux* } } } */ +/* { dg-final { scan-assembler {movq[ \t]*_dispatch} { target { lp64 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {movl[ \t]*[Ll]_dispatch\$non_lazy_ptr-L[0-9]+\$pb} { target { ia32 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "call\[ \t\]*_?__x86_indirect_thunk_(r|e)ax" } } */ /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler-not {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler-not {call[ \t]*\.?LIND} } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c index ece8de15a4b..bdf15d36bac 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ typedef void (*dispatch_t)(long offset); @@ -13,8 +14,10 @@ male_indirect_jump (long offset) return 0; } -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ +/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*dispatch" { target *-*-linux* } } } */ +/* { dg-final { scan-assembler {movq[ \t]*_dispatch} { target { lp64 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {movl[ \t]*[Ll]_dispatch\$non_lazy_ptr-L[0-9]+\$pb} { target { ia32 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "call\[ \t\]*_?__x86_indirect_thunk_(r|e)ax" } } */ /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler-not {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler-not {call[ \t]*\.?LIND} } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c index ffe7350fce4..d5f2ba66af0 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ void func0 (void); void func1 (void); @@ -37,7 +38,9 @@ bar (int i) } /* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*\.L\[0-9\]+\\(,%" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk(_nt|)_(r|e)ax" } } */ +/* { dg-final { scan-assembler {leaq[ \t]*L[0-9]+\(%rip\)} { target { lp64 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {addl[ \t]*L[0-9]+-L[0-9]+\$pb} { target { ia32 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "jmp\[ \t\]*_?__x86_indirect_thunk(_nt|)_(r|e)ax" } } */ /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler-not {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler-not {call[ \t]*\.?LIND} } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-8.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-8.c index d730d31bda1..eb75968522b 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-8.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-8.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ +/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ void func0 (void); void func1 (void); @@ -36,7 +37,7 @@ bar (int i) } } -/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ +/* { dg-final { scan-assembler-not "_?__x86_indirect_thunk" } } */ /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler-not {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler-not {call[ \t]*\.?LIND} } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c index 73d16baddc7..6dce9045812 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-1.c @@ -1,5 +1,6 @@ /* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx" } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ void (*dispatch) (char *); char buf[10]; @@ -11,8 +12,8 @@ foo (void) } /* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler "bnd jmp\[ \t\]*__x86_indirect_thunk_bnd_rax" { target lp64 } } } */ -/* { dg-final { scan-assembler "bnd call\[ \t\]*__x86_indirect_thunk_bnd_eax" { target ia32 } } } */ +/* { dg-final { scan-assembler "bnd jmp\[ \t\]*_?__x86_indirect_thunk_bnd_rax" { target lp64 } } } */ +/* { dg-final { scan-assembler "bnd call\[ \t\]*_?__x86_indirect_thunk_bnd_eax" { target ia32 } } } */ /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ /* { dg-final { scan-assembler "bnd call\[ \t\]*\.LIND" } } */ /* { dg-final { scan-assembler "bnd ret" } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c index 856751ac224..20091c852d7 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-bnd-2.c @@ -1,5 +1,6 @@ /* { dg-do compile { target { ! x32 } } } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fcheck-pointer-bounds -mmpx" } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ void (*dispatch) (char *); char buf[10]; @@ -12,8 +13,8 @@ foo (void) } /* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler "bnd call\[ \t\]*__x86_indirect_thunk_bnd_(r|e)ax" } } */ -/* { dg-final { scan-assembler "bnd call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler "bnd call\[ \t\]*_?__x86_indirect_thunk_bnd_(r|e)ax" } } */ +/* { dg-final { scan-assembler "bnd call\[ \t\]*\.?LIND" } } */ /* { dg-final { scan-assembler "bnd ret" } } */ /* { dg-final { scan-assembler {\tpause} } } */ /* { dg-final { scan-assembler {\tlfence} } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c index c09dd0afd2d..c30c331c23b 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ typedef void (*dispatch_t)(long offset); @@ -11,8 +12,10 @@ male_indirect_jump (long offset) dispatch(offset); } -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ +/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*dispatch" { target *-*-linux* } } } */ +/* { dg-final { scan-assembler {movq[ \t]*_dispatch} { target { lp64 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {movl[ \t]*[Ll]_dispatch\$non_lazy_ptr-L[0-9]+\$pb} { target { ia32 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "jmp\[ \t\]*_?__x86_indirect_thunk_(r|e)ax" } } */ /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler-not {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler-not {call[ \t]*\.âLIND} } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c index 826425a5115..7edd7313027 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ typedef void (*dispatch_t)(long offset); @@ -11,8 +12,10 @@ male_indirect_jump (long offset) dispatch[offset](offset); } -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ +/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*dispatch" { target *-*-linux* } } } */ +/* { dg-final { scan-assembler {movq[ \t]*_dispatch} { target { lp64 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {movl[ \t]*[Ll]_dispatch\$non_lazy_ptr-L[0-9]+\$pb} { target { ia32 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "jmp\[ \t\]*_?__x86_indirect_thunk_(r|e)ax" } } */ /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler-not {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler-not {call[ \t]*\.?LIND} } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c index 385626850a2..8e391797c5e 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ typedef void (*dispatch_t)(long offset); @@ -12,8 +13,10 @@ male_indirect_jump (long offset) return 0; } -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ +/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*dispatch" { target *-*-linux* } } } */ +/* { dg-final { scan-assembler {movq[ \t]*_dispatch} { target { lp64 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {movl[ \t]*[Ll]_dispatch\$non_lazy_ptr-L[0-9]+\$pb} { target { ia32 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "call\[ \t\]*_?__x86_indirect_thunk_(r|e)ax" } } */ /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler-not {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler-not {call[ \t]*\.?LIND} } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c index 1ae49b137ca..6033d13e8a7 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ typedef void (*dispatch_t)(long offset); @@ -12,7 +13,8 @@ male_indirect_jump (long offset) return 0; } -/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" { target x32 } } } */ -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ +/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*dispatch" { target *-*-linux* } } } */ +/* { dg-final { scan-assembler {movq[ \t]*_dispatch} { target { lp64 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {movl[ \t]*[Ll]_dispatch\$non_lazy_ptr-L[0-9]+\$pb} { target { ia32 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "call\[ \t\]*_?__x86_indirect_thunk_(r|e)ax" } } */ /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c index 95c5cc176ae..f4c380f7dd2 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic -fjump-tables" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fjump-tables" } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ void func0 (void); void func1 (void); @@ -36,7 +37,7 @@ bar (int i) } /* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*\.L\[0-9\]+\\(,%" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk(_nt|)_(r|e)ax" } } */ +/* { dg-final { scan-assembler "jmp\[ \t\]*_?__x86_indirect_thunk(_nt|)_(r|e)ax" } } */ /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler-not {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler-not "call\[ \t\]*\.?LIND" } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c index 869d9040838..ef3577d2934 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ typedef void (*dispatch_t)(long offset); @@ -11,10 +12,12 @@ male_indirect_jump (long offset) dispatch(offset); } -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*dispatch" { target *-*-linux* } } } */ +/* { dg-final { scan-assembler {movq[ \t]*_dispatch} { target { lp64 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {movl[ \t]*[Ll]_dispatch\$non_lazy_ptr-L[0-9]+\$pb} { target { ia32 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler {call[ \t]*\.?LIND} } } */ /* { dg-final { scan-assembler {\tpause} } } */ /* { dg-final { scan-assembler {\tlfence} } } */ -/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ +/* { dg-final { scan-assembler-not "_?__x86_indirect_thunk" } } */ /* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c index c5c16ed8bd8..f26a5fb9015 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ typedef void (*dispatch_t)(long offset); @@ -11,10 +12,12 @@ male_indirect_jump (long offset) dispatch[offset](offset); } -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*dispatch" { target *-*-linux* } } } */ +/* { dg-final { scan-assembler {movq[ \t]*_dispatch} { target { lp64 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {movl[ \t]*[Ll]_dispatch\$non_lazy_ptr-L[0-9]+\$pb} { target { ia32 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler {call[ \t]*\.?LIND} } } */ /* { dg-final { scan-assembler {\tpause} } } */ /* { dg-final { scan-assembler {\tlfence} } } */ -/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ +/* { dg-final { scan-assembler-not "_?__x86_indirect_thunk" } } */ /* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c index 4a63ebed8ab..3b8a1eeaffb 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ typedef void (*dispatch_t)(long offset); @@ -12,10 +13,12 @@ male_indirect_jump (long offset) return 0; } -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 2 } } */ -/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 2 } } */ +/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*dispatch" { target *-*-linux* } } } */ +/* { dg-final { scan-assembler {movq[ \t]*_dispatch} { target { lp64 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {movl[ \t]*[Ll]_dispatch\$non_lazy_ptr-L[0-9]+\$pb} { target { ia32 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler-times {jmp[ \t]*\.?LIND} 2 } } */ +/* { dg-final { scan-assembler-times {call[ \t]*\.?LIND} 2 } } */ /* { dg-final { scan-assembler-times {\tpause} 1 } } */ /* { dg-final { scan-assembler-times {\tlfence} 1 } } */ -/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ +/* { dg-final { scan-assembler-not "_?__x86_indirect_thunk" } } */ /* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c index a395ffca018..40d31803a2e 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ typedef void (*dispatch_t)(long offset); @@ -12,10 +13,12 @@ male_indirect_jump (long offset) return 0; } -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?dispatch" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 2 } } */ -/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 2 } } */ +/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*dispatch" { target *-*-linux* } } } */ +/* { dg-final { scan-assembler {movq[ \t]*_dispatch} { target { lp64 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {movl[ \t]*[Ll]_dispatch\$non_lazy_ptr-L[0-9]+\$pb} { target { ia32 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler-times {jmp[ \t]*\.?LIND} 2 } } */ +/* { dg-final { scan-assembler-times {call[ \t]*\.?LIND} 2 } } */ /* { dg-final { scan-assembler-times {\tpause} 1 } } */ /* { dg-final { scan-assembler-times {\tlfence} 1 } } */ -/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ +/* { dg-final { scan-assembler-not "_?__x86_indirect_thunk" } } */ /* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" { target x32 } } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c index e6f064959a1..b161faa44f6 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic -fjump-tables" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fjump-tables" } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ void func0 (void); void func1 (void); @@ -37,8 +38,8 @@ bar (int i) /* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*\.L\[0-9\]+\\(,%" { target *-*-linux* } } } */ /* { dg-final { scan-assembler-not "pushq\[ \t\]%(r|e)ax" } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler {call[ \t]*\.?LIND} } } */ /* { dg-final { scan-assembler {\tpause} } } */ /* { dg-final { scan-assembler {\tlfence} } } */ -/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ +/* { dg-final { scan-assembler-not "_?__x86_indirect_thunk" } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-1.c index 7d396a31953..ea99fd8bdcb 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-1.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mindirect-branch=thunk -mindirect-branch-register -fno-pic" } */ +/* { dg-options "-O2 -mindirect-branch=thunk -mindirect-branch-register " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ typedef void (*dispatch_t)(long offset); @@ -11,12 +12,12 @@ male_indirect_jump (long offset) dispatch(offset); } -/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler "jmp\[ \t\]*_?__x86_indirect_thunk_(r|e)ax" } } */ +/* { dg-final { scan-assembler {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler {call[ \t]*\.?LIND} } } */ /* { dg-final { scan-assembler "mov\[ \t\](%eax|%rax), \\((%esp|%rsp)\\)" } } */ /* { dg-final { scan-assembler {\tpause} } } */ /* { dg-final { scan-assembler-not "push(?:l|q)\[ \t\]*_?dispatch" } } */ /* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */ -/* { dg-final { scan-assembler-not "__x86_indirect_thunk\n" } } */ -/* { dg-final { scan-assembler-not "__x86_indirect_thunk_bnd\n" } } */ +/* { dg-final { scan-assembler-not "_?__x86_indirect_thunk\n" } } */ +/* { dg-final { scan-assembler-not "_?__x86_indirect_thunk_bnd\n" } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-2.c index e7e616bb271..30847db480b 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-2.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-2.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mindirect-branch=thunk-inline -mindirect-branch-register -fno-pic" } */ +/* { dg-options "-O2 -mindirect-branch=thunk-inline -mindirect-branch-register " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ typedef void (*dispatch_t)(long offset); @@ -11,10 +12,10 @@ male_indirect_jump (long offset) dispatch(offset); } -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler {call[ \t]*\.?LIND} } } */ /* { dg-final { scan-assembler "mov\[ \t\](%eax|%rax), \\((%esp|%rsp)\\)" } } */ /* { dg-final { scan-assembler {\tpause} } } */ /* { dg-final { scan-assembler-not "push(?:l|q)\[ \t\]*_?dispatch" } } */ /* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */ -/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ +/* { dg-final { scan-assembler-not "_?__x86_indirect_thunk" } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-3.c index 5320e923be2..cbe14d52d75 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-3.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-3.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mindirect-branch=thunk-extern -mindirect-branch-register -fno-pic" } */ +/* { dg-options "-O2 -mindirect-branch=thunk-extern -mindirect-branch-register " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ typedef void (*dispatch_t)(long offset); @@ -11,9 +12,9 @@ male_indirect_jump (long offset) dispatch(offset); } -/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ +/* { dg-final { scan-assembler "jmp\[ \t\]*_?__x86_indirect_thunk_(r|e)ax" } } */ /* { dg-final { scan-assembler-not "push(?:l|q)\[ \t\]*_?dispatch" } } */ /* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */ /* { dg-final { scan-assembler-not {\t(pause|pause|nop)} } } */ -/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler-not {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler-not {call[ \t]*\.?LIND} } } */ diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c index f0cd9b75be8..6d2bfc911c1 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mindirect-branch=keep -fno-pic" } */ +/* { dg-options "-O2 -mindirect-branch=keep " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ extern void (*func_p) (void); diff --git a/gcc/testsuite/gcc.target/i386/memcpy-strategy-3.c b/gcc/testsuite/gcc.target/i386/memcpy-strategy-3.c index ddd1ef7c0b2..11687e8c9b5 100644 --- a/gcc/testsuite/gcc.target/i386/memcpy-strategy-3.c +++ b/gcc/testsuite/gcc.target/i386/memcpy-strategy-3.c @@ -1,6 +1,9 @@ /* { dg-do compile } */ /* { dg-options "-O2 -march=atom -mmemcpy-strategy=vector_loop:2000:align,libcall:-1:align" } */ -/* { dg-final { scan-assembler-times "memcpy" 2 } } */ +/* On ELF platforms, one hit comes from the .file directive. */ +/* { dg-final { scan-assembler-times "memcpy" 2 { target { ! *-*-darwin* } } } } */ +/* But not on Darwin, which doesn't have a .file directive by default. */ +/* { dg-final { scan-assembler-times "_memcpy" 1 { target *-*-darwin* } } } */ char a[2048]; char b[2048]; diff --git a/gcc/testsuite/gcc.target/i386/memset-strategy-1.c b/gcc/testsuite/gcc.target/i386/memset-strategy-1.c index d1b97c5df10..b4b8e2cfa6f 100644 --- a/gcc/testsuite/gcc.target/i386/memset-strategy-1.c +++ b/gcc/testsuite/gcc.target/i386/memset-strategy-1.c @@ -1,10 +1,12 @@ /* { dg-do compile } */ /* { dg-options "-O2 -march=atom -mmemset-strategy=libcall:-1:align" } */ -/* { dg-final { scan-assembler-times "memset" 2 } } */ +/* On ELF platforms, one hit comes from the .file directive. */ +/* { dg-final { scan-assembler-times "memset" 2 { target { ! *-*-darwin* } } } } */ +/* But not on Darwin, which doesn't have a .file directive by default. */ +/* { dg-final { scan-assembler-times "_memset" 1 { target *-*-darwin* } } } */ char a[2048]; void t (void) { __builtin_memset (a, 1, 2048); } - diff --git a/gcc/testsuite/gcc.target/i386/pconfig-1.c b/gcc/testsuite/gcc.target/i386/pconfig-1.c index a3fc4f411fe..40b4c0c1272 100644 --- a/gcc/testsuite/gcc.target/i386/pconfig-1.c +++ b/gcc/testsuite/gcc.target/i386/pconfig-1.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O2 -mpconfig" } */ -/* { dg-final { scan-assembler-times "pconfig" 5 } } */ +/* { dg-final { scan-assembler-times {\tpconfig} 2 } } */ #include <x86intrin.h> diff --git a/gcc/testsuite/gcc.target/i386/pr22076.c b/gcc/testsuite/gcc.target/i386/pr22076.c index 6c1620b4a3b..d31ffa584b4 100644 --- a/gcc/testsuite/gcc.target/i386/pr22076.c +++ b/gcc/testsuite/gcc.target/i386/pr22076.c @@ -1,6 +1,8 @@ /* { dg-do compile } */ /* { dg-options "-O2 -fomit-frame-pointer -flax-vector-conversions -mmmx" } */ /* { dg-additional-options "-mno-vect8-ret-in-mem" { target *-*-vxworks* } } */ +/* { dg-additional-options "-fno-common" { target *-*-darwin* } } */ +/* { dg-additional-options "-mdynamic-no-pic" { target { ia32 && *-*-darwin* } } } */ #include <mmintrin.h> diff --git a/gcc/testsuite/gcc.target/i386/pr24414.c b/gcc/testsuite/gcc.target/i386/pr24414.c index bd12f0c8492..0acaa001a5c 100644 --- a/gcc/testsuite/gcc.target/i386/pr24414.c +++ b/gcc/testsuite/gcc.target/i386/pr24414.c @@ -1,5 +1,6 @@ /* { dg-do run } */ /* { dg-options "-O2" } */ +/* { dg-skip-if "asm insert mismatches ABI for Darwin" { *-*-darwin* } } */ int test; int diff --git a/gcc/testsuite/gcc.target/i386/pr32219-1.c b/gcc/testsuite/gcc.target/i386/pr32219-1.c index bb28f9f0f58..0fcb138695b 100644 --- a/gcc/testsuite/gcc.target/i386/pr32219-1.c +++ b/gcc/testsuite/gcc.target/i386/pr32219-1.c @@ -12,7 +12,11 @@ foo () return xxx; } -/* { dg-final { scan-assembler "movl\[ \t\]xxx\\(%rip\\), %eax" { target { ! ia32 } } } } */ -/* { dg-final { scan-assembler-not "xxx@GOTPCREL" { target { ! ia32 } } } } */ -/* { dg-final { scan-assembler "movl\[ \t\]xxx@GOTOFF\\(%\[^,\]*\\), %eax" { target ia32 } } } */ -/* { dg-final { scan-assembler-not "movl\[ \t\]xxx@GOT\\(%\[^,\]*\\), %eax" { target ia32 } } } */ +/* { dg-final { scan-assembler {movl[ \t]_?xxx\(%rip\),[ \t]%eax} { target { ! ia32 } } } } */ +/* { dg-final { scan-assembler-not "_?xxx@GOTPCREL" { target { ! ia32 } } } } */ + +/* { dg-final { scan-assembler "movl\[ \t\]xxx@GOTOFF\\(%\[^,\]*\\), %eax" { target { ia32 && { ! *-*-darwin* } } } } } */ +/* { dg-final { scan-assembler-not "movl\[ \t\]_?xxx@GOT\\(%\[^,\]*\\), %eax" { target { ia32 && { ! *-*-darwin* } } } } } */ + +/* For Darwin, we default to PIC - but that's needed for Darwin's PIE. */ +/* { dg-final { scan-assembler {movl[ \t]_xxx-L1\$pb\(%eax\),[ \t]%eax} { target { ia32 && *-*-darwin* } } } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr32219-2.c b/gcc/testsuite/gcc.target/i386/pr32219-2.c index b30862d2488..b6212f7dd4c 100644 --- a/gcc/testsuite/gcc.target/i386/pr32219-2.c +++ b/gcc/testsuite/gcc.target/i386/pr32219-2.c @@ -12,6 +12,13 @@ foo () } /* { dg-final { scan-assembler-not "movl\[ \t\]xxx\\(%rip\\), %" { target { ! ia32 } } } } */ +/* For Darwin m64 we are always PIC, but common symbols are indirected, which happens to + match the general "ELF" case. */ /* { dg-final { scan-assembler "xxx@GOTPCREL" { target { ! ia32 } } } } */ -/* { dg-final { scan-assembler-not "movl\[ \t\]xxx@GOTOFF\\(%\[^,\]*\\), %" { target ia32 } } } */ -/* { dg-final { scan-assembler "movl\[ \t\]xxx@GOT\\(%\[^,\]*\\), %" { target ia32 } } } */ + +/* { dg-final { scan-assembler-not "movl\[ \t\]xxx@GOTOFF\\(%\[^,\]*\\), %" { target { ia32 && { ! *-*-darwin* } } } } } */ +/* { dg-final { scan-assembler "movl\[ \t\]xxx@GOT\\(%\[^,\]*\\), %" { target { ia32 && { ! *-*-darwin* } } } } } */ + +/* Darwin m32 defaults to PIC but common symbols need to be indirected. */ +/* { dg-final { scan-assembler {movl[ \t][Ll]_xxx\$non_lazy_ptr-L1\$pb\(%eax\),[ \t]%eax} { target { ia32 && *-*-darwin* } } } } */ + diff --git a/gcc/testsuite/gcc.target/i386/pr32219-3.c b/gcc/testsuite/gcc.target/i386/pr32219-3.c index 657fb7831f0..a1b0df28d0d 100644 --- a/gcc/testsuite/gcc.target/i386/pr32219-3.c +++ b/gcc/testsuite/gcc.target/i386/pr32219-3.c @@ -12,7 +12,16 @@ foo () return xxx; } -/* { dg-final { scan-assembler "movl\[ \t\]xxx\\(%rip\\), %eax" { target { ! ia32 } } } } */ -/* { dg-final { scan-assembler-not "xxx@GOTPCREL" { target { ! ia32 } } } } */ -/* { dg-final { scan-assembler "movl\[ \t\]xxx@GOTOFF\\(%\[^,\]*\\), %eax" { target ia32 } } } */ -/* { dg-final { scan-assembler-not "movl\[ \t\]xxx@GOT\\(%\[^,\]*\\), %eax" { target ia32 } } } */ +/* { dg-final { scan-assembler {movl[ \t]xxx\(%rip\),[ \t]%eax} { target { { ! ia32 } && { ! *-*-darwin* } } } } } */ +/* { dg-final { scan-assembler-not "xxx@GOTPCREL" { target { { ! ia32 } && { ! *-*-darwin* } } } } } */ + +/* For Darwin m64, code is always PIC and we need to indirect through the GOT to allow + weak symbols to be interposed. The dynamic loader knows how to apply PIE to this. */ +/* { dg-final { scan-assembler {movq[ \t]_xxx@GOTPCREL\(%rip\),[ \t]%rax} { target { { ! ia32 } && *-*-darwin* } } } } */ + +/* { dg-final { scan-assembler "movl\[ \t\]xxx@GOTOFF\\(%\[^,\]*\\), %eax" { target { ia32 && { ! *-*-darwin* } } } } } */ +/* { dg-final { scan-assembler-not "movl\[ \t\]xxx@GOT\\(%\[^,\]*\\), %eax" { target { ia32 && { ! *-*-darwin* } } } } } */ + +/* For Darwin, we need PIC to allow PIE, but also we must indirect weak symbols so that + they can be indirected. Again, dyld knows how to deal with this. */ +/* { dg-final { scan-assembler {movl[ \t][Ll]_xxx\$non_lazy_ptr-L1\$pb\(%eax\),[ \t]%eax} { target { ia32 && *-*-darwin* } } } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr32219-4.c b/gcc/testsuite/gcc.target/i386/pr32219-4.c index ff62fa4c051..31d0710b7ed 100644 --- a/gcc/testsuite/gcc.target/i386/pr32219-4.c +++ b/gcc/testsuite/gcc.target/i386/pr32219-4.c @@ -13,6 +13,12 @@ foo () } /* { dg-final { scan-assembler-not "movl\[ \t\]xxx\\(%rip\\), %" { target { ! ia32 } } } } */ +/* Darwin is always PIC for PIE so no change, weak symbols need to be indirect and this + happens to match the ELF case. */ /* { dg-final { scan-assembler "xxx@GOTPCREL" { target { ! ia32 } } } } */ -/* { dg-final { scan-assembler-not "movl\[ \t\]xxx@GOTOFF\\(%\[^,\]*\\), %" { target ia32 } } } */ -/* { dg-final { scan-assembler "movl\[ \t\]xxx@GOT\\(%\[^,\]*\\), %" { target ia32 } } } */ + +/* { dg-final { scan-assembler-not "movl\[ \t\]xxx@GOTOFF\\(%\[^,\]*\\), %" { target { ia32 && { ! *-*-darwin* } } } } } */ +/* { dg-final { scan-assembler "movl\[ \t\]xxx@GOT\\(%\[^,\]*\\), %" { target { ia32 && { ! *-*-darwin* } } } } } */ + +/* Darwin m32 equivalent (indirect and PIC). */ +/* { dg-final { scan-assembler {movl[ \t][Ll]_xxx\$non_lazy_ptr-L1\$pb\(%eax\),[ \t]%eax} { target { ia32 && *-*-darwin* } } } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr32219-5.c b/gcc/testsuite/gcc.target/i386/pr32219-5.c index e8844c85ff0..11496dc8608 100644 --- a/gcc/testsuite/gcc.target/i386/pr32219-5.c +++ b/gcc/testsuite/gcc.target/i386/pr32219-5.c @@ -11,7 +11,11 @@ foo () return xxx; } -/* { dg-final { scan-assembler "movl\[ \t\]xxx\\(%rip\\), %eax" { target { ! ia32 } } } } */ +/* { dg-final { scan-assembler "movl\[ \t\]_?xxx\\(%rip\\), %eax" { target { ! ia32 } } } } */ /* { dg-final { scan-assembler-not "xxx@GOTPCREL" { target { ! ia32 } } } } */ -/* { dg-final { scan-assembler "movl\[ \t\]xxx@GOTOFF\\(%\[^,\]*\\), %eax" { target ia32 } } } */ -/* { dg-final { scan-assembler-not "movl\[ \t\]xxx@GOT\\(%\[^,\]*\\), %eax" { target ia32 } } } */ + +/* { dg-final { scan-assembler "movl\[ \t\]xxx@GOTOFF\\(%\[^,\]*\\), %eax" { target { ia32 && { ! *-*-darwin* } } } } } */ +/* { dg-final { scan-assembler-not "movl\[ \t\]xxx@GOT\\(%\[^,\]*\\), %eax" { target { ia32 && { ! *-*-darwin* } } } } } */ + +/* For Darwin m32, we need PIC (the default) to allow PIE. */ +/* { dg-final { scan-assembler {movl[ \t]_xxx-L1\$pb\(%eax\),[ \t]%eax} { target { ia32 && *-*-darwin* } } } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr32219-6.c b/gcc/testsuite/gcc.target/i386/pr32219-6.c index 24e55ae0146..ff41ebd399e 100644 --- a/gcc/testsuite/gcc.target/i386/pr32219-6.c +++ b/gcc/testsuite/gcc.target/i386/pr32219-6.c @@ -11,7 +11,14 @@ foo () return xxx; } -/* { dg-final { scan-assembler-not "movl\[ \t\]xxx\\(%rip\\), %" { target { ! ia32 } } } } */ -/* { dg-final { scan-assembler "xxx@GOTPCREL" { target { ! ia32 } } } } */ -/* { dg-final { scan-assembler-not "movl\[ \t\]xxx@GOTOFF\\(%\[^,\]*\\), %" { target ia32 } } } */ -/* { dg-final { scan-assembler "movl\[ \t\]xxx@GOT\\(%\[^,\]*\\), %" { target ia32 } } } */ +/* { dg-final { scan-assembler-not "movl\[ \t\]xxx\\(%rip\\), %" { target { { ! ia32 } && { ! *-*-darwin* } } } } } */ +/* { dg-final { scan-assembler "xxx@GOTPCREL" { target { { ! ia32 } && { ! *-*-darwin* } } } } } */ + +/* Darwin m64 is always PIC, and the dynamic linker doesn't need an indirection. */ +/* { dg-final { scan-assembler {movl[ \t]_xxx\(%rip\),[ \t]%eax} { target { { ! ia32 } && *-*-darwin* } } } } */ + +/* { dg-final { scan-assembler-not "movl\[ \t\]xxx@GOTOFF\\(%\[^,\]*\\), %" { target { ia32 && { ! *-*-darwin* } } } } } */ +/* { dg-final { scan-assembler "movl\[ \t\]xxx@GOT\\(%\[^,\]*\\), %" { target { ia32 && { ! *-*-darwin* } } } } } */ + +/* Darwin m32 defaults to PIC, so no change. */ +/* { dg-final { scan-assembler {movl[ \t]_xxx-L1\$pb\(%eax\),[ \t]%eax} { target { ia32 && *-*-darwin* } } } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr32219-7.c b/gcc/testsuite/gcc.target/i386/pr32219-7.c index 9273d3ed9bb..20fef8dd063 100644 --- a/gcc/testsuite/gcc.target/i386/pr32219-7.c +++ b/gcc/testsuite/gcc.target/i386/pr32219-7.c @@ -12,7 +12,15 @@ foo () return xxx; } -/* { dg-final { scan-assembler "movl\[ \t\]xxx\\(%rip\\), %eax" { target { ! ia32 } } } } */ -/* { dg-final { scan-assembler-not "xxx@GOTPCREL" { target { ! ia32 } } } } */ -/* { dg-final { scan-assembler "movl\[ \t\]xxx@GOTOFF\\(%\[^,\]*\\), %eax" { target ia32 } } } */ -/* { dg-final { scan-assembler-not "movl\[ \t\]xxx@GOT\\(%\[^,\]*\\), %eax" { target ia32 } } } */ +/* { dg-final { scan-assembler "movl\[ \t\]xxx\\(%rip\\), %eax" { target { { ! ia32 } && { ! *-*-darwin* } } } } } */ +/* { dg-final { scan-assembler-not "xxx@GOTPCREL" { target { { ! ia32 } && { ! *-*-darwin* } } } } } */ + +/* For Darwin m64, code is always PIC but we need to indirect through the GOT to allow + weak symbols to be interposed. The dynamic loader knows how to apply PIE to this. */ +/* { dg-final { scan-assembler {movq[ \t]_xxx@GOTPCREL\(%rip\),[ \t]%rax} { target { { ! ia32 } && *-*-darwin* } } } } */ + +/* { dg-final { scan-assembler "movl\[ \t\]xxx@GOTOFF\\(%\[^,\]*\\), %eax" { target { ia32 && { ! *-*-darwin* } } } } } */ +/* { dg-final { scan-assembler-not "movl\[ \t\]xxx@GOT\\(%\[^,\]*\\), %eax" { target { ia32 && { ! *-*-darwin* } } } } } */ + +/* Darwin m32 equivalent (indirect and PIC). */ +/* { dg-final { scan-assembler {movl[ \t][Ll]_xxx\$non_lazy_ptr-L1\$pb\(%eax\),[ \t]%eax} { target { ia32 && *-*-darwin* } } } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr32219-8.c b/gcc/testsuite/gcc.target/i386/pr32219-8.c index c44919509de..767928f049e 100644 --- a/gcc/testsuite/gcc.target/i386/pr32219-8.c +++ b/gcc/testsuite/gcc.target/i386/pr32219-8.c @@ -13,6 +13,12 @@ foo () } /* { dg-final { scan-assembler-not "movl\[ \t\]xxx\\(%rip\\), %" { target { ! ia32 } } } } */ -/* { dg-final { scan-assembler "xxx@GOTPCREL" { target { ! ia32 } } } } */ -/* { dg-final { scan-assembler-not "movl\[ \t\]xxx@GOTOFF\\(%\[^,\]*\\), %" { target ia32 } } } */ -/* { dg-final { scan-assembler "movl\[ \t\]xxx@GOT\\(%\[^,\]*\\), %" { target ia32 } } } */ +/* Darwin is always PIC so no change, weak symbols needs to be indirect and this + happens to match the ELF case. */ +/* { dg-final { scan-assembler "_?xxx@GOTPCREL" { target { ! ia32 } } } } */ + +/* { dg-final { scan-assembler-not "movl\[ \t\]xxx@GOTOFF\\(%\[^,\]*\\), %" { target { ia32 && { ! *-*-darwin* } } } } } */ +/* { dg-final { scan-assembler "movl\[ \t\]xxx@GOT\\(%\[^,\]*\\), %" { target { ia32 && { ! *-*-darwin* } } } } } */ + +/* Darwin m32 default to PIC but needs indirection for the weak symbol. */ +/* { dg-final { scan-assembler {movl[ \t][Ll]_xxx\$non_lazy_ptr-L1\$pb\(%eax\),[ \t]%eax} { target { ia32 && *-*-darwin* } } } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr39013-1.c b/gcc/testsuite/gcc.target/i386/pr39013-1.c index ac22746772b..78b17028a11 100644 --- a/gcc/testsuite/gcc.target/i386/pr39013-1.c +++ b/gcc/testsuite/gcc.target/i386/pr39013-1.c @@ -12,5 +12,9 @@ main (void) return foo () + bar (); } -/* { dg-final { scan-assembler "foo@PLT" } } */ -/* { dg-final { scan-assembler "bar@PLT" } } */ +/* { dg-final { scan-assembler "foo@PLT" { target { ! *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "bar@PLT" { target { ! *-*-darwin* } } } } */ + +/* Darwin's dynamic linker does PIE without indirection. */ +/* { dg-final { scan-assembler {call[ \t]_foo} { target *-*-darwin* } } } */ +/* { dg-final { scan-assembler {call[ \t]_bar} { target *-*-darwin* } } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr39013-2.c b/gcc/testsuite/gcc.target/i386/pr39013-2.c index 3040d81a44d..f4412909bfe 100644 --- a/gcc/testsuite/gcc.target/i386/pr39013-2.c +++ b/gcc/testsuite/gcc.target/i386/pr39013-2.c @@ -12,5 +12,9 @@ main (void) return foo () + bar (); } -/* { dg-final { scan-assembler "foo@PLT" } } */ -/* { dg-final { scan-assembler "bar@PLT" } } */ +/* { dg-final { scan-assembler "foo@PLT" { target { ! *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "bar@PLT" { target { ! *-*-darwin* } } } } */ + +/* Darwin's dynamic linker does PIE without indirection. */ +/* { dg-final { scan-assembler {call[ \t]_foo} { target *-*-darwin* } } } */ +/* { dg-final { scan-assembler {call[ \t]_bar} { target *-*-darwin* } } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr49866.c b/gcc/testsuite/gcc.target/i386/pr49866.c index 622c8f65625..7c80f13ca3a 100644 --- a/gcc/testsuite/gcc.target/i386/pr49866.c +++ b/gcc/testsuite/gcc.target/i386/pr49866.c @@ -1,5 +1,6 @@ /* PR target/49866 */ /* { dg-do assemble { target lp64 } } */ +/* { dg-xfail-if "PR90698" { *-*-darwin* } } */ /* { dg-options "-O2 -mcmodel=large" } */ void fn (void *, int, int); diff --git a/gcc/testsuite/gcc.target/i386/pr52146.c b/gcc/testsuite/gcc.target/i386/pr52146.c index dcc28d007fe..9bd81368bcd 100644 --- a/gcc/testsuite/gcc.target/i386/pr52146.c +++ b/gcc/testsuite/gcc.target/i386/pr52146.c @@ -1,4 +1,5 @@ /* { dg-do compile { target { ! ia32 } } } */ +/* { dg-require-effective-target maybe_x32 } */ /* { dg-options "-O2 -mx32" } */ void diff --git a/gcc/testsuite/gcc.target/i386/pr52698.c b/gcc/testsuite/gcc.target/i386/pr52698.c index d5cfa741112..8d8988fccc3 100644 --- a/gcc/testsuite/gcc.target/i386/pr52698.c +++ b/gcc/testsuite/gcc.target/i386/pr52698.c @@ -1,4 +1,5 @@ /* { dg-do compile { target { ! ia32 } } } */ +/* { dg-require-effective-target maybe_x32 } */ /* { dg-options "-O2 -mx32 -maddress-mode=long" } */ extern void abort (void); diff --git a/gcc/testsuite/gcc.target/i386/pr52857-1.c b/gcc/testsuite/gcc.target/i386/pr52857-1.c index 5c23339b66a..2e8a4afdc10 100644 --- a/gcc/testsuite/gcc.target/i386/pr52857-1.c +++ b/gcc/testsuite/gcc.target/i386/pr52857-1.c @@ -1,4 +1,5 @@ /* { dg-do compile { target { ! ia32 } } } */ +/* { dg-require-effective-target maybe_x32 } */ /* { dg-options "-g -O -mx32 -maddress-mode=long" } */ extern void get_BID128 (int *); diff --git a/gcc/testsuite/gcc.target/i386/pr52857-2.c b/gcc/testsuite/gcc.target/i386/pr52857-2.c index 99acf84347d..62ac5df5eb1 100644 --- a/gcc/testsuite/gcc.target/i386/pr52857-2.c +++ b/gcc/testsuite/gcc.target/i386/pr52857-2.c @@ -1,4 +1,5 @@ /* { dg-do compile { target { ! ia32 } } } */ +/* { dg-require-effective-target maybe_x32 } */ /* { dg-options "-g -O -mx32 -maddress-mode=long" } */ void uw_init_context_1 (void *); diff --git a/gcc/testsuite/gcc.target/i386/pr52876.c b/gcc/testsuite/gcc.target/i386/pr52876.c index 249206c3346..6255b286a78 100644 --- a/gcc/testsuite/gcc.target/i386/pr52876.c +++ b/gcc/testsuite/gcc.target/i386/pr52876.c @@ -1,4 +1,5 @@ /* { dg-do run { target x32 } } */ +/* { dg-require-effective-target maybe_x32 } */ /* { dg-options "-O2 -mx32 -maddress-mode=long" } */ extern void abort (void); diff --git a/gcc/testsuite/gcc.target/i386/pr53698.c b/gcc/testsuite/gcc.target/i386/pr53698.c index e36200af852..9f36707ecf9 100644 --- a/gcc/testsuite/gcc.target/i386/pr53698.c +++ b/gcc/testsuite/gcc.target/i386/pr53698.c @@ -1,4 +1,5 @@ /* { dg-do compile { target { ! ia32 } } } */ +/* { dg-require-effective-target maybe_x32 } */ /* { dg-options "-O -mx32 -maddress-mode=long -fno-tree-dominator-opts" } */ extern char foo[]; diff --git a/gcc/testsuite/gcc.target/i386/pr54157.c b/gcc/testsuite/gcc.target/i386/pr54157.c index 26318677d59..01b02c58a90 100644 --- a/gcc/testsuite/gcc.target/i386/pr54157.c +++ b/gcc/testsuite/gcc.target/i386/pr54157.c @@ -1,4 +1,5 @@ /* { dg-do compile { target { ! ia32 } } } */ +/* { dg-require-effective-target maybe_x32 } */ /* { dg-options "-O2 -mx32 -maddress-mode=long -ftree-vectorize" } */ struct s2{ diff --git a/gcc/testsuite/gcc.target/i386/pr55049-1.c b/gcc/testsuite/gcc.target/i386/pr55049-1.c index 387bbeb81fb..6486ce99a27 100644 --- a/gcc/testsuite/gcc.target/i386/pr55049-1.c +++ b/gcc/testsuite/gcc.target/i386/pr55049-1.c @@ -1,5 +1,6 @@ /* { dg-do compile { target { ! ia32 } } } */ /* { dg-require-effective-target fpic } */ +/* { dg-require-effective-target maybe_x32 } */ /* { dg-options "-O2 -fPIC -mx32" } */ extern void __morestack_fail (const char *msg); diff --git a/gcc/testsuite/gcc.target/i386/pr55093.c b/gcc/testsuite/gcc.target/i386/pr55093.c index bfe2c503d83..190a9423f33 100644 --- a/gcc/testsuite/gcc.target/i386/pr55093.c +++ b/gcc/testsuite/gcc.target/i386/pr55093.c @@ -1,4 +1,5 @@ /* { dg-do compile { target { ! ia32 } } } */ +/* { dg-require-effective-target maybe_x32 } */ /* { dg-options "-O2 -mx32 -maddress-mode=long" } */ /* { dg-skip-if "different ABI" { x86_64-*-mingw* } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr55116-1.c b/gcc/testsuite/gcc.target/i386/pr55116-1.c index a2e2acd858a..a7d17ed014e 100644 --- a/gcc/testsuite/gcc.target/i386/pr55116-1.c +++ b/gcc/testsuite/gcc.target/i386/pr55116-1.c @@ -1,4 +1,5 @@ /* { dg-do compile { target { ! ia32 } } } */ +/* { dg-require-effective-target maybe_x32 } */ /* { dg-options "-O2 -mx32 -maddress-mode=long" } */ int glob_int_arr[100]; diff --git a/gcc/testsuite/gcc.target/i386/pr55116-2.c b/gcc/testsuite/gcc.target/i386/pr55116-2.c index 59bdebe690d..62ac0a1d001 100644 --- a/gcc/testsuite/gcc.target/i386/pr55116-2.c +++ b/gcc/testsuite/gcc.target/i386/pr55116-2.c @@ -1,4 +1,5 @@ /* { dg-do compile { target { ! ia32 } } } */ +/* { dg-require-effective-target maybe_x32 } */ /* { dg-options "-O2 -mx32 -maddress-mode=long" } */ typedef struct rtx_def *rtx; diff --git a/gcc/testsuite/gcc.target/i386/pr55597.c b/gcc/testsuite/gcc.target/i386/pr55597.c index 617c3e5c5ed..b942324892c 100644 --- a/gcc/testsuite/gcc.target/i386/pr55597.c +++ b/gcc/testsuite/gcc.target/i386/pr55597.c @@ -1,5 +1,6 @@ /* { dg-do compile { target { ! ia32 } } } */ /* { dg-require-effective-target fpic } */ +/* { dg-require-effective-target maybe_x32 } */ /* { dg-options "-O2 -fPIC -mx32 -maddress-mode=long" } */ struct initial_sp diff --git a/gcc/testsuite/gcc.target/i386/pr59874-3.c b/gcc/testsuite/gcc.target/i386/pr59874-3.c index ec55a12e2a0..0332f04a977 100644 --- a/gcc/testsuite/gcc.target/i386/pr59874-3.c +++ b/gcc/testsuite/gcc.target/i386/pr59874-3.c @@ -1,7 +1,8 @@ /* PR target/59874 */ /* { dg-do compile } */ /* { dg-options "-O2 -mpopcnt -masm=att" } */ -/* { dg-final { scan-assembler "popcntw" } } */ +/* { dg-final { scan-assembler "\tpopcntw" { target { ! *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "\tpopcnt" { target *-*-darwin* } } } */ unsigned int foo (unsigned short x) diff --git a/gcc/testsuite/gcc.target/i386/pr59929.c b/gcc/testsuite/gcc.target/i386/pr59929.c index 53e0b237c27..f770d4b7d1d 100644 --- a/gcc/testsuite/gcc.target/i386/pr59929.c +++ b/gcc/testsuite/gcc.target/i386/pr59929.c @@ -1,5 +1,6 @@ /* { dg-do run } */ /* { dg-options "-O0 -mno-accumulate-outgoing-args" } */ +/* { dg-require-effective-target maybe_x32 } */ /* { dg-additional-options "-mx32 -maddress-mode=short" { target x32 } } */ void diff --git a/gcc/testsuite/gcc.target/i386/pr61599-1.c b/gcc/testsuite/gcc.target/i386/pr61599-1.c index 71b1c2f02dd..52fea393d60 100644 --- a/gcc/testsuite/gcc.target/i386/pr61599-1.c +++ b/gcc/testsuite/gcc.target/i386/pr61599-1.c @@ -1,5 +1,6 @@ /* PR target/61599 */ /* { dg-do run { target lp64 } } */ +/* { dg-skip-if "PR90698" { *-*-darwin* } } */ /* { dg-additional-sources pr61599-2.c } */ /* { dg-options "-mcmodel=medium -fdata-sections" } */ diff --git a/gcc/testsuite/gcc.target/i386/pr63538.c b/gcc/testsuite/gcc.target/i386/pr63538.c index 7b979c35d81..87d5d3e040f 100644 --- a/gcc/testsuite/gcc.target/i386/pr63538.c +++ b/gcc/testsuite/gcc.target/i386/pr63538.c @@ -9,5 +9,5 @@ char *foo () { return str; } - -/* { dg-final { scan-assembler "movabs" } } */ +/* See PR90698 re. Darwin xfail. */ +/* { dg-final { scan-assembler "movabs" { xfail { *-*-darwin* } } } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr64317.c b/gcc/testsuite/gcc.target/i386/pr64317.c index 9e13da63885..3fbdccd36f2 100644 --- a/gcc/testsuite/gcc.target/i386/pr64317.c +++ b/gcc/testsuite/gcc.target/i386/pr64317.c @@ -2,9 +2,14 @@ /* { dg-require-effective-target ia32 } */ /* { dg-require-effective-target pie } */ /* { dg-options "-O2 -fpie" } */ -/* { dg-final { scan-assembler "addl\[ \\t\]+\[$\]_GLOBAL_OFFSET_TABLE_, %ebx" } } */ -/* { dg-final { scan-assembler "movl\[ \\t\]+c@GOTOFF\[(\]%ebx\[)\]" } } */ -/* { dg-final { scan-assembler-not "movl\[ \\t\]+\[0-9]+\[(\]%esp\[)\], %ebx" } } */ +/* { dg-final { scan-assembler "addl\[ \\t\]+\[$\]_GLOBAL_OFFSET_TABLE_, %ebx" { target { ! *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "movl\[ \\t\]+c@GOTOFF\[(\]%ebx\[)\]" { target { ! *-*-darwin* } } } } */ +/* { dg-final { scan-assembler-not "movl\[ \\t\]+\[0-9]+\[(\]%esp\[)\], %ebx" { target { ! *-*-darwin* } } } } */ + +/* Check PIC access to c and t1 on Darwin (PIC is default, needed for PIE). */ +/* { dg-final { scan-assembler {_c-L1\$pb\(%} { target *-*-darwin* } } } */ +/* { dg-final { scan-assembler {_t1.[0-9]+-L1\$pb\(%} { target *-*-darwin* } } } */ + long c = 1; int bar(); diff --git a/gcc/testsuite/gcc.target/i386/pr66470.c b/gcc/testsuite/gcc.target/i386/pr66470.c index 5c068f3d71b..3515b6d2892 100644 --- a/gcc/testsuite/gcc.target/i386/pr66470.c +++ b/gcc/testsuite/gcc.target/i386/pr66470.c @@ -1,5 +1,6 @@ /* PR target/66470 */ /* { dg-do compile { target { ! ia32 } } } */ +/* { dg-require-effective-target maybe_x32 } */ /* { dg-options "-O2 -mx32 -maddress-mode=long" } */ /* { dg-require-effective-target tls } */ diff --git a/gcc/testsuite/gcc.target/i386/pr66819-3.c b/gcc/testsuite/gcc.target/i386/pr66819-3.c index 3bc5a3471e6..76e3726b38a 100644 --- a/gcc/testsuite/gcc.target/i386/pr66819-3.c +++ b/gcc/testsuite/gcc.target/i386/pr66819-3.c @@ -1,6 +1,6 @@ /* { dg-do compile { target ia32 } } */ /* { dg-options "-O2 -mregparm=3" } */ -/* { dg-final { scan-assembler-not "call" } } */ +/* { dg-final { scan-assembler-not {call[ \t]+_?bar} } } */ void (*bar)(int, int); diff --git a/gcc/testsuite/gcc.target/i386/pr66819-4.c b/gcc/testsuite/gcc.target/i386/pr66819-4.c index 18b2ccf8120..143360d0de3 100644 --- a/gcc/testsuite/gcc.target/i386/pr66819-4.c +++ b/gcc/testsuite/gcc.target/i386/pr66819-4.c @@ -1,6 +1,6 @@ /* { dg-do compile { target ia32 } } */ /* { dg-options "-O2 -mregparm=3" } */ -/* { dg-final { scan-assembler-not "call" } } */ +/* { dg-final { scan-assembler-not {call[ \t]+_?bar} } } */ #include <stdarg.h> diff --git a/gcc/testsuite/gcc.target/i386/pr67985-2.c b/gcc/testsuite/gcc.target/i386/pr67985-2.c index 9c7a25ad177..a45815af66e 100644 --- a/gcc/testsuite/gcc.target/i386/pr67985-2.c +++ b/gcc/testsuite/gcc.target/i386/pr67985-2.c @@ -10,4 +10,4 @@ foo (float x, float y) /* { dg-final { scan-assembler-not "mulss" } } */ /* { dg-final { scan-assembler-not "movl\[ \t\].*, %eax" } } */ -/* { dg-final { scan-assembler "call\[ \t\]__mulsf3" } } */ +/* { dg-final { scan-assembler "call\[ \t\]_?__mulsf3" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr70738-7.c b/gcc/testsuite/gcc.target/i386/pr70738-7.c index 2e5b49f619d..ee9dfbfb35f 100644 --- a/gcc/testsuite/gcc.target/i386/pr70738-7.c +++ b/gcc/testsuite/gcc.target/i386/pr70738-7.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target ia32 } } */ +/* { dg-do compile { target { ia32 && { ! *-*-darwin* } } } } */ /* { dg-options "-msse2 -mgeneral-regs-only" } */ extern float a, b, c; diff --git a/gcc/testsuite/gcc.target/i386/pr77881.c b/gcc/testsuite/gcc.target/i386/pr77881.c index 80d143f2bc5..6803341568f 100644 --- a/gcc/testsuite/gcc.target/i386/pr77881.c +++ b/gcc/testsuite/gcc.target/i386/pr77881.c @@ -8,5 +8,5 @@ foo (long long int a, long long int a2, int b) if (a < 0 || b) baz (); } -/* { dg-final { scan-assembler "js\[ \t\]\.L" } } */ -/* { dg-final { scan-assembler "jne\[ \t\]\.L" } } */ +/* { dg-final { scan-assembler "js\[ \t\]\.?L" } } */ +/* { dg-final { scan-assembler "jne\[ \t\]\.?L" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr82659-3.c b/gcc/testsuite/gcc.target/i386/pr82659-3.c index 3bb83e309e7..a2d97d9b70c 100644 --- a/gcc/testsuite/gcc.target/i386/pr82659-3.c +++ b/gcc/testsuite/gcc.target/i386/pr82659-3.c @@ -1,4 +1,5 @@ /* { dg-do compile } */ +/* { dg-require-alias "" } */ /* { dg-options "-O2 -fcf-protection" } */ /* { dg-final { scan-assembler-times {\mendbr} 2 } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr82662.c b/gcc/testsuite/gcc.target/i386/pr82662.c index 8a9332b5c5b..ec08edc9824 100644 --- a/gcc/testsuite/gcc.target/i386/pr82662.c +++ b/gcc/testsuite/gcc.target/i386/pr82662.c @@ -23,4 +23,4 @@ int f9 (S x, S y) { return x >= y; } int f10 (S x, S y) { return x < y; } int f11 (S x, S y) { return x <= y; } -/* { dg-final { scan-assembler-times {\mset} 12 } } */ +/* { dg-final { scan-assembler-times {\tset} 12 } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr87853.c b/gcc/testsuite/gcc.target/i386/pr87853.c new file mode 100644 index 00000000000..9a288879679 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr87853.c @@ -0,0 +1,20 @@ +/* PR target/87853 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -funsigned-char -msse2 -mno-sse3 -masm=att" } */ +/* { dg-final { scan-assembler-times "\tpcmpgtb\t%xmm" 2 } } */ +/* { dg-final { scan-assembler-not "\tpsubusb\t" } } */ +/* { dg-final { scan-assembler-not "\tpcmpeqb\t" } } */ + +#include <x86intrin.h> + +__m128i +foo (__m128i x, __m128i y) +{ + return _mm_cmpgt_epi8 (x, y); +} + +__m128i +bar (__m128i x, __m128i y) +{ + return _mm_cmplt_epi8 (x, y); +} diff --git a/gcc/testsuite/gcc.target/i386/pr90547.c b/gcc/testsuite/gcc.target/i386/pr90547.c new file mode 100644 index 00000000000..fcfe66953b0 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr90547.c @@ -0,0 +1,21 @@ +/* PR target/90547 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void +foo () +{ + void *g[] = {&&a, &&b}; + + for (unsigned c = 0x1F;; c >>= 1) + { + unsigned d = (long)("a"+1); + long e = 8; + + while (e) + { + a: goto *g[c&d]; + b: e--; + } + } +} diff --git a/gcc/testsuite/gcc.target/i386/pr90867.c b/gcc/testsuite/gcc.target/i386/pr90867.c new file mode 100644 index 00000000000..1ed96b582ed --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr90867.c @@ -0,0 +1,30 @@ +/* PR target/90867 */ +/* { dg-do run { target lp64 } } */ +/* { dg-options "-O2 -msse2" } */ + +unsigned long long freq = 3600000000UL; /* 3.6 GHz = 3600.0 MHz */ + +__attribute__((noipa)) void +bar (double x) +{ + static double d = 3600000000.0; + if (x != d) + __builtin_abort (); + d /= 1000.0; +} + +__attribute__ ((target ("arch=x86-64"))) int +foo () +{ + bar ((double) freq); + bar (1e-3 * freq); + bar (1e-6 * freq); + bar (1e-9 * freq); + return 0; +} + +int +main () +{ + return foo (); +} diff --git a/gcc/testsuite/gcc.target/i386/pr90899.c b/gcc/testsuite/gcc.target/i386/pr90899.c new file mode 100644 index 00000000000..e0e2d5ac6bb --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr90899.c @@ -0,0 +1,6 @@ +/* PR middle-end/90899 */ +/* { dg-do compile } */ +/* { dg-require-ifunc "" } */ + +__attribute__ ((target_clones ("default", "arch=slm"))) static int f () { return 0; } +__attribute__ ((alias ("f"))) __typeof (f) g; diff --git a/gcc/testsuite/gcc.target/i386/pr91131.c b/gcc/testsuite/gcc.target/i386/pr91131.c new file mode 100644 index 00000000000..85008ff8a8b --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr91131.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +struct Reg_T { + unsigned int a : 3; + unsigned int b : 1; + unsigned int c : 4; +}; + +volatile struct Reg_T Reg_A; + +int +main () +{ + Reg_A = (struct Reg_T){ .a = 0, .b = 0, .c = 0 }; + return 0; +} + +/* { dg-final { scan-assembler-times "mov\[^\r\n\]*Reg_A" 1 } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr91623.c b/gcc/testsuite/gcc.target/i386/pr91623.c new file mode 100644 index 00000000000..94de4f91c6d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr91623.c @@ -0,0 +1,32 @@ +/* PR middle-end/91623 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -msse4.1 -mno-sse4.2" } */ + +typedef long long V __attribute__((__vector_size__(16))); +V e, h; +int d; +const int i; + +void foo (void); + +void +bar (int k, int l) +{ + if (d && 0 <= k - 1 && l) + foo (); +} + +void +baz (void) +{ + V n = (V) { 1 }; + V g = (V) {}; + V o = g; + for (int f = 0; f < i; ++f) + { + V a = o == n; + h = a; + bar (f, i); + o = e; + } +} diff --git a/gcc/testsuite/gcc.target/i386/pr91704.c b/gcc/testsuite/gcc.target/i386/pr91704.c new file mode 100644 index 00000000000..b996e24ad74 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr91704.c @@ -0,0 +1,14 @@ +/* PR target/91704 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -funsigned-char -mavx2 -mavx512f -masm=att" } */ +/* { dg-final { scan-assembler-times "\tvpcmpgtb\t%ymm" 1 } } */ +/* { dg-final { scan-assembler-not "\tvpsubusb\t" } } */ +/* { dg-final { scan-assembler-not "\tvpcmpeqb\t" } } */ + +#include <x86intrin.h> + +__m256i +foo (__m256i x, __m256i y) +{ + return _mm256_cmpgt_epi8 (x, y); +} diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-1.c b/gcc/testsuite/gcc.target/i386/ret-thunk-1.c index 7223f67ba5e..77f2cf62e26 100644 --- a/gcc/testsuite/gcc.target/i386/ret-thunk-1.c +++ b/gcc/testsuite/gcc.target/i386/ret-thunk-1.c @@ -6,8 +6,8 @@ foo (void) { } -/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler "jmp\[ \t\]*_?__x86_return_thunk" } } */ +/* { dg-final { scan-assembler {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler {call[ \t]*\.?LIND} } } */ /* { dg-final { scan-assembler {\tpause} } } */ /* { dg-final { scan-assembler {\tlfence} } } */ diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-10.c b/gcc/testsuite/gcc.target/i386/ret-thunk-10.c index b245d21b002..05e96e78189 100644 --- a/gcc/testsuite/gcc.target/i386/ret-thunk-10.c +++ b/gcc/testsuite/gcc.target/i386/ret-thunk-10.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=thunk-inline -mindirect-branch=thunk -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=thunk-inline -mindirect-branch=thunk " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ extern void (*bar) (void); @@ -10,11 +11,11 @@ foo (void) return 0; } -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk" } } */ +/* { dg-final { scan-assembler {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler {call[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler-not "jmp\[ \t\]*_?__x86_return_thunk" } } */ /* { dg-final { scan-assembler-times {\tpause} 2 } } */ /* { dg-final { scan-assembler-times {\tlfence} 2 } } */ -/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ -/* { dg-final { scan-assembler "__x86_indirect_thunk_(r|e)ax:" } } */ +/* { dg-final { scan-assembler "call\[ \t\]*_?__x86_indirect_thunk_(r|e)ax" } } */ +/* { dg-final { scan-assembler "_?__x86_indirect_thunk_(r|e)ax:" } } */ /* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */ diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-11.c b/gcc/testsuite/gcc.target/i386/ret-thunk-11.c index ce0543e1181..19df164beea 100644 --- a/gcc/testsuite/gcc.target/i386/ret-thunk-11.c +++ b/gcc/testsuite/gcc.target/i386/ret-thunk-11.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=thunk-extern -mindirect-branch=thunk -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=thunk-extern -mindirect-branch=thunk " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ extern void (*bar) (void); @@ -10,11 +11,11 @@ foo (void) return 0; } -/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */ +/* { dg-final { scan-assembler "jmp\[ \t\]*_?__x86_return_thunk" } } */ /* { dg-final { scan-assembler-times {\tpause} 1 } } */ /* { dg-final { scan-assembler-times {\tlfence} 1 } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ -/* { dg-final { scan-assembler "__x86_indirect_thunk_(r|e)ax:" } } */ +/* { dg-final { scan-assembler {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler {call[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler "call\[ \t\]*_?__x86_indirect_thunk_(r|e)ax" } } */ +/* { dg-final { scan-assembler "_?__x86_indirect_thunk_(r|e)ax:" } } */ /* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */ diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-12.c b/gcc/testsuite/gcc.target/i386/ret-thunk-12.c index 3b0023a0a6d..b4ca50041ac 100644 --- a/gcc/testsuite/gcc.target/i386/ret-thunk-12.c +++ b/gcc/testsuite/gcc.target/i386/ret-thunk-12.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ extern void (*bar) (void); @@ -10,11 +11,11 @@ foo (void) return 0; } -/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk" } } */ +/* { dg-final { scan-assembler-not "jmp\[ \t\]*_?__x86_return_thunk" } } */ /* { dg-final { scan-assembler-times {\tpause} 1 } } */ /* { dg-final { scan-assembler-times {\tlfence} 1 } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ -/* { dg-final { scan-assembler "__x86_indirect_thunk_(r|e)ax:" } } */ +/* { dg-final { scan-assembler {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler {call[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler "call\[ \t\]*_?__x86_indirect_thunk_(r|e)ax" } } */ +/* { dg-final { scan-assembler "_?__x86_indirect_thunk_(r|e)ax:" } } */ /* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */ diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-13.c b/gcc/testsuite/gcc.target/i386/ret-thunk-13.c index 55f156c4376..2f8d3a04cde 100644 --- a/gcc/testsuite/gcc.target/i386/ret-thunk-13.c +++ b/gcc/testsuite/gcc.target/i386/ret-thunk-13.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ extern void (*bar) (void); extern int foo (void) __attribute__ ((function_return("thunk"))); @@ -11,11 +12,11 @@ foo (void) return 0; } -/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */ +/* { dg-final { scan-assembler "jmp\[ \t\]*_?__x86_return_thunk" } } */ /* { dg-final { scan-assembler-times {\tpause} 2 } } */ /* { dg-final { scan-assembler-times {\tlfence} 2 } } */ -/* { dg-final { scan-assembler-times "jmp\[ \t\]*\.LIND" 3 } } */ -/* { dg-final { scan-assembler-times "call\[ \t\]*\.LIND" 3 } } */ -/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_indirect_thunk" } } */ -/* { dg-final { scan-assembler-not "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ +/* { dg-final { scan-assembler-times {jmp[ \t]*\.?LIND} 3 } } */ +/* { dg-final { scan-assembler-times {call[ \t]*\.?LIND} 3 } } */ +/* { dg-final { scan-assembler-not "jmp\[ \t\]*_?__x86_indirect_thunk" } } */ +/* { dg-final { scan-assembler-not "call\[ \t\]*_?__x86_indirect_thunk_(r|e)ax" } } */ /* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */ diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-14.c b/gcc/testsuite/gcc.target/i386/ret-thunk-14.c index 1c790436a53..881f541772c 100644 --- a/gcc/testsuite/gcc.target/i386/ret-thunk-14.c +++ b/gcc/testsuite/gcc.target/i386/ret-thunk-14.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ extern void (*bar) (void); @@ -13,9 +14,11 @@ foo (void) /* { dg-final { scan-assembler-times {\tpause} 1 } } */ /* { dg-final { scan-assembler-times {\tlfence} 1 } } */ -/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk" } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?bar" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ +/* { dg-final { scan-assembler-not "jmp\[ \t\]*_?__x86_return_thunk" } } */ +/* { dg-final { scan-assembler {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler {call[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*bar" { target *-*-linux* } } } */ +/* { dg-final { scan-assembler {movq[ \t]*_bar} { target { lp64 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {movl[ \t]*[Ll]_bar\$non_lazy_ptr-L[0-9]+\$pb} { target { ia32 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "call\[ \t\]*_?__x86_indirect_thunk_(r|e)ax" } } */ /* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */ diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-15.c b/gcc/testsuite/gcc.target/i386/ret-thunk-15.c index bc2bedf5a9c..5687440bf31 100644 --- a/gcc/testsuite/gcc.target/i386/ret-thunk-15.c +++ b/gcc/testsuite/gcc.target/i386/ret-thunk-15.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=keep -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=keep " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ extern void (*bar) (void); @@ -11,11 +12,13 @@ foo (void) return 0; } -/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler "jmp\[ \t\]*_?__x86_return_thunk" } } */ +/* { dg-final { scan-assembler {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler {call[ \t]*\.?LIND} } } */ /* { dg-final { scan-assembler-times {\tpause} 1 } } */ /* { dg-final { scan-assembler-times {\tlfence} 1 } } */ -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?bar" { target *-*-linux* } } } */ -/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ +/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*bar" { target *-*-linux* } } } */ +/* { dg-final { scan-assembler {movq[ \t]*_bar} { target { lp64 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {movl[ \t]*[Ll]_bar\$non_lazy_ptr-L[0-9]+\$pb} { target { ia32 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "call\[ \t\]*_?__x86_indirect_thunk_(r|e)ax" } } */ /* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */ diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-16.c b/gcc/testsuite/gcc.target/i386/ret-thunk-16.c index a16cad16aaa..5f439e4f360 100644 --- a/gcc/testsuite/gcc.target/i386/ret-thunk-16.c +++ b/gcc/testsuite/gcc.target/i386/ret-thunk-16.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mfunction-return=thunk-inline -mindirect-branch=thunk-extern -fno-pic" } */ +/* { dg-options "-O2 -mfunction-return=thunk-inline -mindirect-branch=thunk-extern " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ extern void (*bar) (void); @@ -11,8 +12,8 @@ foo (void) return 0; } -/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */ -/* { dg-final { scan-assembler-not "__x86_return_thunk" } } */ +/* { dg-final { scan-assembler-not "_?__x86_indirect_thunk" } } */ +/* { dg-final { scan-assembler-not "_?__x86_return_thunk" } } */ /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler-not {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler-not {call[ \t]*\.?LIND} } } */ diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-2.c b/gcc/testsuite/gcc.target/i386/ret-thunk-2.c index c6659e3ad09..3cb94210746 100644 --- a/gcc/testsuite/gcc.target/i386/ret-thunk-2.c +++ b/gcc/testsuite/gcc.target/i386/ret-thunk-2.c @@ -6,8 +6,8 @@ foo (void) { } -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler {call[ \t]*\.?LIND} } } */ /* { dg-final { scan-assembler {\tpause} } } */ /* { dg-final { scan-assembler {\tlfence} } } */ -/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk" } } */ +/* { dg-final { scan-assembler-not "jmp\[ \t\]*_?__x86_return_thunk" } } */ diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-22.c b/gcc/testsuite/gcc.target/i386/ret-thunk-22.c index 89e086de97b..9a9f42ea6a1 100644 --- a/gcc/testsuite/gcc.target/i386/ret-thunk-22.c +++ b/gcc/testsuite/gcc.target/i386/ret-thunk-22.c @@ -6,10 +6,12 @@ struct s { _Complex unsigned short x; }; struct s gs = { 100 + 200i }; struct s __attribute__((noinline)) foo (void) { return gs; } -/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 } } */ -/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk_ecx" } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 { target { ! *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" { target { ! *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "jmp\[ \t\]*_?__x86_return_thunk_ecx" { target { ! *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {call[ \t]*___x86.get_pc_thunk.cx} { target { *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {jmp[ \t]*___x86_return_thunk} { target { *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler {call[ \t]*\.?LIND} } } */ /* { dg-final { scan-assembler {\tpause} } } */ /* { dg-final { scan-assembler {\tlfence} } } */ diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-23.c b/gcc/testsuite/gcc.target/i386/ret-thunk-23.c index 43f0ccaa854..69469a43606 100644 --- a/gcc/testsuite/gcc.target/i386/ret-thunk-23.c +++ b/gcc/testsuite/gcc.target/i386/ret-thunk-23.c @@ -6,10 +6,12 @@ struct s { _Complex unsigned short x; }; struct s gs = { 100 + 200i }; struct s __attribute__((noinline)) foo (void) { return gs; } -/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 } } */ -/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk_ecx" } } */ -/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 { target { ! *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" { target { ! *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "jmp\[ \t\]*_?__x86_return_thunk_ecx" { target { ! *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {call[ \t]*___x86.get_pc_thunk.cx} { target { *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {jmp[ \t]*___x86_return_thunk} { target { *-*-darwin* } } } } */ +/* { dg-final { scan-assembler-not {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler-not {call[ \t]*\.?LIND} } } */ /* { dg-final { scan-assembler-not {\tpause} } } */ /* { dg-final { scan-assembler-not {\tlfence} } } */ diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-24.c b/gcc/testsuite/gcc.target/i386/ret-thunk-24.c index 8729e35147e..0e7877970d7 100644 --- a/gcc/testsuite/gcc.target/i386/ret-thunk-24.c +++ b/gcc/testsuite/gcc.target/i386/ret-thunk-24.c @@ -6,10 +6,12 @@ struct s { _Complex unsigned short x; }; struct s gs = { 100 + 200i }; struct s __attribute__((noinline)) foo (void) { return gs; } -/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 } } */ -/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" } } */ -/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk_ecx" } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler-times "popl\[\\t \]*%ecx" 1 { target { ! *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "lea\[l\]?\[\\t \]*4\\(%esp\\), %esp" { target { ! *-*-darwin* } } } } */ +/* { dg-final { scan-assembler-not "jmp\[ \t\]*_?__x86_return_thunk_ecx" { target { ! *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {call[ \t]*___x86.get_pc_thunk.cx} { target { *-*-darwin* } } } } */ +/* { dg-final { scan-assembler-not {jmp[ \t]*___x86_return_thunk} { target { *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler {call[ \t]*\.?LIND} } } */ /* { dg-final { scan-assembler {\tpause} } } */ /* { dg-final { scan-assembler {\tlfence} } } */ diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-25.c b/gcc/testsuite/gcc.target/i386/ret-thunk-25.c index f73553c9a9f..c0fd9bab257 100644 --- a/gcc/testsuite/gcc.target/i386/ret-thunk-25.c +++ b/gcc/testsuite/gcc.target/i386/ret-thunk-25.c @@ -1,5 +1,6 @@ /* PR target/r84530 */ /* { dg-do compile { target ia32 } } */ +/* { dg-skip-if "ABI differs for return complex value" { *-*-darwin* } } */ /* { dg-options "-O2 -mfunction-return=thunk -fcheck-pointer-bounds -mmpx -fno-pic" } */ struct s { _Complex unsigned short x; }; diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-3.c b/gcc/testsuite/gcc.target/i386/ret-thunk-3.c index 0f7f388f459..eb585169ae2 100644 --- a/gcc/testsuite/gcc.target/i386/ret-thunk-3.c +++ b/gcc/testsuite/gcc.target/i386/ret-thunk-3.c @@ -6,7 +6,7 @@ foo (void) { } -/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */ +/* { dg-final { scan-assembler "jmp\[ \t\]*_?__x86_return_thunk" } } */ /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler-not {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler-not {call[ \t]*\.?LIND} } } */ diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-4.c b/gcc/testsuite/gcc.target/i386/ret-thunk-4.c index 9ae37e835a0..736f7270ba6 100644 --- a/gcc/testsuite/gcc.target/i386/ret-thunk-4.c +++ b/gcc/testsuite/gcc.target/i386/ret-thunk-4.c @@ -6,7 +6,7 @@ foo (void) { } -/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk" } } */ +/* { dg-final { scan-assembler-not "jmp\[ \t\]*_?__x86_return_thunk" } } */ /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler-not {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler-not {call[ \t]*\.?LIND} } } */ diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-5.c b/gcc/testsuite/gcc.target/i386/ret-thunk-5.c index 4bd0d2a27bc..862f21da773 100644 --- a/gcc/testsuite/gcc.target/i386/ret-thunk-5.c +++ b/gcc/testsuite/gcc.target/i386/ret-thunk-5.c @@ -8,8 +8,8 @@ foo (void) { } -/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler "jmp\[ \t\]*_?__x86_return_thunk" } } */ +/* { dg-final { scan-assembler {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler {call[ \t]*\.?LIND} } } */ /* { dg-final { scan-assembler {\tpause} } } */ /* { dg-final { scan-assembler {\tlfence} } } */ diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-6.c b/gcc/testsuite/gcc.target/i386/ret-thunk-6.c index 053841f6f7d..9517c92eade 100644 --- a/gcc/testsuite/gcc.target/i386/ret-thunk-6.c +++ b/gcc/testsuite/gcc.target/i386/ret-thunk-6.c @@ -7,8 +7,8 @@ foo (void) { } -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler {call[ \t]*\.?LIND} } } */ /* { dg-final { scan-assembler {\tpause} } } */ /* { dg-final { scan-assembler {\tlfence} } } */ -/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk" } } */ +/* { dg-final { scan-assembler-not "jmp\[ \t\]*_?__x86_return_thunk" } } */ diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-7.c b/gcc/testsuite/gcc.target/i386/ret-thunk-7.c index 262e6780112..dd68f8326b1 100644 --- a/gcc/testsuite/gcc.target/i386/ret-thunk-7.c +++ b/gcc/testsuite/gcc.target/i386/ret-thunk-7.c @@ -7,7 +7,7 @@ foo (void) { } -/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */ +/* { dg-final { scan-assembler "jmp\[ \t\]*_?__x86_return_thunk" } } */ /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler-not {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler-not {call[ \t]*\.?LIND} } } */ diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-8.c b/gcc/testsuite/gcc.target/i386/ret-thunk-8.c index c1658e96673..0a611d99f59 100644 --- a/gcc/testsuite/gcc.target/i386/ret-thunk-8.c +++ b/gcc/testsuite/gcc.target/i386/ret-thunk-8.c @@ -8,7 +8,7 @@ foo (void) { } -/* { dg-final { scan-assembler-not "jmp\[ \t\]*__x86_return_thunk" } } */ +/* { dg-final { scan-assembler-not "jmp\[ \t\]*_?__x86_return_thunk" } } */ /* { dg-final { scan-assembler-not {\t(lfence|pause)} } } */ -/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */ +/* { dg-final { scan-assembler-not {jmp[ \t]*\.?LIND} } } */ +/* { dg-final { scan-assembler-not {call[ \t]*\.?LIND} } } */ diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c index 819671af933..3d4497000dc 100644 --- a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c +++ b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=thunk -mindirect-branch=thunk -fno-pic" } */ +/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=thunk -mindirect-branch=thunk " } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ extern void (*bar) (void); @@ -10,12 +11,14 @@ foo (void) return 0; } -/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */ -/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "__x86_return_thunk:" } } */ -/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?bar" { target *-*-linux* } } } */ +/* { dg-final { scan-assembler "jmp\[ \t\]*_?__x86_return_thunk" } } */ +/* { dg-final { scan-assembler {jmp[ \t]+\.?LIND} } } */ +/* { dg-final { scan-assembler {call[ \t]+\.?LIND} } } */ +/* { dg-final { scan-assembler "_?__x86_return_thunk:" } } */ +/* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*bar" { target *-*-linux* } } } */ +/* { dg-final { scan-assembler {movq[ \t]*_bar} { target { lp64 && *-*-darwin* } } } } */ +/* { dg-final { scan-assembler {movl[ \t]*[Ll]_bar\$non_lazy_ptr-L[0-9]+\$pb} { target { ia32 && *-*-darwin* } } } } */ /* { dg-final { scan-assembler-times {\tpause} 2 } } */ /* { dg-final { scan-assembler-times {\tlfence} 2 } } */ -/* { dg-final { scan-assembler "call\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */ +/* { dg-final { scan-assembler "call\[ \t\]*_?__x86_indirect_thunk_(r|e)ax" } } */ /* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */ diff --git a/gcc/testsuite/gcc.target/i386/stack-prot-sym.c b/gcc/testsuite/gcc.target/i386/stack-prot-sym.c index 7f63424c55f..dcd7cbd38be 100644 --- a/gcc/testsuite/gcc.target/i386/stack-prot-sym.c +++ b/gcc/testsuite/gcc.target/i386/stack-prot-sym.c @@ -1,4 +1,5 @@ /* { dg-do compile } */ +/* { dg-require-effective-target tls_native } */ /* { dg-options "-O2 -fstack-protector-all -mstack-protector-guard=tls -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=my_guard" } */ void f(void) { } diff --git a/gcc/testsuite/gcc.target/i386/wbinvd-1.c b/gcc/testsuite/gcc.target/i386/wbinvd-1.c index 7854cc22679..9290d9b1945 100644 --- a/gcc/testsuite/gcc.target/i386/wbinvd-1.c +++ b/gcc/testsuite/gcc.target/i386/wbinvd-1.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O2" } */ -/* { dg-final { scan-assembler-times "wbinvd" 2 } } */ +/* { dg-final { scan-assembler-times {\twbinvd} 1 } } */ #include "immintrin.h" diff --git a/gcc/testsuite/gcc.target/i386/wbnoinvd-1.c b/gcc/testsuite/gcc.target/i386/wbnoinvd-1.c index bda84cd4c94..697f148b26c 100644 --- a/gcc/testsuite/gcc.target/i386/wbnoinvd-1.c +++ b/gcc/testsuite/gcc.target/i386/wbnoinvd-1.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O2 -mwbnoinvd" } */ -/* { dg-final { scan-assembler-times "wbnoinvd" 2 } } */ +/* { dg-final { scan-assembler-times {\twbnoinvd} 1 } } */ #include "x86intrin.h" diff --git a/gcc/testsuite/gcc.target/mips/cfgcleanup-jalr1.c b/gcc/testsuite/gcc.target/mips/cfgcleanup-jalr1.c new file mode 100644 index 00000000000..24c18262b1a --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/cfgcleanup-jalr1.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-mabicalls -fpic -mno-mips16 -mno-micromips" } */ +/* { dg-skip-if "needs codesize optimization" { *-*-* } { "-O0" "-O1" "-O2" "-O3" } { "" } } */ + +extern void foo (void*); + +extern void bar (void*); + +void +test (void* p) +{ + if (!p) + foo(p); + else + bar(p); +} + +/* { dg-final { scan-assembler-not "\\\.reloc\t1f,R_MIPS_JALR,foo" } } */ +/* { dg-final { scan-assembler-not "\\\.reloc\t1f,R_MIPS_JALR,bar" } } */ diff --git a/gcc/testsuite/gcc.target/mips/cfgcleanup-jalr2.c b/gcc/testsuite/gcc.target/mips/cfgcleanup-jalr2.c new file mode 100644 index 00000000000..9fd75c98773 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/cfgcleanup-jalr2.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-mabicalls -fpic -mno-mips16 -mno-micromips" } */ +/* { dg-additional-options "-fno-inline -fipa-ra -mcompact-branches=never" } */ +/* { dg-skip-if "needs codesize optimization" { *-*-* } { "-O0" "-O1" "-O2" "-O3" } { "" } } */ + +static int foo (void* p) { __asm__ (""::"r"(p):"$t0"); return 0; } + +static int bar (void* p) { return 1; } + +int +test (void* p) +{ + int res = !p ? foo(p) : bar(p); + + register int tmp __asm__("$t0") = -1; + __asm__ (""::"r"(tmp)); + + return res; +} + +/* { dg-final { scan-assembler "\\\.reloc\t1f,R_MIPS_JALR,foo" } } */ +/* { dg-final { scan-assembler "\\\.reloc\t1f,R_MIPS_JALR,bar" } } */ +/* { dg-final { scan-assembler-not "\\.set\tnomacro\n\tjalr\t\\\$25" } } */ diff --git a/gcc/testsuite/gcc.target/mips/cfgcleanup-jalr3.c b/gcc/testsuite/gcc.target/mips/cfgcleanup-jalr3.c new file mode 100644 index 00000000000..580c6ec069d --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/cfgcleanup-jalr3.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-mabicalls -fpic -mno-mips16 -mno-micromips" } */ +/* { dg-additional-options "-fno-inline -fipa-ra -mcompact-branches=never" } */ +/* { dg-skip-if "needs codesize optimization" { *-*-* } { "-O0" "-O1" "-O2" "-O3" } { "" } } */ + +static int foo (void* p) { return 0; } + +static int bar (void* p) { return 1; } + +int +test (void* p) +{ + int res = !p ? foo(p) : bar(p); + + register int tmp __asm__("$t0") = -1; + __asm__ (""::"r"(tmp)); + + return res; +} + +/* { dg-final { scan-assembler-not "\\\.reloc\t1f,R_MIPS_JALR,foo" } } */ +/* { dg-final { scan-assembler-not "\\\.reloc\t1f,R_MIPS_JALR,bar" } } */ +/* { dg-final { scan-assembler "\\.set\tnomacro\n\tjalr\t\\\$25" } } */ diff --git a/gcc/testsuite/gcc.target/mips/dwarfregtable-1.c b/gcc/testsuite/gcc.target/mips/dwarfregtable-1.c new file mode 100644 index 00000000000..93d0844e6e8 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/dwarfregtable-1.c @@ -0,0 +1,5 @@ +/* Check if content of dwarf reg size table matches the expected. */ +/* { dg-do run } */ +/* { dg-options "-mabi=32 -mfp32" } */ + +#include "dwarfregtable.h" diff --git a/gcc/testsuite/gcc.target/mips/dwarfregtable-2.c b/gcc/testsuite/gcc.target/mips/dwarfregtable-2.c new file mode 100644 index 00000000000..c6dea942a13 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/dwarfregtable-2.c @@ -0,0 +1,5 @@ +/* Check if content of dwarf reg size table matches the expected. */ +/* { dg-do run } */ +/* { dg-options "-mabi=32 -mfpxx" } */ + +#include "dwarfregtable.h" diff --git a/gcc/testsuite/gcc.target/mips/dwarfregtable-3.c b/gcc/testsuite/gcc.target/mips/dwarfregtable-3.c new file mode 100644 index 00000000000..87937c4f0e1 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/dwarfregtable-3.c @@ -0,0 +1,5 @@ +/* Check if content of dwarf reg size table matches the expected. */ +/* { dg-do run } */ +/* { dg-options "-mabi=32 -mfp64" } */ + +#include "dwarfregtable.h" diff --git a/gcc/testsuite/gcc.target/mips/dwarfregtable-4.c b/gcc/testsuite/gcc.target/mips/dwarfregtable-4.c new file mode 100644 index 00000000000..2dd6dea3be7 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/dwarfregtable-4.c @@ -0,0 +1,5 @@ +/* Check if content of dwarf reg size table matches the expected. */ +/* { dg-do run } */ +/* { dg-options "-mabi=32 -mfp64 -modd-spreg" } */ + +#include "dwarfregtable.h" diff --git a/gcc/testsuite/gcc.target/mips/dwarfregtable.h b/gcc/testsuite/gcc.target/mips/dwarfregtable.h new file mode 100644 index 00000000000..403f65fb7b4 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/dwarfregtable.h @@ -0,0 +1,22 @@ + +typedef unsigned Unwind_Word __attribute__((__mode__(__unwind_word__))); + +#define DWARF_FRAME_REGISTERS 188 + +static unsigned char ref_dwarf_reg_size_table[DWARF_FRAME_REGISTERS + 1] = + { + [0 ... 66] = sizeof (Unwind_Word), + [80 ... 181] = sizeof (Unwind_Word) + }; + +static unsigned char dwarf_reg_size_table[DWARF_FRAME_REGISTERS + 1] = {}; + +int +main (void) +{ + __builtin_init_dwarf_reg_size_table (dwarf_reg_size_table); + if (__builtin_memcmp (ref_dwarf_reg_size_table, + dwarf_reg_size_table, DWARF_FRAME_REGISTERS + 1) != 0) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.target/mips/get-fcsr-3.c b/gcc/testsuite/gcc.target/mips/get-fcsr-3.c new file mode 100644 index 00000000000..7bb97b6fbcd --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/get-fcsr-3.c @@ -0,0 +1,9 @@ +/* { dg-options "-mabi=64 -mhard-float" } */ + +NOMIPS16 unsigned int +foo (void) +{ + return __builtin_mips_get_fcsr () & 0x1; +} + +/* { dg-final { scan-assembler "cfc1" } } */ diff --git a/gcc/testsuite/gcc.target/mips/msa-fmadd-n64.c b/gcc/testsuite/gcc.target/mips/msa-fmadd-n64.c new file mode 100644 index 00000000000..199b366512c --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/msa-fmadd-n64.c @@ -0,0 +1,101 @@ +/* { dg-do compile } */ +/* { dg-options "-mabi=64 -mfp64 -mhard-float -mmsa -EL -flax-vector-conversions" } */ +/* { dg-skip-if "uses global registers" { *-*-* } { "-O0" } { "" } } */ + +typedef int v4i32 __attribute__ ((vector_size(16))); +typedef float v4f32 __attribute__ ((vector_size(16))); +typedef double v2f64 __attribute__ ((vector_size(16))); + +/* Test that MSA FMADD-like intrinsics do not use first operand for multiplication. */ + +register v4i32 a __asm__("$f24"); +register v4i32 b __asm__("$f25"); +register v4f32 c __asm__("$f26"); +register v4f32 d __asm__("$f27"); +register v2f64 e __asm__("$f28"); +register v2f64 f __asm__("$f29"); + +void +maddv_b_msa (void) +{ + a = __builtin_msa_maddv_b (a, b, b); +} +/* { dg-final { scan-assembler "maddv\\\.b\t\\\$w24,\\\$w25,\\\$w25" } } */ + +void +maddv_h_msa (void) +{ + a = __builtin_msa_maddv_h (a, b, b); +} +/* { dg-final { scan-assembler "maddv\\\.h\t\\\$w24,\\\$w25,\\\$w25" } } */ + +void +maddv_w_msa (void) +{ + a = __builtin_msa_maddv_w (a, b, b); +} +/* { dg-final { scan-assembler "maddv\\\.w\t\\\$w24,\\\$w25,\\\$w25" } } */ + +void +maddv_d_msa (void) +{ + a = __builtin_msa_maddv_d (a, b, b); +} +/* { dg-final { scan-assembler "maddv\\\.d\t\\\$w24,\\\$w25,\\\$w25" } } */ + +void +msubv_b_msa (void) +{ + a = __builtin_msa_msubv_b (a, b, b); +} +/* { dg-final { scan-assembler "msubv\\\.b\t\\\$w24,\\\$w25,\\\$w25" } } */ + +void +msubv_h_msa (void) +{ + a = __builtin_msa_msubv_h (a, b, b); +} +/* { dg-final { scan-assembler "msubv\\\.h\t\\\$w24,\\\$w25,\\\$w25" } } */ + +void +msubv_w_msa (void) +{ + a = __builtin_msa_msubv_w (a, b, b); +} +/* { dg-final { scan-assembler "msubv\\\.w\t\\\$w24,\\\$w25,\\\$w25" } } */ + +void +msubv_d_msa (void) +{ + a = __builtin_msa_msubv_d (a, b, b); +} +/* { dg-final { scan-assembler "msubv\\\.d\t\\\$w24,\\\$w25,\\\$w25" } } */ + +void +fmadd_w_msa (void) +{ + c = __builtin_msa_fmadd_w (c, d, d); +} +/* { dg-final { scan-assembler "fmadd\\\.w\t\\\$w26,\\\$w27,\\\$w27" } } */ + +void +fmadd_d_msa (void) +{ + e = __builtin_msa_fmadd_d (e, f, f); +} +/* { dg-final { scan-assembler "fmadd\\\.d\t\\\$w28,\\\$w29,\\\$w29" } } */ + +void +fmsub_w_msa (void) +{ + c = __builtin_msa_fmsub_w (c, d, d); +} +/* { dg-final { scan-assembler "fmsub\\\.w\t\\\$w26,\\\$w27,\\\$w27" } } */ + +void +fmsub_d_msa (void) +{ + e = __builtin_msa_fmsub_d (e, f, f); +} +/* { dg-final { scan-assembler "fmsub\\\.d\t\\\$w28,\\\$w29,\\\$w29" } } */ + diff --git a/gcc/testsuite/gcc.target/mips/msa-fmadd-o32.c b/gcc/testsuite/gcc.target/mips/msa-fmadd-o32.c new file mode 100644 index 00000000000..843336990e4 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/msa-fmadd-o32.c @@ -0,0 +1,101 @@ +/* { dg-do compile } */ +/* { dg-options "-mabi=32 -mfp64 -mhard-float -mmsa -EL -flax-vector-conversions" } */ +/* { dg-skip-if "uses global registers" { *-*-* } { "-O0" } { "" } } */ + +typedef int v4i32 __attribute__ ((vector_size(16))); +typedef float v4f32 __attribute__ ((vector_size(16))); +typedef double v2f64 __attribute__ ((vector_size(16))); + +/* Test that MSA FMADD-like intrinsics do not use first operand for multiplication. */ + +register v4i32 a __asm__("$f20"); +register v4i32 b __asm__("$f22"); +register v4f32 c __asm__("$f24"); +register v4f32 d __asm__("$f26"); +register v2f64 e __asm__("$f28"); +register v2f64 f __asm__("$f30"); + +void +maddv_b_msa (void) +{ + a = __builtin_msa_maddv_b (a, b, b); +} +/* { dg-final { scan-assembler "maddv\\\.b\t\\\$w20,\\\$w22,\\\$w22" } } */ + +void +maddv_h_msa (void) +{ + a = __builtin_msa_maddv_h (a, b, b); +} +/* { dg-final { scan-assembler "maddv\\\.h\t\\\$w20,\\\$w22,\\\$w22" } } */ + +void +maddv_w_msa (void) +{ + a = __builtin_msa_maddv_w (a, b, b); +} +/* { dg-final { scan-assembler "maddv\\\.w\t\\\$w20,\\\$w22,\\\$w22" } } */ + +void +maddv_d_msa (void) +{ + a = __builtin_msa_maddv_d (a, b, b); +} +/* { dg-final { scan-assembler "maddv\\\.d\t\\\$w20,\\\$w22,\\\$w22" } } */ + +void +msubv_b_msa (void) +{ + a = __builtin_msa_msubv_b (a, b, b); +} +/* { dg-final { scan-assembler "msubv\\\.b\t\\\$w20,\\\$w22,\\\$w22" } } */ + +void +msubv_h_msa (void) +{ + a = __builtin_msa_msubv_h (a, b, b); +} +/* { dg-final { scan-assembler "msubv\\\.h\t\\\$w20,\\\$w22,\\\$w22" } } */ + +void +msubv_w_msa (void) +{ + a = __builtin_msa_msubv_w (a, b, b); +} +/* { dg-final { scan-assembler "msubv\\\.w\t\\\$w20,\\\$w22,\\\$w22" } } */ + +void +msubv_d_msa (void) +{ + a = __builtin_msa_msubv_d (a, b, b); +} +/* { dg-final { scan-assembler "msubv\\\.d\t\\\$w20,\\\$w22,\\\$w22" } } */ + +void +fmadd_w_msa (void) +{ + c = __builtin_msa_fmadd_w (c, d, d); +} +/* { dg-final { scan-assembler "fmadd\\\.w\t\\\$w24,\\\$w26,\\\$w26" } } */ + +void +fmadd_d_msa (void) +{ + e = __builtin_msa_fmadd_d (e, f, f); +} +/* { dg-final { scan-assembler "fmadd\\\.d\t\\\$w28,\\\$w30,\\\$w30" } } */ + +void +fmsub_w_msa (void) +{ + c = __builtin_msa_fmsub_w (c, d, d); +} +/* { dg-final { scan-assembler "fmsub\\\.w\t\\\$w24,\\\$w26,\\\$w26" } } */ + +void +fmsub_d_msa (void) +{ + e = __builtin_msa_fmsub_d (e, f, f); +} +/* { dg-final { scan-assembler "fmsub\\\.d\t\\\$w28,\\\$w30,\\\$w30" } } */ + diff --git a/gcc/testsuite/gcc.target/powerpc/bfp/bfp.exp b/gcc/testsuite/gcc.target/powerpc/bfp/bfp.exp index 439ad57f72d..59b0eb52b41 100644 --- a/gcc/testsuite/gcc.target/powerpc/bfp/bfp.exp +++ b/gcc/testsuite/gcc.target/powerpc/bfp/bfp.exp @@ -16,9 +16,11 @@ # along with GCC; see the file COPYING3. If not see # <http://www.gnu.org/licenses/>. -# Exit immediately if this isn't a PowerPC target or if the target is aix. +# Exit immediately if this isn't a PowerPC target or if the target is +# aix or Darwin. if { (![istarget powerpc*-*-*] && ![istarget rs6000-*-*]) - || [istarget "powerpc*-*-aix*"] } then { + || [istarget "powerpc*-*-aix*"] + || [istarget "powerpc*-*-darwin*"] } then { return } diff --git a/gcc/testsuite/gcc.target/powerpc/bmi2-bzhi64-1a.c b/gcc/testsuite/gcc.target/powerpc/bmi2-bzhi64-1a.c index 149cbc5d416..89bee61f044 100644 --- a/gcc/testsuite/gcc.target/powerpc/bmi2-bzhi64-1a.c +++ b/gcc/testsuite/gcc.target/powerpc/bmi2-bzhi64-1a.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O3" } */ +/* { dg-options "-O3 -maltivec -mvsx" } */ /* { dg-require-effective-target lp64 } */ #define NO_WARN_X86_INTRINSICS 1 diff --git a/gcc/testsuite/gcc.target/powerpc/builtins-2.c b/gcc/testsuite/gcc.target/powerpc/builtins-2.c index 666e9677673..69ad4b122e7 100644 --- a/gcc/testsuite/gcc.target/powerpc/builtins-2.c +++ b/gcc/testsuite/gcc.target/powerpc/builtins-2.c @@ -1,5 +1,6 @@ /* { dg-do run { target { powerpc*-*-* } } } */ /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */ +/* { dg-require-effective-target vsx_hw } */ /* { dg-options "-mcpu=power8 " } */ #include <altivec.h> diff --git a/gcc/testsuite/gcc.target/powerpc/darn-3.c b/gcc/testsuite/gcc.target/powerpc/darn-3.c new file mode 100644 index 00000000000..96ac21fc58c --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/darn-3.c @@ -0,0 +1,17 @@ +/* { dg-do compile { target { powerpc*-*-* } } } */ +/* { dg-skip-if "" { powerpc*-*-aix* } } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */ +/* { dg-options "-O2 -mcpu=power9" } */ + +static int darn32(void) { return __builtin_darn_32(); } + +int four(void) +{ + int sum = 0; + int i; + for (i = 0; i < 4; i++) + sum += darn32(); + return sum; +} + +/* { dg-final { scan-assembler-times {(?n)\mdarn .*,0\M} 4 } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/darwin-bool-1.c b/gcc/testsuite/gcc.target/powerpc/darwin-bool-1.c index 2f147d07381..f444edff295 100644 --- a/gcc/testsuite/gcc.target/powerpc/darwin-bool-1.c +++ b/gcc/testsuite/gcc.target/powerpc/darwin-bool-1.c @@ -1,6 +1,8 @@ /* Check that sizeof(bool) is 4 if we don't use special options. */ /* Matt Austern <austern@apple.com> */ /* { dg-do run { target { powerpc*-*-darwin* && ilp32 } } } */ +/* We do need to suppress the ISO C doesn't support _Bool message tho. */ +/* { dg-options "-Wno-pedantic" } */ int dummy1[sizeof(_Bool) - 3]; int dummy2[5 - sizeof(_Bool)]; diff --git a/gcc/testsuite/gcc.target/powerpc/dfp/dfp.exp b/gcc/testsuite/gcc.target/powerpc/dfp/dfp.exp index 24769205dc0..17ba6d4f82e 100644 --- a/gcc/testsuite/gcc.target/powerpc/dfp/dfp.exp +++ b/gcc/testsuite/gcc.target/powerpc/dfp/dfp.exp @@ -16,8 +16,11 @@ # along with GCC; see the file COPYING3. If not see # <http://www.gnu.org/licenses/>. -# Exit immediately if this isn't a PowerPC target. -if { ![istarget powerpc*-*-*] && ![istarget rs6000-*-*] } then { +# Exit immediately if this isn't a PowerPC target, also exit if we +# are on Darwin which doesn't support decimal float. +if { (![istarget powerpc*-*-*] && ![istarget rs6000-*-*]) + || [istarget "powerpc*-*-darwin*"] +} then { return } diff --git a/gcc/testsuite/gcc.target/powerpc/pr64205.c b/gcc/testsuite/gcc.target/powerpc/pr64205.c index 7fa987e6f55..64b39ae804f 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr64205.c +++ b/gcc/testsuite/gcc.target/powerpc/pr64205.c @@ -1,4 +1,5 @@ /* { dg-do compile { target { powerpc*-*-* && ilp32 } } } */ +/* { dg-require-effective-target dfp } */ /* { dg-skip-if "" { powerpc*-*-aix* } } */ /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=G5" } } */ /* { dg-options "-O2 -mcpu=G5 -maltivec" } */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr70010-1.c b/gcc/testsuite/gcc.target/powerpc/pr70010-1.c new file mode 100644 index 00000000000..4b3abb7d8fe --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr70010-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -flto -mvsx" } */ +/* { dg-require-effective-target lto } */ + +vector int c, a, b; + +static inline void __attribute__ ((__always_inline__, target ("no-vsx"))) +foo () /* { dg-error "inlining failed in call to .* target specific option mismatch" } */ +{ + c = a + b; +} + +int +main () +{ + foo (); /* { dg-message "called from here" } */ + c = a + b; +} diff --git a/gcc/testsuite/gcc.target/powerpc/pr70010-3.c b/gcc/testsuite/gcc.target/powerpc/pr70010-3.c new file mode 100644 index 00000000000..bca31875632 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr70010-3.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mno-vsx" } */ + +vector int c, a, b; + +static inline void __attribute__ ((__always_inline__, target ("no-vsx"))) +foo () +{ + c = a + b; +} + +int +main () +{ + foo (); + c = a + b; +} diff --git a/gcc/testsuite/gcc.target/powerpc/pr70010-4.c b/gcc/testsuite/gcc.target/powerpc/pr70010-4.c new file mode 100644 index 00000000000..c575cff1b52 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr70010-4.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mvsx" } */ + +vector int c, a, b; + +static inline void __attribute__ ((__always_inline__, target ("no-vsx"))) +foo () /* { dg-error "inlining failed in call to .* target specific option mismatch" } */ +{ + c = a + b; +} + +int +main () +{ + foo (); /* { dg-message "called from here" } */ + c = a + b; +} diff --git a/gcc/testsuite/gcc.target/powerpc/pr70010.c b/gcc/testsuite/gcc.target/powerpc/pr70010.c new file mode 100644 index 00000000000..c8772fcacdb --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr70010.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -finline-functions -Wno-psabi -mvsx" } */ +/* { dg-final { scan-assembler {\mbl \.?vadd_no_vsx\M} } } */ + + +typedef int vec_t __attribute__((vector_size(16))); + +static vec_t +__attribute__((__target__("no-vsx"))) +vadd_no_vsx (vec_t a, vec_t b) +{ + return a + b; +} + +vec_t +__attribute__((__target__("vsx"))) +call_vadd_no_vsx (vec_t x, vec_t y, vec_t z) +{ + return vadd_no_vsx (x, y) - z; +} diff --git a/gcc/testsuite/gcc.target/powerpc/pr71785.c b/gcc/testsuite/gcc.target/powerpc/pr71785.c index 613dcd1a937..c667ad81aa2 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr71785.c +++ b/gcc/testsuite/gcc.target/powerpc/pr71785.c @@ -1,6 +1,11 @@ /* { dg-do compile { target { powerpc*-*-* } } } */ /* { dg-options "-O2" } */ -/* { dg-final { scan-assembler-not {\mb\M} } } */ +/* We have to lose the default pic codegen on Darwin. */ +/* { dg-additional-options "-mdynamic-no-pic" { target powerpc*-*-darwin* } } */ +/* ... and account for the out-of-line GPR restore. */ +/* { dg-final { scan-assembler-times {\mb[ \t]*restGPR} 1 { target powerpc*-*-darwin* } } } */ +/* { dg-final { scan-assembler-not {\mb[ \t]L} { target powerpc*-*-darwin* } } } */ +/* { dg-final { scan-assembler-not {\mb\M} { target { ! powerpc*-*-darwin* } } } } */ /* Check that all computed gotos in this testcase end up unfactored completely. If some is not there will be a unconditional jump left; if all works fine, diff --git a/gcc/testsuite/gcc.target/powerpc/pr79909.c b/gcc/testsuite/gcc.target/powerpc/pr79909.c index d9fb7c332bb..d886c32ff39 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr79909.c +++ b/gcc/testsuite/gcc.target/powerpc/pr79909.c @@ -1,6 +1,7 @@ /* PR rtl-optimization/79909 */ /* { dg-do compile } */ /* { dg-options "-O2 -mxl-compat" } */ +/* { dg-require-effective-target dfp } */ /* { dg-skip-if "DFP" { powerpc*-*-aix* } } */ typedef float T __attribute__ ((mode (TD))); diff --git a/gcc/testsuite/gcc.target/powerpc/pr80125.c b/gcc/testsuite/gcc.target/powerpc/pr80125.c index 494a6e673b1..366602d9668 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr80125.c +++ b/gcc/testsuite/gcc.target/powerpc/pr80125.c @@ -16,7 +16,7 @@ foo () vector int k = vec_mergel (i, j); vector int l = vec_sl (k, c); vector int m = vec_sl (l, d); - vector char o; + vector unsigned char o; vector int p = vec_perm (m, n, o); e = vec_sra (p, c); vec_st (e, 0, a); diff --git a/gcc/testsuite/gcc.target/powerpc/pr89424-0.c b/gcc/testsuite/gcc.target/powerpc/pr89424-0.c new file mode 100644 index 00000000000..301cf90ce5f --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr89424-0.c @@ -0,0 +1,76 @@ +/* { dg-do run { target { powerpc*-*-* && lp64 } } } */ +/* { dg-require-effective-target vsx_hw } */ +/* { dg-options "-mvsx" } */ + +/* This test should run the same on any target that supports vsx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <altivec.h> + +extern void abort (void); + +/* Define PR89626 after that pr is addressed. */ +#ifdef PR89626 +#define SIGNED +#else +#define SIGNED signed +#endif + +#define CONST0 (((__int128) 31415926539) << 60) + +/* Test that indices > length of vector are applied modulo the vector + length. */ + + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +__int128 ei (vector SIGNED __int128 v, int i) +{ + return __builtin_vec_ext_v1ti (v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__int128 mei (vector SIGNED __int128 *vp, int i) +{ + return __builtin_vec_ext_v1ti (*vp, i); +} + +int main (int argc, char *argv[]) { + vector SIGNED __int128 dv = { CONST0 }; + __int128 d; + + d = ei (dv, 0); + if (d != CONST0) + abort (); + + d = ei (dv, 1); + if (d != CONST0) + abort (); + + d = ei (dv, 2); + if (d != CONST0) + abort (); + + d = ei (dv, 3); + if (d != CONST0) + abort (); + + d = mei (&dv, 0); + if (d != CONST0) + abort (); + + d = mei (&dv, 1); + if (d != CONST0) + abort (); + + d = mei (&dv, 2); + if (d != CONST0) + abort (); + + d = mei (&dv, 3); + if (d != CONST0) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/pr89765-mc.c b/gcc/testsuite/gcc.target/powerpc/pr89765-mc.c new file mode 100644 index 00000000000..8384536058b --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr89765-mc.c @@ -0,0 +1,400 @@ +/* { dg-do run { target int128 } } */ +/* { dg-require-effective-target vsx_hw } */ +/* { dg-options "-mvsx -O2" } */ + +/* This test should run the same on any target that supports vsx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <stdlib.h> +#include <stddef.h> +#include <altivec.h> + +#include <stdio.h> + +static vector unsigned __int128 +deoptimize_uint128 (vector unsigned __int128 a) +{ + __asm__ (" # %x0" : "+v" (a)); + return a; +} + +static vector unsigned long long int +deoptimize_ulong (vector unsigned long long int a) +{ + __asm__ (" # %x0" : "+v" (a)); + return a; +} + +static vector unsigned int +deoptimize_uint (vector unsigned int a) +{ + __asm__ (" # %x0" : "+v" (a)); + return a; +} + +static vector unsigned char +deoptimize_uchar (vector unsigned char a) +{ + __asm__ (" # %x0" : "+v" (a)); + return a; +} + +static vector unsigned short +deoptimize_ushort (vector unsigned short a) +{ + __asm__ (" # %x0" : "+v" (a)); + return a; +} + +__attribute ((noinline)) +vector unsigned __int128 +set_auto_n_uint128 (vector unsigned __int128 a, int n, unsigned __int128 x) +{ + return vec_insert (x, a, n); +} + +__attribute ((noinline)) +vector unsigned long long int +set_auto_n_ulong (vector unsigned long long int a, int n, + unsigned long long int x) +{ + return vec_insert (x, a, n); +} + +__attribute ((noinline)) +vector unsigned int +set_auto_n_uint (vector unsigned int a, int n, unsigned int x) +{ + return vec_insert (x, a, n); +} + +__attribute ((noinline)) +vector unsigned char +set_auto_n_uchar (vector unsigned char a, int n, unsigned char x) +{ + return vec_insert (x, a, n); +} + +__attribute ((noinline)) +vector unsigned short +set_auto_n_ushort (vector unsigned short a, int n, unsigned short x) +{ + return vec_insert (x, a, n); +} + +__attribute ((noinline)) +unsigned __int128 +get_auto_n_uint128 (vector unsigned __int128 a, int n) +{ + return vec_extract (a, n); +} + +__attribute ((noinline)) +unsigned long long int +get_auto_n_ulong (vector unsigned long long int a, int n) +{ + return vec_extract (a, n); +} + +__attribute ((noinline)) +unsigned int +get_auto_n_uint (vector unsigned int a, int n) +{ + return vec_extract (a, n); +} + +__attribute ((noinline)) +unsigned char +get_auto_n_uchar (vector unsigned char a, int n) +{ + return vec_extract (a, n); +} + +__attribute ((noinline)) +unsigned short +get_auto_n_ushort (vector unsigned short a, int n) +{ + return vec_extract (a, n); +} + +int check_uint128_element (int i, unsigned __int128 entry) +{ + printf ("checking uint128 entry at index %d\n", i); + + return (entry == ((((unsigned __int128) 0xffeeddccbbaa9988ULL) << 64) + | 0x0706050403020100ULL)); +} + +unsigned __int128 get_uint128_element (int i) +{ + return ((((unsigned __int128) 0xffeeddccbbaa9988ULL) << 64) + | 0x0706050403020100ULL); +} + +int check_ulong_element (int i, unsigned long long int entry) +{ + printf ("checking ulong entry 0x%llx at index %d\n", entry, i); + + switch (i % 2) + { + case 0: return (entry == 0x9999901010ULL); + case 1: return (entry == 0x7777733333ULL); + default: + return 0; + } +} + +unsigned long long int get_ulong_element (int i) +{ + switch (i % 2) + { + case 0: return 0x9999901010ULL; + case 1: return 0x7777733333ULL; + } +} + +int check_uint_element (int i, unsigned int entry) +{ + printf ("checking uint entry 0x%x at index %d\n", entry, i); + + switch (i % 4) + { + case 0: return (entry == 0x99999); + case 1: return (entry == 0x01010); + case 2: return (entry == 0x77777); + case 3: return (entry == 0x33333); + default: + return 0; + } +} + +unsigned int get_uint_element (int i) +{ + switch (i % 4) + { + case 0: return 0x99999; + case 1: return 0x01010; + case 2: return 0x77777; + case 3: return 0x33333; + } +} + +int check_uchar_element (int i, unsigned char entry) +{ + printf ("checking uchar entry 0x%x at index %d\n", entry, i); + switch (i % 16) + { + case 0: return (entry == 0x90); + case 1: return (entry == 0x80); + case 2: return (entry == 0x70); + case 3: return (entry == 0x60); + case 4: return (entry == 0x50); + case 5: return (entry == 0x40); + case 6: return (entry == 0x30); + case 7: return (entry == 0x20); + case 8: return (entry == 0x10); + case 9: return (entry == 0xf0); + case 10: return (entry == 0xe0); + case 11: return (entry == 0xd0); + case 12: return (entry == 0xc0); + case 13: return (entry == 0xb0); + case 14: return (entry == 0xa0); + case 15: return (entry == 0xff); + default: + return 0; + } +} + +unsigned char get_uchar_element (int i) +{ + switch (i % 16) + { + case 0: return 0x90; + case 1: return 0x80; + case 2: return 0x70; + case 3: return 0x60; + case 4: return 0x50; + case 5: return 0x40; + case 6: return 0x30; + case 7: return 0x20; + case 8: return 0x10; + case 9: return 0xf0; + case 10: return 0xe0; + case 11: return 0xd0; + case 12: return 0xc0; + case 13: return 0xb0; + case 14: return 0xa0; + case 15: return 0xff; + } +} + +int check_ushort_element (int i, unsigned short entry) +{ + printf ("checking ushort entry 0x%x at index %d\n", entry, i); + switch (i % 8) + { + case 0: return (entry == 0x9988); + case 1: return (entry == 0x8877); + case 2: return (entry == 0x7766); + case 3: return (entry == 0x6655); + case 4: return (entry == 0x5544); + case 5: return (entry == 0x4433); + case 6: return (entry == 0x3322); + case 7: return (entry == 0x2211); + default: + return 0; + } +} + +unsigned short get_ushort_element (int i) +{ + switch (i % 8) + { + case 0: return 0x9988; + case 1: return 0x8877; + case 2: return 0x7766; + case 3: return 0x6655; + case 4: return 0x5544; + case 5: return 0x4433; + case 6: return 0x3322; + case 7: return 0x2211; + } +} + +vector unsigned __int128 +init_auto_uint128 (vector unsigned __int128 a) +{ + int i; + for (i = 0; i < 32; i += 3) + a = set_auto_n_uint128 (a, i, get_uint128_element (i)); + return a; +} + +void do_auto_uint128 (vector unsigned __int128 a) +{ + int i; + unsigned __int128 c; + for (i = 0; i < 32; i += 3) + { + c = get_auto_n_uint128 (a, i); + if (!check_uint128_element (i, c)) abort (); + } +} + +vector unsigned long long int +init_auto_ulong (vector unsigned long long int a) +{ + int i; + for (i = 0; i < 32; i += 3) + a = set_auto_n_ulong (a, i, get_ulong_element (i)); + return a; +} + +void do_auto_ulong (vector unsigned long long int a) +{ + int i; + unsigned long long int c; + for (i = 0; i < 32; i += 3) + { + c = get_auto_n_ulong (a, i); + if (!check_ulong_element (i, c)) abort (); + } + } + +vector unsigned int init_auto_uint (vector unsigned int a) +{ + int i; + for (i = 0; i < 32; i += 3) + a = set_auto_n_uint (a, i, get_uint_element (i)); + return a; +} + +void do_auto_uint (vector unsigned int a) +{ + int i; + unsigned int c; + for (i = 0; i < 32; i += 3) + { + c = get_auto_n_uint (a, i); + if (!check_uint_element (i, c)) abort (); + } + } + +vector unsigned short init_auto_ushort ( vector unsigned short a ) +{ + int i; + for (i = 0; i < 32; i += 3) + a = set_auto_n_ushort (a, i, get_ushort_element (i)); + return a; +} + +void do_auto_ushort (vector unsigned short a) +{ + int i; + unsigned short c; + for (i = 0; i < 32; i += 3) + { + c = get_auto_n_ushort (a, i); + if (!check_ushort_element (i, c)) abort (); + } +} + +vector unsigned char init_auto_uchar (vector unsigned char a) +{ + int i; + for (i = 0; i < 32; i += 3) + a = set_auto_n_uchar (a, i, get_uchar_element (i)); + return a; +} + +void do_auto_uchar (vector unsigned char a) +{ + int i; + unsigned char c; + for (i = 0; i < 32; i += 3) + { + c = get_auto_n_uchar (a, i); + if (!check_uchar_element (i, c)) abort (); + } +} + +int +main (void) +{ + size_t i; + + vector unsigned __int128 u = { 0 }; + vector unsigned __int128 du; + + vector unsigned long long int v = { 0, 0 }; + vector unsigned long long int dv; + + vector unsigned int x = { 0, 0, 0, 0 }; + vector unsigned int dx; + + vector unsigned char y = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + vector unsigned char dy; + + vector unsigned short z = { 0, 0, 0, 0, 0, 0, 0, 0 }; + vector unsigned short dz; + + du = init_auto_uint128 (u); + dv = init_auto_ulong (v); + dx = init_auto_uint (x); + dy = init_auto_uchar (y); + dz = init_auto_ushort (z); + + du = deoptimize_uint128 (du); + dv = deoptimize_ulong (dv); + dx = deoptimize_uint (dx); + dy = deoptimize_uchar (dy); + dz = deoptimize_ushort (dz); + + do_auto_uint128 (du); + do_auto_ulong (dv); + do_auto_uint (dx); + do_auto_uchar (dy); + do_auto_ushort (dz); + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/pr91275.c b/gcc/testsuite/gcc.target/powerpc/pr91275.c new file mode 100644 index 00000000000..cd461158af7 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr91275.c @@ -0,0 +1,26 @@ +/* Test that we generate vpmsumd correctly without a swap error. */ + +/* { dg-do run { target { p8vector_hw } } } */ +/* { dg-options "-O2 -std=gnu11" } */ + +#include <altivec.h> + +int main() { + + const unsigned long long r0l = 0x8e7dfceac070e3a0; + vector unsigned long long r0 = (vector unsigned long long) {r0l, 0}, v; + const vector unsigned long long pd + = (vector unsigned long long) {0xc2LLU << 56, 0}; + + v = __builtin_crypto_vpmsumd ((vector unsigned long long) {r0[0], 0}, pd); + +#if __LITTLE_ENDIAN__ + if (v[0] != 0x4000000000000000 || v[1] != 0x65bd7ab605a4a8ff) + __builtin_abort (); +#else + if (v[1] != 0x4000000000000000 || v[0] != 0x65bd7ab605a4a8ff) + __builtin_abort (); +#endif + + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/pr92090-2.c b/gcc/testsuite/gcc.target/powerpc/pr92090-2.c new file mode 100644 index 00000000000..893530613f5 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr92090-2.c @@ -0,0 +1,45 @@ +/* { dg-do compile } */ +/* { dg-options "-mcpu=power8 -Os -w" } */ +/* { dg-additional-options "-mbig" { target powerpc64le-*-* } } */ + +/* Verify that we don't ICE. */ + +int a; +static _Atomic long double b, c, d, m; +double n; +extern int foo (void); +extern void bar (int, int, int, int); + +void +bug (void) +{ + b = 1.79769313486231580793728971405301199e308L; + for (int i = 0; i < 10000; i++) + if (__builtin_isinf (n)) + b; + c = 1; + int e, f, g, h; + while (a) + ; + for (int i; i; i++) + { + double j = c /= foo (); + if (__builtin_isinf (j)) + { + if (foo == 1 << 31) + e++; + f++; + c = 0; + } + else + { + if (foo == 1 << 30) + g++; + h++; + c = 1; + } + } + bar (e, f, g, h); + d = 1.79769313486231580793728971405301199e308L; + m = 1; +} diff --git a/gcc/testsuite/gcc.target/powerpc/pr92090.c b/gcc/testsuite/gcc.target/powerpc/pr92090.c new file mode 100644 index 00000000000..9af74946afb --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr92090.c @@ -0,0 +1,43 @@ +/* { dg-do compile } */ +/* { dg-options "-mcpu=power8 -Os" } */ +/* { dg-additional-options "-mbig" { target powerpc64le-*-* } } */ + +/* Verify that we don't ICE. */ + +_Atomic int a; +_Atomic long double b, c; +int j; +void foo (void); +void bar (int, int, int, int); + +void +bug (void) +{ + b = 1; + int d, e, f, g; + while (a) + ; + for (int h = 0; h < 10000; h++) + { + double i = b /= 3; + foo (); + if (i) + { + if (i == 1) + d++; + e++; + b = 0; + } + else + { + if (i == 2) + f++; + g++; + b = 1; + } + } + bar (d, e, f, g); + c = 1; + for (int h; h; h++) + j = 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/pure-builtin-redundant-load.c b/gcc/testsuite/gcc.target/powerpc/pure-builtin-redundant-load.c new file mode 100644 index 00000000000..16ab6abfc3b --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pure-builtin-redundant-load.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target powerpc_vsx_ok } */ +/* { dg-options "-O2 -fdump-tree-fre-all -mvsx" } */ + +/* Verify we remove a redundant load that occurs both before and after +we call a vector load builtin. +This testcase is introduced as we updated a number of our vector load +built-ins with the attribute of PURE instead of MEM, to indicate that +those builtins only read from memory, versus reading from and writing +to the same. +This means we can identify the redundant load instructions in an earlier +pass, and optimize them away. */ + +#include <altivec.h> + +vector signed short load_data; + +vector signed short foo() +{ + vector signed short r11,r12,r13; + r11 = load_data; + r12 = vec_xl (0, &load_data[0]); + r13 = load_data; + return (r11 + r12 + r13); +} + +vector signed short biz() +{ + vector signed short r21,r22,r23; + r21 = load_data; + r22 = vec_lvehx (0, &load_data[0]); + r23 = load_data; + return (r21 + r22 + r23); +} + +vector signed short bar() +{ + vector signed short r31,r32,r33; + r31 = load_data; + r32 = vec_lvx (0, &load_data[0]); + r33 = load_data; + return (r31 + r32 + r33); +} + +/* { dg-final { scan-tree-dump-times "Removing dead stmt r13_. = load_data;" 1 "fre1" } } */ +/* { dg-final { scan-tree-dump-times "Removing dead stmt r23_. = load_data;" 1 "fre1" } } */ +/* { dg-final { scan-tree-dump-times "Removing dead stmt r33_. = load_data;" 1 "fre1" } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/safe-indirect-jump-1.c b/gcc/testsuite/gcc.target/powerpc/safe-indirect-jump-1.c index 16ccfe471f6..b9ad8c1dd36 100644 --- a/gcc/testsuite/gcc.target/powerpc/safe-indirect-jump-1.c +++ b/gcc/testsuite/gcc.target/powerpc/safe-indirect-jump-1.c @@ -1,4 +1,5 @@ /* { dg-do compile } */ +/* { dg-skip-if "not implemented for Darwin" { powerpc*-*-darwin* } } */ /* { dg-additional-options "-mno-speculate-indirect-jumps" } */ /* { dg-warning "'-mno-speculate-indirect-jumps' is deprecated" "" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/gcc.target/powerpc/safe-indirect-jump-7.c b/gcc/testsuite/gcc.target/powerpc/safe-indirect-jump-7.c index e7d81d40ff0..a316e66204f 100644 --- a/gcc/testsuite/gcc.target/powerpc/safe-indirect-jump-7.c +++ b/gcc/testsuite/gcc.target/powerpc/safe-indirect-jump-7.c @@ -1,4 +1,5 @@ /* { dg-do compile } */ +/* { dg-skip-if "not implemented for Darwin" { powerpc*-*-darwin* } } */ /* { dg-additional-options "-mno-speculate-indirect-jumps" } */ /* { dg-warning "'-mno-speculate-indirect-jumps' is deprecated" "" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/gcc.target/powerpc/spec-barr-1.c b/gcc/testsuite/gcc.target/powerpc/spec-barr-1.c index 443938cd106..ef51980c51b 100644 --- a/gcc/testsuite/gcc.target/powerpc/spec-barr-1.c +++ b/gcc/testsuite/gcc.target/powerpc/spec-barr-1.c @@ -7,4 +7,4 @@ void foo () __builtin_ppc_speculation_barrier (); } -/* { dg-final { scan-assembler "ori 31,31,0" } } */ +/* { dg-final { scan-assembler {ori\s+r?31,r?31,r?0} } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/stabs-attrib-vect-darwin.c b/gcc/testsuite/gcc.target/powerpc/stabs-attrib-vect-darwin.c index 3c52287b344..5c7acf18a58 100644 --- a/gcc/testsuite/gcc.target/powerpc/stabs-attrib-vect-darwin.c +++ b/gcc/testsuite/gcc.target/powerpc/stabs-attrib-vect-darwin.c @@ -1,5 +1,6 @@ /* Test Attribute Vector associated with vector type stabs. */ /* { dg-do compile { target powerpc*-*-darwin* } } */ +/* { dg-require-effective-target stabs } */ /* { dg-options "-gstabs+ -fno-eliminate-unused-debug-types -faltivec" } */ int main () diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-10c.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-10c.c new file mode 100644 index 00000000000..5ed6424d64f --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-10c.c @@ -0,0 +1,155 @@ +/* { dg-do run } */ +/* { dg-require-effective-target vmx_hw } */ +/* { dg-options "-maltivec" } */ + +/* This test should run the same on any target that supports altivec/vmx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <altivec.h> + +extern void abort (void); + +#define CONST0 (0) +#define CONST1 (1) +#define CONST2 (2) +#define CONST3 (3) +#define CONST4 (4) +#define CONST5 (5) +#define CONST6 (6) +#define CONST7 (7) + + +/* Test that indices > length of vector are applied modulo the vector + length. */ + +/* Test for vector residing in register. */ +vector short s3 (vector short v, short x) +{ + return vec_insert (x, v, 3); +} + +vector short s7 (vector short v, short x) +{ + return vec_insert (x, v, 7); +} + +vector short s21 (vector short v, short x) +{ + return vec_insert (x, v, 21); +} + +vector short s30 (vector short v, short x) +{ + return vec_insert (x, v, 30); +} + +/* Test for vector residing in memory. */ +vector short ms3 (vector short *vp, short x) +{ + return vec_insert (x, *vp, 3); +} + +vector short ms7 (vector short *vp, short x) +{ + return vec_insert (x, *vp, 7); +} + +vector short ms21 (vector short *vp, short x) +{ + return vec_insert (x, *vp, 21); +} + +vector short ms30 (vector short *vp, short x) +{ + return vec_insert (x, *vp, 30); +} + +/* Test the same with variable indices. */ + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +vector short ci (vector short v, int i, short x) +{ + return vec_insert (x, v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__attribute__((noinline)) +vector short mci (vector short *vp, int i, short x) +{ + return vec_insert (x, *vp, i); +} + + +int main (int argc, short *argv[]) { + vector short sv = { + CONST0, CONST1, CONST2, CONST3, CONST4, CONST5, CONST6, CONST7 }; + short s; + + sv = s3 (sv, CONST6); + if (sv [3] != CONST6) + abort (); + + sv = s7 (sv, CONST4); + if (sv [7] != CONST4) + abort (); + + sv = s21 (sv, CONST3); + if (sv [5] != CONST3) + abort (); + + sv = s30 (sv, CONST2); + if (sv [6] != CONST2) + abort (); + + sv = ms3 (&sv, CONST5); + if (sv [3] != CONST5) + abort (); + + sv = ms7 (&sv, CONST1); + if (sv [7] != CONST1) + abort (); + + sv = ms21 (&sv, CONST2); + if (sv [5] != CONST2) + abort (); + + sv = ms30 (&sv, CONST0); + if (sv [6] != CONST0) + abort (); + + sv = ci (sv, 5, CONST6); + if (sv [5] != CONST6) + abort (); + + sv = ci (sv, 2, CONST4); + if (sv [2] != CONST4) + abort (); + + sv = ci (sv, 15, CONST3); + if (sv [7] != CONST3) + abort (); + + sv = ci (sv, 28, CONST3); + if (sv [4] != CONST3) + abort (); + + sv = mci (&sv, 5, CONST3); + if (sv [5] != CONST3) + abort (); + + sv = mci (&sv, 12, CONST7); + if (sv [4] != CONST7) + abort (); + + sv = mci (&sv, 25, CONST6); + if (sv [1] != CONST6) + abort (); + + sv = mci (&sv, 16, CONST5); + if (sv [0] != CONST5) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-10d.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-10d.c new file mode 100644 index 00000000000..c9aaecad920 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-10d.c @@ -0,0 +1,155 @@ +/* { dg-do run } */ +/* { dg-require-effective-target vmx_hw } */ +/* { dg-options "-maltivec -O3" } */ + +/* This test should run the same on any target that supports altivec/vmx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <altivec.h> + +extern void abort (void); + +#define CONST0 (0) +#define CONST1 (1) +#define CONST2 (2) +#define CONST3 (3) +#define CONST4 (4) +#define CONST5 (5) +#define CONST6 (6) +#define CONST7 (7) + + +/* Test that indices > length of vector are applied modulo the vector + length. */ + +/* Test for vector residing in register. */ +vector short s3 (vector short v, short x) +{ + return vec_insert (x, v, 3); +} + +vector short s7 (vector short v, short x) +{ + return vec_insert (x, v, 7); +} + +vector short s21 (vector short v, short x) +{ + return vec_insert (x, v, 21); +} + +vector short s30 (vector short v, short x) +{ + return vec_insert (x, v, 30); +} + +/* Test for vector residing in memory. */ +vector short ms3 (vector short *vp, short x) +{ + return vec_insert (x, *vp, 3); +} + +vector short ms7 (vector short *vp, short x) +{ + return vec_insert (x, *vp, 7); +} + +vector short ms21 (vector short *vp, short x) +{ + return vec_insert (x, *vp, 21); +} + +vector short ms30 (vector short *vp, short x) +{ + return vec_insert (x, *vp, 30); +} + +/* Test the same with variable indices. */ + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +vector short ci (vector short v, int i, short x) +{ + return vec_insert (x, v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__attribute__((noinline)) +vector short mci (vector short *vp, int i, short x) +{ + return vec_insert (x, *vp, i); +} + + +int main (int argc, short *argv[]) { + vector short sv = { + CONST0, CONST1, CONST2, CONST3, CONST4, CONST5, CONST6, CONST7 }; + short s; + + sv = s3 (sv, CONST6); + if (sv [3] != CONST6) + abort (); + + sv = s7 (sv, CONST4); + if (sv [7] != CONST4) + abort (); + + sv = s21 (sv, CONST3); + if (sv [5] != CONST3) + abort (); + + sv = s30 (sv, CONST2); + if (sv [6] != CONST2) + abort (); + + sv = ms3 (&sv, CONST5); + if (sv [3] != CONST5) + abort (); + + sv = ms7 (&sv, CONST1); + if (sv [7] != CONST1) + abort (); + + sv = ms21 (&sv, CONST2); + if (sv [5] != CONST2) + abort (); + + sv = ms30 (&sv, CONST0); + if (sv [6] != CONST0) + abort (); + + sv = ci (sv, 5, CONST6); + if (sv [5] != CONST6) + abort (); + + sv = ci (sv, 2, CONST4); + if (sv [2] != CONST4) + abort (); + + sv = ci (sv, 15, CONST3); + if (sv [7] != CONST3) + abort (); + + sv = ci (sv, 28, CONST3); + if (sv [4] != CONST3) + abort (); + + sv = mci (&sv, 5, CONST3); + if (sv [5] != CONST3) + abort (); + + sv = mci (&sv, 12, CONST7); + if (sv [4] != CONST7) + abort (); + + sv = mci (&sv, 25, CONST6); + if (sv [1] != CONST6) + abort (); + + sv = mci (&sv, 16, CONST5); + if (sv [0] != CONST5) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-11c.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-11c.c new file mode 100644 index 00000000000..8e514aa2b1f --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-11c.c @@ -0,0 +1,149 @@ +/* { dg-do run } */ +/* { dg-require-effective-target vmx_hw } */ +/* { dg-options "-maltivec" } */ + +/* This test should run the same on any target that supports altivec/vmx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <altivec.h> + +extern void abort (void); + +#define CONST0 (0) +#define CONST1 (1) +#define CONST2 (2) +#define CONST3 (3) + +/* Test that indices > length of vector are applied modulo the vector + length. */ + +/* Test for vector residing in register. */ +vector int s3 (vector int v, int x) +{ + return vec_insert (x, v, 3); +} + +vector int s1 (vector int v, int x) +{ + return vec_insert (x, v, 1); +} + +vector int s21 (vector int v, int x) +{ + return vec_insert (x, v, 21); +} + +vector int s30 (vector int v, int x) +{ + return vec_insert (x, v, 30); +} + +/* Test for vector residing in memory. */ +vector int ms3 (vector int *vp, int x) +{ + return vec_insert (x, *vp, 3); +} + +vector int ms1 (vector int *vp, int x) +{ + return vec_insert (x, *vp, 1); +} + +vector int ms21 (vector int *vp, int x) +{ + return vec_insert (x, *vp, 21); +} + +vector int ms30 (vector int *vp, int x) +{ + return vec_insert (x, *vp, 30); +} + +/* Test the same with variable indices. */ + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +vector int ci (vector int v, int i, int x) +{ + return vec_insert (x, v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__attribute__((noinline)) +vector int mci(vector int *vp, int i, int x) +{ + return vec_insert (x, *vp, i); +} + + +int main (int argc, int *argv[]) { + vector int sv = { CONST0, CONST1, CONST2, CONST3 }; + int s; + + sv = s3 (sv, CONST1); + if (sv [3] != CONST1) + abort (); + + sv = s1 (sv, CONST3); + if (sv [1] != CONST3) + abort (); + + sv = s21 (sv, CONST0); + if (sv [1] != CONST0) + abort (); + + sv = s30 (sv, CONST1); + if (sv [2] != CONST1) + abort (); + + sv = ms3 (&sv, CONST2); + if (sv [3] != CONST2) + abort (); + + sv = ms1 (&sv, CONST0); + if (sv [1] != CONST0) + abort (); + + sv = ms21 (&sv, CONST3); + if (sv [1] != CONST3) + abort (); + + sv = ms30 (&sv, CONST0); + if (sv [2] != CONST0) + abort (); + + sv = ci (sv, 5, CONST0); + if (sv [1] != CONST0) + abort (); + + sv = ci (sv, 2, CONST3); + if (sv [2] != CONST3) + abort (); + + sv = ci (sv, 15, CONST1); + if (sv [3] != CONST1) + abort (); + + sv = ci (sv, 28, CONST3); + if (sv [0] != CONST3) + abort (); + + sv = mci (&sv, 5, CONST2); + if (sv [1] != CONST2) + abort (); + + sv = mci (&sv, 12, CONST1); + if (sv [0] != CONST1) + abort (); + + sv = mci (&sv, 25, CONST2); + if (sv [1] != CONST2) + abort (); + + sv = mci (&sv, 16, CONST3); + if (sv [0] != CONST3) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-11d.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-11d.c new file mode 100644 index 00000000000..116802aeece --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-11d.c @@ -0,0 +1,149 @@ +/* { dg-do run } */ +/* { dg-require-effective-target vmx_hw } */ +/* { dg-options "-maltivec -O3" } */ + +/* This test should run the same on any target that supports altivec/vmx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <altivec.h> + +extern void abort (void); + +#define CONST0 (0) +#define CONST1 (1) +#define CONST2 (2) +#define CONST3 (3) + +/* Test that indices > length of vector are applied modulo the vector + length. */ + +/* Test for vector residing in register. */ +vector int s3 (vector int v, int x) +{ + return vec_insert (x, v, 3); +} + +vector int s1 (vector int v, int x) +{ + return vec_insert (x, v, 1); +} + +vector int s21 (vector int v, int x) +{ + return vec_insert (x, v, 21); +} + +vector int s30 (vector int v, int x) +{ + return vec_insert (x, v, 30); +} + +/* Test for vector residing in memory. */ +vector int ms3 (vector int *vp, int x) +{ + return vec_insert (x, *vp, 3); +} + +vector int ms1 (vector int *vp, int x) +{ + return vec_insert (x, *vp, 1); +} + +vector int ms21 (vector int *vp, int x) +{ + return vec_insert (x, *vp, 21); +} + +vector int ms30 (vector int *vp, int x) +{ + return vec_insert (x, *vp, 30); +} + +/* Test the same with variable indices. */ + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +vector int ci (vector int v, int i, int x) +{ + return vec_insert (x, v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__attribute__((noinline)) +vector int mci(vector int *vp, int i, int x) +{ + return vec_insert (x, *vp, i); +} + + +int main (int argc, int *argv[]) { + vector int sv = { CONST0, CONST1, CONST2, CONST3 }; + int s; + + sv = s3 (sv, CONST1); + if (sv [3] != CONST1) + abort (); + + sv = s1 (sv, CONST3); + if (sv [1] != CONST3) + abort (); + + sv = s21 (sv, CONST0); + if (sv [1] != CONST0) + abort (); + + sv = s30 (sv, CONST1); + if (sv [2] != CONST1) + abort (); + + sv = ms3 (&sv, CONST2); + if (sv [3] != CONST2) + abort (); + + sv = ms1 (&sv, CONST0); + if (sv [1] != CONST0) + abort (); + + sv = ms21 (&sv, CONST3); + if (sv [1] != CONST3) + abort (); + + sv = ms30 (&sv, CONST0); + if (sv [2] != CONST0) + abort (); + + sv = ci (sv, 5, CONST0); + if (sv [1] != CONST0) + abort (); + + sv = ci (sv, 2, CONST3); + if (sv [2] != CONST3) + abort (); + + sv = ci (sv, 15, CONST1); + if (sv [3] != CONST1) + abort (); + + sv = ci (sv, 28, CONST3); + if (sv [0] != CONST3) + abort (); + + sv = mci (&sv, 5, CONST2); + if (sv [1] != CONST2) + abort (); + + sv = mci (&sv, 12, CONST1); + if (sv [0] != CONST1) + abort (); + + sv = mci (&sv, 25, CONST2); + if (sv [1] != CONST2) + abort (); + + sv = mci (&sv, 16, CONST3); + if (sv [0] != CONST3) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-12c.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-12c.c new file mode 100644 index 00000000000..1e57bc46cdd --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-12c.c @@ -0,0 +1,112 @@ +/* { dg-do run { target int128 } } */ +/* { dg-require-effective-target vsx_hw } */ +/* { dg-options "-mvsx" } */ + +/* This test should run the same on any target that supports vsx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <altivec.h> + +extern void abort (void); + +#define CONST0 (31415926539LL) +#define CONST1 (2 * 31415926539LL) +#define CONST2 (3 * 31415926539LL) +#define CONST3 (4 * 31415926539LL) + +/* Test that indices > length of vector are applied modulo the vector + length. */ + +/* Test for vector residing in register. */ +vector long long int e0 (vector long long int v, long long int x) +{ + return vec_insert (x, v, 0); +} + +vector long long int e3 (vector long long int v, long long int x) +{ + return vec_insert (x, v, 3); +} + +/* Test for vector residing in memory. */ +vector long long int me0 (vector long long int *vp, long long int x) +{ + return vec_insert (x, *vp, 0); +} + +vector long long int me3 (vector long long int *vp, long long int x) +{ + return vec_insert (x, *vp, 3); +} + +/* Test the same with variable indices. */ + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +vector long long int ei (vector long long int v, int i, long long int x) +{ + return vec_insert (x, v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__attribute__((noinline)) +vector long long int mei (vector long long int *vp, int i, long long int x) +{ + return vec_insert (x, *vp, i); +} + +int main (int argc, char *argv[]) { + vector long long int dv = { CONST0, CONST1 }; + long long int d; + + dv = e0 (dv, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = e3 (dv, CONST0); + if (dv [1] != CONST0) + abort (); + + dv = me0 (&dv, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = me3 (&dv, CONST2); + if (dv [1] != CONST2) + abort (); + + dv = ei (dv, 0, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = ei (dv, 1, CONST2); + if (dv [1] != CONST2) + abort (); + + dv = ei (dv, 2, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = ei (dv, 3, CONST3); + if (dv [1] != CONST3) + abort (); + + dv = mei (&dv, 0, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = mei (&dv, 1, CONST0); + if (dv [1] != CONST0) + abort (); + + dv = mei (&dv, 2, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = mei (&dv, 3, CONST2); + if (dv [1] != CONST2) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-12d.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-12d.c new file mode 100644 index 00000000000..3bf06085fb5 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-12d.c @@ -0,0 +1,112 @@ +/* { dg-do run { target int128 } } */ +/* { dg-require-effective-target vsx_hw } */ +/* { dg-options "-mvsx -O3" } */ + +/* This test should run the same on any target that supports vsx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <altivec.h> + +extern void abort (void); + +#define CONST0 (31415926539LL) +#define CONST1 (2 * 31415926539LL) +#define CONST2 (3 * 31415926539LL) +#define CONST3 (4 * 31415926539LL) + +/* Test that indices > length of vector are applied modulo the vector + length. */ + +/* Test for vector residing in register. */ +vector long long int e0 (vector long long int v, long long int x) +{ + return vec_insert (x, v, 0); +} + +vector long long int e3 (vector long long int v, long long int x) +{ + return vec_insert (x, v, 3); +} + +/* Test for vector residing in memory. */ +vector long long int me0 (vector long long int *vp, long long int x) +{ + return vec_insert (x, *vp, 0); +} + +vector long long int me3 (vector long long int *vp, long long int x) +{ + return vec_insert (x, *vp, 3); +} + +/* Test the same with variable indices. */ + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +vector long long int ei (vector long long int v, int i, long long int x) +{ + return vec_insert (x, v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__attribute__((noinline)) +vector long long int mei (vector long long int *vp, int i, long long int x) +{ + return vec_insert (x, *vp, i); +} + +int main (int argc, char *argv[]) { + vector long long int dv = { CONST0, CONST1 }; + long long int d; + + dv = e0 (dv, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = e3 (dv, CONST0); + if (dv [1] != CONST0) + abort (); + + dv = me0 (&dv, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = me3 (&dv, CONST2); + if (dv [1] != CONST2) + abort (); + + dv = ei (dv, 0, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = ei (dv, 1, CONST2); + if (dv [1] != CONST2) + abort (); + + dv = ei (dv, 2, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = ei (dv, 3, CONST3); + if (dv [1] != CONST3) + abort (); + + dv = mei (&dv, 0, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = mei (&dv, 1, CONST0); + if (dv [1] != CONST0) + abort (); + + dv = mei (&dv, 2, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = mei (&dv, 3, CONST2); + if (dv [1] != CONST2) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-13a.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-13a.c index 907bcce9236..7dc6bd994e4 100644 --- a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-13a.c +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-13a.c @@ -9,7 +9,7 @@ #include <altivec.h> /* Define this after PR89424 is addressed. */ -#undef PR89424 +#define PR89424 /* Define this after PR89626 is addressed. */ #undef PR89626 diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-13b.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-13b.c index e1d791ded4f..168227214fc 100644 --- a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-13b.c +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-13b.c @@ -9,7 +9,7 @@ #include <altivec.h> /* Define this after PR89424 is addressed. */ -#undef PR89424 +#define PR89424 /* Define this after PR89626 is addressed. */ #undef PR89626 diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-13c.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-13c.c new file mode 100644 index 00000000000..43c6bed7695 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-13c.c @@ -0,0 +1,115 @@ +/* { dg-do run { target int128 } } */ +/* { dg-require-effective-target vsx_hw } */ +/* { dg-options "-mvsx" } */ + +/* This test should run the same on any target that supports vsx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <altivec.h> + +#define SIGNED signed + +extern void abort (void); + +#define CONST0 (((SIGNED __int128) 31415926539) << 60) +#define CONST1 (((SIGNED __int128) 31415926539) << 55) +#define CONST2 (((SIGNED __int128) 31415926539) << 50) +#define CONST3 (((SIGNED __int128) 31415926539) << 45) + +/* Test that indices > length of vector are applied modulo the vector + length. */ + +/* Test for vector residing in register. */ +vector SIGNED __int128 e0 (vector SIGNED __int128 v, SIGNED __int128 x) +{ + return vec_insert (x, v, 0); +} + +vector SIGNED __int128 e3 (vector SIGNED __int128 v, SIGNED __int128 x) +{ + return vec_insert (x, v, 3); +} + +/* Test for vector residing in memory. */ +vector SIGNED __int128 me0 (vector SIGNED __int128 *vp, SIGNED __int128 x) +{ + return vec_insert (x, *vp, 0); +} + +vector SIGNED __int128 me3 (vector SIGNED __int128 *vp, SIGNED __int128 x) +{ + return vec_insert (x, *vp, 3); +} + +/* Test the same with variable indices. */ + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +vector SIGNED __int128 +ei (vector SIGNED __int128 v, int i, SIGNED __int128 x) +{ + return vec_insert (x, v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__attribute__((noinline)) +vector SIGNED __int128 +mei (vector SIGNED __int128 *vp, int i, SIGNED __int128 x) +{ + return vec_insert (x, *vp, i); +} + +int main (int argc, char *argv[]) { + vector SIGNED __int128 dv = { CONST0 }; + SIGNED __int128 d; + + dv = e0 (dv, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = e3 (dv, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = me0 (&dv, CONST2); + if (dv [0] != CONST2) + abort (); + + dv = me3 (&dv, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = ei (dv, 0, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = ei (dv, 1, CONST2); + if (dv [0] != CONST2) + abort (); + + dv = ei (dv, 2, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = ei (dv, 3, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = mei (&dv, 0, CONST2); + if (dv [0] != CONST2) + abort (); + + dv = mei (&dv, 1, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = mei (&dv, 2, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = mei (&dv, 3, CONST2); + if (dv [0] != CONST2) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-13d.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-13d.c new file mode 100644 index 00000000000..257de552e64 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-13d.c @@ -0,0 +1,115 @@ +/* { dg-do run { target int128 } } */ +/* { dg-require-effective-target vsx_hw } */ +/* { dg-options "-mvsx -O3" } */ + +/* This test should run the same on any target that supports vsx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <altivec.h> + +#define SIGNED signed + +extern void abort (void); + +#define CONST0 (((SIGNED __int128) 31415926539) << 60) +#define CONST1 (((SIGNED __int128) 31415926539) << 55) +#define CONST2 (((SIGNED __int128) 31415926539) << 50) +#define CONST3 (((SIGNED __int128) 31415926539) << 45) + +/* Test that indices > length of vector are applied modulo the vector + length. */ + +/* Test for vector residing in register. */ +vector SIGNED __int128 e0 (vector SIGNED __int128 v, SIGNED __int128 x) +{ + return vec_insert (x, v, 0); +} + +vector SIGNED __int128 e3 (vector SIGNED __int128 v, SIGNED __int128 x) +{ + return vec_insert (x, v, 3); +} + +/* Test for vector residing in memory. */ +vector SIGNED __int128 me0 (vector SIGNED __int128 *vp, SIGNED __int128 x) +{ + return vec_insert (x, *vp, 0); +} + +vector SIGNED __int128 me3 (vector SIGNED __int128 *vp, SIGNED __int128 x) +{ + return vec_insert (x, *vp, 3); +} + +/* Test the same with variable indices. */ + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +vector SIGNED __int128 +ei (vector SIGNED __int128 v, int i, SIGNED __int128 x) +{ + return vec_insert (x, v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__attribute__((noinline)) +vector SIGNED __int128 +mei (vector SIGNED __int128 *vp, int i, SIGNED __int128 x) +{ + return vec_insert (x, *vp, i); +} + +int main (int argc, char *argv[]) { + vector SIGNED __int128 dv = { CONST0 }; + SIGNED __int128 d; + + dv = e0 (dv, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = e3 (dv, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = me0 (&dv, CONST2); + if (dv [0] != CONST2) + abort (); + + dv = me3 (&dv, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = ei (dv, 0, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = ei (dv, 1, CONST2); + if (dv [0] != CONST2) + abort (); + + dv = ei (dv, 2, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = ei (dv, 3, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = mei (&dv, 0, CONST2); + if (dv [0] != CONST2) + abort (); + + dv = mei (&dv, 1, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = mei (&dv, 2, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = mei (&dv, 3, CONST2); + if (dv [0] != CONST2) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-14c.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-14c.c new file mode 100644 index 00000000000..5ba4bd59eb3 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-14c.c @@ -0,0 +1,149 @@ +/* { dg-do run } */ +/* { dg-require-effective-target vmx_hw } */ +/* { dg-options "-maltivec" } */ + +/* This test should run the same on any target that supports altivec/vmx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <altivec.h> + +extern void abort (void); + +#define CONST0 ((float) (3.1415926539)) +#define CONST1 ((float) (3.1415926539 * 2)) +#define CONST2 ((float) (3.1415926539 * 3)) +#define CONST3 ((float) (3.1415926539 * 4)) + +/* Test that indices > length of vector are applied modulo the vector + length. */ + +/* Test for vector residing in register. */ +vector float e0(vector float v, float x) +{ + return vec_insert (x, v, 0); +} + +vector float e1(vector float v, float x) +{ + return vec_insert (x, v, 1); +} + +vector float e7(vector float v, float x) +{ + return vec_insert (x, v, 7); +} + +vector float e8(vector float v, float x) +{ + return vec_insert (x, v, 8); +} + +/* Test for vector residing in memory. */ +vector float me0(vector float *vp, float x) +{ + return vec_insert (x, *vp, 0); +} + +vector float me1(vector float *vp, float x) +{ + return vec_insert (x, *vp, 1); +} + +vector float me13(vector float *vp, float x) +{ + return vec_insert (x, *vp, 13); +} + +vector float me15(vector float *vp, float x) +{ + return vec_insert (x, *vp, 15); +} + +/* Test the same with variable indices. */ + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +vector float ei(vector float v, int i, float x) +{ + return vec_insert (x, v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__attribute__((noinline)) +vector float mei(vector float *vp, int i, float x) +{ + return vec_insert (x, *vp, i); +} + + +int main (int argc, char *argv[]) { + vector float dv = { CONST0, CONST1, CONST2, CONST3 }; + float d; + + dv = e0 (dv, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = e1 (dv, CONST0); + if (dv [1] != CONST0) + abort (); + + dv = e7 (dv, CONST2); + if (dv [3] != CONST2) + abort (); + + dv = e8 (dv, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = me0 (&dv, CONST2); + if (dv [0] != CONST2) + abort (); + + dv = me1 (&dv, CONST3); + if (dv [1] != CONST3) + abort (); + + dv = me13 (&dv, CONST2); + if (dv [1] != CONST2) + abort (); + + dv = me15 (&dv, CONST1); + if (dv [3] != CONST1) + abort (); + + dv = ei (dv, 0, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = ei (dv, 2, CONST1); + if (dv [2] != CONST1) + abort (); + + dv = ei (dv, 11, CONST0); + if (dv [3] != CONST0) + abort (); + + dv = ei (dv, 17, CONST2); + if (dv [1] != CONST2) + abort (); + + dv = mei (&dv, 0, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = mei (&dv, 1, CONST0); + if (dv [1] != CONST0) + abort (); + + dv = mei (&dv, 15, CONST1); + if (dv [3] != CONST1) + abort (); + + dv = mei (&dv, 6, CONST0); + if (dv [2] != CONST0) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-14d.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-14d.c new file mode 100644 index 00000000000..63784a2e220 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-14d.c @@ -0,0 +1,149 @@ +/* { dg-do run } */ +/* { dg-require-effective-target vmx_hw } */ +/* { dg-options "-maltivec -O3" } */ + +/* This test should run the same on any target that supports altivec/vmx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <altivec.h> + +extern void abort (void); + +#define CONST0 ((float) (3.1415926539)) +#define CONST1 ((float) (3.1415926539 * 2)) +#define CONST2 ((float) (3.1415926539 * 3)) +#define CONST3 ((float) (3.1415926539 * 4)) + +/* Test that indices > length of vector are applied modulo the vector + length. */ + +/* Test for vector residing in register. */ +vector float e0(vector float v, float x) +{ + return vec_insert (x, v, 0); +} + +vector float e1(vector float v, float x) +{ + return vec_insert (x, v, 1); +} + +vector float e7(vector float v, float x) +{ + return vec_insert (x, v, 7); +} + +vector float e8(vector float v, float x) +{ + return vec_insert (x, v, 8); +} + +/* Test for vector residing in memory. */ +vector float me0(vector float *vp, float x) +{ + return vec_insert (x, *vp, 0); +} + +vector float me1(vector float *vp, float x) +{ + return vec_insert (x, *vp, 1); +} + +vector float me13(vector float *vp, float x) +{ + return vec_insert (x, *vp, 13); +} + +vector float me15(vector float *vp, float x) +{ + return vec_insert (x, *vp, 15); +} + +/* Test the same with variable indices. */ + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +vector float ei(vector float v, int i, float x) +{ + return vec_insert (x, v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__attribute__((noinline)) +vector float mei(vector float *vp, int i, float x) +{ + return vec_insert (x, *vp, i); +} + + +int main (int argc, char *argv[]) { + vector float dv = { CONST0, CONST1, CONST2, CONST3 }; + float d; + + dv = e0 (dv, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = e1 (dv, CONST0); + if (dv [1] != CONST0) + abort (); + + dv = e7 (dv, CONST2); + if (dv [3] != CONST2) + abort (); + + dv = e8 (dv, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = me0 (&dv, CONST2); + if (dv [0] != CONST2) + abort (); + + dv = me1 (&dv, CONST3); + if (dv [1] != CONST3) + abort (); + + dv = me13 (&dv, CONST2); + if (dv [1] != CONST2) + abort (); + + dv = me15 (&dv, CONST1); + if (dv [3] != CONST1) + abort (); + + dv = ei (dv, 0, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = ei (dv, 2, CONST1); + if (dv [2] != CONST1) + abort (); + + dv = ei (dv, 11, CONST0); + if (dv [3] != CONST0) + abort (); + + dv = ei (dv, 17, CONST2); + if (dv [1] != CONST2) + abort (); + + dv = mei (&dv, 0, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = mei (&dv, 1, CONST0); + if (dv [1] != CONST0) + abort (); + + dv = mei (&dv, 15, CONST1); + if (dv [3] != CONST1) + abort (); + + dv = mei (&dv, 6, CONST0); + if (dv [2] != CONST0) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-15c.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-15c.c new file mode 100644 index 00000000000..1a23191e253 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-15c.c @@ -0,0 +1,151 @@ +/* { dg-do run { target int128 } } */ +/* { dg-require-effective-target vsx_hw } */ +/* { dg-options "-mvsx" } */ + +/* This test should run the same on any target that supports vsx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <altivec.h> + +extern void abort (void); + +#define CONST0 (3.1415926539) +#define CONST1 (3.1415926539 * 2) +#define CONST2 (3.1415926539 * 3) +#define CONST3 (3.1415926539 * 4) + + +/* Test that indices > length of vector are applied modulo the vector + length. */ + +/* Test for vector residing in register. */ +vector double e0(vector double v, double x) +{ + return vec_insert (x, v, 0); +} + +vector double e1(vector double v, double x) +{ + return vec_insert (x, v, 1); +} + +vector double e2(vector double v, double x) +{ + return vec_insert (x, v, 2); +} + +vector double e3(vector double v, double x) +{ + return vec_insert (x, v, 3); +} + +/* Test for vector residing in memory. */ +vector double me0(vector double *vp, double x) +{ + return vec_insert (x, *vp, 0); +} + +vector double me1(vector double *vp, double x) +{ + return vec_insert (x, *vp, 1); +} + +vector double me2(vector double *vp, double x) +{ + return vec_insert (x, *vp, 2); +} + +vector double me3(vector double *vp, double x) +{ + return vec_insert (x, *vp, 3); +} + +/* Test the same with variable indices. */ + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +vector double ei(vector double v, int i, double x) +{ + return vec_insert (x, v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__attribute__((noinline)) +vector double mei(vector double *vp, int i, double x) +{ + return vec_insert (x, *vp, i); +} + +int main (int argc, char *argv[]) { + vector double dv; + double d; + dv[0] = CONST0; + dv[1] = CONST1; + + dv = e0 (dv, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = e1 (dv, CONST2); + if (dv [1] != CONST2) + abort (); + + dv = e2 (dv, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = e3 (dv, CONST0); + if (dv [1] != CONST0) + abort (); + + dv = me0 (&dv, CONST2); + if (dv [0] != CONST2) + abort (); + + dv = me1 (&dv, CONST3); + if (dv [1] != CONST3) + abort (); + + dv = me2 (&dv, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = me3 (&dv, CONST0); + if (dv [1] != CONST0) + abort (); + + dv = ei (dv, 0, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = ei (dv, 1, CONST0); + if (dv [1] != CONST0) + abort (); + + dv = ei (dv, 2, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = ei (dv, 3, CONST2); + if (dv [1] != CONST2) + abort (); + + dv = mei (&dv, 0, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = mei (&dv, 1, CONST0); + if (dv [1] != CONST0) + abort (); + + dv = mei (&dv, 2, CONST2); + if (dv [0] != CONST2) + abort (); + + dv = mei (&dv, 3, CONST3); + if (dv [1] != CONST3) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-15d.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-15d.c new file mode 100644 index 00000000000..71f200d831b --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-15d.c @@ -0,0 +1,151 @@ +/* { dg-do run { target int128 } } */ +/* { dg-require-effective-target vsx_hw } */ +/* { dg-options "-mvsx -O3" } */ + +/* This test should run the same on any target that supports vsx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <altivec.h> + +extern void abort (void); + +#define CONST0 (3.1415926539) +#define CONST1 (3.1415926539 * 2) +#define CONST2 (3.1415926539 * 3) +#define CONST3 (3.1415926539 * 4) + + +/* Test that indices > length of vector are applied modulo the vector + length. */ + +/* Test for vector residing in register. */ +vector double e0(vector double v, double x) +{ + return vec_insert (x, v, 0); +} + +vector double e1(vector double v, double x) +{ + return vec_insert (x, v, 1); +} + +vector double e2(vector double v, double x) +{ + return vec_insert (x, v, 2); +} + +vector double e3(vector double v, double x) +{ + return vec_insert (x, v, 3); +} + +/* Test for vector residing in memory. */ +vector double me0(vector double *vp, double x) +{ + return vec_insert (x, *vp, 0); +} + +vector double me1(vector double *vp, double x) +{ + return vec_insert (x, *vp, 1); +} + +vector double me2(vector double *vp, double x) +{ + return vec_insert (x, *vp, 2); +} + +vector double me3(vector double *vp, double x) +{ + return vec_insert (x, *vp, 3); +} + +/* Test the same with variable indices. */ + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +vector double ei(vector double v, int i, double x) +{ + return vec_insert (x, v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__attribute__((noinline)) +vector double mei(vector double *vp, int i, double x) +{ + return vec_insert (x, *vp, i); +} + +int main (int argc, char *argv[]) { + vector double dv; + double d; + dv[0] = CONST0; + dv[1] = CONST1; + + dv = e0 (dv, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = e1 (dv, CONST2); + if (dv [1] != CONST2) + abort (); + + dv = e2 (dv, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = e3 (dv, CONST0); + if (dv [1] != CONST0) + abort (); + + dv = me0 (&dv, CONST2); + if (dv [0] != CONST2) + abort (); + + dv = me1 (&dv, CONST3); + if (dv [1] != CONST3) + abort (); + + dv = me2 (&dv, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = me3 (&dv, CONST0); + if (dv [1] != CONST0) + abort (); + + dv = ei (dv, 0, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = ei (dv, 1, CONST0); + if (dv [1] != CONST0) + abort (); + + dv = ei (dv, 2, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = ei (dv, 3, CONST2); + if (dv [1] != CONST2) + abort (); + + dv = mei (&dv, 0, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = mei (&dv, 1, CONST0); + if (dv [1] != CONST0) + abort (); + + dv = mei (&dv, 2, CONST2); + if (dv [0] != CONST2) + abort (); + + dv = mei (&dv, 3, CONST3); + if (dv [1] != CONST3) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-16c.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-16c.c new file mode 100644 index 00000000000..eea4d406230 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-16c.c @@ -0,0 +1,180 @@ +/* { dg-do run } */ +/* { dg-require-effective-target vmx_hw } */ +/* { dg-options "-maltivec" } */ + +/* This test should run the same on any target that supports altivec/vmx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <stdio.h> +#include <altivec.h> + +extern void abort (void); + +#define CONST0 (0) +#define CONST1 (1) +#define CONST2 (2) +#define CONST3 (3) +#define CONST4 (4) +#define CONST5 (5) +#define CONST6 (6) +#define CONST7 (7) +#define CONST8 (8) +#define CONST9 (9) +#define CONSTA (10) +#define CONSTB (11) +#define CONSTC (12) +#define CONSTD (13) +#define CONSTE (14) +#define CONSTF (15) + + +/* Test that indices > length of vector are applied modulo the vector + length. */ + +/* Test for vector residing in register. */ +vector unsigned char c0 (vector unsigned char v, unsigned char x) +{ + return vec_insert (x, v, 0); +} + +vector unsigned char c9 (vector unsigned char v, unsigned char x) +{ + return vec_insert (x, v, 9); +} + +vector unsigned char c21 (vector unsigned char v, unsigned char x) +{ + return vec_insert (x, v, 21); +} + +vector unsigned char c30 (vector unsigned char v, unsigned char x) +{ + return vec_insert (x, v, 30); +} + +/* Test for vector residing in memory. */ +vector unsigned char mc0 (vector unsigned char *vp, unsigned char x) +{ + return vec_insert (x, *vp, 0); +} + +vector unsigned char mc9 (vector unsigned char *vp, unsigned char x) +{ + return vec_insert (x, *vp, 9); +} + +vector unsigned char mc21 (vector unsigned char *vp, unsigned char x) +{ + return vec_insert (x, *vp, 21); +} + +vector unsigned char mc30 (vector unsigned char *vp, unsigned char x) +{ + return vec_insert (x, *vp, 30); +} + +/* Test the same with variable indices. */ + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +vector unsigned char ci (vector unsigned char v, int i, unsigned char x) +{ + return vec_insert (x, v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__attribute__((noinline)) +vector unsigned char mci (vector unsigned char *vp, int i, unsigned char x) +{ + return vec_insert (x, *vp, i); +} + + +int main (int argc, char *argv[]) { + vector unsigned char cv = { CONST0, CONST1, CONST2, CONST3, + CONST4, CONST5, CONST6, CONST7, + CONST8, CONST9, CONSTA, CONSTB, + CONSTC, CONSTD, CONSTE, CONSTF }; + printf ("A\n"); + cv = c0 (cv, CONST3); + if (cv [0] != CONST3) + abort (); + + printf ("B\n"); + cv = c9 (cv, CONST2); + if (cv [9] != CONST2) + abort (); + + printf ("C\n"); + cv = c21 (cv, CONSTF); + if (cv [5] != CONSTF) + abort (); + + printf ("D\n"); + cv = c30 (cv, CONST3); + if (cv [14] != CONST3) + abort (); + + printf ("E\n"); + cv = mc0 (&cv, CONST4); + if (cv [0] != CONST4) + abort (); + + printf ("F\n"); + cv = mc9 (&cv, CONST3); + if (cv [9] != CONST3) + abort (); + + printf ("G\n"); + cv = mc21 (&cv, CONST1); + if (cv [5] != CONST1) + abort (); + + printf ("H\n"); + cv = mc30 (&cv, CONSTC); + if (cv [14] != CONSTC) + abort (); + + printf ("I\n"); + cv = ci (cv, 8, CONSTD); + if (cv [8] != CONSTD) + abort (); + + printf ("J\n"); + cv = ci (cv, 13, CONST5); + if (cv [13] != CONST5) + abort (); + + printf ("K\n"); + cv = ci (cv, 23, CONST6); + if (cv [7] != CONST6) + abort (); + + printf ("L\n"); + cv = ci (cv, 31, CONST7); + if (cv [15] != CONST7) + abort (); + + printf ("M\n"); + cv = mci (&cv, 5, CONST8); + if (cv [5] != CONST8) + abort (); + + printf ("N\n"); + cv = mci (&cv, 12, CONST9); + if (cv [12] != CONST9) + abort (); + + printf ("O\n"); + cv = mci (&cv, 25, CONSTA); + if (cv [9] != CONSTA) + abort (); + + printf ("P\n"); + cv = mci (&cv, 16, CONSTB); + if (cv [0] != CONSTB) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-16d.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-16d.c new file mode 100644 index 00000000000..f899e57f2d4 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-16d.c @@ -0,0 +1,163 @@ +/* { dg-do run } */ +/* { dg-require-effective-target vmx_hw } */ +/* { dg-options "-maltivec -O3" } */ + +/* This test should run the same on any target that supports altivec/vmx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <altivec.h> + +extern void abort (void); + +#define CONST0 (0) +#define CONST1 (1) +#define CONST2 (2) +#define CONST3 (3) +#define CONST4 (4) +#define CONST5 (5) +#define CONST6 (6) +#define CONST7 (7) +#define CONST8 (8) +#define CONST9 (9) +#define CONSTA (10) +#define CONSTB (11) +#define CONSTC (12) +#define CONSTD (13) +#define CONSTE (14) +#define CONSTF (15) + + +/* Test that indices > length of vector are applied modulo the vector + length. */ + +/* Test for vector residing in register. */ +vector unsigned char c0 (vector unsigned char v, unsigned char x) +{ + return vec_insert (x, v, 0); +} + +vector unsigned char c9 (vector unsigned char v, unsigned char x) +{ + return vec_insert (x, v, 9); +} + +vector unsigned char c21 (vector unsigned char v, unsigned char x) +{ + return vec_insert (x, v, 21); +} + +vector unsigned char c30 (vector unsigned char v, unsigned char x) +{ + return vec_insert (x, v, 30); +} + +/* Test for vector residing in memory. */ +vector unsigned char mc0 (vector unsigned char *vp, unsigned char x) +{ + return vec_insert (x, *vp, 0); +} + +vector unsigned char mc9 (vector unsigned char *vp, unsigned char x) +{ + return vec_insert (x, *vp, 9); +} + +vector unsigned char mc21 (vector unsigned char *vp, unsigned char x) +{ + return vec_insert (x, *vp, 21); +} + +vector unsigned char mc30 (vector unsigned char *vp, unsigned char x) +{ + return vec_insert (x, *vp, 30); +} + +/* Test the same with variable indices. */ + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +vector unsigned char ci (vector unsigned char v, int i, unsigned char x) +{ + return vec_insert (x, v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__attribute__((noinline)) +vector unsigned char mci (vector unsigned char *vp, int i, unsigned char x) +{ + return vec_insert (x, *vp, i); +} + + +int main (int argc, char *argv[]) { + vector unsigned char cv = { CONST0, CONST1, CONST2, CONST3, + CONST4, CONST5, CONST6, CONST7, + CONST8, CONST9, CONSTA, CONSTB, + CONSTC, CONSTD, CONSTE, CONSTF }; + cv = c0 (cv, CONST3); + if (cv [0] != CONST3) + abort (); + + cv = c9 (cv, CONST2); + if (cv [9] != CONST2) + abort (); + + cv = c21 (cv, CONSTF); + if (cv [5] != CONSTF) + abort (); + + cv = c30 (cv, CONST3); + if (cv [14] != CONST3) + abort (); + + cv = mc0 (&cv, CONST4); + if (cv [0] != CONST4) + abort (); + + cv = mc9 (&cv, CONST3); + if (cv [9] != CONST3) + abort (); + + cv = mc21 (&cv, CONST1); + if (cv [5] != CONST1) + abort (); + + cv = mc30 (&cv, CONSTC); + if (cv [14] != CONSTC) + abort (); + + cv = ci (cv, 8, CONSTD); + if (cv [8] != CONSTD) + abort (); + + cv = ci (cv, 13, CONST5); + if (cv [13] != CONST5) + abort (); + + cv = ci (cv, 23, CONST6); + if (cv [7] != CONST6) + abort (); + + cv = ci (cv, 31, CONST7); + if (cv [15] != CONST7) + abort (); + + cv = mci (&cv, 5, CONST8); + if (cv [5] != CONST8) + abort (); + + cv = mci (&cv, 12, CONST9); + if (cv [12] != CONST9) + abort (); + + cv = mci (&cv, 25, CONSTA); + if (cv [9] != CONSTA) + abort (); + + cv = mci (&cv, 16, CONSTB); + if (cv [0] != CONSTB) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-17c.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-17c.c new file mode 100644 index 00000000000..b95dbcdde15 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-17c.c @@ -0,0 +1,154 @@ +/* { dg-do run } */ +/* { dg-require-effective-target vmx_hw } */ +/* { dg-options "-maltivec" } */ + +/* This test should run the same on any target that supports altivec/vmx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <altivec.h> + +extern void abort (void); + +#define CONST0 (0) +#define CONST1 (1) +#define CONST2 (2) +#define CONST3 (3) +#define CONST4 (4) +#define CONST5 (5) +#define CONST6 (6) +#define CONST7 (7) + + +/* Test that indices > length of vector are applied modulo the vector + length. */ + +/* Test for vector residing in register. */ +vector unsigned short s3 (vector unsigned short v, unsigned short x) +{ + return vec_insert (x, v, 3); +} + +vector unsigned short s7 (vector unsigned short v, unsigned short x) +{ + return vec_insert (x, v, 7); +} + +vector unsigned short s21 (vector unsigned short v, unsigned short x) +{ + return vec_insert (x, v, 21); +} + +vector unsigned short s30 (vector unsigned short v, unsigned short x) +{ + return vec_insert (x, v, 30); +} + +/* Test for vector residing in memory. */ +vector unsigned short ms3 (vector unsigned short *vp, unsigned short x) +{ + return vec_insert (x, *vp, 3); +} + +vector unsigned short ms7 (vector unsigned short *vp, unsigned short x) +{ + return vec_insert (x, *vp, 7); +} + +vector unsigned short ms21 (vector unsigned short *vp, unsigned short x) +{ + return vec_insert (x, *vp, 21); +} + +vector unsigned short ms30 (vector unsigned short *vp, unsigned short x) +{ + return vec_insert (x, *vp, 30); +} + +/* Test the same with variable indices. */ + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +vector unsigned short ci (vector unsigned short v, int i, unsigned short x) +{ + return vec_insert (x, v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__attribute__((noinline)) +vector unsigned short mci (vector unsigned short *vp, int i, unsigned short x) +{ + return vec_insert (x, *vp, i); +} + + +int main (int argc, unsigned short *argv[]) { + vector unsigned short sv = { + CONST0, CONST1, CONST2, CONST3, CONST4, CONST5, CONST6, CONST7 }; + + sv = s3 (sv, CONST1); + if (sv [3] != CONST1) + abort (); + + sv = s7 (sv, CONST2); + if (sv [7] != CONST2) + abort (); + + sv = s21 (sv, CONST3); + if (sv [5] != CONST3) + abort (); + + sv = s30 (sv, CONST4); + if (sv [6] != CONST4) + abort (); + + sv = ms3 (&sv, CONST5); + if (sv [3] != CONST5) + abort (); + + sv = ms7 (&sv, CONST6); + if (sv [7] != CONST6) + abort (); + + sv = ms21 (&sv, CONST7); + if (sv [5] != CONST7) + abort (); + + sv = ms30 (&sv, CONST0); + if (sv [6] != CONST0) + abort (); + + sv = ci (sv, 5, CONST1); + if (sv [5] != CONST1) + abort (); + + sv = ci (sv, 2, CONST3); + if (sv [2] != CONST3) + abort (); + + sv = ci (sv, 15, CONST2); + if (sv [7] != CONST2) + abort (); + + sv = ci (sv, 28, CONST5); + if (sv [4] != CONST5) + abort (); + + sv = mci (&sv, 5, CONST4); + if (sv [5] != CONST4) + abort (); + + sv = mci (&sv, 12, CONST6); + if (sv [4] != CONST6) + abort (); + + sv = mci (&sv, 25, CONST7); + if (sv [1] != CONST7) + abort (); + + sv = mci (&sv, 16, CONST4); + if (sv [0] != CONST4) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-17d.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-17d.c new file mode 100644 index 00000000000..b95dbcdde15 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-17d.c @@ -0,0 +1,154 @@ +/* { dg-do run } */ +/* { dg-require-effective-target vmx_hw } */ +/* { dg-options "-maltivec" } */ + +/* This test should run the same on any target that supports altivec/vmx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <altivec.h> + +extern void abort (void); + +#define CONST0 (0) +#define CONST1 (1) +#define CONST2 (2) +#define CONST3 (3) +#define CONST4 (4) +#define CONST5 (5) +#define CONST6 (6) +#define CONST7 (7) + + +/* Test that indices > length of vector are applied modulo the vector + length. */ + +/* Test for vector residing in register. */ +vector unsigned short s3 (vector unsigned short v, unsigned short x) +{ + return vec_insert (x, v, 3); +} + +vector unsigned short s7 (vector unsigned short v, unsigned short x) +{ + return vec_insert (x, v, 7); +} + +vector unsigned short s21 (vector unsigned short v, unsigned short x) +{ + return vec_insert (x, v, 21); +} + +vector unsigned short s30 (vector unsigned short v, unsigned short x) +{ + return vec_insert (x, v, 30); +} + +/* Test for vector residing in memory. */ +vector unsigned short ms3 (vector unsigned short *vp, unsigned short x) +{ + return vec_insert (x, *vp, 3); +} + +vector unsigned short ms7 (vector unsigned short *vp, unsigned short x) +{ + return vec_insert (x, *vp, 7); +} + +vector unsigned short ms21 (vector unsigned short *vp, unsigned short x) +{ + return vec_insert (x, *vp, 21); +} + +vector unsigned short ms30 (vector unsigned short *vp, unsigned short x) +{ + return vec_insert (x, *vp, 30); +} + +/* Test the same with variable indices. */ + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +vector unsigned short ci (vector unsigned short v, int i, unsigned short x) +{ + return vec_insert (x, v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__attribute__((noinline)) +vector unsigned short mci (vector unsigned short *vp, int i, unsigned short x) +{ + return vec_insert (x, *vp, i); +} + + +int main (int argc, unsigned short *argv[]) { + vector unsigned short sv = { + CONST0, CONST1, CONST2, CONST3, CONST4, CONST5, CONST6, CONST7 }; + + sv = s3 (sv, CONST1); + if (sv [3] != CONST1) + abort (); + + sv = s7 (sv, CONST2); + if (sv [7] != CONST2) + abort (); + + sv = s21 (sv, CONST3); + if (sv [5] != CONST3) + abort (); + + sv = s30 (sv, CONST4); + if (sv [6] != CONST4) + abort (); + + sv = ms3 (&sv, CONST5); + if (sv [3] != CONST5) + abort (); + + sv = ms7 (&sv, CONST6); + if (sv [7] != CONST6) + abort (); + + sv = ms21 (&sv, CONST7); + if (sv [5] != CONST7) + abort (); + + sv = ms30 (&sv, CONST0); + if (sv [6] != CONST0) + abort (); + + sv = ci (sv, 5, CONST1); + if (sv [5] != CONST1) + abort (); + + sv = ci (sv, 2, CONST3); + if (sv [2] != CONST3) + abort (); + + sv = ci (sv, 15, CONST2); + if (sv [7] != CONST2) + abort (); + + sv = ci (sv, 28, CONST5); + if (sv [4] != CONST5) + abort (); + + sv = mci (&sv, 5, CONST4); + if (sv [5] != CONST4) + abort (); + + sv = mci (&sv, 12, CONST6); + if (sv [4] != CONST6) + abort (); + + sv = mci (&sv, 25, CONST7); + if (sv [1] != CONST7) + abort (); + + sv = mci (&sv, 16, CONST4); + if (sv [0] != CONST4) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-18c.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-18c.c new file mode 100644 index 00000000000..19932629d4b --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-18c.c @@ -0,0 +1,148 @@ +/* { dg-do run } */ +/* { dg-require-effective-target vmx_hw } */ +/* { dg-options "-maltivec" } */ + +/* This test should run the same on any target that supports altivec/vmx + instructions. Unsigned Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <altivec.h> + +extern void abort (void); + +#define CONST0 (0) +#define CONST1 (1) +#define CONST2 (2) +#define CONST3 (3) + +/* Test that indices > length of vector are applied modulo the vector + length. */ + +/* Test for vector residing in register. */ +vector unsigned int s3 (vector unsigned int v, unsigned int x) +{ + return vec_insert (x, v, 3); +} + +vector unsigned int s1 (vector unsigned int v, unsigned int x) +{ + return vec_insert (x, v, 1); +} + +vector unsigned int s21 (vector unsigned int v, unsigned int x) +{ + return vec_insert (x, v, 21); +} + +vector unsigned int s30 (vector unsigned int v, unsigned int x) +{ + return vec_insert (x, v, 30); +} + +/* Test for vector residing in memory. */ +vector unsigned int ms3 (vector unsigned int *vp, unsigned int x) +{ + return vec_insert (x, *vp, 3); +} + +vector unsigned int ms1(vector unsigned int *vp, unsigned int x) +{ + return vec_insert (x, *vp, 1); +} + +vector unsigned int ms21(vector unsigned int *vp, unsigned int x) +{ + return vec_insert (x, *vp, 21); +} + +vector unsigned int ms30(vector unsigned int *vp, unsigned int x) +{ + return vec_insert (x, *vp, 30); +} + +/* Test the same with variable indices. */ + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +vector unsigned int ci (vector unsigned int v, int i, unsigned int x) +{ + return vec_insert (x, v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__attribute__((noinline)) +vector unsigned int mci(vector unsigned int *vp, int i, unsigned int x) +{ + return vec_insert (x, *vp, i); +} + + +int main (int argc, unsigned char *argv[]) { + vector unsigned int sv = { CONST0, CONST1, CONST2, CONST3 }; + + sv = s3 (sv, CONST2); + if (sv [3] != CONST2) + abort (); + + sv = s1 (sv, CONST2); + if (sv [1] != CONST2) + abort (); + + sv = s21 (sv, CONST3); + if (sv [1] != CONST3) + abort (); + + sv = s30 (sv, CONST1); + if (sv [2] != CONST1) + abort (); + + sv = ms3 (&sv, CONST0); + if (sv [3] != CONST0) + abort (); + + sv = ms1 (&sv, CONST0); + if (sv [1] != CONST0) + abort (); + + sv = ms21 (&sv, CONST1); + if (sv [1] != CONST1) + abort (); + + sv = ms30 (&sv, CONST0); + if (sv [2] != CONST0) + abort (); + + sv = ci (sv, 5, CONST3); + if (sv [1] != CONST3) + abort (); + + sv = ci (sv, 2, CONST0); + if (sv [2] != CONST0) + abort (); + + sv = ci (sv, 15, CONST1); + if (sv [3] != CONST1) + abort (); + + sv = ci (sv, 28, CONST3); + if (sv [0] != CONST3) + abort (); + + sv = mci (&sv, 5, CONST0); + if (sv [1] != CONST0) + abort (); + + sv = mci (&sv, 12, CONST2); + if (sv [0] != CONST2) + abort (); + + sv = mci (&sv, 25, CONST3); + if (sv [1] != CONST3) + abort (); + + sv = mci (&sv, 16, CONST1); + if (sv [0] != CONST1) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-18d.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-18d.c new file mode 100644 index 00000000000..8c643aaafd3 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-18d.c @@ -0,0 +1,148 @@ +/* { dg-do run } */ +/* { dg-require-effective-target vmx_hw } */ +/* { dg-options "-maltivec -O3" } */ + +/* This test should run the same on any target that supports altivec/vmx + instructions. Unsigned Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <altivec.h> + +extern void abort (void); + +#define CONST0 (0) +#define CONST1 (1) +#define CONST2 (2) +#define CONST3 (3) + +/* Test that indices > length of vector are applied modulo the vector + length. */ + +/* Test for vector residing in register. */ +vector unsigned int s3 (vector unsigned int v, unsigned int x) +{ + return vec_insert (x, v, 3); +} + +vector unsigned int s1 (vector unsigned int v, unsigned int x) +{ + return vec_insert (x, v, 1); +} + +vector unsigned int s21 (vector unsigned int v, unsigned int x) +{ + return vec_insert (x, v, 21); +} + +vector unsigned int s30 (vector unsigned int v, unsigned int x) +{ + return vec_insert (x, v, 30); +} + +/* Test for vector residing in memory. */ +vector unsigned int ms3 (vector unsigned int *vp, unsigned int x) +{ + return vec_insert (x, *vp, 3); +} + +vector unsigned int ms1(vector unsigned int *vp, unsigned int x) +{ + return vec_insert (x, *vp, 1); +} + +vector unsigned int ms21(vector unsigned int *vp, unsigned int x) +{ + return vec_insert (x, *vp, 21); +} + +vector unsigned int ms30(vector unsigned int *vp, unsigned int x) +{ + return vec_insert (x, *vp, 30); +} + +/* Test the same with variable indices. */ + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +vector unsigned int ci (vector unsigned int v, int i, unsigned int x) +{ + return vec_insert (x, v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__attribute__((noinline)) +vector unsigned int mci(vector unsigned int *vp, int i, unsigned int x) +{ + return vec_insert (x, *vp, i); +} + + +int main (int argc, unsigned char *argv[]) { + vector unsigned int sv = { CONST0, CONST1, CONST2, CONST3 }; + + sv = s3 (sv, CONST2); + if (sv [3] != CONST2) + abort (); + + sv = s1 (sv, CONST2); + if (sv [1] != CONST2) + abort (); + + sv = s21 (sv, CONST3); + if (sv [1] != CONST3) + abort (); + + sv = s30 (sv, CONST1); + if (sv [2] != CONST1) + abort (); + + sv = ms3 (&sv, CONST0); + if (sv [3] != CONST0) + abort (); + + sv = ms1 (&sv, CONST0); + if (sv [1] != CONST0) + abort (); + + sv = ms21 (&sv, CONST1); + if (sv [1] != CONST1) + abort (); + + sv = ms30 (&sv, CONST0); + if (sv [2] != CONST0) + abort (); + + sv = ci (sv, 5, CONST3); + if (sv [1] != CONST3) + abort (); + + sv = ci (sv, 2, CONST0); + if (sv [2] != CONST0) + abort (); + + sv = ci (sv, 15, CONST1); + if (sv [3] != CONST1) + abort (); + + sv = ci (sv, 28, CONST3); + if (sv [0] != CONST3) + abort (); + + sv = mci (&sv, 5, CONST0); + if (sv [1] != CONST0) + abort (); + + sv = mci (&sv, 12, CONST2); + if (sv [0] != CONST2) + abort (); + + sv = mci (&sv, 25, CONST3); + if (sv [1] != CONST3) + abort (); + + sv = mci (&sv, 16, CONST1); + if (sv [0] != CONST1) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-19c.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-19c.c new file mode 100644 index 00000000000..3ff0dfe20b0 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-19c.c @@ -0,0 +1,122 @@ +/* { dg-do run { target int128 } } */ +/* { dg-require-effective-target vsx_hw } */ +/* { dg-options "-mvsx" } */ + +/* This test should run the same on any target that supports vsx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <altivec.h> + +extern void abort (void); + +#define CONST0 (31415926539LL) +#define CONST1 (2 * 31415926539LL) +#define CONST2 (3 * 31415926539LL) +#define CONST3 (4 * 31415926539LL) +#define CONST4 (5 * 31415926539LL) +#define CONST5 (6 * 31415926539LL) +#define CONST6 (7 * 31415926539LL) +#define CONST7 (8 * 31415926539LL) + +/* Test that indices > length of vector are applied modulo the vector + length. */ + +/* Test for vector residing in register. */ +vector unsigned long long int +e0 (vector unsigned long long int v, unsigned long long int x) +{ + return vec_insert (x, v, 0); +} + +vector unsigned long long int +e3 (vector unsigned long long int v, unsigned long long int x) +{ + return vec_insert (x, v, 3); +} + +/* Test for vector residing in memory. */ +vector unsigned long long int +me0 (vector unsigned long long int *vp, unsigned long long int x) +{ + return vec_insert (x, *vp, 0); +} + +vector unsigned long long int +me3 (vector unsigned long long int *vp, unsigned long long int x) +{ + return vec_insert (x, *vp, 3); +} + +/* Test the same with variable indices. */ + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +vector unsigned long long int +ei (vector unsigned long long int v, int i, unsigned long long int x) +{ + return vec_insert (x, v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__attribute__((noinline)) +vector unsigned long long int +mei (vector unsigned long long int *vp, int i, unsigned long long int x) +{ + return vec_insert (x, *vp, i); +} + +int main (int argc, char *argv[]) { + vector unsigned long long int dv = { CONST0, CONST1 }; + unsigned long long int d; + + dv = e0 (dv, CONST7); + if (dv [0] != CONST7) + abort (); + + dv = e3 (dv, CONST2); + if (dv [1] != CONST2) + abort (); + + dv = me0 (&dv, CONST4); + if (dv [0] != CONST4) + abort (); + + dv = me3 (&dv, CONST3); + if (dv [1] != CONST3) + abort (); + + dv = ei (dv, 0, CONST5); + if (dv [0] != CONST5) + abort (); + + dv = ei (dv, 1, CONST2); + if (dv [1] != CONST2) + abort (); + + dv = ei (dv, 2, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = ei (dv, 3, CONST6); + if (dv [1] != CONST6) + abort (); + + dv = mei (&dv, 0, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = mei (&dv, 1, CONST3); + if (dv [1] != CONST3) + abort (); + + dv = mei (&dv, 2, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = mei (&dv, 3, CONST2); + if (dv [1] != CONST2) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-19d.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-19d.c new file mode 100644 index 00000000000..d0236df5308 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-19d.c @@ -0,0 +1,122 @@ +/* { dg-do run { target int128 } } */ +/* { dg-require-effective-target vsx_hw } */ +/* { dg-options "-mvsx -O3" } */ + +/* This test should run the same on any target that supports vsx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <altivec.h> + +extern void abort (void); + +#define CONST0 (31415926539LL) +#define CONST1 (2 * 31415926539LL) +#define CONST2 (3 * 31415926539LL) +#define CONST3 (4 * 31415926539LL) +#define CONST4 (5 * 31415926539LL) +#define CONST5 (6 * 31415926539LL) +#define CONST6 (7 * 31415926539LL) +#define CONST7 (8 * 31415926539LL) + +/* Test that indices > length of vector are applied modulo the vector + length. */ + +/* Test for vector residing in register. */ +vector unsigned long long int +e0 (vector unsigned long long int v, unsigned long long int x) +{ + return vec_insert (x, v, 0); +} + +vector unsigned long long int +e3 (vector unsigned long long int v, unsigned long long int x) +{ + return vec_insert (x, v, 3); +} + +/* Test for vector residing in memory. */ +vector unsigned long long int +me0 (vector unsigned long long int *vp, unsigned long long int x) +{ + return vec_insert (x, *vp, 0); +} + +vector unsigned long long int +me3 (vector unsigned long long int *vp, unsigned long long int x) +{ + return vec_insert (x, *vp, 3); +} + +/* Test the same with variable indices. */ + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +vector unsigned long long int +ei (vector unsigned long long int v, int i, unsigned long long int x) +{ + return vec_insert (x, v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__attribute__((noinline)) +vector unsigned long long int +mei (vector unsigned long long int *vp, int i, unsigned long long int x) +{ + return vec_insert (x, *vp, i); +} + +int main (int argc, char *argv[]) { + vector unsigned long long int dv = { CONST0, CONST1 }; + unsigned long long int d; + + dv = e0 (dv, CONST7); + if (dv [0] != CONST7) + abort (); + + dv = e3 (dv, CONST2); + if (dv [1] != CONST2) + abort (); + + dv = me0 (&dv, CONST4); + if (dv [0] != CONST4) + abort (); + + dv = me3 (&dv, CONST3); + if (dv [1] != CONST3) + abort (); + + dv = ei (dv, 0, CONST5); + if (dv [0] != CONST5) + abort (); + + dv = ei (dv, 1, CONST2); + if (dv [1] != CONST2) + abort (); + + dv = ei (dv, 2, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = ei (dv, 3, CONST6); + if (dv [1] != CONST6) + abort (); + + dv = mei (&dv, 0, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = mei (&dv, 1, CONST3); + if (dv [1] != CONST3) + abort (); + + dv = mei (&dv, 2, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = mei (&dv, 3, CONST2); + if (dv [1] != CONST2) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-20a.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-20a.c index 638f5a1c904..12350c3ed7a 100644 --- a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-20a.c +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-20a.c @@ -9,7 +9,7 @@ #include <altivec.h> /* Define this after PR89424 is addressed. */ -#undef PR89424 +#define PR89424 extern void abort (void); diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-20b.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-20b.c index 7b127a06c77..37fb7133ba0 100644 --- a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-20b.c +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-20b.c @@ -9,7 +9,7 @@ #include <altivec.h> /* Define this after PR89424 is addressed. */ -#undef PR89424 +#define PR89424 extern void abort (void); diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-20c.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-20c.c new file mode 100644 index 00000000000..e56d500515e --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-20c.c @@ -0,0 +1,115 @@ +/* { dg-do run { target int128 } } */ +/* { dg-require-effective-target vsx_hw } */ +/* { dg-options "-mvsx" } */ + +/* This test should run the same on any target that supports vsx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <altivec.h> + +extern void abort (void); + +#define CONST0 (((unsigned __int128) 31415926539) << 60) +#define CONST1 (((unsigned __int128) 31415926539) << 54) +#define CONST2 (((unsigned __int128) 31415926539) << 48) +#define CONST3 (((unsigned __int128) 31415926539) << 32) + +/* Test that indices > length of vector are applied modulo the vector + length. */ + +/* Test for vector residing in register. */ +vector unsigned __int128 e0 (vector unsigned __int128 v, unsigned __int128 x) +{ + return vec_insert (x, v, 0); +} + +vector unsigned __int128 e3 (vector unsigned __int128 v, unsigned __int128 x) +{ + return vec_insert (x, v, 3); +} + +/* Test for vector residing in memory. */ +vector unsigned __int128 +me0 (vector unsigned __int128 *vp, unsigned __int128 x) +{ + return vec_insert (x, *vp, 0); +} + +vector unsigned __int128 +me3 (vector unsigned __int128 *vp, unsigned __int128 x) +{ + return vec_insert (x, *vp, 3); +} + +/* Test the same with variable indices. */ + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +vector unsigned __int128 +ei (vector unsigned __int128 v, int i, unsigned __int128 x) +{ + return vec_insert (x, v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__attribute__((noinline)) +vector unsigned __int128 +mei (vector unsigned __int128 *vp, int i, unsigned __int128 x) +{ + return vec_insert (x, *vp, i); +} + +int main (int argc, char *argv[]) { + vector unsigned __int128 dv = { CONST0 }; + + dv = e0 (dv, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = e3 (dv, CONST2); + if (dv [0] != CONST2) + abort (); + + dv = me0 (&dv, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = me3 (&dv, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = ei (dv, 0, CONST0); + if (dv [0] != CONST0) + abort (); + + dv = ei (dv, 1, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = ei (dv, 2, CONST2); + if (dv [0] != CONST2) + abort (); + + dv = ei (dv, 3, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = mei (&dv, 0, CONST0); + if (dv [0] != CONST0) + abort (); + + dv = mei (&dv, 1, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = mei (&dv, 2, CONST2); + if (dv [0] != CONST2) + abort (); + + dv = mei (&dv, 3, CONST3); + if (dv [0] != CONST3) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-20d.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-20d.c new file mode 100644 index 00000000000..17c7b0e48a9 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-20d.c @@ -0,0 +1,115 @@ +/* { dg-do run { target int128 } } */ +/* { dg-require-effective-target vsx_hw } */ +/* { dg-options "-mvsx -O3" } */ + +/* This test should run the same on any target that supports vsx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <altivec.h> + +extern void abort (void); + +#define CONST0 (((unsigned __int128) 31415926539) << 60) +#define CONST1 (((unsigned __int128) 31415926539) << 54) +#define CONST2 (((unsigned __int128) 31415926539) << 48) +#define CONST3 (((unsigned __int128) 31415926539) << 32) + +/* Test that indices > length of vector are applied modulo the vector + length. */ + +/* Test for vector residing in register. */ +vector unsigned __int128 e0 (vector unsigned __int128 v, unsigned __int128 x) +{ + return vec_insert (x, v, 0); +} + +vector unsigned __int128 e3 (vector unsigned __int128 v, unsigned __int128 x) +{ + return vec_insert (x, v, 3); +} + +/* Test for vector residing in memory. */ +vector unsigned __int128 +me0 (vector unsigned __int128 *vp, unsigned __int128 x) +{ + return vec_insert (x, *vp, 0); +} + +vector unsigned __int128 +me3 (vector unsigned __int128 *vp, unsigned __int128 x) +{ + return vec_insert (x, *vp, 3); +} + +/* Test the same with variable indices. */ + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +vector unsigned __int128 +ei (vector unsigned __int128 v, int i, unsigned __int128 x) +{ + return vec_insert (x, v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__attribute__((noinline)) +vector unsigned __int128 +mei (vector unsigned __int128 *vp, int i, unsigned __int128 x) +{ + return vec_insert (x, *vp, i); +} + +int main (int argc, char *argv[]) { + vector unsigned __int128 dv = { CONST0 }; + + dv = e0 (dv, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = e3 (dv, CONST2); + if (dv [0] != CONST2) + abort (); + + dv = me0 (&dv, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = me3 (&dv, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = ei (dv, 0, CONST0); + if (dv [0] != CONST0) + abort (); + + dv = ei (dv, 1, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = ei (dv, 2, CONST2); + if (dv [0] != CONST2) + abort (); + + dv = ei (dv, 3, CONST3); + if (dv [0] != CONST3) + abort (); + + dv = mei (&dv, 0, CONST0); + if (dv [0] != CONST0) + abort (); + + dv = mei (&dv, 1, CONST1); + if (dv [0] != CONST1) + abort (); + + dv = mei (&dv, 2, CONST2); + if (dv [0] != CONST2) + abort (); + + dv = mei (&dv, 3, CONST3); + if (dv [0] != CONST3) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-9c.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-9c.c new file mode 100644 index 00000000000..3bec1474954 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-9c.c @@ -0,0 +1,164 @@ +/* { dg-do run } */ +/* { dg-require-effective-target vmx_hw } */ +/* { dg-options "-maltivec" } */ + +/* This test should run the same on any target that supports altivec/vmx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <altivec.h> + +extern void abort (void); + +#define CONST0 (0) +#define CONST1 (1) +#define CONST2 (2) +#define CONST3 (3) +#define CONST4 (4) +#define CONST5 (5) +#define CONST6 (6) +#define CONST7 (7) +#define CONST8 (8) +#define CONST9 (9) +#define CONSTA (10) +#define CONSTB (11) +#define CONSTC (12) +#define CONSTD (13) +#define CONSTE (14) +#define CONSTF (15) + + +/* Test that indices > length of vector are applied modulo the vector + length. */ + +/* Test for vector residing in register. */ +vector signed char c0 (vector signed char v, signed char x) +{ + return vec_insert (x, v, 0); +} + +vector signed char c9 (vector signed char v, signed char x) +{ + return vec_insert (x, v, 9); +} + +vector signed char c21 (vector signed char v, signed char x) +{ + return vec_insert (x, v, 21); +} + +vector signed char c30 (vector signed char v, signed char x) +{ + return vec_insert (x, v, 30); +} + +/* Test for vector residing in memory. */ +vector signed char mc0 (vector signed char *vp, signed char x) +{ + return vec_insert (x, *vp, 0); +} + +vector signed char mc9 (vector signed char *vp, signed char x) +{ + return vec_insert (x, *vp, 9); +} + +vector signed char mc21 (vector signed char *vp, signed char x) +{ + return vec_insert (x, *vp, 21); +} + +vector signed char mc30 (vector signed char *vp, signed char x) +{ + return vec_insert (x, *vp, 30); +} + +/* Test the same with variable indices. */ + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +vector signed char ci (vector signed char v, int i, signed char x) +{ + return vec_insert (x, v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__attribute__((noinline)) +vector signed char mci(vector signed char *vp, int i, signed char x) { + return vec_insert (x, *vp, i); +} + + +int main (int argc, char *argv[]) { + vector signed char cv = { CONST0, CONST1, CONST2, CONST3, + CONST4, CONST5, CONST6, CONST7, + CONST8, CONST9, CONSTA, CONSTB, + CONSTC, CONSTD, CONSTE, CONSTF }; + signed char c; + + cv = c0 (cv, CONSTF); + if (cv [0] != CONSTF) + abort (); + + cv = c9 (cv, CONST7); + if (cv [9] != CONST7) + abort (); + + cv = c21 (cv, CONSTA); + if (cv [5] != CONSTA) + abort (); + + cv = c30 (cv, CONSTC); + if (cv [14] != CONSTC) + abort (); + + cv = mc0 (&cv, CONSTB); + if (cv [0] != CONSTB) + abort (); + + cv = mc9 (&cv, CONST1); + if (cv [9] != CONST1) + abort (); + + cv = mc21 (&cv, CONST7); + if (cv [5] != CONST7) + abort (); + + cv = mc30 (&cv, CONST2); + if (cv [14] != CONST2) + abort (); + + cv = ci (cv, 8, CONST4); + if (cv [8] != CONST4) + abort (); + + cv = ci (cv, 13, CONSTB); + if (cv [13] != CONSTB) + abort (); + + cv = ci (cv, 23, CONST3); + if (cv [7] != CONST3) + abort (); + + cv = ci (cv, 31, CONST2); + if (cv [15] != CONST2) + abort (); + + cv = mci (&cv, 5, CONST1); + if (cv [5] != CONST1) + abort (); + + cv = mci (&cv, 12, CONST3); + if (cv [12] != CONST3) + abort (); + + cv = mci (&cv, 25, CONST5); + if (cv [9] != CONST5) + abort (); + + cv = mci (&cv, 16, CONSTD); + if (cv [0] != CONSTD) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-9d.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-9d.c new file mode 100644 index 00000000000..1e70c521fec --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-9d.c @@ -0,0 +1,164 @@ +/* { dg-do run } */ +/* { dg-require-effective-target vmx_hw } */ +/* { dg-options "-maltivec -O3" } */ + +/* This test should run the same on any target that supports altivec/vmx + instructions. Intentionally not specifying cpu in order to test + all code generation paths. */ + +#include <altivec.h> + +extern void abort (void); + +#define CONST0 (0) +#define CONST1 (1) +#define CONST2 (2) +#define CONST3 (3) +#define CONST4 (4) +#define CONST5 (5) +#define CONST6 (6) +#define CONST7 (7) +#define CONST8 (8) +#define CONST9 (9) +#define CONSTA (10) +#define CONSTB (11) +#define CONSTC (12) +#define CONSTD (13) +#define CONSTE (14) +#define CONSTF (15) + + +/* Test that indices > length of vector are applied modulo the vector + length. */ + +/* Test for vector residing in register. */ +vector signed char c0 (vector signed char v, signed char x) +{ + return vec_insert (x, v, 0); +} + +vector signed char c9 (vector signed char v, signed char x) +{ + return vec_insert (x, v, 9); +} + +vector signed char c21 (vector signed char v, signed char x) +{ + return vec_insert (x, v, 21); +} + +vector signed char c30 (vector signed char v, signed char x) +{ + return vec_insert (x, v, 30); +} + +/* Test for vector residing in memory. */ +vector signed char mc0 (vector signed char *vp, signed char x) +{ + return vec_insert (x, *vp, 0); +} + +vector signed char mc9 (vector signed char *vp, signed char x) +{ + return vec_insert (x, *vp, 9); +} + +vector signed char mc21 (vector signed char *vp, signed char x) +{ + return vec_insert (x, *vp, 21); +} + +vector signed char mc30 (vector signed char *vp, signed char x) +{ + return vec_insert (x, *vp, 30); +} + +/* Test the same with variable indices. */ + +/* Test for variable selector and vector residing in register. */ +__attribute__((noinline)) +vector signed char ci (vector signed char v, int i, signed char x) +{ + return vec_insert (x, v, i); +} + +/* Test for variable selector and vector residing in memory. */ +__attribute__((noinline)) +vector signed char mci(vector signed char *vp, int i, signed char x) { + return vec_insert (x, *vp, i); +} + + +int main (int argc, char *argv[]) { + vector signed char cv = { CONST0, CONST1, CONST2, CONST3, + CONST4, CONST5, CONST6, CONST7, + CONST8, CONST9, CONSTA, CONSTB, + CONSTC, CONSTD, CONSTE, CONSTF }; + signed char c; + + cv = c0 (cv, CONSTF); + if (cv [0] != CONSTF) + abort (); + + cv = c9 (cv, CONST7); + if (cv [9] != CONST7) + abort (); + + cv = c21 (cv, CONSTA); + if (cv [5] != CONSTA) + abort (); + + cv = c30 (cv, CONSTC); + if (cv [14] != CONSTC) + abort (); + + cv = mc0 (&cv, CONSTB); + if (cv [0] != CONSTB) + abort (); + + cv = mc9 (&cv, CONST1); + if (cv [9] != CONST1) + abort (); + + cv = mc21 (&cv, CONST7); + if (cv [5] != CONST7) + abort (); + + cv = mc30 (&cv, CONST2); + if (cv [14] != CONST2) + abort (); + + cv = ci (cv, 8, CONST4); + if (cv [8] != CONST4) + abort (); + + cv = ci (cv, 13, CONSTB); + if (cv [13] != CONSTB) + abort (); + + cv = ci (cv, 23, CONST3); + if (cv [7] != CONST3) + abort (); + + cv = ci (cv, 31, CONST2); + if (cv [15] != CONST2) + abort (); + + cv = mci (&cv, 5, CONST1); + if (cv [5] != CONST1) + abort (); + + cv = mci (&cv, 12, CONST3); + if (cv [12] != CONST3) + abort (); + + cv = mci (&cv, 25, CONST5); + if (cv [9] != CONST5) + abort (); + + cv = mci (&cv, 16, CONSTD); + if (cv [0] != CONSTD) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/promote-type-for-libcall.c b/gcc/testsuite/gcc.target/riscv/promote-type-for-libcall.c new file mode 100644 index 00000000000..bdbcbc0316a --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/promote-type-for-libcall.c @@ -0,0 +1,37 @@ +/* { dg-do run } */ +/* { dg-options "-O1 -ftree-slp-vectorize -funroll-loops" } */ + +#include <stdio.h> +#include <stdlib.h> +#define N 4 +volatile float f[N]; +int x[N] __attribute__((aligned(8))); +int main() { + int i; + x[0] = -1; + x[1] = 2; + x[2] = -2; + x[3] = 2; + + for (i=0;i<N;++i){ + f[i] = x[i]; + } + + if (f[0] != -1.0f) { + abort(); + } + + if (f[1] != 2.0f) { + abort(); + } + + if (f[2] != -2.0f) { + abort(); + } + + if (f[3] != 2.0f) { + abort(); + } + + return 0; +} diff --git a/gcc/testsuite/gcc.target/s390/vector/vec-shift-2.c b/gcc/testsuite/gcc.target/s390/vector/vec-shift-2.c new file mode 100644 index 00000000000..c7a1d93b817 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/vector/vec-shift-2.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -mzarch -march=z13 --save-temps" } */ + +/* { dg-final { scan-assembler-times "veslf" 1 } } */ + +typedef __attribute__((vector_size(16))) signed int v4si; + +v4si __attribute__((noinline,noclone)) +shift_left_by_scalar (v4si in, int shift_count) +{ + return in << (3 + shift_count); +} + +int +main () +{ + v4si a = { 1, 2, 3, 4 }; + v4si result = shift_left_by_scalar (a, 1); + + if (result[1] != 32) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/sparc/20161111-1.c b/gcc/testsuite/gcc.target/sparc/20161111-1.c index eda8b0a9f12..8195fec8990 100644 --- a/gcc/testsuite/gcc.target/sparc/20161111-1.c +++ b/gcc/testsuite/gcc.target/sparc/20161111-1.c @@ -14,4 +14,4 @@ unsigned char ee_isdigit2(unsigned int i) return retval; } -/* { dg-final { scan-assembler-not "and\t%" } } */ +/* { dg-final { scan-assembler-not "and\t%" { xfail *-*-* } } } */ diff --git a/gcc/testsuite/gcc.target/sparc/overflow-1.c b/gcc/testsuite/gcc.target/sparc/overflow-1.c index e3fa0d04573..75f69ba4f9d 100644 --- a/gcc/testsuite/gcc.target/sparc/overflow-1.c +++ b/gcc/testsuite/gcc.target/sparc/overflow-1.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O -mcpu=v8" } */ +/* { dg-options "-O -fno-pie -mcpu=v8" } */ /* { dg-require-effective-target ilp32 } */ #include <stdbool.h> diff --git a/gcc/testsuite/gcc.target/sparc/overflow-2.c b/gcc/testsuite/gcc.target/sparc/overflow-2.c index 9e42bd214de..feb3f194828 100644 --- a/gcc/testsuite/gcc.target/sparc/overflow-2.c +++ b/gcc/testsuite/gcc.target/sparc/overflow-2.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O -mcpu=v8" } */ +/* { dg-options "-O -fno-pie -mcpu=v8" } */ /* { dg-require-effective-target ilp32 } */ #include <stdbool.h> diff --git a/gcc/testsuite/gcc.target/sparc/overflow-3.c b/gcc/testsuite/gcc.target/sparc/overflow-3.c index 8cb24f52f7b..18253bb6e5e 100644 --- a/gcc/testsuite/gcc.target/sparc/overflow-3.c +++ b/gcc/testsuite/gcc.target/sparc/overflow-3.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O" } */ +/* { dg-options "-O -fno-pie" } */ /* { dg-require-effective-target lp64 } */ #include <stdbool.h> diff --git a/gcc/testsuite/gcc.target/sparc/overflow-4.c b/gcc/testsuite/gcc.target/sparc/overflow-4.c index 868edea2b9e..fb30877efb9 100644 --- a/gcc/testsuite/gcc.target/sparc/overflow-4.c +++ b/gcc/testsuite/gcc.target/sparc/overflow-4.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O -mno-vis3" } */ +/* { dg-options "-O -fno-pie -mno-vis3" } */ /* { dg-require-effective-target lp64 } */ #include <stdbool.h> diff --git a/gcc/testsuite/gcc.target/sparc/overflow-5.c b/gcc/testsuite/gcc.target/sparc/overflow-5.c index 501ce04f7a1..509d957715d 100644 --- a/gcc/testsuite/gcc.target/sparc/overflow-5.c +++ b/gcc/testsuite/gcc.target/sparc/overflow-5.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O -mvis3" } */ +/* { dg-options "-O -fno-pie -mvis3" } */ /* { dg-require-effective-target lp64 } */ #include <stdbool.h> diff --git a/gcc/testsuite/gcc.target/x86_64/abi/avx512f/abi-avx512f.exp b/gcc/testsuite/gcc.target/x86_64/abi/avx512f/abi-avx512f.exp index d9408d81fbb..a0da7bbe976 100644 --- a/gcc/testsuite/gcc.target/x86_64/abi/avx512f/abi-avx512f.exp +++ b/gcc/testsuite/gcc.target/x86_64/abi/avx512f/abi-avx512f.exp @@ -37,7 +37,6 @@ set additional_flags "-W -Wall -mavx512f" foreach src [lsort [glob -nocomplain $srcdir/$subdir/test_*.c]] { if {[runtest_file_p $runtests $src]} { if { ([istarget *-*-darwin*]) } then { - # FIXME: Darwin isn't tested. c-torture-execute [list $src \ $srcdir/$subdir/asm-support-darwin.s] \ $additional_flags diff --git a/gcc/testsuite/gcc.target/x86_64/abi/avx512f/asm-support-darwin.s b/gcc/testsuite/gcc.target/x86_64/abi/avx512f/asm-support-darwin.s new file mode 100644 index 00000000000..53647262019 --- /dev/null +++ b/gcc/testsuite/gcc.target/x86_64/abi/avx512f/asm-support-darwin.s @@ -0,0 +1,93 @@ + .text + .p2align 4,,15 + .globl _snapshot +_snapshot: +LFB3: + movq %rax, _rax(%rip) + movq %rbx, _rbx(%rip) + movq %rcx, _rcx(%rip) + movq %rdx, _rdx(%rip) + movq %rdi, _rdi(%rip) + movq %rsi, _rsi(%rip) + movq %rbp, _rbp(%rip) + movq %rsp, _rsp(%rip) + movq %r8, _r8(%rip) + movq %r9, _r9(%rip) + movq %r10, _r10(%rip) + movq %r11, _r11(%rip) + movq %r12, _r12(%rip) + movq %r13, _r13(%rip) + movq %r14, _r14(%rip) + movq %r15, _r15(%rip) + vmovdqu32 %zmm0, _zmm_regs+0(%rip) + vmovdqu32 %zmm1, _zmm_regs+64(%rip) + vmovdqu32 %zmm2, _zmm_regs+128(%rip) + vmovdqu32 %zmm3, _zmm_regs+192(%rip) + vmovdqu32 %zmm4, _zmm_regs+256(%rip) + vmovdqu32 %zmm5, _zmm_regs+320(%rip) + vmovdqu32 %zmm6, _zmm_regs+384(%rip) + vmovdqu32 %zmm7, _zmm_regs+448(%rip) + vmovdqu32 %zmm8, _zmm_regs+512(%rip) + vmovdqu32 %zmm9, _zmm_regs+576(%rip) + vmovdqu32 %zmm10, _zmm_regs+640(%rip) + vmovdqu32 %zmm11, _zmm_regs+704(%rip) + vmovdqu32 %zmm12, _zmm_regs+768(%rip) + vmovdqu32 %zmm13, _zmm_regs+832(%rip) + vmovdqu32 %zmm14, _zmm_regs+896(%rip) + vmovdqu32 %zmm15, _zmm_regs+960(%rip) + vmovdqu32 %zmm16, _zmm_regs+1024(%rip) + vmovdqu32 %zmm17, _zmm_regs+1088(%rip) + vmovdqu32 %zmm18, _zmm_regs+1152(%rip) + vmovdqu32 %zmm19, _zmm_regs+1216(%rip) + vmovdqu32 %zmm20, _zmm_regs+1280(%rip) + vmovdqu32 %zmm21, _zmm_regs+1344(%rip) + vmovdqu32 %zmm22, _zmm_regs+1408(%rip) + vmovdqu32 %zmm23, _zmm_regs+1472(%rip) + vmovdqu32 %zmm24, _zmm_regs+1536(%rip) + vmovdqu32 %zmm25, _zmm_regs+1600(%rip) + vmovdqu32 %zmm26, _zmm_regs+1664(%rip) + vmovdqu32 %zmm27, _zmm_regs+1728(%rip) + vmovdqu32 %zmm28, _zmm_regs+1792(%rip) + vmovdqu32 %zmm29, _zmm_regs+1856(%rip) + vmovdqu32 %zmm30, _zmm_regs+1920(%rip) + vmovdqu32 %zmm31, _zmm_regs+1984(%rip) + jmp *_callthis(%rip) +LFE3: + + .p2align 4,,15 + .globl _snapshot_ret +_snapshot_ret: + movq %rdi, _rdi(%rip) + subq $8, %rsp + call *_callthis(%rip) + addq $8, %rsp + movq %rax, _rax(%rip) + movq %rdx, _rdx(%rip) + vmovdqu32 %zmm0, _zmm_regs+0(%rip) + vmovdqu32 %zmm1, _zmm_regs+64(%rip) + fstpt _x87_regs(%rip) + fstpt _x87_regs+16(%rip) + fldt _x87_regs+16(%rip) + fldt _x87_regs(%rip) + ret + + .comm _callthis,8,8 + .comm _rax,8,8 + .comm _rbx,8,8 + .comm _rcx,8,8 + .comm _rdx,8,8 + .comm _rsi,8,8 + .comm _rdi,8,8 + .comm _rsp,8,8 + .comm _rbp,8,8 + .comm _r8,8,8 + .comm _r9,8,8 + .comm _r10,8,8 + .comm _r11,8,8 + .comm _r12,8,8 + .comm _r13,8,8 + .comm _r14,8,8 + .comm _r15,8,8 + .comm _zmm_regs,2048,64 + .comm _x87_regs,128,32 + .comm _volatile_var,8,8 diff --git a/gcc/testsuite/gfortran.dg/assign_10.f90 b/gcc/testsuite/gfortran.dg/assign_10.f90 index 6e57bef1650..c207f9e5e2b 100644 --- a/gcc/testsuite/gfortran.dg/assign_10.f90 +++ b/gcc/testsuite/gfortran.dg/assign_10.f90 @@ -24,4 +24,4 @@ end ! Note that it is the kind conversion that generates the temp. ! ! { dg-final { scan-tree-dump-times "parm" 20 "original" } } -! { dg-final { scan-tree-dump-times "atmp" 18 "original" } } +! { dg-final { scan-tree-dump-times "atmp" 20 "original" } } diff --git a/gcc/testsuite/gfortran.dg/associate_48.f90 b/gcc/testsuite/gfortran.dg/associate_48.f90 new file mode 100644 index 00000000000..5ce3a496d14 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/associate_48.f90 @@ -0,0 +1,41 @@ +! { dg=do run } +! +! Test the fix for PR90498. +! +! Contributed by Vladimir Fuka <vladimir.fuka@gmail.com> +! + type field_names_a + class(*), pointer :: var(:) =>null() + end type + + type(field_names_a),pointer :: a(:) + allocate (a(2)) + + allocate (a(1)%var(2), source = ["hello"," vlad"]) + allocate (a(2)%var(2), source = ["HELLO"," VLAD"]) + call s(a) + deallocate (a(1)%var) + deallocate (a(2)%var) + deallocate (a) +contains + subroutine s(a) + + type(field_names_a) :: a(:) + + select type (var => a(1)%var) + type is (character(*)) + if (any (var .ne. ["hello"," vlad"])) stop 1 + class default + stop + end select + + associate (var => a(2)%var) + select type (var) + type is (character(*)) + if (any (var .ne. ["HELLO"," VLAD"])) stop 2 + class default + stop + end select + end associate + end +end diff --git a/gcc/testsuite/gfortran.dg/associate_49.f90 b/gcc/testsuite/gfortran.dg/associate_49.f90 new file mode 100644 index 00000000000..1b205950556 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/associate_49.f90 @@ -0,0 +1,34 @@ +! { dg-do run } +! +! Test the fix for PR91588, in which the declaration of 'a' caused +! an ICE. +! +! Contributed by Gerhardt Steinmetz <gscfq@t-online.de> +! +program p + character(4), parameter :: parm = '7890' + associate (z => '1234') + block + integer(len(z)) :: a + if (kind(a) .ne. 4) stop 1 + end block + end associate + associate (z => '123') + block + integer(len(z)+1) :: a + if (kind(a) .ne. 4) stop 2 + end block + end associate + associate (z => 1_8) + block + integer(kind(z)) :: a + if (kind(a) .ne. 8) stop 3 + end block + end associate + associate (z => parm) + block + integer(len(z)) :: a + if (kind(a) .ne. 4) stop 4 + end block + end associate +end diff --git a/gcc/testsuite/gfortran.dg/char_result_19.f90 b/gcc/testsuite/gfortran.dg/char_result_19.f90 new file mode 100644 index 00000000000..e66ebdcda53 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/char_result_19.f90 @@ -0,0 +1,24 @@ +! { dg-do preprocess } +! { dg-additional-options "-cpp" } +! +! Test the fix for PR86248 +! +! Contributed by Bill Long <longb@cray.com> +! +program test + use test_module + implicit none + integer :: i + character(:), allocatable :: chr + do i = 0, 2 + chr = func_1 (i) + select case (i) + case (0) + if (chr .ne. 'el0') stop i + case (1) + if (chr .ne. 'el11') stop i + case (2) + if (chr .ne. 'el2') stop i + end select + end do +end program test diff --git a/gcc/testsuite/gfortran.dg/char_result_mod_19.f90 b/gcc/testsuite/gfortran.dg/char_result_mod_19.f90 new file mode 100644 index 00000000000..a2b5e94f1b6 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/char_result_mod_19.f90 @@ -0,0 +1,18 @@ +! { dg-do run } +! { dg-additional-sources char_result_19.f90 } +! +! Module for char_result_19.f90 +! Tests fix for PR86248 +! +module test_module + implicit none + public :: func_1 + private + character(len=*),dimension(0:2),parameter :: darray = (/"el0 ","el11","el2 "/) +contains + function func_1 (func_1_input) result(f) + integer, intent(in) :: func_1_input + character(len = len_trim (darray(func_1_input))) :: f + f = darray(func_1_input) + end function func_1 +end module test_module diff --git a/gcc/testsuite/gfortran.dg/class_70.f03 b/gcc/testsuite/gfortran.dg/class_70.f03 new file mode 100644 index 00000000000..b689563916d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/class_70.f03 @@ -0,0 +1,38 @@ +! { dg-do run } +! +! Test the fix for PR57284 - [OOP] ICE with find_array_spec for polymorphic +! arrays. Once thw ICE was fixed, work was needed to fix a segfault while +! determining the size of 'z'. +! +! Contributed by Lorenz Huedepohl <bugs@stellardeath.org> +! +module testmod + type type_t + integer :: idx + end type type_t + type type_u + type(type_t), allocatable :: cmp(:) + end type +contains + function foo(a, b) result(add) + class(type_t), intent(in) :: a(:), b(size(a)) + type(type_t) :: add(size(a)) + add%idx = a%idx + b%idx + end function +end module testmod +program p + use testmod + class(type_t), allocatable, dimension(:) :: x, y, z + class(type_u), allocatable :: w + allocate (x, y, source = [type_t (1), type_t(2)]) + z = foo (x, y) + if (any (z%idx .ne. [2, 4])) stop 1 + +! Try something a bit more complicated than the original. + + allocate (w) + allocate (w%cmp, source = [type_t (2), type_t(3)]) + z = foo (w%cmp, y) + if (any (z%idx .ne. [3, 5])) stop 2 + deallocate (w, x, y, z) +end program diff --git a/gcc/testsuite/gfortran.dg/deferred_character_33.f90 b/gcc/testsuite/gfortran.dg/deferred_character_33.f90 new file mode 100644 index 00000000000..ec864d83c31 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/deferred_character_33.f90 @@ -0,0 +1,35 @@ +! { dg-do run } +! { dg-additional-sources deferred_character_33a.f90 } +! PR fortran/90744 - this used to pass a wrong length +! to an external function without a prototype. +! Original test case by Tomáš Trnka. +module StringModule + implicit none + +contains + function getstr() + character(:), allocatable :: getstr + + getstr = 'OK' + end function +end module +module TestModule + use StringModule + implicit none + +contains + subroutine DoTest() + if (.false.) then + call convrs('A',getstr()) + else + call convrs('B',getstr()) + end if + end subroutine +end module +program external_char_length + use TestModule + + implicit none + + call DoTest() +end program diff --git a/gcc/testsuite/gfortran.dg/deferred_character_33a.f90 b/gcc/testsuite/gfortran.dg/deferred_character_33a.f90 new file mode 100644 index 00000000000..db117cc0b38 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/deferred_character_33a.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +subroutine convrs(quanty,fromto) + implicit none + + character(*), intent(in) :: quanty,fromto + + if (len(fromto) /= 2) stop 1 + if (fromto /= 'OK') stop 2 +end subroutine diff --git a/gcc/testsuite/gfortran.dg/do_subscript_5.f90 b/gcc/testsuite/gfortran.dg/do_subscript_5.f90 new file mode 100644 index 00000000000..54a4f1ba51a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/do_subscript_5.f90 @@ -0,0 +1,20 @@ +! { dg-do compile } +! { dg-additional-options "-Wdo-subscript" } +! PR 90563 - this used to be rejected, wrongly +! Original test case by Tobias Neumann +program test + implicit none + integer, parameter :: swap(4) = [2,1,3,4] + real :: p(20) + integer :: j + + p = 0.0 + + ! The following warnings are actually bogus, but we are not yet + ! clever enough to suppress them. + do j=1,6 ! { dg-warning "out of bounds" } + if (j<5) then + p(j) = p(swap(j)) ! { dg-warning "out of bounds" } + endif + enddo +end program diff --git a/gcc/testsuite/gfortran.dg/do_subscript_6.f90 b/gcc/testsuite/gfortran.dg/do_subscript_6.f90 new file mode 100644 index 00000000000..d78b9d39056 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/do_subscript_6.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! { dg-options "-std=legacy" } +! PR 91550 - this used to cause an ICE +! Test case by Gerhard Steinmetz +program p + real :: a(3) + integer :: i + do i = 1, 3, .1 ! { dg-error "cannot be zero" } + a(i) = i + end do +end diff --git a/gcc/testsuite/gfortran.dg/external_procedure_4.f90 b/gcc/testsuite/gfortran.dg/external_procedure_4.f90 new file mode 100644 index 00000000000..403f1732e26 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/external_procedure_4.f90 @@ -0,0 +1,19 @@ +! { dg-do compile } +! PR fortran/90937 - this used to cause an ICE. +! Original test case by Toon Moene. +subroutine lfidiff + + implicit none + + contains + + subroutine grlfi(cdnom) + + character(len=*) cdnom(:) + character(len=len(cdnom)) clnoma + + call lficas(clnoma) + + end subroutine grlfi + +end subroutine lfidiff diff --git a/gcc/testsuite/gfortran.dg/pdt_4.f03 b/gcc/testsuite/gfortran.dg/pdt_4.f03 index 0bb58f91c67..c1af65a5248 100644 --- a/gcc/testsuite/gfortran.dg/pdt_4.f03 +++ b/gcc/testsuite/gfortran.dg/pdt_4.f03 @@ -97,9 +97,9 @@ contains type (mytype(4, *)) :: arg ! OK end subroutine subroutine bar(arg) ! { dg-error "is neither allocatable nor a pointer" } - type (thytype(8, :, 4) :: arg + type (thytype(8, :, 4)) :: arg end subroutine subroutine foobar(arg) ! OK - type (thytype(8, *, 4) :: arg + type (thytype(8, *, 4)) :: arg end subroutine end diff --git a/gcc/testsuite/gfortran.dg/pointer_array_11.f90 b/gcc/testsuite/gfortran.dg/pointer_array_11.f90 new file mode 100644 index 00000000000..11885ae4301 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pointer_array_11.f90 @@ -0,0 +1,90 @@ +! { dg-do run } +! +! Test the fix for PR91077 - both the original test and that in comment #4 of the PR. +! +! Contribute by Ygal Klein <ygalklein@gmail.com> +! +program test + implicit none + call original + call comment_4 +contains + subroutine original + integer, parameter :: length = 9 + real(8), dimension(2) :: a, b + integer :: i + type point + real(8) :: x + end type point + + type stored + type(point), dimension(:), allocatable :: np + end type stored + type(stored), dimension(:), pointer :: std =>null() + allocate(std(1)) + allocate(std(1)%np(length)) + std(1)%np(1)%x = 0.3d0 + std(1)%np(2)%x = 0.3555d0 + std(1)%np(3)%x = 0.26782d0 + std(1)%np(4)%x = 0d0 + std(1)%np(5)%x = 1.555d0 + std(1)%np(6)%x = 7.3d0 + std(1)%np(7)%x = 7.8d0 + std(1)%np(8)%x = 6.3d0 + std(1)%np(9)%x = 5.5d0 +! do i = 1, 2 +! write(*, "('std(1)%np(',i1,')%x = ',1e22.14)") i, std(1)%np(i)%x +! end do +! do i = 1, 2 +! write(*, "('std(1)%np(1:',i1,') = ',9e22.14)") i, std(1)%np(1:i)%x +! end do + a = std(1)%np(1:2)%x + b = [std(1)%np(1)%x, std(1)%np(2)%x] +! print *,a +! print *,b + if (allocated (std(1)%np)) deallocate (std(1)%np) + if (associated (std)) deallocate (std) + if (norm2(a - b) .gt. 1d-3) stop 1 + end subroutine + + subroutine comment_4 + integer, parameter :: length = 2 + real(8), dimension(length) :: a, b + integer :: i + + type point + real(8) :: x + end type point + + type points + type(point), dimension(:), pointer :: np=>null() + end type points + + type stored + integer :: l + type(points), pointer :: nfpoint=>null() + end type stored + + type(stored), dimension(:), pointer :: std=>null() + + + allocate(std(1)) + allocate(std(1)%nfpoint) + allocate(std(1)%nfpoint%np(length)) + std(1)%nfpoint%np(1)%x = 0.3d0 + std(1)%nfpoint%np(2)%x = 0.3555d0 + +! do i = 1, length +! write(*, "('std(1)%nfpoint%np(',i1,')%x = ',1e22.14)") i, std(1)%nfpoint%np(i)%x +! end do +! do i = 1, length +! write(*, "('std(1)%nfpoint%np(1:',i1,')%x = ',2e22.14)") i, std(1)%nfpoint%np(1:i)%x +! end do + a = std(1)%nfpoint%np(1:2)%x + b = [std(1)%nfpoint%np(1)%x, std(1)%nfpoint%np(2)%x] + if (associated (std(1)%nfpoint%np)) deallocate (std(1)%nfpoint%np) + if (associated (std(1)%nfpoint)) deallocate (std(1)%nfpoint) + if (associated (std)) deallocate (std) + if (norm2(a - b) .gt. 1d-3) stop 2 + end subroutine +end program test diff --git a/gcc/testsuite/gfortran.dg/pr69455_1.f90 b/gcc/testsuite/gfortran.dg/pr69455_1.f90 new file mode 100644 index 00000000000..fe62e5c1b0b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr69455_1.f90 @@ -0,0 +1,14 @@ +! { dg-do run } +program foo + block + use, intrinsic :: iso_c_binding, only: wp => c_float, ik => c_int + if (ik /= 4) stop 1 + if (wp /= 4) stop 2 + end block + block + use, intrinsic :: iso_c_binding, only: wp => c_double, ik => c_int64_t + if (ik /= 8) stop 3 + if (wp /= 8) stop 4 + end block +end program foo + diff --git a/gcc/testsuite/gfortran.dg/pr69455_2.f90 b/gcc/testsuite/gfortran.dg/pr69455_2.f90 new file mode 100644 index 00000000000..8f9fb35021f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr69455_2.f90 @@ -0,0 +1,13 @@ +! { dg-do run } +program foo + block + use, intrinsic :: ISO_FORTRAN_ENV, only: wp => REAL32, ik => INT32 + if (ik /= 4) stop 1 + if (wp /= 4) stop 2 + end block + block + use, intrinsic :: ISO_FORTRAN_ENV, only: wp => REAL64, ik => INT64 + if (ik /= 8) stop 3 + if (wp /= 8) stop 4 + end block +end program foo diff --git a/gcc/testsuite/gfortran.dg/pr91660_1.f90 b/gcc/testsuite/gfortran.dg/pr91660_1.f90 new file mode 100644 index 00000000000..b0c96d95d0f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr91660_1.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! PR fortran/91660 +! Code contributed by Gerhard Steinmetz +program p + type t + end type + type (t x ! { dg-error "Malformed type-spec" } + x = t() ! { dg-error "Can't convert" } +end diff --git a/gcc/testsuite/gfortran.dg/pr91660_2.f90 b/gcc/testsuite/gfortran.dg/pr91660_2.f90 new file mode 100644 index 00000000000..0072aba1680 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr91660_2.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! PR fortran/91660 +program foo + type(doubleprecision :: x ! { dg-error "Malformed type-spec" } + type(double precision :: y ! { dg-error "Malformed type-spec" } + type(character(len=3) :: a ! { dg-error "Malformed type-spec" } + type(doublecomplex :: b ! { dg-error "Malformed type-spec" } + type(double complex :: c ! { dg-error "Malformed type-spec" } +end program foo diff --git a/gcc/testsuite/gfortran.dg/proc_ptr_51.f90 b/gcc/testsuite/gfortran.dg/proc_ptr_51.f90 new file mode 100644 index 00000000000..62b5d71e30b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/proc_ptr_51.f90 @@ -0,0 +1,38 @@ +! { dg-do run } +! +! Test the fix for PR90786. +! +! Contributed by Andrew benson <abensonca@gmail.com> +! +module f +procedure(c), pointer :: c_ + + type :: s + integer :: i = 42 + end type s + class(s), pointer :: res, tgt + +contains + + function c() + implicit none + class(s), pointer :: c + c => tgt + return + end function c + + subroutine fs() + implicit none + c_ => c ! This used to ICE + return + end subroutine fs + +end module f + + use f + allocate (tgt, source = s(99)) + call fs() + res => c_() + if (res%i .ne. 99) stop 1 + deallocate (tgt) +end diff --git a/gcc/testsuite/gfortran.dg/transpose_optimization_2.f90 b/gcc/testsuite/gfortran.dg/transpose_optimization_2.f90 index 4748da19547..c49cd421058 100644 --- a/gcc/testsuite/gfortran.dg/transpose_optimization_2.f90 +++ b/gcc/testsuite/gfortran.dg/transpose_optimization_2.f90 @@ -61,4 +61,4 @@ end ! The check below for temporaries gave 14 and 33 for "parm" and "atmp". ! ! { dg-final { scan-tree-dump-times "parm" 72 "original" } } -! { dg-final { scan-tree-dump-times "atmp" 12 "original" } } +! { dg-final { scan-tree-dump-times "atmp" 13 "original" } } diff --git a/gcc/testsuite/gfortran.dg/typebound_call_22.f03 b/gcc/testsuite/gfortran.dg/typebound_call_22.f03 index b9f0b712573..30f86937fe2 100644 --- a/gcc/testsuite/gfortran.dg/typebound_call_22.f03 +++ b/gcc/testsuite/gfortran.dg/typebound_call_22.f03 @@ -26,4 +26,4 @@ program test call x%bar () end program -! { dg-final { scan-tree-dump-times "base \\(\\);" 1 "optimized" } } +! { dg-final { scan-tree-dump-times "base \\(\\);" 1 "optimized" { xfail *-*-* } } } diff --git a/gcc/testsuite/gfortran.dg/warn_unused_dummy_argument_5.f90 b/gcc/testsuite/gfortran.dg/warn_unused_dummy_argument_5.f90 new file mode 100644 index 00000000000..fa93f1d7ff2 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/warn_unused_dummy_argument_5.f90 @@ -0,0 +1,16 @@ +! { dg-do compile } +! { dg-additional-options "-Wunused-dummy-argument" } +! PR 91557 - this used to generate a bogus warning +! Test case by Gerhard Steinmetz +program p + integer :: a, b + a = 1 + call g +contains + subroutine g + integer :: x, y + call h (x, y) + if ( a > 0 ) y = y - 1 + b = y - x + 1 + end +end diff --git a/gcc/testsuite/gnat.dg/opt78.adb b/gcc/testsuite/gnat.dg/opt78.adb new file mode 100644 index 00000000000..e46c92b2759 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt78.adb @@ -0,0 +1,16 @@ +-- { dg-do compile } +-- { dg-options "-O" } + +package body Opt78 is + + procedure Proc (P : UC; Msg : String) is + Default : UC := (1, "!"); + begin + if P = Default then + raise Program_Error; + else + raise Constraint_Error; + end if; + end; + +end Opt78; diff --git a/gcc/testsuite/gnat.dg/opt78.ads b/gcc/testsuite/gnat.dg/opt78.ads new file mode 100644 index 00000000000..2c489bd7b38 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt78.ads @@ -0,0 +1,13 @@ +package Opt78 is + + subtype Reasonable is Integer range 1..10; + + type UC (D: Reasonable := 2) is record + S: String (1 .. D) := "Hi"; + end record; + + type AUC is access all UC; + + procedure Proc (P : UC; Msg : String); + +end Opt78; diff --git a/gcc/testsuite/gnat.dg/opt79.adb b/gcc/testsuite/gnat.dg/opt79.adb new file mode 100644 index 00000000000..f58e25bc11d --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt79.adb @@ -0,0 +1,28 @@ +-- { dg-do compile } +-- { dg-options "-O" } + +package body Opt79 is + + function F (I : Integer) return Arr is + A : Arr; + + procedure Nested is + + procedure Inner is + begin + A (1) := 0; + end; + + begin + Inner; + end; + + begin + Nested; + for J in A'Range loop + A (J) := I; + end loop; + return A; + end; + +end Opt79; diff --git a/gcc/testsuite/gnat.dg/opt79.ads b/gcc/testsuite/gnat.dg/opt79.ads new file mode 100644 index 00000000000..aa90c17f8dd --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt79.ads @@ -0,0 +1,7 @@ +package Opt79 is + + type Arr is array (1 .. 8) of Integer; + + function F (I : Integer) return Arr; + +end Opt79; diff --git a/gcc/testsuite/gnat.dg/specs/array4.ads b/gcc/testsuite/gnat.dg/specs/array4.ads new file mode 100644 index 00000000000..ab12c1e2a9e --- /dev/null +++ b/gcc/testsuite/gnat.dg/specs/array4.ads @@ -0,0 +1,17 @@ +-- { dg-do compile } +-- { dg-skip-if "missing -gsplit-dwarf support" { *-*-darwin* } } +-- { dg-options "-gsplit-dwarf" } + +package Array4 is + + type Arr1 is array (Positive range <>) of Boolean; + + Size : Positive := 20; + + type Rec is record + A : Arr1 (1 .. Size); + end record; + + type Arr2 is array (Positive range <>) of Rec; + +end Array4; diff --git a/gcc/testsuite/gnat.dg/specs/array5.ads b/gcc/testsuite/gnat.dg/specs/array5.ads new file mode 100644 index 00000000000..b0c2d2b56da --- /dev/null +++ b/gcc/testsuite/gnat.dg/specs/array5.ads @@ -0,0 +1,9 @@ +-- { dg-do compile }
+
+with Array5_Pkg1; use Array5_Pkg1;
+
+package Array5 is
+
+ C : constant Integer := Arr'Last;
+
+end Array5;
diff --git a/gcc/testsuite/gnat.dg/specs/array5_pkg1.ads b/gcc/testsuite/gnat.dg/specs/array5_pkg1.ads new file mode 100644 index 00000000000..885d6a44ac6 --- /dev/null +++ b/gcc/testsuite/gnat.dg/specs/array5_pkg1.ads @@ -0,0 +1,14 @@ +with Array5_Pkg2; use Array5_Pkg2;
+with Array5_Pkg2.G;
+
+package Array5_Pkg1 is
+
+ type Derived is new Root with record
+ N : Integer;
+ end record;
+
+ package My_G is new Array5_Pkg2.G (Derived);
+
+ type Arr is array (1 .. My_G.Data.N) of Integer;
+
+end Array5_Pkg1;
diff --git a/gcc/testsuite/gnat.dg/specs/array5_pkg2-g.ads b/gcc/testsuite/gnat.dg/specs/array5_pkg2-g.ads new file mode 100644 index 00000000000..1bb93960333 --- /dev/null +++ b/gcc/testsuite/gnat.dg/specs/array5_pkg2-g.ads @@ -0,0 +1,13 @@ +with System.Address_To_Access_Conversions;
+
+generic
+
+ type T is new Root with private;
+
+package Array5_Pkg2.G is
+
+ package Ptr is new System.Address_To_Access_Conversions (T);
+
+ Data : Ptr.Object_Pointer;
+
+end Array5_Pkg2.G;
diff --git a/gcc/testsuite/gnat.dg/specs/array5_pkg2.ads b/gcc/testsuite/gnat.dg/specs/array5_pkg2.ads new file mode 100644 index 00000000000..6c83460aeb3 --- /dev/null +++ b/gcc/testsuite/gnat.dg/specs/array5_pkg2.ads @@ -0,0 +1,5 @@ +package Array5_Pkg2 is
+
+ type Root is tagged null record;
+
+end Array5_Pkg2;
diff --git a/gcc/testsuite/gnat.dg/unchecked_convert13.adb b/gcc/testsuite/gnat.dg/unchecked_convert13.adb new file mode 100644 index 00000000000..6297e276e0f --- /dev/null +++ b/gcc/testsuite/gnat.dg/unchecked_convert13.adb @@ -0,0 +1,30 @@ +-- { dg-do compile } + +with Ada.Unchecked_Conversion; + +procedure Unchecked_Convert13 is + + type B16_T is mod 2 ** 16; + for B16_T'Size use 16; + for B16_T'Alignment use 1; + + type Rec_T is record + A : Short_Integer; + end record; + for Rec_T use record + A at 0 range 0 .. 15; + end record; + for Rec_T'Size use 16; + + Rec : constant Rec_T := (A => 0); + + function Rec_To_B16 is new Ada.Unchecked_Conversion (Rec_T, B16_T); + + procedure Nested (B16 : B16_T) is + begin + null; + end; + +begin + Nested (Rec_To_B16 (Rec)); +end; diff --git a/gcc/testsuite/lib/scanasm.exp b/gcc/testsuite/lib/scanasm.exp index 61e0f3f48ae..e653b1e7597 100644 --- a/gcc/testsuite/lib/scanasm.exp +++ b/gcc/testsuite/lib/scanasm.exp @@ -504,7 +504,10 @@ proc dg-function-on-line { args } { } } - if { [istarget hppa*-*-*] } { + if { [istarget hppa*-*-linux*] } { + set pattern [format {%s:\n\t.PROC\n\t.CALLINFO.*\n\t.ENTRY\n.L.*:\n(\t.file[^\t]*)*\t[^:]+:%d(:[0-9]+)?\n} \ + $symbol $line] + } elseif { [istarget hppa*-*-*] } { set pattern [format {\t;[^:]+:%d(:[0-9]+)?\n(\t[^\t]+\n)+%s:\n\t.PROC} \ $line $symbol] } elseif { [istarget mips*-*-*] } { diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index c591acd0a26..e6b84041fc5 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -5018,13 +5018,13 @@ proc check_effective_target_powerpc_p8vector_ok { } { || [istarget powerpc*-*-aix5.2*] } { return 0 } + # Darwin doesn't run on power8, so far. + if { [istarget *-*-darwin*] } { + return 0 + } return [check_no_compiler_messages powerpc_p8vector_ok object { int main (void) { -#ifdef __MACH__ - asm volatile ("xxlorc vs0,vs0,vs0"); -#else asm volatile ("xxlorc 0,0,0"); -#endif return 0; } } "-mpower8-vector"] @@ -5045,6 +5045,10 @@ proc check_effective_target_powerpc_p9vector_ok { } { || [istarget powerpc*-*-aix5.2*] } { return 0 } + # Darwin doesn't run on power9, so far. + if { [istarget *-*-darwin*] } { + return 0 + } return [check_no_compiler_messages powerpc_p9vector_ok object { int main (void) { long e = -1; @@ -5095,6 +5099,10 @@ proc check_effective_target_powerpc_float128_sw_ok { } { || [istarget powerpc*-*-aix5.2*] } { return 0 } + # Darwin doesn't have VSX, so no soft support for float128. + if { [istarget *-*-darwin*] } { + return 0 + } return [check_no_compiler_messages powerpc_float128_sw_ok object { volatile __float128 x = 1.0q; volatile __float128 y = 2.0q; @@ -5121,6 +5129,10 @@ proc check_effective_target_powerpc_float128_hw_ok { } { || [istarget powerpc*-*-aix5.2*] } { return 0 } + # Darwin doesn't run on any machine with float128 h/w so far. + if { [istarget *-*-darwin*] } { + return 0 + } return [check_no_compiler_messages powerpc_float128_hw_ok object { volatile __float128 x = 1.0q; volatile __float128 y = 2.0q; @@ -5147,13 +5159,14 @@ proc check_effective_target_powerpc_vsx_ok { } { || [istarget powerpc*-*-aix6*] } { return 0 } + # Darwin doesn't have VSX, even if it's used with an assembler + #Â which recognises the insns. + if { [istarget *-*-darwin*] } { + return 0 + } return [check_no_compiler_messages powerpc_vsx_ok object { int main (void) { -#ifdef __MACH__ - asm volatile ("xxlor vs0,vs0,vs0"); -#else asm volatile ("xxlor 0,0,0"); -#endif return 0; } } "-mvsx"] diff --git a/gcc/testsuite/obj-c++.dg/cxx-ivars-3.mm b/gcc/testsuite/obj-c++.dg/cxx-ivars-3.mm index 0098349cbce..18b671d122a 100644 --- a/gcc/testsuite/obj-c++.dg/cxx-ivars-3.mm +++ b/gcc/testsuite/obj-c++.dg/cxx-ivars-3.mm @@ -2,13 +2,14 @@ // { dg-do run { target *-*-darwin* } } // { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } +// { dg-skip-if "Headers incompatible with 10.4 APIs" { *-*-darwin1[3-8]* } { "-fnext-runtime" } { "" } } // { dg-additional-options "-fobjc-call-cxx-cdtors -mmacosx-version-min=10.4 -framework Foundation" } // This test has no equivalent or meaning for m64/ABI V2 -// { dg-xfail-run-if "No Test Avail" { *-*-darwin* && lp64 } { "-fnext-runtime" } { "" } } +// { dg-xfail-run-if "No Test Avail" { *-*-darwin* && lp64 } { "-fnext-runtime" } { "" } } #include <objc/objc-runtime.h> #include <stdlib.h> -#include <Foundation/NSObject.h> +#include "../objc-obj-c++-shared/F-NSObject.h" //extern "C" { int printf(const char *,...); } #define CHECK_IF(expr) if(!(expr)) abort() diff --git a/gcc/testsuite/obj-c++.dg/isa-field-1.mm b/gcc/testsuite/obj-c++.dg/isa-field-1.mm index 4501d01a11e..3fb27d5f641 100644 --- a/gcc/testsuite/obj-c++.dg/isa-field-1.mm +++ b/gcc/testsuite/obj-c++.dg/isa-field-1.mm @@ -1,5 +1,7 @@ /* Ensure there are no bizarre difficulties with accessing the 'isa' field of objects. */ /* { dg-do compile } */ +/* The use of isa is deprecated, but we still want to test that is works. */ +/* { dg-additional-options "-Wno-deprecated-declarations" } */ #include "../objc-obj-c++-shared/TestsuiteObject.h" #include "../objc-obj-c++-shared/runtime.h" diff --git a/gcc/testsuite/obj-c++.dg/objc-gc-3.mm b/gcc/testsuite/obj-c++.dg/objc-gc-3.mm index 430e5832eb6..68bebf8fc96 100644 --- a/gcc/testsuite/obj-c++.dg/objc-gc-3.mm +++ b/gcc/testsuite/obj-c++.dg/objc-gc-3.mm @@ -3,6 +3,7 @@ /* Contributed by Ziemowit Laski <zlaski@apple.com> */ /* { dg-do compile } */ +/* { dg-skip-if "GC API is an error from Darwin16." { *-*-darwin1[6-8]* } { "-fnext-runtime" } { "" } } */ /* { dg-options "-fobjc-gc" } */ /* { dg-prune-output "cc1objplus: warning: '-fobjc-gc' is ignored for '-fgnu-runtime'" } */ diff --git a/gcc/testsuite/obj-c++.dg/proto-lossage-7.mm b/gcc/testsuite/obj-c++.dg/proto-lossage-7.mm index b32cfd8a0dd..d136af92d67 100644 --- a/gcc/testsuite/obj-c++.dg/proto-lossage-7.mm +++ b/gcc/testsuite/obj-c++.dg/proto-lossage-7.mm @@ -1,9 +1,11 @@ /* Check that typedefs of ObjC classes preserve any @protocol qualifiers. */ /* { dg-do compile } */ +/* Suppress warnings that the GNUStep headers introduce. */ +/* { dg-additional-options "-std=gnu++11 -Wno-expansion-to-defined -Wno-variadic-macros" { target *-*-darwin* } } */ #ifdef __NEXT_RUNTIME__ -#include <Foundation/NSObject.h> +#include "../objc-obj-c++-shared/F-NSObject.h" #define OBJECT NSObject #else #include <objc/Object.h> diff --git a/gcc/testsuite/obj-c++.dg/qual-types-1.mm b/gcc/testsuite/obj-c++.dg/qual-types-1.mm index dd0eb42bc4f..2fe06e4c80d 100644 --- a/gcc/testsuite/obj-c++.dg/qual-types-1.mm +++ b/gcc/testsuite/obj-c++.dg/qual-types-1.mm @@ -4,6 +4,8 @@ /* { dg-do run } */ /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ +/* { dg-prune-output ".*ld: warning: direct access in.*" } */ + #include "../objc-obj-c++-shared/TestsuiteObject.m" #include <stdlib.h> diff --git a/gcc/testsuite/obj-c++.dg/strings/const-cfstring-2.mm b/gcc/testsuite/obj-c++.dg/strings/const-cfstring-2.mm index b4fc9e6ed4f..e81f4713828 100644 --- a/gcc/testsuite/obj-c++.dg/strings/const-cfstring-2.mm +++ b/gcc/testsuite/obj-c++.dg/strings/const-cfstring-2.mm @@ -8,8 +8,8 @@ /* { dg-skip-if "NeXT only" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { dg-options "-ftrack-macro-expansion=0 -mconstant-cfstrings -Wnonportable-cfstrings" } */ -#import <Foundation/NSString.h> -#import <CoreFoundation/CFString.h> +#include "../../objc-obj-c++-shared/F-NSString.h" +#include "../../objc-obj-c++-shared/CF-CFString.h" #ifndef __CONSTANT_CFSTRINGS__ #error The -fconstant-cfstrings option is not functioning properly diff --git a/gcc/testsuite/obj-c++.dg/strings/const-cfstring-5.mm b/gcc/testsuite/obj-c++.dg/strings/const-cfstring-5.mm index 98bb7c5bddc..762afb6b1ba 100644 --- a/gcc/testsuite/obj-c++.dg/strings/const-cfstring-5.mm +++ b/gcc/testsuite/obj-c++.dg/strings/const-cfstring-5.mm @@ -6,7 +6,7 @@ /* { dg-skip-if "NeXT only" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { dg-options "-mconstant-cfstrings" } */ -#include <Foundation/NSObject.h> +#include "../../objc-obj-c++-shared/F-NSObject.h" @interface Foo: NSObject { char *cString; diff --git a/gcc/testsuite/obj-c++.dg/strings/const-str-12.mm b/gcc/testsuite/obj-c++.dg/strings/const-str-12.mm index d0dfb668ea9..ade24b3a22c 100644 --- a/gcc/testsuite/obj-c++.dg/strings/const-str-12.mm +++ b/gcc/testsuite/obj-c++.dg/strings/const-str-12.mm @@ -6,7 +6,7 @@ /* { dg-options "-mno-constant-cfstrings -fconstant-string-class=Foo" { target *-*-darwin* } } */ #ifdef __NEXT_RUNTIME__ -#include <Foundation/NSObject.h> +#include "../../objc-obj-c++-shared/F-NSObject.h" #define OBJECT NSObject #else #include <objc/Object.h> diff --git a/gcc/testsuite/obj-c++.dg/stubify-1.mm b/gcc/testsuite/obj-c++.dg/stubify-1.mm index 687739ceccd..e8f21882de9 100644 --- a/gcc/testsuite/obj-c++.dg/stubify-1.mm +++ b/gcc/testsuite/obj-c++.dg/stubify-1.mm @@ -4,13 +4,13 @@ /* { dg-do compile { target *-*-darwin* } } */ /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { dg-require-effective-target ilp32 } */ -/* { dg-options "-Os -mdynamic-no-pic -fno-exceptions -mmacosx-version-min=10.4" } */ +/* { dg-options "-mdynamic-no-pic -fno-exceptions -mmacosx-version-min=10.4 -msymbol-stubs" } */ typedef struct objc_object { } *id ; int x = 41 ; extern "C" { - extern id objc_msgSend(id self, char * op, ...); + extern id objc_msgSend(id self, objc_selector* op, ...); extern int bogonic (int, int, int); } @@ -20,9 +20,9 @@ extern "C" { - (Document *) close; @end @implementation Document -- (Document *) class { } -- (Document *) close { } -- (Document *) window { } +- (Document *) class { return (Document *)0; } +- (Document *) close { return (Document *)0; } +- (Document *) window { return (Document *)0; } - (void)willEndCloseSheet:(void *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo { [[self window] close]; ((void (*)(id, char *, int))objc_msgSend)([self class], (char *)contextInfo, 1); @@ -32,8 +32,8 @@ extern "C" { } @end -/* { dg-final { scan-assembler-not "\(bl|call\)\[ \t\]+_objc_msgSend\n" } } */ -/* { dg-final { scan-assembler "\(bl|call\)\[ \t\]+L_objc_msgSend\\\$stub\n" } } */ -/* { dg-final { scan-assembler-not "\(bl|call\)\[ \t\]+_bogonic\n" } } */ -/* { dg-final { scan-assembler "\(bl|call\)\[ \t\]+L_bogonic\\\$stub\n" } } */ -/* { dg-final { scan-assembler-not "\\\$non_lazy_ptr" } } */ +/* { dg-final { scan-assembler-not {(bl|call)[ \t]+_objc_msgSend\n} } } */ +/* { dg-final { scan-assembler {(bl|call)[ \t]+L_objc_msgSend\$stub\n} } } */ +/* { dg-final { scan-assembler-not {(bl|call)[ \t]+_bogonic\n} } } */ +/* { dg-final { scan-assembler {(bl|call)[ \t]+L_bogonic\$stub\n} } } */ +/* { dg-final { scan-assembler-not {\$non_lazy_ptr} } } */ diff --git a/gcc/testsuite/obj-c++.dg/stubify-2.mm b/gcc/testsuite/obj-c++.dg/stubify-2.mm index 9968672ed34..1863f986ce0 100644 --- a/gcc/testsuite/obj-c++.dg/stubify-2.mm +++ b/gcc/testsuite/obj-c++.dg/stubify-2.mm @@ -4,7 +4,7 @@ /* { dg-do compile { target *-*-darwin* } } */ /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { dg-require-effective-target ilp32 } */ -/* { dg-options "-mdynamic-no-pic -fdump-rtl-jump -mmacosx-version-min=10.4" } */ +/* { dg-options "-mdynamic-no-pic -mmacosx-version-min=10.4 -msymbol-stubs" } */ typedef struct objc_object { } *id ; int x = 41 ; @@ -16,9 +16,9 @@ extern int bogonic (int, int, int) ; - (Document *) close; @end @implementation Document -- (Document *) class { } -- (Document *) close { } -- (Document *) window { } +- (Document *) class { return (Document *)0; } +- (Document *) close { return (Document *)0; } +- (Document *) window { return (Document *)0; } - (void)willEndCloseSheet:(void *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo { [[self window] close]; ((void (*)(id, char *, int))objc_msgSend)([self class], (char *)contextInfo, 1); @@ -30,4 +30,9 @@ extern int bogonic (int, int, int) ; /* Any symbol_ref of an un-stubified objc_msgSend is an error; look for "objc_msgSend" in quotes, without the $stub suffix. */ -/* { dg-final { scan-rtl-dump-not "symbol_ref.*\"objc_msgSend\"" "jump" } } */ + +/* { dg-final { scan-assembler-not {(bl|call)[ \t]+_objc_msgSend\n} } } */ +/* { dg-final { scan-assembler {(bl|call)[ \t]+L_objc_msgSend\$stub\n} } } */ +/* { dg-final { scan-assembler-not {(bl|call)[ \t]+_Z7bogoniciii\n} } } */ +/* { dg-final { scan-assembler {(bl|call)[ \t]+L__Z7bogoniciii\$stub\n} } } */ +/* { dg-final { scan-assembler-not {\$non_lazy_ptr} } } */ diff --git a/gcc/testsuite/obj-c++.dg/syntax-error-1.mm b/gcc/testsuite/obj-c++.dg/syntax-error-1.mm index 320d56c5ec1..edbd9efc964 100644 --- a/gcc/testsuite/obj-c++.dg/syntax-error-1.mm +++ b/gcc/testsuite/obj-c++.dg/syntax-error-1.mm @@ -1,8 +1,10 @@ /* Graceful handling of a syntax error. */ /* { dg-do compile } */ +/* Suppress warnings that the GNUStep headers introduce. */ +/* { dg-additional-options "-std=gnu++11 -Wno-expansion-to-defined -Wno-variadic-macros" { target *-*-darwin* } } */ #ifdef __NEXT_RUNTIME__ -#include <Foundation/NSObject.h> +#include "../objc-obj-c++-shared/F-NSObject.h" #define OBJECT NSObject #else #include <objc/Object.h> diff --git a/gcc/testsuite/obj-c++.dg/torture/strings/const-cfstring-1.mm b/gcc/testsuite/obj-c++.dg/torture/strings/const-cfstring-1.mm index 2983c43c445..0f1d92bb5ce 100644 --- a/gcc/testsuite/obj-c++.dg/torture/strings/const-cfstring-1.mm +++ b/gcc/testsuite/obj-c++.dg/torture/strings/const-cfstring-1.mm @@ -13,8 +13,8 @@ well, we don't implement writable ones at this juncture. */ /* { dg-options "-mconstant-cfstrings -framework Cocoa -Wl,-w" { target *-*-darwin[123]* } } */ -#import <Foundation/NSString.h> -#import <CoreFoundation/CFString.h> +#include "../../../objc-obj-c++-shared/F-NSString.h" +#include "../../../objc-obj-c++-shared/CF-CFString.h" #include <stdlib.h> void printOut(NSString *str) { @@ -47,10 +47,10 @@ int main(void) { checkNSRange([@"Hello World" rangeOfString:(id)CFSTR("World")]); checkNSRange([(id)CFSTR("Hello World") rangeOfString:(id)CFSTR("World")]); - checkCFRange(CFStringFind((CFStringRef)@"Hello World", (CFStringRef)@"World", 0)); - checkCFRange(CFStringFind(CFSTR("Hello World"), (CFStringRef)@"World", 0)); - checkCFRange(CFStringFind((CFStringRef)@"Hello World", CFSTR("World"), 0)); - checkCFRange(CFStringFind(CFSTR("Hello World"), CFSTR("World"), 0)); + checkCFRange(CFStringFind((CFStringRef)@"Hello World", (CFStringRef)@"World", (CFStringCompareFlags)0)); + checkCFRange(CFStringFind(CFSTR("Hello World"), (CFStringRef)@"World", (CFStringCompareFlags)0)); + checkCFRange(CFStringFind((CFStringRef)@"Hello World", CFSTR("World"), (CFStringCompareFlags)0)); + checkCFRange(CFStringFind(CFSTR("Hello World"), CFSTR("World"), (CFStringCompareFlags)0)); /* Check for string uniquing. */ if (s0a != s0b || s0a != s2 || s1 != (id)s2) { diff --git a/gcc/testsuite/obj-c++.dg/torture/strings/const-str-10.mm b/gcc/testsuite/obj-c++.dg/torture/strings/const-str-10.mm index f2e912beb0a..e1dad124cd6 100644 --- a/gcc/testsuite/obj-c++.dg/torture/strings/const-str-10.mm +++ b/gcc/testsuite/obj-c++.dg/torture/strings/const-str-10.mm @@ -6,7 +6,7 @@ /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */ -#include <Foundation/NSObject.h> +#include "../../../objc-obj-c++-shared/F-NSObject.h" #include "../../../objc-obj-c++-shared/runtime.h" /* For NEXT_OBJC_USE_NEW_INTERFACE. */ @interface NSString: NSObject diff --git a/gcc/testsuite/obj-c++.dg/torture/strings/const-str-11.mm b/gcc/testsuite/obj-c++.dg/torture/strings/const-str-11.mm index 7e5d9b61e71..30a9228a64e 100644 --- a/gcc/testsuite/obj-c++.dg/torture/strings/const-str-11.mm +++ b/gcc/testsuite/obj-c++.dg/torture/strings/const-str-11.mm @@ -7,7 +7,7 @@ /* { dg-options "-fconstant-string-class=XStr" } */ /* { dg-options "-mno-constant-cfstrings -fconstant-string-class=XStr" { target *-*-darwin* } } */ -#include <Foundation/NSObject.h> +#include "../../../objc-obj-c++-shared/F-NSObject.h" #include "../../../objc-obj-c++-shared/runtime.h" /* For NEXT_OBJC_USE_NEW_INTERFACE. */ @interface XString: NSObject { diff --git a/gcc/testsuite/obj-c++.dg/torture/strings/const-str-9.mm b/gcc/testsuite/obj-c++.dg/torture/strings/const-str-9.mm index d78dc73f937..a1a14295e90 100644 --- a/gcc/testsuite/obj-c++.dg/torture/strings/const-str-9.mm +++ b/gcc/testsuite/obj-c++.dg/torture/strings/const-str-9.mm @@ -5,7 +5,7 @@ /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */ -#include <Foundation/NSObject.h> +#include "../../../objc-obj-c++-shared/F-NSObject.h" #include "../../../objc-obj-c++-shared/runtime.h" /* For NEXT_OBJC_USE_NEW_INTERFACE. */ @interface NSConstantString: NSObject { diff --git a/gcc/testsuite/obj-c++.dg/try-catch-1.mm b/gcc/testsuite/obj-c++.dg/try-catch-1.mm index cbdace62d43..1688995a2bf 100644 --- a/gcc/testsuite/obj-c++.dg/try-catch-1.mm +++ b/gcc/testsuite/obj-c++.dg/try-catch-1.mm @@ -39,4 +39,5 @@ int foo() @finally { printf("In @finally block (%d)... ", exc_control); } + return -1; } diff --git a/gcc/testsuite/obj-c++.dg/try-catch-3.mm b/gcc/testsuite/obj-c++.dg/try-catch-3.mm index b0822d3d7c7..e6868a350eb 100644 --- a/gcc/testsuite/obj-c++.dg/try-catch-3.mm +++ b/gcc/testsuite/obj-c++.dg/try-catch-3.mm @@ -15,4 +15,5 @@ const char *foo(void) @catch (TestsuiteObject* theException) { return [theException name]; } + return (const char *)0; } diff --git a/gcc/testsuite/objc-obj-c++-shared/CF-CFString.h b/gcc/testsuite/objc-obj-c++-shared/CF-CFString.h new file mode 100644 index 00000000000..626001bb1fa --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/CF-CFString.h @@ -0,0 +1,33 @@ +/* Copyright (C) 2019 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#ifndef _OBJC_CF_CFSTRING_H_ +#define _OBJC_CF_CFSTRING_H_ + +/* This is a workaround to PR90709 for the NeXT runtime. + If we're on a system version that has headers with items we can't + consume, then use the GNUStep header instead. +*/ + +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1090 +# import "GNUStep/CoreFoundation/CFString.h" +#else +# import <CoreFoundation/CFString.h> +#endif + +#endif /* _OBJC_CF_CFSTRING_H_ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/F-NSArray.h b/gcc/testsuite/objc-obj-c++-shared/F-NSArray.h new file mode 100644 index 00000000000..99b6189c103 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/F-NSArray.h @@ -0,0 +1,33 @@ +/* Copyright (C) 2019 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#ifndef _OBJC_F_NSARRAY_H_ +#define _OBJC_F_NSARRAY_H_ + +/* This is a workaround to PR90709 for the NeXT runtime. + If we're on a system version that has headers with items we can't + consume, then use the GNUStep header instead. +*/ + +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1090 +# import "GNUStep/Foundation/NSArray.h" +#else +# import <Foundation/NSArray.h> +#endif + +#endif /* _OBJC_F_NSARRAY_H_ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/F-NSAutoreleasePool.h b/gcc/testsuite/objc-obj-c++-shared/F-NSAutoreleasePool.h new file mode 100644 index 00000000000..17599e8dfa0 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/F-NSAutoreleasePool.h @@ -0,0 +1,33 @@ +/* Copyright (C) 2019 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#ifndef _OBJC_F_NSAUTORELEASEPOOL_H_ +#define _OBJC_F_NSAUTORELEASEPOOL_H_ + +/* This is a workaround to PR90709 for the NeXT runtime. + If we're on a system version that has headers with items we can't + consume, then use the GNUStep header instead. +*/ + +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1090 +# import "GNUStep/Foundation/NSAutoreleasePool.h" +#else +# import <Foundation/NSAutoreleasePool.h> +#endif + +#endif /* _OBJC_F_NSAUTORELEASEPOOL_H_ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/F-NSObject.h b/gcc/testsuite/objc-obj-c++-shared/F-NSObject.h new file mode 100644 index 00000000000..a372d607b1d --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/F-NSObject.h @@ -0,0 +1,33 @@ +/* Copyright (C) 2019 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#ifndef _OBJC_F_NSOBJECT_H_ +#define _OBJC_F_NSOBJECT_H_ + +/* This is a workaround to PR90709 for the NeXT runtime. + If we're on a system version that has headers with items we can't + consume, then use the GNUStep header instead. +*/ + +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1090 +# import "GNUStep/Foundation/NSObject.h" +#else +# import <Foundation/NSObject.h> +#endif + +#endif /* _OBJC_F_NSOBJECT_H_ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/F-NSString.h b/gcc/testsuite/objc-obj-c++-shared/F-NSString.h new file mode 100644 index 00000000000..5c29398eab7 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/F-NSString.h @@ -0,0 +1,33 @@ +/* Copyright (C) 2019 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#ifndef _OBJC_F_NSSTRING_H_ +#define _OBJC_F_NSSTRING_H_ + +/* This is a workaround to PR90709 for the NeXT runtime. + If we're on a system version that has headers with items we can't + consume, then use the GNUStep header instead. +*/ + +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1090 +# import "GNUStep/Foundation/NSString.h" +#else +# import <Foundation/NSString.h> +#endif + +#endif /* _OBJC_F_NSSTRING_H_ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/F-NSValue.h b/gcc/testsuite/objc-obj-c++-shared/F-NSValue.h new file mode 100644 index 00000000000..fbe2ab34592 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/F-NSValue.h @@ -0,0 +1,33 @@ +/* Copyright (C) 2019 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#ifndef _OBJC_F_NSSTRING_H_ +#define _OBJC_F_NSSTRING_H_ + +/* This is a workaround to PR90709 for the NeXT runtime. + If we're on a system version that has headers with items we can't + consume, then use the GNUStep header instead. +*/ + +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1090 +# import "GNUStep/Foundation/NSValue.h" +#else +# import <Foundation/NSValue.h> +#endif + +#endif /* _OBJC_F_NSSTRING_H_ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFArray.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFArray.h new file mode 100644 index 00000000000..0145855dbb4 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFArray.h @@ -0,0 +1,191 @@ +/* CFArray.h + + Copyright (C) 2010 Free Software Foundation, Inc. + + Written by: Stefan Bidigaray + Date: January, 2010 + + This file is part of CoreBase. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; see the file COPYING.LIB. + If not, see <http://www.gnu.org/licenses/> or write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + + +#ifndef __COREFOUNDATION_CFARRAY_H__ +#define __COREFOUNDATION_CFARRAY_H__ + +#include "CFBase.h" + +CF_EXTERN_C_BEGIN +/** \ingroup CFArrayRef + \brief Reference to an immutable array object. + */ +typedef const struct __CFArray *CFArrayRef; +/** + \ingroup CFMutableArrayRef + \brief Reference to a mutable array object. + */ +typedef struct __CFArray *CFMutableArrayRef; + +/** \defgroup CFArrayRef CFArray Reference + \brief A CFArray and its mutable type, \ref CFMutableArrayRef + "CFMutableArray", are simple, low overhead, ordered containers for + objects. + \details + <code>\#include <CoreFoundation/CFArray.h></code> + \{ + */ + +/** \name Callbacks + \{ + */ +typedef void (*CFArrayApplierFunction) (const void *value, void *context); +typedef CFStringRef (*CFArrayCopyDescriptionCallBack) (const void *value); +typedef void (*CFArrayReleaseCallBack) (CFAllocatorRef allocator, + const void *value); +typedef const void *(*CFArrayRetainCallBack) (CFAllocatorRef allocator, + const void *value); +typedef Boolean (*CFArrayEqualCallBack) (const void *value1, + const void *value2); +/** \} */ + +/** \brief Structure with CFArray callbacks. + */ +typedef struct _CFArrayCallBacks CFArrayCallBacks; +struct _CFArrayCallBacks +{ + CFIndex version; /**< Structure's version number. Current version is 0. */ + CFArrayRetainCallBack retain; + /**< The callback used to retain values added to the array. If NULL, + values are not retained. */ + CFArrayReleaseCallBack release; + CFArrayCopyDescriptionCallBack copyDescription; + CFArrayEqualCallBack equal; +}; + +/** \name Predefined Callback Structures + \{ + */ +CF_EXPORT const CFArrayCallBacks kCFTypeArrayCallBacks; +/** \} */ + + + +/** \name Creating an Array + \{ + */ +CF_EXPORT CFArrayRef +CFArrayCreate (CFAllocatorRef allocator, const void **values, + CFIndex numValues, const CFArrayCallBacks * callBacks); + +CF_EXPORT CFArrayRef +CFArrayCreateCopy (CFAllocatorRef allocator, CFArrayRef theArray); +/** \} */ + +/** \name Examining an Array + \{ + */ +CF_EXPORT CFIndex +CFArrayBSearchValues (CFArrayRef theArray, CFRange range, const void *value, + CFComparatorFunction comparator, void *context); + +CF_EXPORT Boolean +CFArrayContainsValue (CFArrayRef theArray, CFRange range, const void *value); + +CF_EXPORT CFIndex CFArrayGetCount (CFArrayRef theArray); + +CF_EXPORT CFIndex +CFArrayGetCountOfValue (CFArrayRef theArray, CFRange range, const void *value); + +CF_EXPORT CFIndex +CFArrayGetFirstIndexOfValue (CFArrayRef theArray, CFRange range, + const void *value); + +CF_EXPORT CFIndex +CFArrayGetLastIndexOfValue (CFArrayRef theArray, CFRange range, + const void *value); + +CF_EXPORT void +CFArrayGetValues (CFArrayRef theArray, CFRange range, const void **values); + +CF_EXPORT const void *CFArrayGetValueAtIndex (CFArrayRef theArray, CFIndex idx); +/** \} */ + +/** \name Applying a Function to Elements + \{ + */ +CF_EXPORT void +CFArrayApplyFunction (CFArrayRef theArray, CFRange range, + CFArrayApplierFunction applier, void *context); +/** \} */ + +/** \name Getting the CFArray Type ID + \{ + */ +CF_EXPORT CFTypeID CFArrayGetTypeID (void); +/** \} */ + +/** \} */ + +/** \defgroup CFMutableArrayRef CFMutableArray Reference + \details <code>\#include <CoreFoundation/CFArray.h></code> + \{ + */ +CF_EXPORT void +CFArrayAppendArray (CFMutableArrayRef theArray, CFArrayRef otherArray, + CFRange otherRange); + +CF_EXPORT void +CFArrayAppendValue (CFMutableArrayRef theArray, const void *value); + +CF_EXPORT CFMutableArrayRef +CFArrayCreateMutable (CFAllocatorRef allocator, CFIndex capacity, + const CFArrayCallBacks * callBacks); + +CF_EXPORT CFMutableArrayRef +CFArrayCreateMutableCopy (CFAllocatorRef allocator, CFIndex capacity, + CFArrayRef theArray); + +CF_EXPORT void +CFArrayExchangeValuesAtIndices (CFMutableArrayRef theArray, CFIndex idx1, + CFIndex idx2); + +CF_EXPORT void +CFArrayInsertValueAtIndex (CFMutableArrayRef theArray, CFIndex idx, + const void *value); + +CF_EXPORT void CFArrayRemoveAllValues (CFMutableArrayRef theArray); + +CF_EXPORT void +CFArrayRemoveValueAtIndex (CFMutableArrayRef theArray, CFIndex idx); + +CF_EXPORT void +CFArrayReplaceValues (CFMutableArrayRef theArray, CFRange range, + const void **newValues, CFIndex newCount); + +CF_EXPORT void +CFArraySetValueAtIndex (CFMutableArrayRef theArray, CFIndex idx, + const void *value); + +CF_EXPORT void +CFArraySortValues (CFMutableArrayRef theArray, CFRange range, + CFComparatorFunction comparator, void *context); + +/** \} */ + +CF_EXTERN_C_END +#endif /* __COREFOUNDATION_CFARRAY_H__ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFAvailability.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFAvailability.h new file mode 100644 index 00000000000..855ff5c48a9 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFAvailability.h @@ -0,0 +1,52 @@ +/* CFAvailability.h + + Copyright (C) 2017 Free Software Foundation, Inc. + + Written by: Stefan Bidigaray + Date: August, 2017 + + This file is part of the GNUstep CoreBase Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; see the file COPYING.LIB. + If not, see <http://www.gnu.org/licenses/> or write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + + +#ifndef __COREFOUNDATION_CFAVAILABILITY_H__ +#define __COREFOUNDATION_CFAVAILABILITY_H__ + +/* Compiler features */ +#ifndef __has_feature +#define __has_feature(x) 0 +#endif +#ifndef __has_attribute +#define __has_attribute(x) 0 +#endif +#ifndef __has_extension +#define __has_extension(x) __has_feature +#endif + +/* CFEnum macro for type definitions */ +#if (__cplusplus && __cplusplus >= 201103L) +#define CF_ENUM(_type, _name) _type _name; enum : _type +#define CF_OPTIONS(_type, _name) _type _name; enum : _type +#else +#define CF_ENUM(_type, _name) _type _name; enum +#define CF_OPTIONS(_type, _name) _type _name; enum +#endif + +#endif /* __COREFOUNDATION_CFAVAILABILITY_H__ */ + diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFBase.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFBase.h new file mode 100644 index 00000000000..2df7b2925b2 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFBase.h @@ -0,0 +1,464 @@ +/* CFBase.h + + Copyright (C) 2010 Free Software Foundation, Inc. + + Written by: Stefan Bidigaray + Date: January, 2010 + + This file is part of the GNUstep CoreBase Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; see the file COPYING.LIB. + If not, see <http://www.gnu.org/licenses/> or write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + + +#ifndef __COREFOUNDATION_CFBASE_H__ +#define __COREFOUNDATION_CFBASE_H__ + +/* CoreFoundation defines __LITTLE_ENDIAN__ or __BIG_ENDIAN__ so we'll + * do the same here for compatibility. + */ +#if !defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) +#define __LITTLE_ENDIAN__ 1 +#endif + +#include "CFAvailability.h" +#include "../GNUstepBase/GSVersionMacros.h" + +/* + * CoreFoundation types + */ +typedef unsigned char Boolean; +typedef unsigned char UInt8; +typedef signed char SInt8; +typedef unsigned short UInt16; +typedef signed short SInt16; +typedef unsigned int UInt32; +typedef signed int SInt32; +typedef unsigned long long UInt64; +typedef signed long long SInt64; +typedef SInt32 OSStatus; + +typedef float Float32; +typedef double Float64; +typedef UInt16 UniChar; +typedef UInt8 *StringPtr; +typedef const StringPtr *ConstStringPtr; +typedef UInt8 Str255[256]; +typedef const Str255 *ConstStr255Param; +typedef SInt16 OSErr; +typedef SInt16 RegionCode; +typedef SInt16 LangCode; +typedef SInt16 ScriptCode; +typedef UInt32 FourCharCode; +#ifndef OSTYPE_DECLARED +typedef FourCharCode OSType; +#define OSTYPE_DECLARED +#endif +typedef UInt8 Byte; +typedef SInt8 SignedByte; + +#ifndef UTF32Char /* UTF32Char is also defined in GSConfig.h */ +typedef UInt32 UTF32Char; +#endif +typedef UInt16 UTF16Char; +typedef UInt8 UTF8Char; + +#if !defined(CF_EXTERN_C_BEGIN) +#if defined(__cplusplus) +#define CF_EXTERN_C_BEGIN extern "C" { +#define CF_EXTERN_C_END } +#else +#define CF_EXTERN_C_BEGIN +#define CF_EXTERN_C_END +#endif +#endif + +#if defined(_WIN32) +#if defined(BUILDING_SELF) +#if defined(__cplusplus) +#define CF_EXPORT extern "C" __declspec(dllexport) +#else +#define CF_EXPORT extern __declspec(dllexport) +#endif +#else +#if defined(__cplusplus) +#define CF_EXPORT extern "C" __declspec(dllimport) +#else +#define CF_EXPORT extern __declspec(dllimport) +#endif +#endif +#else +#if defined(__cplusplus) +#define CF_EXPORT extern "C" +#else +#define CF_EXPORT extern +#endif +#endif + +#if !defined(__bool_true_false_are_defined) +#define true 1 +#define false 0 +#endif + +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif + +#if !defined(CF_INLINE) +#if defined(__GNUC__) && (__GNUC__ >= 4) +#define CF_INLINE static __inline__ __attribute__((always_inline)) +#elif defined(__GNUC__) +#define CF_INLINE static __inline__ +#elif defined(__MWERKS__) || defined(__cplusplus) +#define CF_INLINE static inline +#elif defined(_MSC_VER) +#define CF_INLINE static __inline +#elif _WIN32 +#define CF_INLINE static __inline__ +#else +#define CF_INLINE static inline +#endif +#endif + +#if defined(__GNUC__) || defined(__llvm__) +#define GS_PURE_FUNCTION __attribute__((pure)) +#else +#define GS_PURE_FUNCTION +#endif + +CF_EXTERN_C_BEGIN +/** \defgroup CFTypeRef CFType Reference + \{ + */ +typedef unsigned long CFTypeID; +typedef const void *CFTypeRef; +/** @} + */ + +/** \defgroup BaseUtils Base Utilities + \{ + */ +/** An integer value to store a hash code. */ +typedef unsigned long CFHashCode; +/** A bitfield for passing information to functions. Can hold as many bits + as a word. + */ +typedef unsigned long CFOptionFlags; +/** A signed integer representing an index, size, length or count. */ +typedef signed long CFIndex; + +/** A structure that represents a range of items in a container, such as + an array. + */ +typedef struct CFRange CFRange; +struct CFRange +{ + CFIndex location; + /**< An integer representing the start location of the range, inclusive. */ + CFIndex length; + /**< An integer representing the total number of items in the range */ +}; + +/** Creates a CFRange structure. + \param location The starting location. + \param length The length. + \return An initialized CFRange structure. + */ +CF_INLINE CFRange +CFRangeMake (CFIndex location, CFIndex length) +{ + CFRange range; + + range.location = location; + range.length = length; + return range; +} + +/* Returned by comparison functions */ +typedef enum +{ + kCFCompareLessThan = -1, + kCFCompareEqualTo = 0, + kCFCompareGreaterThan = 1 +} CFComparisonResult; + +/* Return when a value is not found */ +enum +{ + kCFNotFound = -1 +}; + +/* Definition for standard comparison function callback. */ +typedef CFComparisonResult (*CFComparatorFunction) (const void *val1, + const void *val2, + void *context); + +/* CoreFoundation version numbers */ +/** \name Library Version Numbers + \{ + */ +CF_EXPORT const double kCFCoreFoundationVersionNumber; +#define kCFCoreFoundationVersionNumber10_0 196.40 +#define kCFCoreFoundationVersionNumber10_0_3 196.50 +#define kCFCoreFoundationVersionNumber10_1 226.00 +#define kCFCoreFoundationVersionNumber10_1_1 226.00 +#define kCFCoreFoundationVersionNumber10_1_2 227.20 +#define kCFCoreFoundationVersionNumber10_1_3 227.20 +#define kCFCoreFoundationVersionNumber10_1_4 227.30 +#define kCFCoreFoundationVersionNumber10_2 263.00 +#define kCFCoreFoundationVersionNumber10_2_1 263.10 +#define kCFCoreFoundationVersionNumber10_2_2 263.10 +#define kCFCoreFoundationVersionNumber10_2_3 263.30 +#define kCFCoreFoundationVersionNumber10_2_4 263.30 +#define kCFCoreFoundationVersionNumber10_2_5 263.50 +#define kCFCoreFoundationVersionNumber10_2_6 263.50 +#define kCFCoreFoundationVersionNumber10_2_7 263.50 +#define kCFCoreFoundationVersionNumber10_2_8 263.50 +#define kCFCoreFoundationVersionNumber10_3 299.00 +#define kCFCoreFoundationVersionNumber10_3_1 299.00 +#define kCFCoreFoundationVersionNumber10_3_2 299.00 +#define kCFCoreFoundationVersionNumber10_3_3 299.30 +#define kCFCoreFoundationVersionNumber10_3_4 299.31 +#define kCFCoreFoundationVersionNumber10_3_5 299.31 +#define kCFCoreFoundationVersionNumber10_3_6 299.32 +#define kCFCoreFoundationVersionNumber10_3_7 299.33 +#define kCFCoreFoundationVersionNumber10_3_8 299.33 +#define kCFCoreFoundationVersionNumber10_3_9 299.35 +#define kCFCoreFoundationVersionNumber10_4 368.00 +#define kCFCoreFoundationVersionNumber10_4_1 368.10 +#define kCFCoreFoundationVersionNumber10_4_2 368.11 +#define kCFCoreFoundationVersionNumber10_4_3 368.18 +#define kCFCoreFoundationVersionNumber10_4_4_Intel 368.26 +#define kCFCoreFoundationVersionNumber10_4_4_PowerPC 368.25 +#define kCFCoreFoundationVersionNumber10_4_5_Intel 368.26 +#define kCFCoreFoundationVersionNumber10_4_5_PowerPC 368.25 +#define kCFCoreFoundationVersionNumber10_4_6_Intel 368.26 +#define kCFCoreFoundationVersionNumber10_4_6_PowerPC 368.25 +#define kCFCoreFoundationVersionNumber10_4_7 368.27 +#define kCFCoreFoundationVersionNumber10_4_8 368.27 +#define kCFCoreFoundationVersionNumber10_4_9 368.28 +#define kCFCoreFoundationVersionNumber10_4_10 368.28 +#define kCFCoreFoundationVersionNumber10_4_11 368.31 +#define kCFCoreFoundationVersionNumber10_5 476.00 +#define kCFCoreFoundationVersionNumber10_5_1 476.00 +#define kCFCoreFoundationVersionNumber10_5_2 476.10 +#define kCFCoreFoundationVersionNumber10_5_3 476.13 +#define kCFCoreFoundationVersionNumber10_5_4 476.14 +#define kCFCoreFoundationVersionNumber10_5_5 476.15 +#define kCFCoreFoundationVersionNumber10_5_6 476.17 +/** \} */ +/** \} */ + +#if __has_feature(attribute_cf_returns_retained) +#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) +#else +#define CF_RETURNS_RETAINED +#endif + +#if __has_feature(attribute_cf_returns_not_retained) +#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained)) +#else +#define CF_RETURNS_NOT_RETAINED +#endif + +/** \ingroup CFPropertyListRef + */ +typedef CFTypeRef CFPropertyListRef; + +/** \ingroup CFStringRef + */ +typedef const struct __CFString *CFStringRef; +/** \ingroup CFMutableStringRef + */ +typedef struct __CFString *CFMutableStringRef; + + + +/** \defgroup CFAllocatorRef CFAllocator Reference + \brief CFAllocator is an opaque type used to allocate and deallocate + memory. + \{ + */ +/** \brief A reference to a CFAllocator object. + */ +typedef const struct __CFAllocator *CFAllocatorRef; + +typedef void *(*CFAllocatorAllocateCallBack) (CFIndex allocSize, + CFOptionFlags hint, void *info); +typedef void (*CFAllocatorDeallocateCallBack) (void *ptr, void *info); +typedef void *(*CFAllocatorReallocateCallBack) (void *ptr, + CFIndex newsize, + CFOptionFlags hint, void *info); +typedef CFIndex (*CFAllocatorPreferredSizeCallBack) (CFIndex size, + CFOptionFlags hint, + void *info); +typedef const void *(*CFAllocatorRetainCallBack) (const void *info); +typedef void (*CFAllocatorReleaseCallBack) (const void *info); +typedef CFStringRef (*CFAllocatorCopyDescriptionCallBack) (const void *info); + +struct _CFAllocatorContext +{ + CFIndex version; + void *info; + CFAllocatorRetainCallBack retain; + CFAllocatorReleaseCallBack release; + CFAllocatorCopyDescriptionCallBack copyDescription; + CFAllocatorAllocateCallBack allocate; + CFAllocatorReallocateCallBack reallocate; + CFAllocatorDeallocateCallBack deallocate; + CFAllocatorPreferredSizeCallBack preferredSize; +}; +typedef struct _CFAllocatorContext CFAllocatorContext; + +/** The default allocator and is equivalent to NULL. + \see CFAllocatorGetDefault() + \see CFAllocatorSetDefault() + */ +CF_EXPORT CFAllocatorRef kCFAllocatorDefault; +/** The default system allocator is used internally by GNUstep and is the + default allocator if none is been defined. + \see CFAllocatorSetDefault() + */ +CF_EXPORT CFAllocatorRef kCFAllocatorSystemDefault; +/** An allocator that uses the system's malloc, realloc and free functions. + */ +CF_EXPORT CFAllocatorRef kCFAllocatorMalloc; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +/** Equivalent to kCFAllocatorSystemDefault + */ +CF_EXPORT CFAllocatorRef kCFAllocatorMallocZone; +#endif +/** The NULL allocator does perform any operations. Can be passed as + a deallocator if you do not want GNUstep to deallocate the data. + */ +CF_EXPORT CFAllocatorRef kCFAllocatorNull; +/** This is a special case allocator directing CFAllocatorCreate() to use + the given CFAllocatorContext structure to allocate the new allocator. + */ +CF_EXPORT CFAllocatorRef kCFAllocatorUseContext; + +/** Create a new CFAllocator. + \param allocator The allocator used to create this allocator or + kCFAllocatorUseContext to use the functions in \b context. + \param context The new allocator's context functions. + \return A new CFAllocator or NULL in case of failure. + \see CFAllocatorContext + */ +CF_EXPORT CFAllocatorRef +CFAllocatorCreate (CFAllocatorRef allocator, CFAllocatorContext * context); + +/** Allocate new memory. + \param allocator The CFAllocator to use. + \param size The number of bytes to allocate. + \param hint Option flags. Currently unused and should be 0. + \return Newly allocated memory of NULL in case of failure. + \see CFAllocatorDeallocate() + */ +CF_EXPORT void *CFAllocatorAllocate (CFAllocatorRef allocator, CFIndex size, + CFOptionFlags hint); + +/** Deallocate the memory pointed to by \b ptr. + \param allocator The CFAllocator to use. + \param ptr A pointer previously allocated by CFAllocatorAllocate(). + \see CFAllocatorAllocate() + */ +CF_EXPORT void CFAllocatorDeallocate (CFAllocatorRef allocator, void *ptr); + +CF_EXPORT CFIndex +CFAllocatorGetPreferredSizeForSize (CFAllocatorRef allocator, CFIndex size, + CFOptionFlags hint); + +CF_EXPORT void *CFAllocatorReallocate (CFAllocatorRef allocator, void *ptr, + CFIndex newsize, CFOptionFlags hint); + +CF_EXPORT CFAllocatorRef CFAllocatorGetDefault (void); + +CF_EXPORT void CFAllocatorSetDefault (CFAllocatorRef allocator); + +CF_EXPORT void +CFAllocatorGetContext (CFAllocatorRef allocator, CFAllocatorContext * context); + +CF_EXPORT CFTypeID CFAllocatorGetTypeID (void); +/** \} */ + + + +/** \ingroup CFTypeRef + \{ + */ +/* These function will be implemented in CFRuntime.c since they + require runtime support. */ +CF_EXPORT CFStringRef CFCopyDescription (CFTypeRef cf); + +CF_EXPORT CFStringRef CFCopyTypeIDDescription (CFTypeID typeID); + +CF_EXPORT Boolean CFEqual (CFTypeRef cf1, CFTypeRef cf2); + +CF_EXPORT CFAllocatorRef CFGetAllocator (CFTypeRef cf); + +CF_EXPORT CFIndex CFGetRetainCount (CFTypeRef cf); + +CF_EXPORT CFTypeID CFGetTypeID (CFTypeRef cf); + +CF_EXPORT CFHashCode CFHash (CFTypeRef cf); + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +CF_EXPORT CFTypeRef CFMakeCollectable (CFTypeRef cf); +#endif + +CF_EXPORT void CFRelease (CFTypeRef cf); + +CF_EXPORT CFTypeRef CFRetain (CFTypeRef cf); + +CF_EXPORT CFTypeRef CFAutorelease(CFTypeRef arg); + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST) +CF_EXPORT void *_CFBridgingRelease (CFTypeRef cf); +CF_EXPORT CFTypeRef _CFBridgingRetain (void *obj); + +#if __has_feature(objc_arc) +#define CFBridgingRetain(x) (__bridge_retained CFTypeRef)(x) +#define CFBridgingRelease(x) (__bridge_transfer id)(x) +#elif __OBJC__ +#define CFBridgingRetain(x) _CFBridgingRetain((void *)(x)) +#define CFBridgingRelease(x) (id)_CFBridgingRelease((x)) +#else +#define CFBridgingRetain(x) _CFBridgingRetain((void *)(x)) +#define CFBridgingRelease(x) _CFBridgingRelease((x)) +#endif +#endif +/** \} */ + + + +/** \defgroup CFNullRef CFNull Reference + \{ + */ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST) +typedef struct __CFNull *CFNullRef; + +CF_EXPORT CFNullRef kCFNull; + +CFTypeID CFNullGetTypeID (void); +#endif +/** \} */ + +CF_EXTERN_C_END +#endif /* __COREFOUNDATION_CFBASE_H__ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFCharacterSet.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFCharacterSet.h new file mode 100644 index 00000000000..1cb6c66cac8 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFCharacterSet.h @@ -0,0 +1,173 @@ +/* CFCharacterSet.h + + Copyright (C) 2012 Free Software Foundation, Inc. + + Written by: Stefan Bidigaray + Date: January, 2012 + + This file is part of the GNUstep CoreBase Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; see the file COPYING.LIB. + If not, see <http://www.gnu.org/licenses/> or write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __COREFOUNDATION_CFCHARACTERSET_H__ +#define __COREFOUNDATION_CFCHARACTERSET_H__ + +#include "CFBase.h" +#include "CFData.h" + +CF_EXTERN_C_BEGIN + +/** \ingroup CFCharacterSetRef */ +typedef const struct __CFCharacterSet * CFCharacterSetRef; +/** \ingroup CFMutableCharacterSetRef */ +typedef struct __CFCharacterSet * CFMutableCharacterSetRef; + +/** \defgroup CFCharacterSetRef CFCharacterSet Reference + \{ + */ +typedef enum +{ + kCFCharacterSetControl = 1, + kCFCharacterSetWhitespace, + kCFCharacterSetWhitespaceAndNewline, + kCFCharacterSetDecimalDigit, + kCFCharacterSetLetter, + kCFCharacterSetLowercaseLetter, + kCFCharacterSetUppercaseLetter, + kCFCharacterSetNonBase, + kCFCharacterSetDecomposable, + kCFCharacterSetAlphaNumeric, + kCFCharacterSetPunctuation, +#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST) + kCFCharacterSetCapitalizedLetter = 13, +#endif +#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST) + kCFCharacterSetSymbol = 14, +#endif +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) + kCFCharacterSetNewline = 15, +#endif + kCFCharacterSetIllegal = 12 +} CFCharacterSetPredefinedSet; + + + +/** \name Creating Character Sets + \{ + */ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST) +CF_EXPORT CFCharacterSetRef +CFCharacterSetCreateCopy (CFAllocatorRef alloc, CFCharacterSetRef set); +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST) +CF_EXPORT CFCharacterSetRef +CFCharacterSetCreateInvertedSet (CFAllocatorRef alloc, CFCharacterSetRef set); +#endif + +CF_EXPORT CFCharacterSetRef +CFCharacterSetCreateWithCharactersInRange (CFAllocatorRef alloc, + CFRange range); + +CF_EXPORT CFCharacterSetRef +CFCharacterSetCreateWithCharactersInString (CFAllocatorRef alloc, + CFStringRef string); + +CF_EXPORT CFCharacterSetRef +CFCharacterSetCreateWithBitmapRepresentation (CFAllocatorRef alloc, + CFDataRef data); +/** \} */ + +/** \name Getting Predefined Character Sets + \{ + */ +CF_EXPORT CFCharacterSetRef +CFCharacterSetGetPredefined (CFCharacterSetPredefinedSet setIdentifier); +/** \} */ + +/** \name Querying Character Sets + \{ + */ +CF_EXPORT CFDataRef +CFCharacterSetCreateBitmapRepresentation (CFAllocatorRef alloc, + CFCharacterSetRef set); + +CF_EXPORT Boolean +CFCharacterSetIsCharacterMember (CFCharacterSetRef set, UniChar c); + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST) +CF_EXPORT Boolean +CFCharacterSetHasMemberInPlane (CFCharacterSetRef set, CFIndex plane); + +CF_EXPORT Boolean +CFCharacterSetIsLongCharacterMember (CFCharacterSetRef set, UTF32Char c); + +CF_EXPORT Boolean +CFCharacterSetIsSupersetOfSet (CFCharacterSetRef set, + CFCharacterSetRef otherSet); +#endif +/** \} */ + +/** \name Getting the Character Set Type Identifier + \{ + */ +CF_EXPORT CFTypeID +CFCharacterSetGetTypeID (void); +/** \} */ +/** \} */ + +/** \defgroup CFMutableCharacterSetRef CFMutableCharacterSet Reference + \{ + */ +CF_EXPORT CFMutableCharacterSetRef +CFCharacterSetCreateMutable (CFAllocatorRef alloc); + +CF_EXPORT CFMutableCharacterSetRef +CFCharacterSetCreateMutableCopy (CFAllocatorRef alloc, CFCharacterSetRef set); + +CF_EXPORT void +CFCharacterSetAddCharactersInRange (CFMutableCharacterSetRef set, + CFRange range); + +CF_EXPORT void +CFCharacterSetAddCharactersInString (CFMutableCharacterSetRef set, + CFStringRef string); + +CF_EXPORT void +CFCharacterSetRemoveCharactersInRange (CFMutableCharacterSetRef set, + CFRange range); + +CF_EXPORT void +CFCharacterSetRemoveCharactersInString (CFMutableCharacterSetRef set, + CFStringRef string); + +CF_EXPORT void +CFCharacterSetIntersect (CFMutableCharacterSetRef set, + CFCharacterSetRef otherSet); + +CF_EXPORT void +CFCharacterSetInvert (CFMutableCharacterSetRef set); + +CF_EXPORT void +CFCharacterSetUnion (CFMutableCharacterSetRef set, CFCharacterSetRef otherSet); +/** \} */ + +CF_EXTERN_C_END + +#endif /* __COREFOUNDATION_CFCHARACTERSET_H__ */ + diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFData.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFData.h new file mode 100644 index 00000000000..9e98a6969cd --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFData.h @@ -0,0 +1,114 @@ +/* CFData.h + + Copyright (C) 2010 Free Software Foundation, Inc. + + Written by: Stefan Bidigaray + Date: January, 2010 + + This file is part of CoreBase. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; see the file COPYING.LIB. + If not, see <http://www.gnu.org/licenses/> or write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __COREFOUNDATION_CFDATA_H__ +#define __COREFOUNDATION_CFDATA_H__ + +#include "CFBase.h" + +CF_EXTERN_C_BEGIN +/** \ingroup CFDataRef */ +typedef const struct __CFData *CFDataRef; +/** \ingroup CFMutableDataRef */ +typedef struct __CFData *CFMutableDataRef; + +/** \defgroup CFDataRef CFData Reference + \{ + */ +/** \name Creating a CFData Object + \{ + */ +CF_EXPORT CFDataRef +CFDataCreate (CFAllocatorRef allocator, const UInt8 * bytes, CFIndex length); + +CF_EXPORT CFDataRef +CFDataCreateCopy (CFAllocatorRef allocator, CFDataRef theData); + +CF_EXPORT CFDataRef +CFDataCreateWithBytesNoCopy (CFAllocatorRef allocator, const UInt8 * bytes, + CFIndex length, CFAllocatorRef bytesDeallocator); +/** \} */ + +/** \name Examining a CFData Object + \{ + */ +CF_EXPORT const UInt8 *CFDataGetBytePtr (CFDataRef theData); + +CF_EXPORT void +CFDataGetBytes (CFDataRef theData, CFRange range, UInt8 * buffer); + +CF_EXPORT CFIndex CFDataGetLength (CFDataRef theData); +/** \} */ + +/** \name Getting the CFData Type ID + \{ + */ +CF_EXPORT CFTypeID CFDataGetTypeID (void); +/** \} */ +/** \} */ + +/** \defgroup CFMutableDataRef CFMutableData Reference + \{ + */ +/** \name Creating a Mutable Data Object + \{ + */ +CF_EXPORT CFMutableDataRef +CFDataCreateMutable (CFAllocatorRef allocator, CFIndex capacity); + +CF_EXPORT CFMutableDataRef +CFDataCreateMutableCopy (CFAllocatorRef allocator, CFIndex capacity, + CFDataRef theData); +/** \} */ + +/** \name Accessing Mutable Data + \{ + */ +CF_EXPORT UInt8 *CFDataGetMutableBytePtr (CFMutableDataRef theData); +/** \} */ + +/** \name Modifying a Mutable Data Object + \{ + */ +CF_EXPORT void +CFDataAppendBytes (CFMutableDataRef theData, const UInt8 * bytes, + CFIndex length); + +CF_EXPORT void CFDataDeleteBytes (CFMutableDataRef theData, CFRange range); + +CF_EXPORT void +CFDataReplaceBytes (CFMutableDataRef theData, CFRange range, + const UInt8 * newBytes, CFIndex newLength); + +CF_EXPORT void +CFDataIncreaseLength (CFMutableDataRef theData, CFIndex extraLength); + +CF_EXPORT void CFDataSetLength (CFMutableDataRef theData, CFIndex length); +/** \} */ +/** \} */ + +CF_EXTERN_C_END +#endif /* __COREFOUNDATION_CFDATA_H__ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFDictionary.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFDictionary.h new file mode 100644 index 00000000000..adc0dd8c4b0 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFDictionary.h @@ -0,0 +1,174 @@ +/* CFDictionary.h + + Copyright (C) 2010 Free Software Foundation, Inc. + + Written by: Stefan Bidigaray + Date: January, 2010 + + This file is part of the GNUstep CoreBase Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; see the file COPYING.LIB. + If not, see <http://www.gnu.org/licenses/> or write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __COREFOUNDATION_CFDICTIONARY_H__ +#define __COREFOUNDATION_CFDICTIONARY_H__ 1 + +#include "CFBase.h" + +CF_EXTERN_C_BEGIN +/** \ingroup CFDictionaryRef */ +typedef const struct __CFDictionary *CFDictionaryRef; +/** \ingroup CFMutableDictionaryRef */ +typedef struct __CFDictionary *CFMutableDictionaryRef; + +/** \defgroup CFDictionaryRef CFDictionary Reference + \{ + */ +typedef void (*CFDictionaryApplierFunction) (const void *key, + const void *value, void *context); + +typedef CFStringRef (*CFDictionaryCopyDescriptionCallBack) (const void *value); +typedef Boolean (*CFDictionaryEqualCallBack) (const void *value1, + const void *value2); +typedef CFHashCode (*CFDictionaryHashCallBack) (const void *value); +typedef void (*CFDictionaryReleaseCallBack) (CFAllocatorRef allocator, + const void *value); +typedef const void *(*CFDictionaryRetainCallBack) (CFAllocatorRef allocator, + const void *value); + +typedef struct _CFDictionaryKeyCallBacks CFDictionaryKeyCallBacks; +struct _CFDictionaryKeyCallBacks +{ + CFIndex version; + CFDictionaryRetainCallBack retain; + CFDictionaryReleaseCallBack release; + CFDictionaryCopyDescriptionCallBack copyDescription; + CFDictionaryEqualCallBack equal; + CFDictionaryHashCallBack hash; +}; + +typedef struct _CFDictionaryValueCallBacks CFDictionaryValueCallBacks; +struct _CFDictionaryValueCallBacks +{ + CFIndex version; + CFDictionaryRetainCallBack retain; + CFDictionaryReleaseCallBack release; + CFDictionaryCopyDescriptionCallBack copyDescription; + CFDictionaryEqualCallBack equal; +}; + +CF_EXPORT const CFDictionaryKeyCallBacks kCFCopyStringDictionaryKeyCallBacks; +CF_EXPORT const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks; +CF_EXPORT const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks; + +/** \name Creating a dictionary + \{ + */ +CF_EXPORT CFDictionaryRef +CFDictionaryCreate (CFAllocatorRef allocator, const void **keys, + const void **values, CFIndex numValues, + const CFDictionaryKeyCallBacks * keyCallBacks, + const CFDictionaryValueCallBacks * valueCallBacks); + +CF_EXPORT CFDictionaryRef +CFDictionaryCreateCopy (CFAllocatorRef allocator, CFDictionaryRef theDict); +/** \} */ + +/** \name Examining a dictionary + \{ + */ +CF_EXPORT Boolean +CFDictionaryContainsKey (CFDictionaryRef theDict, const void *key); + +CF_EXPORT Boolean +CFDictionaryContainsValue (CFDictionaryRef theDict, const void *value); + +CF_EXPORT CFIndex CFDictionaryGetCount (CFDictionaryRef theDict); + +CF_EXPORT CFIndex +CFDictionaryGetCountOfKey (CFDictionaryRef theDict, const void *key); + +CF_EXPORT CFIndex +CFDictionaryGetCountOfValue (CFDictionaryRef theDict, const void *value); + +CF_EXPORT void +CFDictionaryGetKeysAndValues (CFDictionaryRef theDict, const void **keys, + const void **values); + +CF_EXPORT const void *CFDictionaryGetValue (CFDictionaryRef theDict, + const void *key); + +CF_EXPORT Boolean +CFDictionaryGetValueIfPresent (CFDictionaryRef theDict, const void *key, + const void **value); +/** \} */ + +/** \name Applying a funcation to a dictionary + \{ + */ +CF_EXPORT void +CFDictionaryApplyFunction (CFDictionaryRef theDict, + CFDictionaryApplierFunction applier, void *context); +/** \} */ + +/** \name Getting the CFDictionary type ID + \{ + */ +CF_EXPORT CFTypeID CFDictionaryGetTypeID (void); +/** \} */ +/** \} */ + +/** \defgroup CFMutableDictionaryRef CFMutableDictionary Reference + \{ + */ +/** \name Creating a Mutable Dictionary + \{ + */ +CF_EXPORT CFMutableDictionaryRef +CFDictionaryCreateMutable (CFAllocatorRef allocator, CFIndex capacity, + const CFDictionaryKeyCallBacks * keyCallBacks, + const CFDictionaryValueCallBacks * valueCallBacks); + +CF_EXPORT CFMutableDictionaryRef +CFDictionaryCreateMutableCopy (CFAllocatorRef allocator, CFIndex capacity, + CFDictionaryRef theDict); +/** \} */ + +/** \name Modifying a Dictionary + \{ + */ +CF_EXPORT void +CFDictionaryAddValue (CFMutableDictionaryRef theDict, const void *key, + const void *value); + +CF_EXPORT void CFDictionaryRemoveAllValues (CFMutableDictionaryRef theDict); + +CF_EXPORT void +CFDictionaryRemoveValue (CFMutableDictionaryRef theDict, const void *key); + +CF_EXPORT void +CFDictionaryReplaceValue (CFMutableDictionaryRef theDict, const void *key, + const void *value); + +CF_EXPORT void +CFDictionarySetValue (CFMutableDictionaryRef theDict, const void *key, + const void *value); +/** \} */ +/** \} */ + +CF_EXTERN_C_END +#endif /* __COREFOUNDATION_CFDICTIONARY_H__ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFLocale.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFLocale.h new file mode 100644 index 00000000000..7ae082de886 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFLocale.h @@ -0,0 +1,249 @@ +/* CFLocale.h + + Copyright (C) 2010 Free Software Foundation, Inc. + + Written by: Stefan Bidigaray + Date: March, 2011 + + This file is part of the GNUstep CoreBase Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; see the file COPYING.LIB. + If not, see <http://www.gnu.org/licenses/> or write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __COREFOUNDATION_CFLOCALE__ +#define __COREFOUNDATION_CFLOCALE__ 1 + +#include "CFBase.h" + +#include "CFArray.h" +#include "CFDictionary.h" + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST) + +CF_EXTERN_C_BEGIN + +/** \defgroup CFLocaleRef CFLocale Reference + \brief CFLocale provides basic functionality for language and/or region + specific operations. + + Locale-sensitive operations, such as collation, calendars and + capitalization, may use CFLocale objects to provide language and/or region + specific functionality. + + CFLocale is "toll-free bridged" to NSLocale. + + \{ + */ +typedef const struct __CFLocale *CFLocaleRef; + +/** + */ +enum +{ + kCFLocaleLanguageDirectionUnknown = 0, + kCFLocaleLanguageDirectionLeftToRight = 1, + kCFLocaleLanguageDirectionRightToLeft = 2, + kCFLocaleLanguageDirectionTopToBottom = 3, + kCFLocaleLanguageDirectionBottomToTop = 4 +}; +typedef CFIndex CFLocaleLanguageDirection; + +/** \name CFLocale Property Keys + \{ + */ +CF_EXPORT const CFStringRef kCFLocaleMeasurementSystem; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleDecimalSeparator; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleGroupingSeparator; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleCurrencySymbol; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleCurrencyCode; /* CFString */ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +CF_EXPORT const CFStringRef kCFLocaleIdentifier; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleLanguageCode; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleCountryCode; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleScriptCode; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleVariantCode; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleExemplarCharacterSet; /* CFCharacterSet */ +CF_EXPORT const CFStringRef kCFLocaleCalendarIdentifier; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleCalendar; /* CFCalendar */ +CF_EXPORT const CFStringRef kCFLocaleCollationIdentifier; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleUsesMetricSystem; /* CFBoolean */ +#endif +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) +CF_EXPORT const CFStringRef kCFLocaleCollatorIdentifier; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleQuotationBeginDelimiterKey; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleQuotationEndDelimiterKey; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleAlternateQuotationBeginDelimiterKey; /* CFString */ +CF_EXPORT const CFStringRef kCFLocaleAlternateQuotationEndDelimiterKey; /* CFString */ +#endif +/** \} */ + +/** \name CFCalendar Identifiers + \{ + */ +CF_EXPORT const CFStringRef kCFGregorianCalendar; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +CF_EXPORT const CFStringRef kCFBuddhistCalendar; +CF_EXPORT const CFStringRef kCFChineseCalendar; +CF_EXPORT const CFStringRef kCFHebrewCalendar; +CF_EXPORT const CFStringRef kCFIslamicCalendar; +CF_EXPORT const CFStringRef kCFIslamicCivilCalendar; +CF_EXPORT const CFStringRef kCFJapaneseCalendar; +#endif +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) +CF_EXPORT const CFStringRef kCFRepublicOfChinaCalendar; +CF_EXPORT const CFStringRef kCFPersianCalendar; +CF_EXPORT const CFStringRef kCFIndianCalendar; +CF_EXPORT const CFStringRef kCFISO8601Calendar; +#endif +/** \} */ + +/** CFLocale Change Notification + */ +CF_EXPORT const CFStringRef kCFLocaleCurrentLocaleDidChangeNotification; + + + +/** \name Creating a Locale + \{ + */ +CF_EXPORT CFLocaleRef +CFLocaleCopyCurrent (void); + +CF_EXPORT CFLocaleRef +CFLocaleCreate (CFAllocatorRef allocator, + CFStringRef localeIdent); + +CF_EXPORT CFLocaleRef +CFLocaleCreateCopy (CFAllocatorRef allocator, + CFLocaleRef locale); + +CF_EXPORT CFLocaleRef +CFLocaleGetSystem (void); +/** \} */ + +/** \name Getting System Locale Information + \{ + */ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +CF_EXPORT CFArrayRef +CFLocaleCopyAvailableLocaleIdentifiers (void); +#endif +/** \} */ + +/** \name Getting ISO Information + \{ + */ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +CF_EXPORT CFArrayRef +CFLocaleCopyISOCountryCodes (void); + +CF_EXPORT CFArrayRef +CFLocaleCopyISOLanguageCodes (void); + +CF_EXPORT CFArrayRef +CFLocaleCopyISOCurrencyCodes (void); +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) +CF_EXPORT CFArrayRef +CFLocaleCopyCommonISOCurrencyCodes (void); +#endif +/** \{ */ + +/** \name Accessing Language Information + \{ + */ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) +CF_EXPORT CFArrayRef +CFLocaleCopyPreferredLanguages (void); +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) +CF_EXPORT CFLocaleLanguageDirection +CFLocaleGetLanguageCharacterDirection (CFStringRef isoLangCode); + +CF_EXPORT CFLocaleLanguageDirection +CFLocaleGetLanguageLineDirection (CFStringRef isoLangCode); +#endif +/** \} */ + +/** \name Getting Information About a Locale + \{ + */ +CF_EXPORT CFStringRef +CFLocaleCopyDisplayNameForPropertyValue (CFLocaleRef displayLocale, + CFStringRef key, + CFStringRef value); + +CF_EXPORT CFTypeRef +CFLocaleGetValue (CFLocaleRef locale, + CFStringRef key); + +CF_EXPORT CFStringRef +CFLocaleGetIdentifier (CFLocaleRef locale); +/** \} */ + +/** \name Getting and Creating Locale Identifiers + \{ + */ +CF_EXPORT CFStringRef +CFLocaleCreateCanonicalLocaleIdentifierFromString (CFAllocatorRef allocator, + CFStringRef localeIdent); + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +CF_EXPORT CFStringRef +CFLocaleCreateCanonicalLanguageIdentifierFromString (CFAllocatorRef allocator, + CFStringRef localeIdent); + +CF_EXPORT CFDictionaryRef +CFLocaleCreateComponentsFromLocaleIdentifier (CFAllocatorRef allocator, + CFStringRef localeIdent); + +CF_EXPORT CFStringRef +CFLocaleCreateLocaleIdentifierFromComponents (CFAllocatorRef allocator, + CFDictionaryRef dictionary); +#endif +/** \} */ + +/** \name Windows Locale Codes + \{ + */ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) +CF_EXPORT CFStringRef +CFLocaleCreateLocaleIdentifierFromWindowsLocaleCode (CFAllocatorRef allocator, + UInt32 lcid); + +CF_EXPORT UInt32 +CFLocaleGetWindowsLocaleCodeFromLocaleIdentifier (CFStringRef localeIdent); +#endif +/** \} */ + +/** \name Getting the CFLocale Type ID + \{ + */ +CF_EXPORT CFTypeID +CFLocaleGetTypeID (void); +/** \} */ + +/** \} */ + +CF_EXTERN_C_END + +#endif /* OS_API_VERSION >= MAC_OS_X_VERSION_10_3 */ + +#endif /* __COREFOUNDATION_CFLOCALE__ */ + diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFString.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFString.h new file mode 100644 index 00000000000..42e4967ce90 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFString.h @@ -0,0 +1,593 @@ +/* CFString.h + + Copyright (C) 2010 Free Software Foundation, Inc. + + Written by: Stefan Bidigaray + Date: January, 2010 + + This file is part of CoreBase. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; see the file COPYING.LIB. + If not, see <http://www.gnu.org/licenses/> or write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __COREFOUNDATION_CFSTRING_H__ +#define __COREFOUNDATION_CFSTRING_H__ + +#include "CFBase.h" +#include "CFArray.h" +#include "CFCharacterSet.h" +#include "CFData.h" +#include "CFDictionary.h" +#include "CFLocale.h" + +#include <stdarg.h> + +CF_EXTERN_C_BEGIN + +/** \defgroup CFStringRef CFString Reference + \brief The CFString type defines opaque objects representing strings. + + CFString is "toll-free bridged" to NSString. + + \{ + */ + +/* + * Data Types + */ +typedef UInt32 CFStringEncoding; + +/* + * Constants + */ +typedef enum +{ + kCFCompareCaseInsensitive = 1, + kCFCompareBackwards = 4, + kCFCompareAnchored = 8, + kCFCompareNonliteral = 16, + kCFCompareLocalized = 32, + kCFCompareNumerically = 64, +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) + kCFCompareDiacriticInsensitive = 128, + kCFCompareWidthInsensitive = 256, + kCFCompareForcedOrdering = 512 +#endif +} CFStringCompareFlags; + +enum CFStringBuiltInEncodings +{ + kCFStringEncodingMacRoman = 0, + kCFStringEncodingWindowsLatin1 = 0x0500, + kCFStringEncodingISOLatin1 = 0x0201, + kCFStringEncodingNextStepLatin = 0x0B01, + kCFStringEncodingASCII = 0x0600, + kCFStringEncodingUnicode = 0x0100, + kCFStringEncodingUTF8 = 0x08000100, + kCFStringEncodingNonLossyASCII = 0x0BFF, +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) + kCFStringEncodingUTF16 = 0x0100, + kCFStringEncodingUTF16BE = 0x10000100, + kCFStringEncodingUTF16LE = 0x14000100, + kCFStringEncodingUTF32 = 0x0c000100, + kCFStringEncodingUTF32BE = 0x18000100, + kCFStringEncodingUTF32LE = 0x1c000100 +#endif +}; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST) +# define kCFStringEncodingInvalidId (0xffffffffU) +#endif + +/** \def CFSTR(x) + \brief Creates a constant string object. + + \note This macro will create the constant string at runtime. + */ +/* The 'pure' attribute tells the compiler that this function will always + return the same result with the same input. If it has any skill, then + constant propagation passes will magically make sure that this function is + called as few times as possible. */ +CF_EXPORT CFStringRef +__CFStringMakeConstantString (const char *str) GS_PURE_FUNCTION; +//#define CFSTR(x) __CFStringMakeConstantString("" x "") + +#ifdef __CONSTANT_CFSTRINGS__ +#define CFSTR(x) ((CFStringRef) __builtin___CFStringMakeConstantString ("" x "")) +#else +#define CFSTR(x) __CFStringMakeConstantString("" x "") +#endif + +/** \name Creating a CFString + \{ + */ +CF_EXPORT CFArrayRef +CFStringCreateArrayBySeparatingStrings (CFAllocatorRef alloc, + CFStringRef theString, CFStringRef separatorString); + +CF_EXPORT CFStringRef +CFStringCreateByCombiningStrings (CFAllocatorRef alloc, CFArrayRef theArray, + CFStringRef separatorString); + +CF_EXPORT CFStringRef +CFStringCreateCopy (CFAllocatorRef alloc, CFStringRef theString); + +CF_EXPORT CFStringRef +CFStringCreateFromExternalRepresentation (CFAllocatorRef alloc, CFDataRef data, + CFStringEncoding encoding); + +CF_EXPORT CFStringRef +CFStringCreateWithBytes (CFAllocatorRef alloc, const UInt8 *bytes, + CFIndex numBytes, CFStringEncoding encoding, Boolean isExternalRepresentation); + +CF_EXPORT CFStringRef +CFStringCreateWithCharacters (CFAllocatorRef alloc, const UniChar *chars, + CFIndex numChars); + +CF_EXPORT CFStringRef +CFStringCreateWithCharactersNoCopy (CFAllocatorRef alloc, const UniChar *chars, + CFIndex numChars, CFAllocatorRef contentsDeallocator); + +CF_EXPORT CFStringRef +CFStringCreateWithCString (CFAllocatorRef alloc, const char *cStr, + CFStringEncoding encoding); + +CF_EXPORT CFStringRef +CFStringCreateWithCStringNoCopy (CFAllocatorRef alloc, const char *cStr, + CFStringEncoding encoding, CFAllocatorRef contentsDeallocator); + +CF_EXPORT CFStringRef +CFStringCreateWithFormat (CFAllocatorRef alloc, CFDictionaryRef formatOptions, + CFStringRef format, ...); + +CF_EXPORT CFStringRef +CFStringCreateWithFormatAndArguments (CFAllocatorRef alloc, + CFDictionaryRef formatOptions, CFStringRef format, va_list arguments); + +CF_EXPORT CFStringRef +CFStringCreateWithSubstring (CFAllocatorRef alloc, CFStringRef str, + CFRange range); + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +CF_EXPORT CFStringRef +CFStringCreateWithFileSystemRepresentation (CFAllocatorRef alloc, + const char *buffer); +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) +CF_EXPORT CFStringRef +CFStringCreateWithBytesNoCopy (CFAllocatorRef alloc, const UInt8 *bytes, + CFIndex numBytes, CFStringEncoding encoding, Boolean isExternalReprentation, + CFAllocatorRef contentsDeallocator); +#endif +/** \} */ + +/** \name Searching CFStrings + \{ + */ +CF_EXPORT CFArrayRef +CFStringCreateArrayWithFindResults (CFAllocatorRef alloc, CFStringRef theString, + CFStringRef stringToFind, CFRange rangeToSearch, + CFStringCompareFlags compareOptions); + +CF_EXPORT CFRange +CFStringFind (CFStringRef theString, CFStringRef stringToFind, + CFStringCompareFlags compareOptions); + +CF_EXPORT Boolean +CFStringFindWithOptions (CFStringRef theString, CFStringRef stringToFind, + CFRange rangeToSearch, CFStringCompareFlags searchOptions, CFRange *result); + +CF_EXPORT Boolean +CFStringFindWithOptionsAndLocale (CFStringRef theString,CFStringRef stringToFind, + CFRange rangeToSearch, CFStringCompareFlags searchOptions, + CFLocaleRef locale, CFRange *result); + +CF_EXPORT void +CFStringGetLineBounds (CFStringRef theString, CFRange range, + CFIndex *lineBeginIndex, CFIndex *lineEndIndex, CFIndex *contentsEndIndex); + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST) +CF_EXPORT Boolean +CFStringFindCharacterFromSet (CFStringRef theString, CFCharacterSetRef theSet, + CFRange rangeToSearch, CFStringCompareFlags searchOptions, CFRange *result); +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) +CF_EXPORT void +CFStringGetParagraphBounds (CFStringRef string, CFRange range, + CFIndex *parBeginIndex, CFIndex *parEndIndex, CFIndex *contentsEndIndex); +#endif +/** \} */ + +/** \name Comparing String + \{ + */ +CF_EXPORT CFComparisonResult +CFStringCompare (CFStringRef theString1, CFStringRef theString2, + CFStringCompareFlags compareOptions); + +CF_EXPORT CFComparisonResult +CFStringCompareWithOptions (CFStringRef theString1, CFStringRef theString2, + CFRange rangeToCOmpare, CFStringCompareFlags compareOptions); + +CF_EXPORT Boolean +CFStringHasPrefix (CFStringRef theString, CFStringRef prefix); + +CF_EXPORT Boolean +CFStringHasSuffix (CFStringRef theString, CFStringRef suffix); + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) +CF_EXPORT CFComparisonResult +CFStringCompareWithOptionsAndLocale (CFStringRef theString1, + CFStringRef theString2, CFRange rangeToCOmpare, + CFStringCompareFlags compareOptions, CFLocaleRef locale); +#endif +/** \} */ + +/** \name Accessing Characters + \{ + */ +CF_EXPORT CFDataRef +CFStringCreateExternalRepresentation (CFAllocatorRef alloc, + CFStringRef theString, CFStringEncoding encoding, UInt8 lossByte); + +CF_EXPORT CFIndex +CFStringGetBytes (CFStringRef theString, CFRange range, + CFStringEncoding encoding, UInt8 lossByte, Boolean isExternalRepresentation, + UInt8 *buffer, CFIndex maxBufLen, CFIndex *usedBufLen); + +CF_EXPORT UniChar +CFStringGetCharacterAtIndex (CFStringRef theString, CFIndex idx); + +CF_EXPORT void +CFStringGetCharacters (CFStringRef theString, CFRange range, UniChar *buffer); + +CF_EXPORT const UniChar * +CFStringGetCharactersPtr (CFStringRef theString); + +CF_EXPORT Boolean +CFStringGetCString (CFStringRef theString, char *buffer, CFIndex bufferSize, + CFStringEncoding encoding); + +CF_EXPORT const char * +CFStringGetCStringPtr (CFStringRef theString, CFStringEncoding encoding); + +CF_EXPORT CFIndex +CFStringGetLength (CFStringRef str); + +CF_EXPORT CFRange +CFStringGetRangeOfComposedCharactersAtIndex (CFStringRef theString, + CFIndex theIndex); + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) +CF_EXPORT UTF32Char +CFStringGetLongCharacterForSurrogatePair (UniChar surrogateHigh, + UniChar surrogateLow); + +CF_EXPORT Boolean +CFStringGetSurrogatePairForLongCharacter (UTF32Char character, + UniChar *surrogates); + +CF_EXPORT Boolean +CFStringIsSurrogateHighCharacter (UniChar character); + +CF_EXPORT Boolean +CFStringIsSurrogateLowCharacter (UniChar character); +#endif +/** \} */ + +/** \name Working with Encodings + \{ + */ +CF_EXPORT CFStringRef +CFStringConvertEncodingToIANACharSetName (CFStringEncoding encoding); + +CF_EXPORT unsigned long +CFStringConvertEncodingToNSStringEncoding (CFStringEncoding encoding); + +UInt32 +CFStringConvertEncodingToWindowsCodepage (CFStringEncoding encoding); + +CF_EXPORT CFStringEncoding +CFStringConvertIANACharSetNameToEncoding (CFStringRef theString); + +CF_EXPORT CFStringEncoding +CFStringConvertNSStringEncodingToEncoding (unsigned long encoding); + +CF_EXPORT CFStringEncoding +CFStringConvertWindowsCodepageToEncoding (UInt32 codepage); + +CF_EXPORT CFStringEncoding +CFStringGetFastestEncoding (CFStringRef theString); + +CF_EXPORT const CFStringEncoding * +CFStringGetListOfAvailableEncodings (void); + +CF_EXPORT CFIndex +CFStringGetMaximumSizeForEncoding (CFIndex length, CFStringEncoding encoding); + +CF_EXPORT CFStringEncoding +CFStringGetMostCompatibleMacStringEncoding (CFStringEncoding encoding); + +CF_EXPORT CFStringRef +CFStringGetNameOfEncoding (CFStringEncoding encoding); + +CF_EXPORT CFStringEncoding +CFStringGetSmallestEncoding (CFStringRef theString); + +CF_EXPORT CFStringEncoding +CFStringGetSystemEncoding (void); + +CF_EXPORT Boolean +CFStringIsEncodingAvailable (CFStringEncoding encoding); + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +CF_EXPORT Boolean +CFStringGetFileSystemRepresentation (CFStringRef string, char *buffer, + CFIndex maxBufLen); + +CF_EXPORT CFIndex +CFStringGetMaximumSizeOfFileSystemRepresentation (CFStringRef string); +#endif +/** \} */ + +/** \name Getting Numeric Values + \{ + */ +CF_EXPORT double +CFStringGetDoubleValue (CFStringRef str); + +CF_EXPORT SInt32 +CFStringGetIntValue (CFStringRef str); +/** \} */ + +/** \name Getting String Properties + \{ + */ +CF_EXPORT void +CFShow (CFTypeRef obj); + +CF_EXPORT void +CFShowStr (CFStringRef str); + +CF_EXPORT CFTypeID +CFStringGetTypeID (void); +/** \} */ + + + +/** \name Pascal Strings + \{ + */ +CF_EXPORT CFStringRef +CFStringCreateWithPascalString (CFAllocatorRef alloc, ConstStr255Param pStr, + CFStringEncoding encoding); + +CF_EXPORT CFStringRef +CFStringCreateWithPascalStringNoCopy (CFAllocatorRef alloc, + ConstStr255Param pStr, CFStringEncoding encoding, + CFAllocatorRef contentsDeallocate); + +CF_EXPORT Boolean +CFStringGetPascalString (CFStringRef theString, StringPtr buffer, + CFIndex bufferSize, CFStringEncoding encoding); + +CF_EXPORT ConstStringPtr +CFStringGetPascalStringPtr (CFStringRef theString, CFStringEncoding encoding); +/** \} */ +/** \} */ + + + +/** \defgroup CFMutableStringRef CFMutableString Reference + * \{ + */ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST) +typedef enum +{ + kCFStringNormalizationFormD = 0, + kCFStringNormalizationFormKD = 1, + kCFStringNormalizationFormC = 2, + kCFStringNormalizationFormKC = 3 +} CFStringNormalizationForm; +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +CF_EXPORT const CFStringRef kCFStringTransformStripCombiningMarks; +CF_EXPORT const CFStringRef kCFStringTransformToLatin; +CF_EXPORT const CFStringRef kCFStringTransformFullwidthHalfwidth; +CF_EXPORT const CFStringRef kCFStringTransformLatinKatakana; +CF_EXPORT const CFStringRef kCFStringTransformLatinHiragana; +CF_EXPORT const CFStringRef kCFStringTransformHiraganaKatakana; +CF_EXPORT const CFStringRef kCFStringTransformMandarinLatin; +CF_EXPORT const CFStringRef kCFStringTransformLatinHangul; +CF_EXPORT const CFStringRef kCFStringTransformLatinArabic; +CF_EXPORT const CFStringRef kCFStringTransformLatinHebrew; +CF_EXPORT const CFStringRef kCFStringTransformLatinThai; +CF_EXPORT const CFStringRef kCFStringTransformLatinCyrillic; +CF_EXPORT const CFStringRef kCFStringTransformLatinGreek; +CF_EXPORT const CFStringRef kCFStringTransformToXMLHex; +CF_EXPORT const CFStringRef kCFStringTransformToUnicodeName; +#endif +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) +CF_EXPORT const CFStringRef kCFStringTransformStripDiacritics; +#endif + +CF_EXPORT void +CFStringAppend (CFMutableStringRef theString, CFStringRef appendedString); + +CF_EXPORT void +CFStringAppendCharacters (CFMutableStringRef theString, + const UniChar *chars, CFIndex numChars); + +CF_EXPORT void +CFStringAppendCString (CFMutableStringRef theString, const char *cStr, + CFStringEncoding encoding); + +CF_EXPORT void +CFStringAppendFormat (CFMutableStringRef theString, + CFDictionaryRef formatOptions, CFStringRef format, ...); + +CF_EXPORT void +CFStringAppendFormatAndArguments (CFMutableStringRef theString, + CFDictionaryRef formatOptions, CFStringRef format, va_list arguments); + +CF_EXPORT void +CFStringAppendPascalString (CFMutableStringRef theString, + ConstStr255Param pStr, CFStringEncoding encoding); + +CF_EXPORT void +CFStringCapitalize (CFMutableStringRef theString, CFLocaleRef locale); + +CF_EXPORT CFMutableStringRef +CFStringCreateMutable (CFAllocatorRef alloc, CFIndex maxLength); + +CF_EXPORT CFMutableStringRef +CFStringCreateMutableCopy (CFAllocatorRef alloc, CFIndex maxLength, + CFStringRef theString); + +CF_EXPORT CFMutableStringRef +CFStringCreateMutableWithExternalCharactersNoCopy (CFAllocatorRef alloc, + UniChar *chars, CFIndex numChars, CFIndex capacity, + CFAllocatorRef externalCharactersAllocator); + +CF_EXPORT void +CFStringDelete (CFMutableStringRef theString, CFRange range); + +CF_EXPORT void +CFStringInsert (CFMutableStringRef str, CFIndex idx, CFStringRef insertedStr); + +CF_EXPORT void +CFStringLowercase (CFMutableStringRef theString, CFLocaleRef locale); + +CF_EXPORT void +CFStringPad (CFMutableStringRef theString, CFStringRef padString, + CFIndex length, CFIndex indexIntoPad); + +CF_EXPORT void +CFStringReplace (CFMutableStringRef theString, CFRange range, + CFStringRef replacement); + +CF_EXPORT void +CFStringReplaceAll (CFMutableStringRef theString, CFStringRef replacement); + +CF_EXPORT void +CFStringSetExternalCharactersNoCopy (CFMutableStringRef theString, + UniChar *chars, CFIndex length, CFIndex capacity); + +CF_EXPORT void +CFStringTrim (CFMutableStringRef theString, CFStringRef trimString); + +CF_EXPORT void +CFStringTrimWhitespace (CFMutableStringRef theString); + +CF_EXPORT void +CFStringUppercase (CFMutableStringRef theString, CFLocaleRef locale); + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST) +CF_EXPORT CFIndex +CFStringFindAndReplace (CFMutableStringRef theString, + CFStringRef stringToFind, CFStringRef replacementString, + CFRange rangeToSearch, CFOptionFlags compareOptions); + +CF_EXPORT void +CFStringNormalize (CFMutableStringRef theString, + CFStringNormalizationForm theForm); +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +CF_EXPORT Boolean +CFStringTransform (CFMutableStringRef string, CFRange *range, + CFStringRef transform, Boolean reverse); +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) +CF_EXPORT void +CFStringFold (CFMutableStringRef theString, CFOptionFlags theFlags, + CFLocaleRef theLocale); +#endif +/** \} */ + + + +/** \ingroup CFStringRef + \name CFStringInlineBuffer + \{ + */ +#define __kCFStringInlineBufferLength 64 +struct CFStringInlineBuffer +{ + UniChar buffer[__kCFStringInlineBufferLength]; + CFStringRef theString; + const UniChar *directBuffer; + CFRange rangeToBuffer; + CFIndex bufferedRangeStart; + CFIndex bufferedRangeEnd; +}; +typedef struct CFStringInlineBuffer CFStringInlineBuffer; + +CF_INLINE void +CFStringInitInlineBuffer (CFStringRef str, CFStringInlineBuffer *buf, + CFRange range) +{ + buf->theString = str; + buf->rangeToBuffer = range; + buf->directBuffer = CFStringGetCharactersPtr (str); + buf->bufferedRangeStart = 0; + buf->bufferedRangeEnd = 0; +} + +CF_INLINE UniChar +CFStringGetCharacterFromInlineBuffer (CFStringInlineBuffer *buf, CFIndex idx) +{ + if (buf->directBuffer) + { + if (idx < 0 || idx >= buf->rangeToBuffer.length) + return 0; + return buf->directBuffer[idx + buf->rangeToBuffer.location]; + } + else if (idx >= buf->bufferedRangeEnd || idx < buf->bufferedRangeStart) + { + CFRange range; + + if (idx < 0 || idx >= buf->rangeToBuffer.length) + return 0; + + /* Use 16 here so it's efficient to go backwards, too */ + buf->bufferedRangeStart = idx - 16; + if (buf->bufferedRangeStart < 0) + buf->bufferedRangeStart = 0; + buf->bufferedRangeEnd = + buf->bufferedRangeStart + __kCFStringInlineBufferLength; + if (buf->bufferedRangeEnd > buf->rangeToBuffer.length) + buf->bufferedRangeEnd = buf->rangeToBuffer.length; + + range = CFRangeMake (buf->rangeToBuffer.location + buf->bufferedRangeStart, + buf->bufferedRangeEnd - buf->bufferedRangeStart); + + CFStringGetCharacters (buf->theString, range, buf->buffer); + } + + return buf->buffer[(idx - buf->bufferedRangeStart)]; +} +/** \} */ + +CF_EXTERN_C_END + +#endif /* __COREFOUNDATION_CFSTRING_H__ */ + diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSArray.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSArray.h new file mode 100644 index 00000000000..661e90faf89 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSArray.h @@ -0,0 +1,430 @@ +/* Interface for NSArray for GNUStep + Copyright (C) 1995-2015 Free Software Foundation, Inc. + + Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu> + Created: 1995 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + */ + +#ifndef __NSArray_h_GNUSTEP_BASE_INCLUDE +#define __NSArray_h_GNUSTEP_BASE_INCLUDE +#import "../GNUstepBase/GSVersionMacros.h" + +#import "NSObject.h" +#import "NSRange.h" +#import "NSEnumerator.h" +#if __BLOCKS__ +#import "../GNUstepBase/GSBlocks.h" +#endif + +#if defined(__cplusplus) +extern "C" { +#endif + +@class NSString; +@class NSURL; +@class NSIndexSet; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) +enum +{ + NSBinarySearchingFirstEqual = (1UL << 8), /** Specifies that the binary + * search should find the first object equal in the array. + */ + NSBinarySearchingLastEqual = (1UL << 9), /** Specifies that the binary + * search should find the last object equal in the array. + */ + NSBinarySearchingInsertionIndex = (1UL << 10), /** Specifies that the binary + * search should find the index at which an equal object should be inserted + * in order to keep the array sorted + */ +}; + +typedef NSUInteger NSBinarySearchingOptions; +#endif + +@interface GS_GENERIC_CLASS(NSArray, __covariant ElementT) : NSObject + <NSCoding, NSCopying, NSMutableCopying, NSFastEnumeration> + ++ (instancetype) array; ++ (instancetype) arrayWithArray: (GS_GENERIC_CLASS(NSArray, ElementT) *)array; ++ (instancetype) arrayWithContentsOfFile: (NSString*)file; +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) ++ (instancetype) arrayWithContentsOfURL: (NSURL*)aURL; +#endif ++ (instancetype) arrayWithObject: (id)anObject; ++ (instancetype) arrayWithObjects: (id)firstObject, ...; ++ (instancetype) arrayWithObjects: (const id[])objects count: (NSUInteger)count; + +- (GS_GENERIC_CLASS(NSArray, ElementT) *) arrayByAddingObject: + (GS_GENERIC_TYPE(ElementT))anObject; +- (GS_GENERIC_CLASS(NSArray, ElementT) *) arrayByAddingObjectsFromArray: + (GS_GENERIC_CLASS(NSArray, ElementT)*)anotherArray; +- (BOOL) containsObject: (GS_GENERIC_TYPE(ElementT))anObject; + +/** <override-subclass /> + * Returns the number of elements contained in the receiver. + */ +- (NSUInteger) count; +- (void) getObjects: (__unsafe_unretained GS_GENERIC_TYPE(ElementT)[])aBuffer; +- (void) getObjects: (__unsafe_unretained GS_GENERIC_TYPE(ElementT)[])aBuffer + range: (NSRange)aRange; +- (NSUInteger) indexOfObject: (GS_GENERIC_TYPE(ElementT))anObject; +- (NSUInteger) indexOfObject: (GS_GENERIC_TYPE(ElementT))anObject + inRange: (NSRange)aRange; +- (NSUInteger) indexOfObjectIdenticalTo: (GS_GENERIC_TYPE(ElementT))anObject; +- (NSUInteger) indexOfObjectIdenticalTo: (GS_GENERIC_TYPE(ElementT))anObject + inRange: (NSRange)aRange; +- (instancetype) init; +- (instancetype) initWithArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)array; +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +- (instancetype) initWithArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)array + copyItems: (BOOL)shouldCopy; +#endif +- (instancetype) initWithContentsOfFile: (NSString*)file; +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +- (instancetype) initWithContentsOfURL: (NSURL*)aURL; +#endif +- (instancetype) initWithObjects: (GS_GENERIC_TYPE(ElementT)) firstObject, ...; + +/** <init /> <override-subclass /> + * This should initialize the array with count (may be zero) objects.<br /> + * Retains each object placed in the array.<br /> + * Calls -init (which does nothing but maintain MacOS-X compatibility), + * and needs to be re-implemented in subclasses in order to have all + * other initialisers work. + */ +- (instancetype) initWithObjects: (const GS_GENERIC_TYPE(ElementT)[])objects + count: (NSUInteger)count; +- (GS_GENERIC_TYPE(ElementT)) lastObject; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) +- (GS_GENERIC_TYPE(ElementT)) firstObject; +#endif + +/** <override-subclass /> + * Returns the object at the specified index. + * Raises an exception of the index is beyond the array. + */ +- (GS_GENERIC_TYPE(ElementT)) objectAtIndex: (NSUInteger)index; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +- (GS_GENERIC_CLASS(NSArray, ElementT) *) objectsAtIndexes: + (NSIndexSet *)indexes; +#endif + +- (GS_GENERIC_TYPE(ElementT)) firstObjectCommonWithArray: + (GS_GENERIC_CLASS(NSArray, ElementT) *)otherArray; +- (BOOL) isEqualToArray: (NSArray*)otherArray; + +#if OS_API_VERSION(GS_API_OPENSTEP, GS_API_MACOSX) +- (void) makeObjectsPerform: (SEL)aSelector; +- (void) makeObjectsPerform: (SEL)aSelector withObject: (id)argument; +#endif +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +- (void) makeObjectsPerformSelector: (SEL)aSelector; +- (void) makeObjectsPerformSelector: (SEL)aSelector withObject: (id)arg; +#endif + +- (NSData*) sortedArrayHint; +- (GS_GENERIC_CLASS(NSArray, ElementT)*) sortedArrayUsingFunction: + (NSComparisonResult (*)(id, id, void*))comparator + context: (void*)context; +- (GS_GENERIC_CLASS(NSArray, ElementT)*) sortedArrayUsingFunction: + (NSComparisonResult (*)(id, id, void*))comparator + context: (void*)context + hint: (NSData*)hint; +- (GS_GENERIC_CLASS(NSArray, ElementT)*) sortedArrayUsingSelector: + (SEL)comparator; +- (GS_GENERIC_CLASS(NSArray, ElementT)*) subarrayWithRange: (NSRange)aRange; + +- (NSString*) componentsJoinedByString: (NSString*)separator; +- (GS_GENERIC_CLASS(NSArray, NSString*)*) pathsMatchingExtensions: + (GS_GENERIC_CLASS(NSArray, NSString*)*)extensions; + +- (GS_GENERIC_CLASS(NSEnumerator, ElementT)*) objectEnumerator; +- (GS_GENERIC_CLASS(NSEnumerator, ElementT)*) reverseObjectEnumerator; + +- (NSString*) description; +- (NSString*) descriptionWithLocale: (id)locale; +- (NSString*) descriptionWithLocale: (id)locale + indent: (NSUInteger)level; + +- (BOOL) writeToFile: (NSString*)path atomically: (BOOL)useAuxiliaryFile; +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +- (BOOL) writeToURL: (NSURL*)url atomically: (BOOL)useAuxiliaryFile; +- (GS_GENERIC_TYPE(ElementT)) valueForKey: (NSString*)key; +- (void) setValue: (GS_GENERIC_TYPE(ElementT))value forKey: (NSString*)key; +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) + +#if __BLOCKS__ +DEFINE_BLOCK_TYPE(GSEnumeratorBlock, void, GS_GENERIC_TYPE(ElementT), + NSUInteger, BOOL*); +DEFINE_BLOCK_TYPE(GSPredicateBlock, BOOL, GS_GENERIC_TYPE(ElementT), + NSUInteger, BOOL*); +/** + * Enumerate over the collection using the given block. The first argument is + * the object and the second is the index in the array. The final argument is + * a pointer to a BOOL indicating whether the enumeration should stop. Setting + * this to YES will interrupt the enumeration. + */ +- (void) enumerateObjectsUsingBlock: (GSEnumeratorBlock)aBlock; + +/** + * Enumerate over the collection using the given block. The first argument is + * the object and the second is the index in the array. The final argument is + * a pointer to a BOOL indicating whether the enumeration should stop. Setting + * this to YES will interrupt the enumeration. + * + * The opts argument is a bitfield. Setting the NSNSEnumerationConcurrent flag + * specifies that it is thread-safe. The NSEnumerationReverse bit specifies + * that it should be enumerated in reverse order. + */ +- (void) enumerateObjectsWithOptions: (NSEnumerationOptions)opts + usingBlock: (GSEnumeratorBlock)aBlock; +/** + * Enumerate over the specified indexes in the collection using the given + * block. The first argument is the object and the second is the index in the + * array. The final argument is a pointer to a BOOL indicating whether the + * enumeration should stop. Setting this to YES will interrupt the + * enumeration. + * + * The opts argument is a bitfield. Setting the NSNSEnumerationConcurrent flag + * specifies that it is thread-safe. The NSEnumerationReverse bit specifies + * that it should be enumerated in reverse order. + */ +- (void) enumerateObjectsAtIndexes: (NSIndexSet*)indexSet + options: (NSEnumerationOptions)opts + usingBlock: (GSEnumeratorBlock)block; +/** + * Returns the indexes of the objects in a collection that match the condition + * specified by the block. + * + * The opts argument is a bitfield. Setting the NSNSEnumerationConcurrent flag + * specifies that it is thread-safe. The NSEnumerationReverse bit specifies + * that it should be enumerated in reverse order. + */ +- (NSIndexSet *) indexesOfObjectsWithOptions: (NSEnumerationOptions)opts + passingTest: (GSPredicateBlock)predicate; + +/** + * Returns the indexes of the objects in a collection that match the condition + * specified by the block. + */ +- (NSIndexSet*) indexesOfObjectsPassingTest: (GSPredicateBlock)predicate; + +/** + * Returns the indexes of the objects in a collection that match the condition + * specified by the block and are in the range specified by the index set. + * + * The opts argument is a bitfield. Setting the NSNSEnumerationConcurrent flag + * specifies that it is thread-safe. The NSEnumerationReverse bit specifies + * that it should be enumerated in reverse order. + */ +- (NSIndexSet*) indexesOfObjectsAtIndexes: (NSIndexSet*)indexSet + options: (NSEnumerationOptions)opts + passingTest: (GSPredicateBlock)predicate; + +/** + * Returns the index of the first object in the array that matches the + * condition specified by the block. + * + * The opts argument is a bitfield. Setting the NSNSEnumerationConcurrent flag + * specifies that it is thread-safe. The NSEnumerationReverse bit specifies + * that it should be enumerated in reverse order. + */ +- (NSUInteger) indexOfObjectWithOptions: (NSEnumerationOptions)opts + passingTest: (GSPredicateBlock)predicate; + +/** + * Returns the index of the first object in the array that matches the + * condition specified by the block. + */ +- (NSUInteger) indexOfObjectPassingTest: (GSPredicateBlock)predicate; + +/** + * Returns the index of the first object in the specified range in a collection + * that matches the condition specified by the block. + * + * The opts argument is a bitfield. Setting the NSNSEnumerationConcurrent flag + * specifies that it is thread-safe. The NSEnumerationReverse bit specifies + * that it should be enumerated in reverse order. + */ +- (NSUInteger) indexOfObjectAtIndexes: (NSIndexSet*)indexSet + options: (NSEnumerationOptions)opts + passingTest: (GSPredicateBlock)predicate; + +/** Returns a sorted array using the comparator to determine the + * order of objects. + */ +- (GS_GENERIC_CLASS(NSArray, ElementT) *) sortedArrayUsingComparator: + (NSComparator)comparator; + +/** Returns a sorted array using the block to determine the order of objects. + * + * The opts argument is a bitfield. Setting the NSSortConcurrent flag + * specifies that it is thread-safe. The NSSortStable bit specifies that + * it should keep equal objects in the same order. + */ +- (GS_GENERIC_CLASS(NSArray, ElementT) *) + sortedArrayWithOptions: (NSSortOptions)options + usingComparator: (NSComparator)comparator; + +/** + * Performs a binary search of the array within the specified range for the + * index of an object equal to obj according to cmp. + * If NSBinarySearchingInsertionIndex is specified, searches for the index + * at which such an object should be inserted. + */ +- (NSUInteger) indexOfObject: (id)key + inSortedRange: (NSRange)range + options: (NSBinarySearchingOptions)options + usingComparator: (NSComparator)comparator; +#endif +#endif +/** + * Accessor for subscripting. This is called by the compiler when you write + * code like anArray[12]. It should not be called directly. + */ +- (GS_GENERIC_TYPE(ElementT)) objectAtIndexedSubscript: (NSUInteger)anIndex; +@end + + +@interface GS_GENERIC_CLASS(NSMutableArray, ElementT) : NSArray + ++ (instancetype) arrayWithCapacity: (NSUInteger)numItems; + +/** <override-subclass /> + * Adds anObject at the end of the array, thus increasing the size of + * the array. The object is retained upon addition. + */ +- (void) addObject: (GS_GENERIC_TYPE(ElementT))anObject; +- (void) addObjectsFromArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)otherArray; +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +- (void) exchangeObjectAtIndex: (NSUInteger)i1 + withObjectAtIndex: (NSUInteger)i2; +#endif + +/** <init /> <override-subclass /> + * Initialise the array with the specified capacity ... this + * should ensure that the array can have numItems added efficiently.<br /> + * Calls -init (which does nothing but maintain MacOS-X compatibility), + * and needs to be re-implemented in subclasses in order to have all + * other initialisers work. + */ +- (instancetype) initWithCapacity: (NSUInteger)numItems; + +/** <override-subclass /> + * Inserts an object into the receiver at the specified location.<br /> + * Raises an exception if given an array index which is too large.<br /> + * The size of the array increases by one.<br /> + * The object is retained by the array. + */ +- (void) insertObject: (GS_GENERIC_TYPE(ElementT))anObject + atIndex: (NSUInteger)index; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +- (void) insertObjects: (GS_GENERIC_CLASS(NSArray, ElementT) *)objects + atIndexes: (NSIndexSet *)indexes; +#endif + +/** <override-subclass /> + * Removes an object from the receiver at the specified location.<br /> + * The size of the array decreases by one.<br /> + * Raises an exception if given an array index which is too large.<br /> + */ +- (void) removeObjectAtIndex: (NSUInteger)index; + +- (void) removeObjectsAtIndexes: (NSIndexSet *)indexes; + +/** <override-subclass /> + * Places an object into the receiver at the specified location.<br /> + * Raises an exception if given an array index which is too large.<br /> + * The object is retained by the array. + */ +- (void) replaceObjectAtIndex: (NSUInteger)index + withObject: (GS_GENERIC_TYPE(ElementT))anObject; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +- (void) replaceObjectsAtIndexes: (NSIndexSet *)indexes + withObjects: (GS_GENERIC_CLASS(NSArray, ElementT)*)objects; +#endif + +- (void) replaceObjectsInRange: (NSRange)aRange + withObjectsFromArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)anArray; + +- (void) replaceObjectsInRange: (NSRange)aRange + withObjectsFromArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)anArray + range: (NSRange)anotherRange; + +- (void) setArray: (GS_GENERIC_CLASS(NSArray, ElementT) *)otherArray; + +- (void) removeAllObjects; +- (void) removeLastObject; +- (void) removeObject: (GS_GENERIC_TYPE(ElementT))anObject; +- (void) removeObject: (GS_GENERIC_TYPE(ElementT))anObject + inRange: (NSRange)aRange; +- (void) removeObjectIdenticalTo: (GS_GENERIC_TYPE(ElementT))anObject; +- (void) removeObjectIdenticalTo: (GS_GENERIC_TYPE(ElementT))anObject + inRange: (NSRange)aRange; +- (void) removeObjectsInArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)otherArray; +- (void) removeObjectsInRange: (NSRange)aRange; +- (void) removeObjectsFromIndices: (NSUInteger*)indices + numIndices: (NSUInteger)count; + +- (void) sortUsingFunction: + (NSComparisonResult (*)(GS_GENERIC_TYPE(ElementT), + GS_GENERIC_TYPE(ElementT),void*))compare + context: (void*)context; +- (void) sortUsingSelector: (SEL)comparator; + + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) +#if __BLOCKS__ +/** + * Sorts the array using the specified comparator block. + */ +- (void) sortUsingComparator: (NSComparator)comparator; + +/** + * Sorts the array using the specified comparator block and options. + */ +- (void) sortWithOptions: (NSSortOptions)options + usingComparator: (NSComparator)comparator; +#endif +#endif +#if OS_API_VERSION(MAC_OS_X_VERSION_10_8, GS_API_LATEST) +/** Set method called by the compiler with array subscripting.<br /> + * Replaces the object at anIndex or, if anIndex is the length of the array, + * this method appends abObject to the array. + */ +- (void) setObject: (GS_GENERIC_TYPE(ElementT))anObject +atIndexedSubscript: (NSUInteger)anIndex; +#endif +@end + +#if defined(__cplusplus) +} +#endif + +#if !NO_GNUSTEP && !defined(GNUSTEP_BASE_INTERNAL) +#import "../GNUstepBase/NSArray+GNUstepBase.h" +#endif + +#endif /* __NSArray_h_GNUSTEP_BASE_INCLUDE */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSAutoreleasePool.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSAutoreleasePool.h new file mode 100644 index 00000000000..c7ec486ddde --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSAutoreleasePool.h @@ -0,0 +1,333 @@ +/* Interface for NSAutoreleasePool for GNUStep + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + + Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu> + Date: 1995 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + */ + +#ifndef __NSAutoreleasePool_h_GNUSTEP_BASE_INCLUDE +#define __NSAutoreleasePool_h_GNUSTEP_BASE_INCLUDE +#import "../GNUstepBase/GSVersionMacros.h" + +#import "NSObject.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +@class NSAutoreleasePool; +@class NSThread; + + +/** + * Each thread has its own copy of these variables. + <example> +{ + NSAutoreleasePool *current_pool; // current pool for thread + unsigned total_objects_count; // total #/autoreleased objects over thread's lifetime + id *pool_cache; // cache of previously-allocated pools, + int pool_cache_size; // used internally for recycling + int pool_cache_count; +} + </example> +*/ +typedef struct autorelease_thread_vars +{ + /* The current, default NSAutoreleasePool for the calling thread; + the one that will hold objects that are arguments to + [NSAutoreleasePool +addObject:]. */ + __unsafe_unretained NSAutoreleasePool *current_pool; + + /* The total number of objects autoreleased since the thread was + started, or since -resetTotalAutoreleasedObjects was called + in this thread. (if compiled in) */ + unsigned total_objects_count; + + /* A cache of NSAutoreleasePool's already alloc'ed. Caching old pools + instead of deallocating and re-allocating them will save time. */ + __unsafe_unretained id *pool_cache; + int pool_cache_size; + int pool_cache_count; +} thread_vars_struct; + +/* Initialize an autorelease_thread_vars structure for a new thread. + This function is called in NSThread each time an NSThread is created. + TV should be of type `struct autorelease_thread_vars *' */ +#define init_autorelease_thread_vars(TV) \ +memset (TV, 0, sizeof (__typeof__ (*TV))) + + + +/** + * Each pool holds its objects-to-be-released in a linked-list of + these structures. + <example> +{ + struct autorelease_array_list *next; + unsigned size; + unsigned count; + id objects[0]; +} + </example> + */ +typedef struct autorelease_array_list +{ + struct autorelease_array_list *next; + unsigned size; + unsigned count; + __unsafe_unretained id objects[0]; +} array_list_struct; + + + +/** + * <p> + * The standard OpenStep system of memory management employs retain counts. + * When an object is created, it has a retain count of 1. When an object + * is retained, the retain count is incremented. When it is released the + * retain count is decremented, and when the retain count goes to zero the + * object gets deallocated. + * </p> + * <p> + * A simple retain/release mechanism has problems with passing objects + * from one scope to another, + * so it's augmented with autorelease pools. You can use the + * AUTORELEASE() macro to call the [NSObject-autorelease] + * method, which adds an object to the current autorelease pool by + * calling [NSAutoreleasePool+addObject:].<br /> + * An autorelease pool simply maintains a reference to each object + * added to it, and for each addition, the autorelease pool will + * call the [NSObject-release] method of the object when the pool + * is released. So doing an AUTORELEASE() is just the same as + * doing a RELEASE(), but deferred until the current autorelease + * pool is deallocated. + * </p> + * <p> + * The NSAutoreleasePool class maintains a separate stack of + * autorelease pools objects in each thread. + * </p> + * <p> + * When an autorelease pool is created, it is automatically + * added to the stack of pools in the thread. + * </p> + * <p> + * When a pool is destroyed, it (and any pool later in + * the stack) is removed from the stack. + * </p> + * <p> + * This mechanism provides a simple but controllable and reasonably + * efficient way of managing temporary objects. An object can be + * autoreleased and then passed around and used until the topmost + * pool in the stack is destroyed. + * </p> + * <p> + * Most methods return objects which are either owned by autorelease + * pools or by the receiver of the method, so the lifetime of the + * returned object can be assumed to be the shorter of the lifetime + * of the current autorelease pool, or that of the receiver on which + * the method was called.<br /> + * The exceptions to this are those object returned by - + * </p> + * <deflist> + * <term>[NSObject+alloc], [NSObject+allocWithZone:]</term> + * <desc> + * Methods whose names begin with alloc return an uninitialised + * object, owned by the caller. + * </desc> + * <term>[NSObject-init]</term> + * <desc> + * Methods whose names begin with init return an initialised + * version of the receiving object, owned by the caller.<br /> + * NB. The returned object may not actually be the same as the + * receiver ... sometimes an init method releases the original + * receiver and returns an alternative. + * </desc> + * <term>[NSObject+new]</term> + * <desc> + * Methods whose names begin with new combine the effects of + * allocation and initialisation. + * </desc> + * <term>[NSObject-copy], [(NSCopying)-copyWithZone:]</term> + * <desc> + * Methods whose names begin with copy create a copy of the receiver + * which is owned by the caller. + * </desc> + * <term> + * [NSObject-mutableCopy], [(NSMutableCopying)-mutableCopyWithZone:] + * </term> + * <desc> + * Methods whose names begin with mutableCopy create a copy of the receiver + * which is owned by the caller. + * </desc> + * </deflist> + */ +NS_AUTOMATED_REFCOUNT_UNAVAILABLE +@interface NSAutoreleasePool : NSObject +{ +#if GS_EXPOSE(NSAutoreleasePool) && !__has_feature(objc_arc) + /* For re-setting the current pool when we are dealloc'ed. */ + NSAutoreleasePool *_parent; + /* This pointer to our child pool is necessary for co-existing + with exceptions. */ + NSAutoreleasePool *_child; + /* A collection of the objects to be released. */ + struct autorelease_array_list *_released; + struct autorelease_array_list *_released_head; + /* The total number of objects autoreleased in this pool. */ + unsigned _released_count; + /* The method to add an object to this pool */ + void (*_addImp)(id, SEL, id); +#endif +#if GS_NONFRAGILE +#else + /* Pointer to private additional data used to avoid breaking ABI + * when we don't have the non-fragile ABI available. + * Use this mechanism rather than changing the instance variable + * layout (see Source/GSInternal.h for details). + */ + @private id _internal GS_UNUSED_IVAR; +#endif +} + +/** + * Adds anObj to the current autorelease pool.<br /> + * If there is no autorelease pool in the thread, + * a warning is logged and the object is leaked (ie it will not be released). + */ ++ (void) addObject: (id)anObj; + +/** + * Allocate and return an autorelease pool instance.<br /> + * If there is an already-allocated NSAutoreleasePool available, + * save time by just returning that, rather than allocating a new one.<br /> + * The pool instance becomes the current autorelease pool for this thread. + */ ++ (id) allocWithZone: (NSZone*)zone; + +/** + * Adds anObj to this autorelease pool. + */ +- (void) addObject: (id)anObj; + +/** + * Raises an exception - pools should not be autoreleased. + */ +- (id) autorelease; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) +/** + * Intended to trigger a garbage collection run (if needed) when called in + * a garbage collected environment.<br /> + * In a non-garbage collected environment, this method implements the + * undocumented MacOS-X behavior, and releases the receiver. + */ +- (void) drain; +#endif + +/** + * Destroys the receiver (calls -dealloc). + */ +- (oneway void) release; + +/** + * Raises an exception ... pools should not be retained. + */ +- (id) retain; + +#if OS_API_VERSION(GS_API_NONE, GS_API_NONE) +/** + * <p> + * Counts the number of times that the specified object occurs + * in autorelease pools in the current thread. + * </p> + * <p> + * This method is <em>slow</em> and should probably only be + * used for debugging purposes. + * </p> + */ ++ (unsigned) autoreleaseCountForObject: (id)anObject; + +/** + * Return the currently active autorelease pool. + */ ++ (id) currentPool; + +/** + * <p> + * Specifies whether objects contained in autorelease pools are to + * be released when the pools are deallocated (by default YES). + * </p> + * <p> + * You can set this to NO for debugging purposes. + * </p> + */ ++ (void) enableRelease: (BOOL)enable; + +/** + * <p> + * When autorelease pools are deallocated, the memory they used + * is retained in a cache for re-use so that new polls can be + * created very quickly. + * </p> + * <p> + * This method may be used to empty that cache, ensuring that + * the minimum memory is used by the application. + * </p> + */ ++ (void) freeCache; + +/** + * <p> + * Specifies a limit to the number of objects that may be added to + * an autorelease pool. When this limit is reached an exception is + * raised. + * </p> + * <p> + * You can set this to a smallish value to catch problems with code + * that autoreleases too many objects to operate efficiently. + * </p> + * <p> + * Default value is maxint. + * </p> + */ ++ (void) setPoolCountThreshold: (unsigned)c; + +/** + * Return the number of objects in this pool. + */ +- (unsigned) autoreleaseCount; + +/** + * Empties the current pool by releasing all the autoreleased objects + * in it. Also destroys any child pools (ones created after + * the receiver in the same thread) causing any objects in those pools + * to be released.<br /> + * This is a low cost (efficient) method which may be used to get rid of + * autoreleased objects in the pool, but carry on using the pool. + */ +- (void) emptyPool; +#endif +@end + +#if defined(__cplusplus) +} +#endif + +#endif /* __NSAutoreleasePool_h_GNUSTEP_BASE_INCLUDE */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSDate.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSDate.h new file mode 100644 index 00000000000..dbec39e46e9 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSDate.h @@ -0,0 +1,300 @@ +/* Interface for NSDate for GNUStep + Copyright (C) 1994, 1996, 1999 Free Software Foundation, Inc. + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + */ + +#ifndef __NSDate_h_GNUSTEP_BASE_INCLUDE +#define __NSDate_h_GNUSTEP_BASE_INCLUDE +#import "../GNUstepBase/GSVersionMacros.h" + +#import "NSObjCRuntime.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +GS_EXPORT NSString * const NSSystemClockDidChangeNotification; + +/** + * Time interval difference between two dates, in seconds. + */ +typedef double NSTimeInterval; + +/** + * Time interval between the unix standard reference date of 1 January 1970 + * and the OpenStep reference date of 1 January 2001<br /> + * This number comes from:<br /> + * (((31 years * 365 days) + 8 days for leap years) = total number of days<br /> + * 24 hours * 60 minutes * 60 seconds)<br /> + * This ignores leap-seconds. + */ +GS_EXPORT const NSTimeInterval NSTimeIntervalSince1970; + +#import "NSObject.h" + +@class NSArray; +@class NSCalendarDate; +@class NSData; +@class NSDictionary; +@class NSString; +@class NSTimeZone; +@class NSTimeZoneDetail; + +@interface NSDate : NSObject <NSCoding,NSCopying> +{ +} + +/** Returns an autoreleased instance with the current date/time. + */ ++ (id) date; + +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +/** Returns an autoreleased instance representing the date and time given + * by string. The value of string may be a 'natural' specification as + * specified by the preferences in the user defaults database, allowing + * phrases like 'last tuesday' + */ ++ (id) dateWithNaturalLanguageString: (NSString*)string; + +/** + * <p>Returns an autoreleased instance representing the date and time given + * by string. The value of string may be a 'natural' specification as + * specified by the preferences in the user defaults database, allowing + * phrases like 'last tuesday' + * </p> + * The locale contains keys such as - + * <deflist> + * <term>NSDateTimeOrdering</term> + * <desc>Controls the use of ambiguous numbers. This is done as a + * sequence of the letters D(ay), M(onth), Y(ear), and H(our). + * YMDH means that the first number encountered is assumed to be a + * year, the second a month, the third a day, and the last an hour. + * </desc> + * <term>NSEarlierTimeDesignations</term> + * <desc>An array of strings for times in the past.<br /> + * Defaults are <em>ago</em>, <em>last</em>, <em>past</em>, <em>prior</em> + * </desc> + * <term>NSHourNameDesignations</term> + * <desc>An array of arrays of strings identifying the time of day. + * Each array has an hour as its first value, and one or more words + * as subsequent values.<br /> + * Defaults are: (0, midnight), (10, morning), (12, noon, lunch), + * (14, afternoon), (19, dinner). + * </desc> + * <term>NSLaterTimeDesignations</term> + * <desc>An array of strings for times in the future.<br /> + * Default is <em>next</em> + * </desc> + * <term>NSNextDayDesignations</term> + * <desc>The day after today. Default is <em>tomorrow.</em> + * </desc> + * <term>NSNextNextDayDesignations</term> + * <desc>The day after tomorrow. Default is <em>nextday.</em> + * </desc> + * <term>NSPriorDayDesignations</term> + * <desc>The day before today. Default is <em>yesterday.</em> + * </desc> + * <term>NSThisDayDesignations</term> + * <desc>Identifies the current day. Default is <em>today.</em> + * </desc> + * <term>NSYearMonthWeekDesignations</term> + * <desc>An array giving the word for year, month, and week.<br /> + * Defaults are <em>year</em>, <em>month</em> and <em>week</em>. + * </desc> + * </deflist> + */ ++ (id) dateWithNaturalLanguageString: (NSString*)string + locale: (NSDictionary*)locale; +#endif + +/** Returns an autoreleased instance with the date and time value given + * by the string using the ISO standard format YYYY-MM-DD HH:MM:SS +/-HHHMM + * (all the fields of which must be present). + */ ++ (id) dateWithString: (NSString*)description; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6,GS_API_LATEST) +/** Returns an autoreleased NSDate instance whose value is offset from + * that of the given date by the specified interval in seconds. + */ ++ (id) dateWithTimeInterval: (NSTimeInterval)seconds sinceDate: (NSDate*)date; +#endif + +/** Returns an autoreleased instance with the offset from the unix system + * reference date of 1 January 1970, GMT. + */ ++ (id) dateWithTimeIntervalSince1970: (NSTimeInterval)seconds; + +/** Returns an autoreleased instance with the offset from the current + * date/time given by seconds (which may be fractional). + */ ++ (id) dateWithTimeIntervalSinceNow: (NSTimeInterval)seconds; + +/** Returns an autoreleased instance with the offset from the OpenStep + * reference date of 1 January 2001, GMT. + */ ++ (id) dateWithTimeIntervalSinceReferenceDate: (NSTimeInterval)seconds; + +/** Returns an autoreleased instance with the date/time set in the far + * past. + */ ++ (id) distantPast; + +/** Returns an autoreleased instance with the date/time set in the far + * future. + */ ++ (id) distantFuture; + +/** Returns the time interval between the reference date and the current + * time. + */ ++ (NSTimeInterval) timeIntervalSinceReferenceDate; + +/** Returns an autorelease date instance formed by adding the specified + * time interval in seconds to the receiver's time interval. + */ +- (id) addTimeInterval: (NSTimeInterval)seconds; + +/** Returns the time interval between the receivers value and the + * OpenStep reference date of 1 Jan 2001 GMT. + */ +- (NSComparisonResult) compare: (NSDate*)otherDate; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6,GS_API_LATEST) +/** Returns an autoreleased NSDate instance whose value is offset from + * that of the receiver by the specified interval. + */ +- (id) dateByAddingTimeInterval: (NSTimeInterval)ti; +#endif + +/** Returns an autoreleased instance of the [NSCalendarDate] class whose + * date/time value is the same as that of the receiver, and which uses + * the formatString and timeZone specified. + */ +- (NSCalendarDate*) dateWithCalendarFormat: (NSString*)formatString + timeZone: (NSTimeZone*)timeZone; + +/** Returns a string representation of the receiver formatted according + * to the default format string, time zone, and locale. + */ +- (NSString*) description; + +/** Returns a string representation of the receiver formatted according + * to the specified format string, time zone, and locale. + */ +- (NSString*) descriptionWithCalendarFormat: (NSString*)format + timeZone: (NSTimeZone*)aTimeZone + locale: (NSDictionary*)l; + +/** Returns a string representation of the receiver formatted according + * to the default format string and time zone, but using the given locale. + */ +- (NSString*) descriptionWithLocale: (id)locale; + +/** Returns the earlier of the receiver and otherDate.<br /> + * If the two represent identical date/time values, returns the receiver. + */ +- (NSDate*) earlierDate: (NSDate*)otherDate; + +/** Returns an instance initialised with the current date/time. + */ +- (id) init; + +/** Returns an instance with the date and time value given + * by the string using the ISO standard format YYYY-MM-DD HH:MM:SS +/-HHHMM + * (all the fields of which must be present). + */ +- (id) initWithString: (NSString*)description; + +/** Returns an instance with the given offset from anotherDate. + */ +- (id) initWithTimeInterval: (NSTimeInterval)secsToBeAdded + sinceDate: (NSDate*)anotherDate; + +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +/** Returns an instance with the offset from the unix system + * reference date of 1 January 1970, GMT. + */ +- (id) initWithTimeIntervalSince1970: (NSTimeInterval)seconds; +#endif + +/** Returns an instance with the offset from the current date/time. + */ +- (id) initWithTimeIntervalSinceNow: (NSTimeInterval)secsToBeAdded; + +/** <init /> + * Returns an instance with the given offset from the OpenStep + * reference date of 1 January 2001, GMT. + */ +- (id) initWithTimeIntervalSinceReferenceDate: (NSTimeInterval)secs; + +/** Returns NO if other is not a date, otherwise returns the result of + * calling the -isEqualtoDate: method. + */ +- (BOOL) isEqual: (id)other; + +/** Returns whether the receiver is exactly equal to other, to the limit + * of the NSTimeInterval precision.<br /> + * This is the behavior of the current MacOS-X system, not that of the + * OpenStep specification (which counted two dates within a second of + * each other as being equal).<br /> + * The old behavior meant that two dates equal to a third date were not + * necessarily equal to each other (confusing), and meant that there was + * no reasonable way to use a date as a dictionary key or store dates + * in a set. + */ +- (BOOL) isEqualToDate: (NSDate*)other; + +/** Returns the earlier of the receiver and otherDate.<br /> + * If the two represent identical date/time values, returns the receiver. + */ +- (NSDate*) laterDate: (NSDate*)otherDate; + +/** Returns the time interval between the receivers value and the + * unix system reference date of 1 January 1970, GMT. + */ +- (NSTimeInterval) timeIntervalSince1970; + +/** Returns the time interval between the receivers value and that of the + * otherDate argument. If otherDate is earlier than the receiver, the + * returned value will be positive, if it is later it will be negative.<br /> + * For current (2011) OSX compatibility, this method returns NaN if otherDate + * is nil ... do not write code depending on that behavior. + */ +- (NSTimeInterval) timeIntervalSinceDate: (NSDate*)otherDate; + +/** Returns the time interval between the receivers value and the + * current date/time. If the receiver represents a date/time in + * the past this will be negative, if it is in the future the + * returned value will be positive. + */ +- (NSTimeInterval) timeIntervalSinceNow; + +/** Returns the time interval between the receivers value and the + * OpenStep reference date of 1 Jan 2001 GMT. + */ +- (NSTimeInterval) timeIntervalSinceReferenceDate; + +@end + +#if defined(__cplusplus) +} +#endif + +#endif /* __NSDate_h_GNUSTEP_BASE_INCLUDE*/ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSEnumerator.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSEnumerator.h new file mode 100644 index 00000000000..5f31abdf13d --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSEnumerator.h @@ -0,0 +1,63 @@ +/* + NSEnumerator.h + + Copyright (C) 1998 Free Software Foundation, Inc. + + Author: Scott Christley <scottc@net-community.com> + Date: January 1998 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. +*/ + +#ifndef __NSEnumerator_h_GNUSTEP_BASE_INCLUDE +#define __NSEnumerator_h_GNUSTEP_BASE_INCLUDE +#import "../GNUstepBase/GSVersionMacros.h" + +#import "NSObject.h" + + +#if defined(__cplusplus) +extern "C" { +#endif + +@class GS_GENERIC_CLASS(NSArray, ElementT); + +typedef struct +{ + unsigned long state; + __unsafe_unretained id *itemsPtr; + unsigned long *mutationsPtr; + unsigned long extra[5]; +} NSFastEnumerationState; + +@protocol NSFastEnumeration +- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState *)state + objects: (__unsafe_unretained id[])stackbuf + count: (NSUInteger)len; +@end + +@interface GS_GENERIC_CLASS(NSEnumerator, IterT) : NSObject <NSFastEnumeration> +- (GS_GENERIC_CLASS(NSArray, IterT) *) allObjects; +- (GS_GENERIC_TYPE(IterT)) nextObject; +@end + +#if defined(__cplusplus) +} +#endif + +#endif /* __NSEnumerator_h_GNUSTEP_BASE_INCLUDE */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSGeometry.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSGeometry.h new file mode 100644 index 00000000000..05888b7d206 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSGeometry.h @@ -0,0 +1,609 @@ +/* Interface for NSGeometry routines for GNUStep + * Copyright (C) 1995 Free Software Foundation, Inc. + * + * Written by: Adam Fedor <fedor@boulder.colorado.edu> + * Date: 1995,199 + * + * This file is part of the GNUstep Base Library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02111 USA. + */ + +#ifndef __NSGeometry_h_GNUSTEP_BASE_INCLUDE +#define __NSGeometry_h_GNUSTEP_BASE_INCLUDE +#import "../GNUstepBase/GSVersionMacros.h" + +#import <objc/objc.h> + +#import "NSString.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +/**** Type, Constant, and Macro Definitions **********************************/ + +#ifndef MAX +#define MAX(a,b) \ + ({__typeof__(a) _MAX_a = (a); __typeof__(b) _MAX_b = (b); \ + _MAX_a > _MAX_b ? _MAX_a : _MAX_b; }) +#define GS_DEFINED_MAX +#endif + +#ifndef MIN +#define MIN(a,b) \ + ({__typeof__(a) _MIN_a = (a); __typeof__(b) _MIN_b = (b); \ + _MIN_a < _MIN_b ? _MIN_a : _MIN_b; }) +#define GS_DEFINED_MIN +#endif + +/** +<example>{ + CGFloat x; + CGFloat y; +}</example> + <p>Represents a 2-d cartesian position.</p> */ +typedef struct _NSPoint NSPoint; +struct _NSPoint +{ + CGFloat x; + CGFloat y; +}; + +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +/** Array of NSPoint structs. */ +typedef NSPoint *NSPointArray; +/** Pointer to NSPoint struct. */ +typedef NSPoint *NSPointPointer; +#endif + +/** +<example>{ + CGFloat width; + CGFloat height; +}</example> + <p>Floating point rectangle size.</p> */ +typedef struct _NSSize NSSize; +struct _NSSize +{ + CGFloat width; + CGFloat height; +}; + +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +/** Array of NSSize structs. */ +typedef NSSize *NSSizeArray; +/** Pointer to NSSize struct. */ +typedef NSSize *NSSizePointer; +#endif + +/** +<example>{ + NSPoint origin; + NSSize size; +}</example> + + <p>Rectangle.</p> */ +typedef struct _NSRect NSRect; +struct _NSRect +{ + NSPoint origin; + NSSize size; +}; + +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +/** Array of NSRect structs. */ +typedef NSRect *NSRectArray; +/** Pointer to NSRect struct. */ +typedef NSRect *NSRectPointer; +#endif + +enum +{ + NSMinXEdge = 0, + NSMinYEdge = 1, + NSMaxXEdge = 2, + NSMaxYEdge = 3 +}; +/** Sides of a rectangle. +<example> +{ + NSMinXEdge, + NSMinYEdge, + NSMaxXEdge, + NSMaxYEdge +} +</example> + */ +typedef NSUInteger NSRectEdge; + +/** +<example>{ + CGFloat top; + CGFloat left; + CGFloat bottom; + CGFloat right; +}</example> + + <p>A description of the distance between the edges of two rectangles.</p> */ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST) +typedef struct NSEdgeInsets { + CGFloat top; + CGFloat left; + CGFloat bottom; + CGFloat right; +} NSEdgeInsets; +#endif + +/** Point at 0,0 */ +static const NSPoint NSZeroPoint __attribute__((unused)) = {0.0,0.0}; +/** Zero-size rectangle at 0,0 */ +static const NSRect NSZeroRect __attribute__((unused)) = {{0.0,0.0},{0.0,0.0}}; +/** Zero size */ +static const NSSize NSZeroSize __attribute__((unused)) = {0.0,0.0}; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST) +/** Zero edge insets **/ +static const NSEdgeInsets NSEdgeInsetsZero __attribute__((unused)) = {0.0,0.0,0.0,0.0}; +#endif + +/**** Function Prototypes ****************************************************/ + +/* + * All but the most complex functions are declared static inline in this + * header file so that they are maximally efficient. In order to provide + * true functions (for code modules that don't have this header) this + * header is included in NSGeometry.m where the functions are no longer + * declared inline. + */ +#ifdef IN_NSGEOMETRY_M +#define GS_GEOM_SCOPE extern +#define GS_GEOM_ATTR +#else +#define GS_GEOM_SCOPE static inline +#define GS_GEOM_ATTR __attribute__((unused)) +#endif + +/** Create Basic Structures... **/ + +GS_GEOM_SCOPE NSPoint +NSMakePoint(CGFloat x, CGFloat y) GS_GEOM_ATTR; + +/** Returns an NSPoint having x-coordinate X and y-coordinate Y. */ +GS_GEOM_SCOPE NSPoint +NSMakePoint(CGFloat x, CGFloat y) +{ + NSPoint point; + + point.x = x; + point.y = y; + return point; +} + +GS_GEOM_SCOPE NSSize +NSMakeSize(CGFloat w, CGFloat h) GS_GEOM_ATTR; + +/** Returns an NSSize having width w and height h. */ +GS_GEOM_SCOPE NSSize +NSMakeSize(CGFloat w, CGFloat h) +{ + NSSize size; + + size.width = w; + size.height = h; + return size; +} + +GS_GEOM_SCOPE NSRect +NSMakeRect(CGFloat x, CGFloat y, CGFloat w, CGFloat h) GS_GEOM_ATTR; + +/** Returns an NSRect having point of origin (x, y) and size {w, h}. */ +GS_GEOM_SCOPE NSRect +NSMakeRect(CGFloat x, CGFloat y, CGFloat w, CGFloat h) +{ + NSRect rect; + + rect.origin.x = x; + rect.origin.y = y; + rect.size.width = w; + rect.size.height = h; + return rect; +} + +/** Constructs NSEdgeInsets. **/ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST) +GS_GEOM_SCOPE NSEdgeInsets +NSEdgeInsetsMake(CGFloat top, CGFloat left, + CGFloat bottom, CGFloat right) GS_GEOM_ATTR; + +GS_GEOM_SCOPE NSEdgeInsets +NSEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat bottom, CGFloat right) +{ + NSEdgeInsets edgeInsets; + + edgeInsets.top = top; + edgeInsets.left = left; + edgeInsets.bottom = bottom; + edgeInsets.right = right; + + return edgeInsets; +} + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_10, GS_API_LATEST) +/** Compares two edge insets for equality. **/ +GS_EXPORT BOOL +NSEdgeInsetsEqual(NSEdgeInsets e1, NSEdgeInsets e2); +#endif + +#endif + +/** Get a Rectangle's Coordinates... **/ + +GS_GEOM_SCOPE CGFloat +NSMaxX(NSRect aRect) GS_GEOM_ATTR; + +/** Returns the greatest x-coordinate value still inside aRect. */ +GS_GEOM_SCOPE CGFloat +NSMaxX(NSRect aRect) +{ + return aRect.origin.x + aRect.size.width; +} + +GS_GEOM_SCOPE CGFloat +NSMaxY(NSRect aRect) GS_GEOM_ATTR; + +/** Returns the greatest y-coordinate value still inside aRect. */ +GS_GEOM_SCOPE CGFloat +NSMaxY(NSRect aRect) +{ + return aRect.origin.y + aRect.size.height; +} + +GS_GEOM_SCOPE CGFloat +NSMidX(NSRect aRect) GS_GEOM_ATTR; + +/** Returns the x-coordinate of aRect's middle point. */ +GS_GEOM_SCOPE CGFloat +NSMidX(NSRect aRect) +{ + return aRect.origin.x + (aRect.size.width / 2.0); +} + +GS_GEOM_SCOPE CGFloat +NSMidY(NSRect aRect) GS_GEOM_ATTR; + +/** Returns the y-coordinate of aRect's middle point. */ +GS_GEOM_SCOPE CGFloat +NSMidY(NSRect aRect) +{ + return aRect.origin.y + (aRect.size.height / 2.0); +} + +GS_GEOM_SCOPE CGFloat +NSMinX(NSRect aRect) GS_GEOM_ATTR; + +/** Returns the least x-coordinate value still inside aRect. */ +GS_GEOM_SCOPE CGFloat +NSMinX(NSRect aRect) +{ + return aRect.origin.x; +} + +GS_GEOM_SCOPE CGFloat +NSMinY(NSRect aRect) GS_GEOM_ATTR; + +/** Returns the least y-coordinate value still inside aRect. */ +GS_GEOM_SCOPE CGFloat +NSMinY(NSRect aRect) +{ + return aRect.origin.y; +} + +GS_GEOM_SCOPE CGFloat +NSWidth(NSRect aRect) GS_GEOM_ATTR; + +/** Returns aRect's width. */ +GS_GEOM_SCOPE CGFloat +NSWidth(NSRect aRect) +{ + return aRect.size.width; +} + +GS_GEOM_SCOPE CGFloat +NSHeight(NSRect aRect) GS_GEOM_ATTR; + +/** Returns aRect's height. */ +GS_GEOM_SCOPE CGFloat +NSHeight(NSRect aRect) +{ + return aRect.size.height; +} + +GS_GEOM_SCOPE BOOL +NSIsEmptyRect(NSRect aRect) GS_GEOM_ATTR; + +/** Returns 'YES' iff the area of aRect is zero (i.e., iff either + * of aRect's width or height is negative or zero). */ +GS_GEOM_SCOPE BOOL +NSIsEmptyRect(NSRect aRect) +{ + return ((NSWidth(aRect) > 0) && (NSHeight(aRect) > 0)) ? NO : YES; +} + +/** Modify a Copy of a Rectangle... **/ + +GS_GEOM_SCOPE NSRect +NSOffsetRect(NSRect aRect, CGFloat dx, CGFloat dy) GS_GEOM_ATTR; + +/** Returns the rectangle obtained by translating aRect + * horizontally by dx and vertically by dy. */ +GS_GEOM_SCOPE NSRect +NSOffsetRect(NSRect aRect, CGFloat dx, CGFloat dy) +{ + NSRect rect = aRect; + + rect.origin.x += dx; + rect.origin.y += dy; + return rect; +} + +GS_GEOM_SCOPE NSRect +NSInsetRect(NSRect aRect, CGFloat dX, CGFloat dY) GS_GEOM_ATTR; + +/** Returns the rectangle obtained by moving each of aRect's + * horizontal sides inward by dy and each of aRect's vertical + * sides inward by dx.<br /> + * NB. For MacOS-X compatability, this is permitted to return + * a rectanglew with nagative width or height, strange as that seems. + */ +GS_GEOM_SCOPE NSRect +NSInsetRect(NSRect aRect, CGFloat dX, CGFloat dY) +{ + NSRect rect; + + rect = NSOffsetRect(aRect, dX, dY); + rect.size.width -= (2 * dX); + rect.size.height -= (2 * dY); + return rect; +} + +/** Divides aRect into two rectangles (namely slice and remainder) by + * "cutting" aRect---parallel to, and a distance amount from the given edge + * of aRect. You may pass 0 in as either of slice or + * remainder to avoid obtaining either of the created rectangles. */ +GS_EXPORT void +NSDivideRect(NSRect aRect, + NSRect *slice, + NSRect *remainder, + CGFloat amount, + NSRectEdge edge); + +/** Returns a rectangle obtained by expanding aRect minimally + * so that all four of its defining components are integers. */ +GS_EXPORT NSRect +NSIntegralRect(NSRect aRect); + +/** Compute a Third Rectangle from Two Rectangles... **/ + +GS_GEOM_SCOPE NSRect +NSUnionRect(NSRect aRect, NSRect bRect) GS_GEOM_ATTR; + +/** Returns the smallest rectangle which contains both aRect + * and bRect (modulo a set of measure zero). If either of aRect + * or bRect is an empty rectangle, then the other rectangle is + * returned. If both are empty, then the empty rectangle is returned. */ +GS_GEOM_SCOPE NSRect +NSUnionRect(NSRect aRect, NSRect bRect) +{ + NSRect rect; + + if (NSIsEmptyRect(aRect) && NSIsEmptyRect(bRect)) + return NSMakeRect(0.0,0.0,0.0,0.0); + else if (NSIsEmptyRect(aRect)) + return bRect; + else if (NSIsEmptyRect(bRect)) + return aRect; + + rect = NSMakeRect(MIN(NSMinX(aRect), NSMinX(bRect)), + MIN(NSMinY(aRect), NSMinY(bRect)), 0.0, 0.0); + + rect = NSMakeRect(NSMinX(rect), + NSMinY(rect), + MAX(NSMaxX(aRect), NSMaxX(bRect)) - NSMinX(rect), + MAX(NSMaxY(aRect), NSMaxY(bRect)) - NSMinY(rect)); + + return rect; +} + +GS_GEOM_SCOPE NSRect +NSIntersectionRect(NSRect aRect, NSRect bRect) GS_GEOM_ATTR; + +/** Returns the largest rectangle which lies in both aRect and + * bRect. If aRect and bRect have empty intersection (or, rather, + * intersection of measure zero, since this includes having their + * intersection be only a point or a line), then the empty + * rectangle is returned. */ +GS_GEOM_SCOPE NSRect +NSIntersectionRect (NSRect aRect, NSRect bRect) +{ + if (NSMaxX(aRect) <= NSMinX(bRect) || NSMaxX(bRect) <= NSMinX(aRect) + || NSMaxY(aRect) <= NSMinY(bRect) || NSMaxY(bRect) <= NSMinY(aRect)) + { + return NSMakeRect(0.0, 0.0, 0.0, 0.0); + } + else + { + NSRect rect; + + if (NSMinX(aRect) <= NSMinX(bRect)) + rect.origin.x = bRect.origin.x; + else + rect.origin.x = aRect.origin.x; + + if (NSMinY(aRect) <= NSMinY(bRect)) + rect.origin.y = bRect.origin.y; + else + rect.origin.y = aRect.origin.y; + + if (NSMaxX(aRect) >= NSMaxX(bRect)) + rect.size.width = NSMaxX(bRect) - rect.origin.x; + else + rect.size.width = NSMaxX(aRect) - rect.origin.x; + + if (NSMaxY(aRect) >= NSMaxY(bRect)) + rect.size.height = NSMaxY(bRect) - rect.origin.y; + else + rect.size.height = NSMaxY(aRect) - rect.origin.y; + + return rect; + } +} + +/** Test geometric relationships... **/ + +/** Returns 'YES' iff aRect's and bRect's origin and size are the same. */ +GS_EXPORT BOOL +NSEqualRects(NSRect aRect, NSRect bRect) GS_GEOM_ATTR; + +/** Returns 'YES' iff aSize's and bSize's width and height are the same. */ +GS_EXPORT BOOL +NSEqualSizes(NSSize aSize, NSSize bSize) GS_GEOM_ATTR; + +/** Returns 'YES' iff aPoint's and bPoint's x- and y-coordinates + * are the same. */ +GS_EXPORT BOOL +NSEqualPoints(NSPoint aPoint, NSPoint bPoint) GS_GEOM_ATTR; + +GS_GEOM_SCOPE BOOL +NSMouseInRect(NSPoint aPoint, NSRect aRect, BOOL flipped) GS_GEOM_ATTR; + +/** Returns 'YES' iff aPoint is inside aRect. */ +GS_GEOM_SCOPE BOOL +NSMouseInRect(NSPoint aPoint, NSRect aRect, BOOL flipped) +{ + if (flipped) + { + return ((aPoint.x >= NSMinX(aRect)) + && (aPoint.y >= NSMinY(aRect)) + && (aPoint.x < NSMaxX(aRect)) + && (aPoint.y < NSMaxY(aRect))) ? YES : NO; + } + else + { + return ((aPoint.x >= NSMinX(aRect)) + && (aPoint.y > NSMinY(aRect)) + && (aPoint.x < NSMaxX(aRect)) + && (aPoint.y <= NSMaxY(aRect))) ? YES : NO; + } +} + +GS_GEOM_SCOPE BOOL +NSPointInRect(NSPoint aPoint, NSRect aRect) GS_GEOM_ATTR; + +/** Just like 'NSMouseInRect(aPoint, aRect, YES)'. */ +GS_GEOM_SCOPE BOOL +NSPointInRect(NSPoint aPoint, NSRect aRect) +{ + return NSMouseInRect(aPoint, aRect, YES); +} + +GS_GEOM_SCOPE BOOL +NSContainsRect(NSRect aRect, NSRect bRect) GS_GEOM_ATTR; + +/** Returns 'YES' iff aRect totally encloses bRect. NOTE: For + * this to be the case, aRect cannot be empty, nor can any side + * of bRect go beyond any side of aRect. Note that this behavior + * is different than the original OpenStep behavior, where the sides + * of bRect could not touch aRect. */ +GS_GEOM_SCOPE BOOL +NSContainsRect(NSRect aRect, NSRect bRect) +{ + return (!NSIsEmptyRect(bRect) + && (NSMinX(aRect) <= NSMinX(bRect)) + && (NSMinY(aRect) <= NSMinY(bRect)) + && (NSMaxX(aRect) >= NSMaxX(bRect)) + && (NSMaxY(aRect) >= NSMaxY(bRect))) ? YES : NO; +} + +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +GS_GEOM_SCOPE BOOL +NSIntersectsRect(NSRect aRect, NSRect bRect) GS_GEOM_ATTR; + +/** Returns YES if aRect and bRect have non-zero intersection area + (intersecting at a line or a point doesn't count). */ +GS_GEOM_SCOPE BOOL +NSIntersectsRect(NSRect aRect, NSRect bRect) +{ + /* Note that intersecting at a line or a point doesn't count */ + return (NSMaxX(aRect) <= NSMinX(bRect) + || NSMaxX(bRect) <= NSMinX(aRect) + || NSMaxY(aRect) <= NSMinY(bRect) + || NSMaxY(bRect) <= NSMinY(aRect) + || NSIsEmptyRect(aRect) + || NSIsEmptyRect(bRect)) ? NO : YES; +} +#endif + +/** Get a String Representation... **/ + +#ifdef __OBJC__ +/** Returns an NSString of the form "{x=X; y=Y}", where + * X and Y are the x- and y-coordinates of aPoint, respectively. */ +GS_EXPORT NSString * +NSStringFromPoint(NSPoint aPoint); + +/** Returns an NSString of the form "{x=X; y=Y; width=W; height=H}", + * where X, Y, W, and H are the x-coordinate, y-coordinate, + * width, and height of aRect, respectively. */ +GS_EXPORT NSString * +NSStringFromRect(NSRect aRect); + +/** Returns an NSString of the form "{width=W; height=H}", where + * W and H are the width and height of aSize, respectively. */ +GS_EXPORT NSString * +NSStringFromSize(NSSize aSize); + +/** Parses point from string of form "<code>{x=a; y=b}</code>". (0,0) returned + if parsing fails. */ +GS_EXPORT NSPoint NSPointFromString(NSString* string); + +/** Parses size from string of form "<code>{width=a; height=b}</code>". Size of + 0,0 returned if parsing fails. */ +GS_EXPORT NSSize NSSizeFromString(NSString* string); + +/** Parses point from string of form "<code>{x=a; y=b; width=c; + height=d}</code>". Rectangle of 0 size at origin returned if parsing + fails. +*/ +GS_EXPORT NSRect NSRectFromString(NSString* string); + +#endif /* __OBJC__ */ + +#ifdef GS_DEFINED_MAX +#undef GS_DEFINED_MAX +#undef MAX +#endif + +#ifdef GS_DEFINED_MIN +#undef GS_DEFINED_MIN +#undef MIN +#endif + +#if defined(__cplusplus) +} +#endif + +#endif /* __NSGeometry_h_GNUSTEP_BASE_INCLUDE */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h new file mode 100644 index 00000000000..189af80436a --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h @@ -0,0 +1,317 @@ +/** Interface to ObjC runtime for GNUStep + Copyright (C) 1995, 1997, 2000 Free Software Foundation, Inc. + + Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu> + Date: 1995 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + + AutogsdocSource: NSObjCRuntime.m + AutogsdocSource: NSLog.m + + */ + +#ifndef __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE +#define __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE + +#ifdef __cplusplus +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif +#endif + +#import "../GNUstepBase/GSVersionMacros.h" +#import "../GNUstepBase/GSConfig.h" +#import "../GNUstepBase/GNUstep.h" +#if __BLOCKS__ +#import "../GNUstepBase/GSBlocks.h" +#endif + +#include <stdarg.h> +#include <limits.h> +#include <float.h> + +/* PA HP-UX kludge. */ +#if defined(__hppa__) && defined(__hpux__) && !defined(PRIuPTR) +#define PRIuPTR "lu" +#endif + +/* IRIX kludge. */ +#if defined(__sgi) +/* IRIX 6.5 <inttypes.h> provides all definitions, but only for C99 + compilations. */ +#define PRId8 "hhd" +#define PRIu8 "hhu" +#if (_MIPS_SZLONG == 32) +#define PRId64 "lld" +#define PRIu64 "llu" +#endif +/* This doesn't match <inttypes.h>, which always has "lld" here, but the + arguments are uint64_t, int64_t, which are unsigned long, long for + 64-bit in <sgidefs.h>. */ +#if (_MIPS_SZLONG == 64) +#define PRId64 "ld" +#define PRIu64 "lu" +#endif +/* This doesn't match <inttypes.h>, which has "u" here, but the arguments + are uintptr_t, which is always unsigned long. */ +#define PRIuPTR "lu" +#endif + +/* Solaris < 10 kludge. */ +#if defined(__sun__) && defined(__svr4__) && !defined(PRIuPTR) +#if defined(__arch64__) || defined (__x86_64__) +#define PRIuPTR "lu" +#define PRIdPTR "ld" +#define PRIxPTR "lx" +#else +#define PRIuPTR "u" +#define PRIdPTR "d" +#define PRIxPTR "x" +#endif +#endif + + +/* These typedefs must be in place before GSObjCRuntime.h is imported. + */ + +#if !defined(NSINTEGER_DEFINED) +typedef intptr_t NSInteger; +typedef uintptr_t NSUInteger; +# define NSIntegerMax INTPTR_MAX +# define NSIntegerMin INTPTR_MIN +# define NSUIntegerMax UINTPTR_MAX +#endif /* !defined(NSINTEGER_DEFINED) */ + +#if !defined(CGFLOAT_DEFINED) +#if GS_SIZEOF_VOIDP == 8 +#define CGFLOAT_IS_DBL 1 +typedef double CGFloat; +#define CGFLOAT_MIN DBL_MIN +#define CGFLOAT_MAX DBL_MAX +#else +typedef float CGFloat; +#define CGFLOAT_MIN FLT_MIN +#define CGFLOAT_MAX FLT_MAX +#endif +#endif /* !defined(CGFLOAT_DEFINED) */ + +#define NSINTEGER_DEFINED 1 +#define CGFLOAT_DEFINED 1 +#ifndef NS_AUTOMATED_REFCOUNT_UNAVAILABLE +# if __has_feature(objc_arc) +# define NS_AUTOMATED_REFCOUNT_UNAVAILABLE \ + __attribute__((unavailable("Not available with automatic reference counting"))) +# else +# define NS_AUTOMATED_REFCOUNT_UNAVAILABLE +# endif +#endif + + +#if defined(__cplusplus) +extern "C" { +#endif + + +/* + * We can have strongly typed enums in C++11 mode or when the objc_fixed_enum + * feature is availble. + */ +#if (__has_feature(objc_fixed_enum) || (__cplusplus && (__cplusplus > 199711L) && __has_extension(cxx_strong_enums))) +# define _GS_NAMED_ENUM(ty, name) enum name : ty name; enum name : ty +# define _GS_ANON_ENUM(ty) enum : ty +# if __cplusplus +# define NS_OPTIONS(ty,name) ty name; enum : ty +# else +# define NS_OPTIONS(ty,name) NS_ENUM(ty,name) +# endif +#else // this provides less information, but works with older compilers +# define _GS_NAMED_ENUM(ty, name) ty name; enum +# define _GS_ANON_ENUM(ty) enum +# define NS_OPTIONS(ty, name) NS_ENUM(ty, name) +#endif +// A bit of fairy dust to expand NS_ENUM to the correct variant +#define _GS_GET_ENUM_MACRO(_first,_second,NAME,...) NAME +/* The trick here is that placing the variadic args first will push the name + * that the _GS_GET_ENUM_MACRO expands to into the correct position. + */ +#define NS_ENUM(...) _GS_GET_ENUM_MACRO(__VA_ARGS__,_GS_NAMED_ENUM,_GS_ANON_ENUM)(__VA_ARGS__) + +/* + * If the compiler supports nullability qualifiers, we define the macros for + * non-null sections. + */ +#if __has_feature(nullability) +# define NS_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin") +# define NS_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end") +#else +# define NS_ASSUME_NONNULL_BEGIN +# define NS_ASSUME_NONNULL_END +#endif + +/* + * Backwards compatibility macro for instance type. + */ +#if !__has_feature(objc_instancetype) +# define instancetype id +#endif + +/* + * Backwards compatibility macros for Objective-C lightweight generics. + */ +#if __has_feature(objc_generics) +# define GS_GENERIC_CLASS(clz, ...) clz<__VA_ARGS__> +# define GS_GENERIC_TYPE_F(typeRef, fallback) typeRef +#else +# define GS_GENERIC_CLASS(clz, ...) clz +# define GS_GENERIC_TYPE_F(typeRef, fallback) fallback +#endif +#define GS_GENERIC_TYPE(typeRef) GS_GENERIC_TYPE_F(typeRef, id) + +/** + * Backwards compatibility macro for the objc_designated_initializer attribute + */ +#if __has_attribute(objc_designated_initializer) +# define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) +#else +# define NS_DESIGNATED_INITIALIZER +#endif + +/** Bitfield used to specify options to control enumeration over collections. + */ +typedef NS_OPTIONS(NSUInteger, NSEnumerationOptions) +{ + NSEnumerationConcurrent = (1UL << 0), /** Specifies that the enumeration + * is concurrency-safe. Note that this does not mean that it will be + * carried out in a concurrent manner, only that it can be. + */ + + NSEnumerationReverse = (1UL << 1) /** Specifies that the enumeration should + * happen in the opposite of the natural order of the collection. + */ +}; + + +/** Bitfield used to specify options to control the sorting of collections. + */ +typedef NS_OPTIONS(NSUInteger, NSSortOptions) +{ + NSSortConcurrent = (1UL << 0), /** Specifies that the sort + * is concurrency-safe. Note that this does not mean that it will be + * carried out in a concurrent manner, only that it can be. + */ + NSSortStable = (1UL << 4) /** Specifies that the sort should keep + * equal objects in the same order in the collection. + */ +}; + + +#import "../GNUstepBase/GSObjCRuntime.h" + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5,GS_API_LATEST) +GS_EXPORT NSString *NSStringFromProtocol(Protocol *aProtocol); +GS_EXPORT Protocol *NSProtocolFromString(NSString *aProtocolName); +#endif +GS_EXPORT SEL NSSelectorFromString(NSString *aSelectorName); +GS_EXPORT NSString *NSStringFromSelector(SEL aSelector); +GS_EXPORT SEL NSSelectorFromString(NSString *aSelectorName); +GS_EXPORT Class NSClassFromString(NSString *aClassName); +GS_EXPORT NSString *NSStringFromClass(Class aClass); +GS_EXPORT const char *NSGetSizeAndAlignment(const char *typePtr, + NSUInteger *sizep, NSUInteger *alignp); + +#if OS_API_VERSION(GS_API_NONE, GS_API_NONE) +/* Logging */ +/** + * OpenStep spec states that log messages go to stderr, but just in case + * someone wants them to go somewhere else, they can implement a function + * like this and assign a pointer to it to _NSLog_printf_handler. + */ +typedef void NSLog_printf_handler (NSString* message); +GS_EXPORT NSLog_printf_handler *_NSLog_printf_handler; +GS_EXPORT int _NSLogDescriptor; +@class NSRecursiveLock; +GS_EXPORT NSRecursiveLock *GSLogLock(void); +#endif + +GS_EXPORT void NSLog(NSString *format, ...) NS_FORMAT_FUNCTION(1,2); +GS_EXPORT void NSLogv(NSString *format, va_list args) NS_FORMAT_FUNCTION(1,0); + +#ifndef YES +#define YES 1 +#endif +#ifndef NO +#define NO 0 +#endif +#ifndef nil +#define nil 0 +#endif + +/** + * Contains values <code>NSOrderedSame</code>, <code>NSOrderedAscending</code> + * <code>NSOrderedDescending</code>, for left hand side equals, less than, or + * greater than right hand side. + */ +typedef NS_ENUM(NSInteger, NSComparisonResult) +{ + NSOrderedAscending = (NSInteger)-1, NSOrderedSame, NSOrderedDescending +}; + +enum {NSNotFound = NSIntegerMax}; + +#if __BLOCKS__ +DEFINE_BLOCK_TYPE(NSComparator, NSComparisonResult, id, id); +#endif + +/** + * Declare the foundation export macro as an alias to GS_EXPORT + */ +#define FOUNDATION_EXPORT GS_EXPORT + +#if defined(__cplusplus) +} +#endif + +/** + * Declare Apple availability macros for compatibility purposes as no-ops. + */ +#define NS_CLASS_AVAILABLE(...) +#define NS_AVAILABLE(...) +#define NS_AVAILABLE_MAC(...) +#define NS_DEPRECATED(...) +#define NS_DEPRECATED_MAC(...) +#define NS_ENUM_AVAILABLE(...) +#define NS_ENUM_AVAILABLE_MAC(...) +#define NS_ENUM_DEPRECATED(...) +#define NS_ENUM_DEPRECATED_MAC(...) +#define NS_CLASS_AVAILABLE(...) +#define NS_CLASS_DEPRECATED(...) +#define NS_CLASS_AVAILABLE_MAC(...) +#define NS_CLASS_DEPRECATED_MAC(...) +#define NS_UNAVAILABLE + +/* Define root class NS macro */ +#ifndef NS_ROOT_CLASS +#if __has_attribute(objc_root_class) +#define NS_ROOT_CLASS __attribute__((objc_root_class)) +#else +#define NS_ROOT_CLASS +#endif +#endif + +#endif /* __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObject.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObject.h new file mode 100644 index 00000000000..35647eadab6 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObject.h @@ -0,0 +1,594 @@ +/**Interface for NSObject for GNUStep + Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc. + + Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu> + Date: 1995 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + + AutogsdocSource: NSObject.m + */ + +#ifndef __NSObject_h_GNUSTEP_BASE_INCLUDE +#define __NSObject_h_GNUSTEP_BASE_INCLUDE + +#import "NSObjCRuntime.h" +#import <objc/objc.h> +#import "NSZone.h" + +#ifdef GS_WITH_GC +#undef GS_WITH_GC +#endif +#define GS_WITH_GC 0 + +#import "../GNUstepBase/GNUstep.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +@class NSArchiver; +@class NSArray; +@class NSCoder; +@class NSDictionary; +@class NSPortCoder; +@class NSMethodSignature; +@class NSMutableString; +@class NSRecursiveLock; +@class NSString; +@class NSInvocation; +@class Protocol; + +/** + * The NSObject protocol describes a minimal set of methods that all + * objects are expected to support. You should be able to send any + * of the messages listed in this protocol to an object, and be safe + * in assuming that the receiver can handle it. + */ +@protocol NSObject +/** + * Returns the class of the receiver. If the receiver is a proxy, then this + * may return the class of the proxy target. Use -isProxy to determine whether + * the receiver is a proxy. If you wish to find the real class of the + * receiver, ignoring proxies, then use object_getClass(). + */ +- (Class) class; +/** + * Returns the superclass of receiver's class. If the receiver is a proxy, + * then this may return the class of the proxy target. Use -isProxy to + * determine whether the receiver is a proxy. If you wish to find the real + * superclass of the receiver's class, ignoring proxies, then use + * class_getSuperclass(object_getClass()). + */ +- (Class) superclass; +/** + * Returns whether the receiver is equal to the argument. Defining equality is + * complex, so be careful when implementing this method. Collections such as + * NSSet depend on the behaviour of this method. In particular, this method + * must be commutative, so for any objects a and b: + * + * [a isEqual: b] == [b isEqual: a] + * + * This means that you must be very careful when returning YES if the argument + * is of another class. For example, if you define a number class that returns + * YES if the argument is a string representation of the number, then this will + * break because the string will not recognise your object as being equal to + * itself. + * + * If two objects are equal, then they must have the same hash value, however + * equal hash values do not imply equality. + */ +- (BOOL) isEqual: (id)anObject; +/** + * Returns YES if the receiver is an instance of the class, an instance of the + * subclass, or (in the case of proxies), an instance of something that can be + * treated as an instance of the class. + */ +- (BOOL) isKindOfClass: (Class)aClass; +/** + * Returns YES if the receiver is an instance of the class or (in the case of + * proxies), an instance of something that can be treated as an instance of the + * class. + * + * Calling this method is rarely the correct thing to do. In most cases, a + * subclass can be substituted for a superclass, so you should never need to + * check that an object is really an instance of a specific class and not a + * subclass. + */ +- (BOOL) isMemberOfClass: (Class)aClass; +/** + * Returns YES if the receiver is a proxy, NO otherwise. The default + * implementation of this method in NSObject returns NO, while the + * implementation in NSProxy returns YES. + */ +- (BOOL) isProxy; +/** + * Returns a hash value for the object. All objects that are equal *MUST* + * return the same hash value. For efficient storage in sets, or as keys in + * dictionaries, different objects should return hashes spread evenly over the + * range of an integer. + * + * An object may not return different values from this method after being + * stored in a collection. This typically means that ether the hash value must + * be constant after the object's creation, or that the object may not be + * modified while stored in an unordered collection. + */ +- (NSUInteger) hash; +/** + * Returns the receiver. In a proxy, this may (but is not required to) return + * the proxied object. + */ +- (id) self; +/** + * Performs the specified selector. The selector must correspond to a method + * that takes no arguments. + */ +- (id) performSelector: (SEL)aSelector; +/** + * Performs the specified selector, with the object as the argument. This + * method does not perform any automatic unboxing, so the selector must + * correspond to a method that takes one object argument. + */ +- (id) performSelector: (SEL)aSelector + withObject: (id)anObject; +/** + * Performs the specified selector, with the objects as the arguments. This + * method does not perform any automatic unboxing, so the selector must + * correspond to a method that takes two object arguments. + */ +- (id) performSelector: (SEL)aSelector + withObject: (id)object1 + withObject: (id)object2; +/** + * Returns YES if the object can respond to messages with the specified + * selector. The default implementation in NSObject returns YES if the + * receiver has a method corresponding to the method, but other classes may + * return YES if they can respond to a selector using one of the various + * forwarding mechanisms. + */ +- (BOOL) respondsToSelector: (SEL)aSelector; +/** + * Returns YES if the receiver conforms to the specified protocol. + */ +- (BOOL) conformsToProtocol: (Protocol*)aProtocol; +/** + * Increments the reference count of the object and returns the receiver. In + * garbage collected mode, this method does nothing. In automated reference + * counting mode, you may neither implement this method nor call it directly. + */ +- (id) retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE; +/** + * Decrements the reference count of the object and destroys if it there are no + * remaining references. In garbage collected mode, this method does nothing. + * In automated reference counting mode, you may neither implement this method + * nor call it directly. + */ +- (oneway void) release NS_AUTOMATED_REFCOUNT_UNAVAILABLE; +/** + * Performs a deferred -release operation. The object's reference count is + * decremented at the end of the scope of the current autorelease pool, + * identified either by a -drain message sent to the current NSAutoreleasePool + * instance, or in more recent versions of Objective-C by the end of an + * @autorelease_pool scope. + * + * In garbage collected mode, this method does nothing. In automated reference + * counting mode, you may neither implement this method nor call it directly. + */ +- (id) autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE; +/** + * Returns the current retain count of an object. This does not include the + * result of any pending autorelease operations. + * + * Code that relies on this method returning a sane value is broken. For + * singletons, it may return NSUIntegerMax. Even when it is tracking a retain + * count, it will not include on-stack pointers in manual retain/release mode, + * pointers marked as __unsafe_unretain or __weak in ARC mode, or pending + * autorelease operations. Its value is therefore largely meaningless. It can + * occasionally be useful for debugging. + */ +- (NSUInteger) retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE; +/** + * Returns the description of the object. This is used by the %@ format + * specifier in strings. + */ +- (NSString*) description; +/** + * Returns the zone of the object. + */ +- (NSZone*) zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE; +@end + +/** + * This protocol must be adopted by any class wishing to support copying - + * ie where instances of the class should be able to create new instances + * which are copies of the original and, where a class has mutable and + * immutable versions, where the copies are immutable. + */ +@protocol NSCopying +/** + * Called by [NSObject-copy] passing NSDefaultMallocZone() as zone.<br /> + * This method returns a copy of the receiver and, where the receiver is a + * mutable variant of a class which has an immutable partner class, the + * object returned is an instance of that immutable class.<br /> + * The new object is <em>not</em> autoreleased, and is considered to be + * 'owned' by the calling code ... which is therefore responsible for + * releasing it.<br /> + * In the case where the receiver is an instance of a container class, + * it is undefined whether contained objects are merely retained in the + * new copy, or are themselves copied, or whether some other mechanism + * entirely is used. + */ +- (id) copyWithZone: (NSZone*)zone; +@end + +/** + * This protocol must be adopted by any class wishing to support + * mutable copying - ie where instances of the class should be able + * to create mutable copies of themselves. + */ +@protocol NSMutableCopying +/** + * Called by [NSObject-mutableCopy] passing NSDefaultMallocZone() as zone.<br /> + * This method returns a copy of the receiver and, where the receiver is an + * immutable variant of a class which has a mutable partner class, the + * object returned is an instance of that mutable class. + * The new object is <em>not</em> autoreleased, and is considered to be + * 'owned' by the calling code ... which is therefore responsible for + * releasing it.<br /> + * In the case where the receiver is an instance of a container class, + * it is undefined whether contained objects are merely retained in the + * new copy, or are themselves copied, or whether some other mechanism + * entirely is used. + */ +- (id) mutableCopyWithZone: (NSZone*)zone; +@end + +/** + * This protocol must be adopted by any class wishing to support + * saving and restoring instances to an archive, or copying them + * to remote processes via the Distributed Objects mechanism. + */ +@protocol NSCoding + +/** + * Called when it is time for receiver to be serialized for writing to an + * archive or network connection. Receiver should record all of its instance + * variables using methods on aCoder. See documentation for [NSCoder], + * [NSArchiver], [NSKeyedArchiver], and/or [NSPortCoder] for more information. + */ +- (void) encodeWithCoder: (NSCoder*)aCoder; + +/** + * Called on a freshly allocated receiver when it is time to reconstitute from + * serialized bytes in an archive or from a network connection. Receiver + * should load all of its instance variables using methods on aCoder. See + * documentation for [NSCoder], [NSUnarchiver], [NSKeyedUnarchiver], and/or + * [NSPortCoder] for more information. + */ +- (id) initWithCoder: (NSCoder*)aDecoder; +@end + +@protocol NSSecureCoding <NSCoding> ++ (BOOL)supportsSecureCoding; +@end + + +GS_ROOT_CLASS @interface NSObject <NSObject> +{ + /** + * Points to instance's class. Used by runtime to access method + * implementations, etc.. Set in +alloc, Unlike other instance variables, + * which are cleared there. + */ + Class isa; +} + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) +/** On a system which performs garbage collection, you should implement + * this method to execute code when the receiver is collected.<br /> + * You must not call this method yourself (except when a subclass + * calls the superclass method within its own implementation). + */ +- (void) finalize; +#endif + +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +- (NSString*) className; +#endif + ++ (id) allocWithZone: (NSZone*)z; ++ (id) alloc; ++ (Class) class; + +/** + * This method is automatically invoked on any class which implements it + * when the class is loaded into the runtime.<br /> + * It is also invoked on any category where the method is implemented + * when that category is loaded into the runtime.<br /> + * The +load method is called directly by the runtime and you should never + * send a +load message to a class yourself.<br /> + * This method is called <em>before</em> the +initialize message is sent + * to the class, so you cannot depend on class initialisation having been + * performed, or upon other classes existing (apart from superclasses of + * the receiver, since +load is called on superclasses before it is called + * on their subclasses).<br /> + * As a gross generalisation, it is safe to use C code, including + * most ObjectiveC runtime functions within +load, but attempting to send + * messages to ObjectiveC objects is likely to fail.<br /> + * In GNUstep, this method is implemented for NSObject to perform some + * initialisation for the base library.<br /> + * If you implement +load for a class, don't call [super load] in your + * implementation. + */ ++ (void) load; + +/** + * This message is automatically sent to a class by the runtime. It is + * sent once for each class, just before the class is used for the first + * time (excluding any automatic call to +load by the runtime).<br /> + * The message is sent in a thread-safe manner ... other threads may not + * call methods of the class until +initialize has finished executing.<br /> + * If the class has a superclass, its implementation of +initialize is + * called first.<br /> + * If the class does not implement +initialize then the implementation + * in the closest superclass may be called. This means that +initialize may + * be called more than once, and the recommended way to handle this by + * using the + * <code> + * if (self == [classname class]) + * </code> + * conditional to check whether the method is being called for a subclass.<br /> + * You should never call +initialize yourself ... let the runtime do it.<br /> + * You can implement +initialize in your own class if you need to. + * NSObject's implementation handles essential root object and base + * library initialization.<br /> + * It should be safe to call [super initialize] in your implementation + * of +initialize. + */ ++ (void) initialize; ++ (IMP) instanceMethodForSelector: (SEL)aSelector; ++ (NSMethodSignature*) instanceMethodSignatureForSelector: (SEL)aSelector; ++ (BOOL) instancesRespondToSelector: (SEL)aSelector; ++ (BOOL) isSubclassOfClass: (Class)aClass; ++ (id) new; ++ (void) poseAsClass: (Class)aClassObject; ++ (id) setVersion: (NSInteger)aVersion; ++ (NSInteger) version; + +- (id) awakeAfterUsingCoder: (NSCoder*)aDecoder; +- (Class) classForArchiver; +- (Class) classForCoder; +- (id) copy; +- (void) dealloc; +- (void) doesNotRecognizeSelector: (SEL)aSelector; +- (void) forwardInvocation: (NSInvocation*)anInvocation; +- (id) init; +- (IMP) methodForSelector: (SEL)aSelector; +- (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector; +- (id) mutableCopy; +- (id) replacementObjectForArchiver: (NSArchiver*)anArchiver; +- (id) replacementObjectForCoder: (NSCoder*)anEncoder; +- (Class) superclass; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) +/** + * This method will be called when attempting to send a message a class that + * does not understand it. The class may install a new method for the given + * selector and return YES, otherwise it should return NO. + * + * Note: This method is only reliable when using the GNUstep runtime. If you + * require compatibility with the GCC runtime, you must also implement + * -forwardInvocation: with equivalent semantics. This will be considerably + * slower, but more portable. + */ ++ (BOOL) resolveClassMethod: (SEL)name; + +/** + * This method will be called when attempting to send a message an instance + * that does not understand it. The class may install a new method for the + * given selector and return YES, otherwise it should return NO. + * + * Note: This method is only reliable when using the GNUstep runtime. If you + * require compatibility with the GCC runtime, you must also implement + * -forwardInvocation: with equivalent semantics. This will be considerably + * slower, but more portable. + */ ++ (BOOL) resolveInstanceMethod: (SEL)name; +#endif +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) +/** + * Returns an auto-accessing proxy for the given object. This proxy sends a + * -beginContentAccess message to the receiver when it is created and an + * -endContentAccess message when it is destroyed. This prevents an object + * that implements the NSDiscardableContent protocol from having its contents + * discarded for as long as the proxy exists. + * + * On systems using the GNUstep runtime, messages send to the proxy will be + * slightly slower than direct messages. With the GCC runtime, they will be + * approximately two orders of magnitude slower. The GNUstep runtime, + * therefore, is strongly recommended for code calling this method. + */ +- (id) autoContentAccessingProxy; + +/** + * If an object does not understand a message, it may delegate it to another + * object. Returning nil indicates that forwarding should not take place. The + * default implementation of this returns nil, but care should be taken when + * subclassing NSObject subclasses and overriding this method that + * the superclass implementation is called if returning nil. + * + * Note: This method is only reliable when using the GNUstep runtime and code + * compiled with clang. If you require compatibility with GCC and the GCC + * runtime, you must also implement -forwardInvocation: with equivalent + * semantics. This will be considerably slower, but more portable. + */ +- (id) forwardingTargetForSelector: (SEL)aSelector; + +#endif +@end + +/** + * Used to allocate memory to hold an object, and initialise the + * class of the object to be aClass etc. The allocated memory will + * be extraBytes larger than the space actually needed to hold the + * instance variables of the object.<br /> + * This function is used by the [NSObject+allocWithZone:] method. + */ +GS_EXPORT id +NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); + +/** + * Used to release the memory used by an object.<br /> + * This function is used by the [NSObject-dealloc] method. + */ +GS_EXPORT void +NSDeallocateObject(id anObject); + +/** + * Used to copy anObject. This makes a bitwise copy of anObject to + * memory allocated from zone. The allocated memory will be extraBytes + * longer than that necessary to actually store the instance variables + * of the copied object.<br /> + */ +GS_EXPORT NSObject * +NSCopyObject(NSObject *anObject, NSUInteger extraBytes, NSZone *zone); + +/** + * Returns a flag to indicate whether anObject should be retained or + * copied in order to make a copy in the specified zone.<br /> + * Basically, this tests to see if anObject was allocated from + * requestedZone and returns YES if it was. + */ +GS_EXPORT BOOL +NSShouldRetainWithZone(NSObject *anObject, NSZone *requestedZone); + +GS_EXPORT BOOL +NSDecrementExtraRefCountWasZero(id anObject); + +GS_EXPORT NSUInteger +NSExtraRefCount(id anObject); + +GS_EXPORT void +NSIncrementExtraRefCount(id anObject); + +#if OS_API_VERSION(GS_API_NONE, GS_API_NONE) + +/** Global lock to be used by classes when operating on any global + data that invoke other methods which also access global; thus, + creating the potential for deadlock. */ +GS_EXPORT NSRecursiveLock *gnustep_global_lock; + +@interface NSObject (NEXTSTEP) +- (id) error:(const char *)aString, ...; +/* - (const char *) name; + Removed because OpenStep has -(NSString*)name; */ +@end + +#if GS_API_VERSION(GS_API_NONE, 011700) +@interface NSObject (GNUstep) ++ (void) enableDoubleReleaseCheck: (BOOL)enable; +@end +#endif + +#endif + +#import "NSDate.h" +/** + * Declares some methods for sending messages to self after a fixed delay. + * (These methods <em>are</em> in OpenStep and OS X.) + */ +@interface NSObject (TimedPerformers) + +/** + * Cancels any perform operations set up for the specified target + * in the current run loop. + */ ++ (void) cancelPreviousPerformRequestsWithTarget: (id)obj; + +/** + * Cancels any perform operations set up for the specified target + * in the current loop, but only if the value of aSelector and argument + * with which the performs were set up match those supplied.<br /> + * Matching of the argument may be either by pointer equality or by + * use of the [NSObject-isEqual:] method. + */ ++ (void) cancelPreviousPerformRequestsWithTarget: (id)obj + selector: (SEL)s + object: (id)arg; +/** + * Sets given message to be sent to this instance after given delay, + * in any run loop mode. See [NSRunLoop]. + */ +- (void) performSelector: (SEL)s + withObject: (id)arg + afterDelay: (NSTimeInterval)seconds; + +/** + * Sets given message to be sent to this instance after given delay, + * in given run loop modes. See [NSRunLoop]. + */ +- (void) performSelector: (SEL)s + withObject: (id)arg + afterDelay: (NSTimeInterval)seconds + inModes: (NSArray*)modes; +@end + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) +/** + * The NSDiscardableContent protocol is used by objects which encapsulate data + * which may be discarded if resource constraints are exceeded. These + * constraints are typically, but not always, related memory. + */ +@protocol NSDiscardableContent + +/** + * This method is called before any access to the object. It returns YES if + * the object's content is still valid. The caller must call -endContentAccess + * once for every call to -beginContentAccess; + */ +- (BOOL) beginContentAccess; + +/** + * Discards the contents of the object if it is not currently being edited. + */ +- (void) discardContentIfPossible; + +/** + * This method indicates that the caller has finished accessing the contents of + * the object adopting this protocol. Every call to -beginContentAccess must + * be be paired with a call to this method after the caller has finished + * accessing the contents. + */ +- (void) endContentAccess; + +/** + * Returns YES if the contents of the object have been discarded, either via a + * call to -discardContentIfPossible while the object is not in use, or by some + * implementation dependent mechanism. + */ +- (BOOL) isContentDiscarded; +@end +#endif +#if defined(__cplusplus) +} +#endif + +#if !NO_GNUSTEP && !defined(GNUSTEP_BASE_INTERNAL) +#import "../GNUstepBase/NSObject+GNUstepBase.h" +#endif + +#endif /* __NSObject_h_GNUSTEP_BASE_INCLUDE */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSRange.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSRange.h new file mode 100644 index 00000000000..845d44ac2d5 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSRange.h @@ -0,0 +1,235 @@ +/* + * Copyright (C) 1995,1999 Free Software Foundation, Inc. + * + * Written by: Adam Fedor <fedor@boulder.colorado.edu> + * Date: 1995 + * + * This file is part of the GNUstep Base Library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02111 USA. + */ + +#ifndef __NSRange_h_GNUSTEP_BASE_INCLUDE +#define __NSRange_h_GNUSTEP_BASE_INCLUDE +#import "../GNUstepBase/GSVersionMacros.h" + +/**** Included Headers *******************************************************/ + +#import "NSObject.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +@class NSException; +@class NXConstantString; + +/**** Type, Constant, and Macro Definitions **********************************/ + +#ifndef MAX +#define MAX(a,b) \ + ({__typeof__(a) _MAX_a = (a); __typeof__(b) _MAX_b = (b); \ + _MAX_a > _MAX_b ? _MAX_a : _MAX_b; }) +#define GS_DEFINED_MAX +#endif + +#ifndef MIN +#define MIN(a,b) \ + ({__typeof__(a) _MIN_a = (a); __typeof__(b) _MIN_b = (b); \ + _MIN_a < _MIN_b ? _MIN_a : _MIN_b; }) +#define GS_DEFINED_MIN +#endif + +/** + * <example> +{ + NSUInteger location; + NSUInteger length; +}</example> + * <p> + * The NSRange type is used to specify ranges of locations, + * typically items in an array, characters in a string, and bytes + * in a data object. + * </p> + * <p> + * As 'boundary' or 'fencepost' errors are a particularly common + * problem in programming, it is important that you understand + * how an NSRange works. + * </p> + * <p> + * An NSRange consists of a <em>location</em> and a <em>length</em>. The + * points that are considered to lie in a range are the integers from + * the location to the location plus the length, so the number + * of points in a range is the length of the range plus one.<br /> + * However, if you consider these points like the marks on a + * ruler, you can only store information <strong>between</strong> + * points. So the number of items that can be stored in a range + * is the length of the range. + * </p> + */ +typedef struct _NSRange NSRange; +struct _NSRange +{ + NSUInteger location; + NSUInteger length; +}; + +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +/** Pointer to an NSRange structure. */ +typedef NSRange *NSRangePointer; +#endif + +/**** Function Prototypes ****************************************************/ + +/* + * All but the most complex functions are declared static inline in this + * header file so that they are maximally efficient. In order to provide + * true functions (for code modules that don't have this header) this + * header is included in NSRange.m where the functions are no longer + * declared inline. + */ +#ifdef IN_NSRANGE_M +#define GS_RANGE_SCOPE extern +#define GS_RANGE_ATTR +#else +#define GS_RANGE_SCOPE static inline +#define GS_RANGE_ATTR __attribute__((unused)) +#endif + +GS_RANGE_SCOPE NSUInteger +NSMaxRange(NSRange range) GS_RANGE_ATTR; + +/** Returns top end of range (location + length). */ +GS_RANGE_SCOPE NSUInteger +NSMaxRange(NSRange range) +{ + return range.location + range.length; +} + +GS_RANGE_SCOPE BOOL +NSLocationInRange(NSUInteger location, NSRange range) GS_RANGE_ATTR; + +/** Returns whether location is greater than or equal to range's location + * and less than its max. + */ +GS_RANGE_SCOPE BOOL +NSLocationInRange(NSUInteger location, NSRange range) +{ + return (location >= range.location) && (location < NSMaxRange(range)); +} + +/** Convenience method for raising an NSRangeException. */ +GS_EXPORT void _NSRangeExceptionRaise (void); +/* NB: The implementation of _NSRangeExceptionRaise is: + [NSException raise: NSRangeException + format: @"Range location + length too great"]; + + _NSRangeExceptionRaise is defined in NSRange.m so that this + file (NSRange.h) can be included without problems in the + implementation of the base classes themselves. */ + +GS_RANGE_SCOPE NSRange +NSMakeRange(NSUInteger location, NSUInteger length) GS_RANGE_ATTR; + +/** Creates new range starting at location and of given length. */ +GS_RANGE_SCOPE NSRange +NSMakeRange(NSUInteger location, NSUInteger length) +{ + NSRange range; + NSUInteger end = location + length; + + if (end < location || end < length) + { + _NSRangeExceptionRaise (); + } + range.location = location; + range.length = length; + return range; +} + +GS_RANGE_SCOPE BOOL +NSEqualRanges(NSRange range1, NSRange range2) GS_RANGE_ATTR; + +/** Returns whether range1 and range2 have same location and length. */ +GS_RANGE_SCOPE BOOL +NSEqualRanges(NSRange range1, NSRange range2) +{ + return ((range1.location == range2.location) + && (range1.length == range2.length)); +} + +GS_RANGE_SCOPE NSRange +NSUnionRange(NSRange range1, NSRange range2) GS_RANGE_ATTR; + +/** Returns range going from minimum of aRange's and bRange's locations to + maximum of their two max's. */ +GS_RANGE_SCOPE NSRange +NSUnionRange(NSRange aRange, NSRange bRange) +{ + NSRange range; + + range.location = MIN(aRange.location, bRange.location); + range.length = MAX(NSMaxRange(aRange), NSMaxRange(bRange)) + - range.location; + return range; +} + +GS_RANGE_SCOPE NSRange +NSIntersectionRange(NSRange range1, NSRange range2) GS_RANGE_ATTR; + +/** Returns range containing indices existing in both aRange and bRange. If + * the returned length is 0, the location is undefined and should be ignored. + */ +GS_RANGE_SCOPE NSRange +NSIntersectionRange (NSRange aRange, NSRange bRange) +{ + NSRange range; + + if (NSMaxRange(aRange) < bRange.location + || NSMaxRange(bRange) < aRange.location) + return NSMakeRange(0, 0); + + range.location = MAX(aRange.location, bRange.location); + range.length = MIN(NSMaxRange(aRange), NSMaxRange(bRange)) + - range.location; + return range; +} + + +@class NSString; + +/** Returns string of form {location=a, length=b}. */ +GS_EXPORT NSString *NSStringFromRange(NSRange range); + +/** Parses range from string of form {location=a, length=b}; returns range + with 0 location and length if this fails. */ +GS_EXPORT NSRange NSRangeFromString(NSString *aString); + +#ifdef GS_DEFINED_MAX +#undef GS_DEFINED_MAX +#undef MAX +#endif + +#ifdef GS_DEFINED_MIN +#undef GS_DEFINED_MIN +#undef MIN +#endif + +#if defined(__cplusplus) +} +#endif + +#endif /* __NSRange_h_GNUSTEP_BASE_INCLUDE */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSString.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSString.h new file mode 100644 index 00000000000..7863d9404f9 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSString.h @@ -0,0 +1,977 @@ +/* Interface for NSString for GNUstep + Copyright (C) 1995, 1996, 1999 Free Software Foundation, Inc. + + Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu> + Date: 1995 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + */ + +/** +<chapter> + <heading>Portable path handling</heading> + <p>Portable path handling (across both unix-like and mswindows operating + systems) requires some care. A modern operating system uses the concept + of a single root to the filesystem, but mswindows has multiple filesystems + with no common root, so code must be aware of this. There is also the + more minor issue that windows often uses a backslash as a separator between + the components of a path and unix-like systems always use forward slash.<br /> + On windows there is also the issue that two styles of path are used, + most commonly with a drive letter and a path on that drive + (eg. 'C:\directory\file') but also UNC paths + (eg. '//host/share/directory/file') so path handling functions must deal + with both formats. + </p> + <p>GNUstep has three path handling modes, 'gnustep', 'unix', and 'windows'. + The mode defaults to 'gnustep' but may be set using the GSPathHandling() + function.<br /> + You should probably stick to using the default 'gnustep' mode in which the + path handling methods cope with both 'unix' and 'windows' style paths in + portable and tolerant manner:<br /> + Paths are read in literally so they can be in the native format provided + by the operating system or in a non-native format. See + [NSFileManager-stringWithFileSystemRepresentation:length:].<br /> + Paths are written out using the native format of the system the application + is running on (eg on windows slashes are converted to backslashes). + See [NSFileManager-fileSystemRepresentationWithPath:].<br /> + The path handling methods accept either a forward or backward slash as a + path separator when parsing any path.<br /> + Unless operating in 'unix' mode, a leading letter followed by a colon is + considered the start of a windows style path (the drive specifier), and a + path beginning with something of the form '//host/share/' is considered + the start of a UNC style path.<br /> + The path handling methods add forward slashes when building new paths + internally or when standardising paths, so those path strings provide + a portable representation (as long as they are relative paths, not including + system specific roots).<br /> + An important case to note is that on windows a path which looks at first + glance like an absolute path may actually be a relative one.<br /> + 'C:file' is a relative path because it specifies a file on the C drive + but does not say what directory it is in.<br /> +Similarly, '/dir/file' is a relative path because it specifies the full +location fo a file on a drive, but does not specify which drive it is on. + </p> +<p>As a consequence of this path handling, you are able to work completely +portably using relative paths (adding components, extensions and +relative paths to a pth, or removing components, extensions and relative +paths from a path etc), and when you save paths as strings in files +which may be transferred to another platform, you should save a relative +path.<br /> +When you need to know absolute paths of various points in the filesystem, +you can use various path utility functions to obtain those absolute paths. +For instance, instead of saving an absolute path to a file, you might want +to save a path relative to a user's home directory. You could do that by +calling NSHomeDirectory() to get the home directory, and only saving the +part of the full path after that prefix. +</p> +</chapter> + */ + +#ifndef __NSString_h_GNUSTEP_BASE_INCLUDE +#define __NSString_h_GNUSTEP_BASE_INCLUDE +#import "../GNUstepBase/GSVersionMacros.h" + +#import "NSObject.h" +#import "NSRange.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +/** + * Type for representing unicode characters. (16-bit) + */ +typedef uint16_t unichar; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5,GS_API_LATEST) +#define NSMaximumStringLength (INT_MAX-1) +#endif + +@class NSArray; +@class NSCharacterSet; +@class NSData; +@class NSDictionary; +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +@class NSError; +@class NSLocale; +@class NSURL; +#endif + +#define NSMaximumStringLength (INT_MAX-1) + +enum +{ + NSCaseInsensitiveSearch = 1, + NSLiteralSearch = 2, + NSBackwardsSearch = 4, + NSAnchoredSearch = 8, + NSNumericSearch = 64 /* MacOS-X 10.2 */ +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5,GS_API_LATEST) + , + NSDiacriticInsensitiveSearch = 128, + NSWidthInsensitiveSearch = 256, + NSForcedOrderingSearch = 512 +#endif +#if OS_API_VERSION(MAC_OS_X_VERSION_10_7,GS_API_LATEST) + , + /** + * Treats the search string as a regular expression. This option may be + * combined with NSCaseInsensitiveSearch and NSAnchoredSearch, but no other + * search options. + * + * This option may only be used with the -rangeOfString: family of methods. + */ + NSRegularExpressionSearch = 1024 +#endif +}; +typedef NSUInteger NSStringCompareOptions; + +/** + * <p>Enumeration of available encodings for converting between bytes and + * characters (in [NSString]s). The ones that are shared with OpenStep and + * Cocoa are: <code>NSASCIIStringEncoding, NSNEXTSTEPStringEncoding, + * NSJapaneseEUCStringEncoding, NSUTF8StringEncoding, + * NSISOLatin1StringEncoding, NSSymbolStringEncoding, + * NSNonLossyASCIIStringEncoding, NSShiftJISStringEncoding, + * NSISOLatin2StringEncoding, NSUnicodeStringEncoding, + * NSWindowsCP1251StringEncoding, NSWindowsCP1252StringEncoding, + * NSWindowsCP1253StringEncoding, NSWindowsCP1254StringEncoding, + * NSWindowsCP1250StringEncoding, NSISO2022JPStringEncoding, + * NSMacOSRomanStringEncoding, NSProprietaryStringEncoding</code>.</p> + * + * <p>Additional encodings available under GNUstep are: + * <code>NSKOI8RStringEncoding, NSISOLatin3StringEncoding, + * NSISOLatin4StringEncoding, NSISOCyrillicStringEncoding, + * NSISOArabicStringEncoding, NSISOGreekStringEncoding, + * NSISOHebrewStringEncoding, NSISOLatin5StringEncoding, + * NSISOLatin6StringEncoding, NSISOThaiStringEncoding, + * NSISOLatin7StringEncoding, NSISOLatin8StringEncoding, + * NSISOLatin9StringEncoding, NSGB2312StringEncoding, NSUTF7StringEncoding, + * NSGSM0338StringEncoding, NSBIG5StringEncoding, + * NSKoreanEUCStringEncoding</code>.</p> + */ +typedef enum _NSStringEncoding +{ +/* NB. Must not have an encoding with value zero - so we can use zero to + tell that a variable that should contain an encoding has not yet been + initialised */ + GSUndefinedEncoding = 0, + NSASCIIStringEncoding = 1, + NSNEXTSTEPStringEncoding = 2, + NSJapaneseEUCStringEncoding = 3, + NSUTF8StringEncoding = 4, + NSISOLatin1StringEncoding = 5, // ISO-8859-1; West European + NSSymbolStringEncoding = 6, + NSNonLossyASCIIStringEncoding = 7, + NSShiftJISStringEncoding = 8, + NSISOLatin2StringEncoding = 9, // ISO-8859-2; East European + NSUnicodeStringEncoding = 10, + NSUTF16StringEncoding = NSUnicodeStringEncoding, // An alias + NSWindowsCP1251StringEncoding = 11, + NSWindowsCP1252StringEncoding = 12, // WinLatin1 + NSWindowsCP1253StringEncoding = 13, // Greek + NSWindowsCP1254StringEncoding = 14, // Turkish + NSWindowsCP1250StringEncoding = 15, // WinLatin2 + NSISO2022JPStringEncoding = 21, + NSMacOSRomanStringEncoding = 30, + NSProprietaryStringEncoding = 31, + + NSKOI8RStringEncoding = 50, // Russian/Cyrillic + NSISOLatin3StringEncoding = 51, // ISO-8859-3; South European + NSISOLatin4StringEncoding = 52, // ISO-8859-4; North European + NSISOCyrillicStringEncoding = 22, // ISO-8859-5 + NSISOArabicStringEncoding = 53, // ISO-8859-6 + NSISOGreekStringEncoding = 54, // ISO-8859-7 + NSISOHebrewStringEncoding = 55, // ISO-8859-8 + NSISOLatin5StringEncoding = 57, // ISO-8859-9; Turkish + NSISOLatin6StringEncoding = 58, // ISO-8859-10; Nordic + NSISOThaiStringEncoding = 59, // ISO-8859-11 +/* Possible future ISO-8859 additions + // ISO-8859-12 +*/ + NSISOLatin7StringEncoding = 61, // ISO-8859-13 + NSISOLatin8StringEncoding = 62, // ISO-8859-14 + NSISOLatin9StringEncoding = 63, // ISO-8859-15; Replaces ISOLatin1 + NSGB2312StringEncoding = 56, + NSUTF7StringEncoding = 64, // RFC 2152 + NSGSM0338StringEncoding, // GSM (mobile phone) default alphabet + NSBIG5StringEncoding, // Traditional chinese + NSKoreanEUCStringEncoding // Korean + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4,GS_API_LATEST) + , + NSUTF16BigEndianStringEncoding = 0x90000100, + NSUTF16LittleEndianStringEncoding = 0x94000100, + NSUTF32StringEncoding = 0x8c000100, + NSUTF32BigEndianStringEncoding = 0x98000100, + NSUTF32LittleEndianStringEncoding = 0x9c000100 +#endif +} NSStringEncoding; + +enum { + NSOpenStepUnicodeReservedBase = 0xF400 +}; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4,GS_API_LATEST) +enum { + NSStringEncodingConversionAllowLossy = 1, + NSStringEncodingConversionExternalRepresentation = 2 +}; +typedef NSUInteger NSStringEncodingConversionOptions; +#endif + +/** + * <p> + * <code>NSString</code> objects represent an immutable string of Unicode 3.0 + * characters. These may be accessed individually as type + * <code>unichar</code>, an unsigned short.<br/> + * The [NSMutableString] subclass represents a modifiable string. Both are + * implemented as part of a class cluster and the instances you receive may + * actually be of unspecified concrete subclasses. + * </p> + * <p> + * A constant <code>NSString</code> can be created using the following syntax: + * <code>@"..."</code>, where the contents of the quotes are the + * string, using only ASCII characters. + * </p> + * <p> + * A variable string can be created using a C printf-like <em>format</em>, + * as in <code>[NSString stringWithFormat: @"Total is %f", t]</code>. + * </p> + * <p> + * To create a concrete subclass of <code>NSString</code>, you must have your + * class inherit from <code>NSString</code> and override at least the two + * primitive methods - -length and -characterAtIndex: + * </p> + * <p> + * In general the rule is that your subclass must override any + * initialiser that you want to use with it. The GNUstep + * implementation relaxes that to say that, you may override + * only the <em>designated initialiser</em> and the other + * initialisation methods should work. + * </p> + * <p> + * Where an NSString instance method returns an NSString object, + * the class of the actual object returned may be any subclass + * of NSString. The actual value returned may be a new + * autoreleased object, an autoreleased copy of the receiver, + * or the receiver itsself. While the abstract base class + * implementations of methods (other than initialisers) will + * avoid returning mutable strings by returning an autoreleased + * copy of a mutable receiver, concrete subclasses may behave + * differently, so code should not rely upon the mutability of + * returned strings nor upon their lifetime being greater than + * that of the receiver which returned them. + * </p> + */ +@interface NSString :NSObject <NSCoding, NSCopying, NSMutableCopying> + ++ (id) string; ++ (id) stringWithCharacters: (const unichar*)chars + length: (NSUInteger)length; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4,GS_API_LATEST) && GS_API_VERSION( 10200,GS_API_LATEST) ++ (id) stringWithCString: (const char*)byteString + encoding: (NSStringEncoding)encoding; +#endif ++ (id) stringWithCString: (const char*)byteString + length: (NSUInteger)length; ++ (id) stringWithCString: (const char*)byteString; ++ (id) stringWithFormat: (NSString*)format, ... NS_FORMAT_FUNCTION(1,2); ++ (id) stringWithContentsOfFile:(NSString *)path; + +// Initializing Newly Allocated Strings +- (id) init; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4,GS_API_LATEST) && GS_API_VERSION( 10200,GS_API_LATEST) +- (id) initWithBytes: (const void*)bytes + length: (NSUInteger)length + encoding: (NSStringEncoding)encoding; +- (id) initWithBytesNoCopy: (void*)bytes + length: (NSUInteger)length + encoding: (NSStringEncoding)encoding + freeWhenDone: (BOOL)flag; +#endif +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4,GS_API_LATEST) ++ (id) stringWithContentsOfFile: (NSString*)path + usedEncoding: (NSStringEncoding*)enc + error: (NSError**)error; +- (id) initWithContentsOfFile: (NSString*)path + usedEncoding: (NSStringEncoding*)enc + error: (NSError**)error; ++ (id) stringWithContentsOfFile: (NSString*)path + encoding: (NSStringEncoding)enc + error: (NSError**)error; +- (id) initWithContentsOfFile: (NSString*)path + encoding: (NSStringEncoding)enc + error: (NSError**)error; ++ (id) stringWithContentsOfURL: (NSURL*)url + usedEncoding: (NSStringEncoding*)enc + error: (NSError**)error; +- (id) initWithContentsOfURL: (NSURL*)url + usedEncoding: (NSStringEncoding*)enc + error: (NSError**)error; ++ (id) stringWithContentsOfURL: (NSURL*)url + encoding: (NSStringEncoding)enc + error: (NSError**)error; +- (id) initWithContentsOfURL: (NSURL*)url + encoding: (NSStringEncoding)enc + error: (NSError**)error; +- (BOOL) writeToFile: (NSString*)path + atomically: (BOOL)atomically + encoding: (NSStringEncoding)enc + error: (NSError**)error; +- (BOOL) writeToURL: (NSURL*)url + atomically: (BOOL)atomically + encoding: (NSStringEncoding)enc + error: (NSError**)error; +#endif +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5,GS_API_LATEST) +- (NSString*)stringByReplacingOccurrencesOfString: (NSString*)replace + withString: (NSString*)by + options: (NSStringCompareOptions)opts + range: (NSRange)searchRange; +- (NSString*)stringByReplacingOccurrencesOfString: (NSString*)replace + withString: (NSString*)by; +- (NSString*) stringByReplacingCharactersInRange: (NSRange)aRange + withString: (NSString*)by; +#endif +- (id) initWithCharactersNoCopy: (unichar*)chars + length: (NSUInteger)length + freeWhenDone: (BOOL)flag; +- (id) initWithCharacters: (const unichar*)chars + length: (NSUInteger)length; +- (id) initWithCStringNoCopy: (char*)byteString + length: (NSUInteger)length + freeWhenDone: (BOOL)flag; +- (id) initWithCString: (const char*)byteString + length: (NSUInteger)length; +- (id) initWithCString: (const char*)byteString; +- (id) initWithString: (NSString*)string; +- (id) initWithFormat: (NSString*)format, ... NS_FORMAT_FUNCTION(1,2); +- (id) initWithFormat: (NSString*)format + arguments: (va_list)argList NS_FORMAT_FUNCTION(1,0); +- (id) initWithData: (NSData*)data + encoding: (NSStringEncoding)encoding; +- (id) initWithContentsOfFile: (NSString*)path; + +// Getting a String's Length +- (NSUInteger) length; + +// Accessing Characters +- (unichar) characterAtIndex: (NSUInteger)index; +- (void) getCharacters: (unichar*)buffer; +- (void) getCharacters: (unichar*)buffer + range: (NSRange)aRange; + +// Combining Strings +- (NSString*) stringByAppendingFormat: (NSString*)format, ... + NS_FORMAT_FUNCTION(1,2); +- (NSString*) stringByAppendingString: (NSString*)aString; + +// Dividing Strings into Substrings +- (NSArray*) componentsSeparatedByString: (NSString*)separator; +- (NSString*) substringFromIndex: (NSUInteger)index; +- (NSString*) substringToIndex: (NSUInteger)index; + +// Finding Ranges of Characters and Substrings +- (NSRange) rangeOfCharacterFromSet: (NSCharacterSet*)aSet; +- (NSRange) rangeOfCharacterFromSet: (NSCharacterSet*)aSet + options: (NSUInteger)mask; +- (NSRange) rangeOfCharacterFromSet: (NSCharacterSet*)aSet + options: (NSUInteger)mask + range: (NSRange)aRange; +- (NSRange) rangeOfString: (NSString*)string; +- (NSRange) rangeOfString: (NSString*)string + options: (NSUInteger)mask; +- (NSRange) rangeOfString: (NSString*)aString + options: (NSUInteger)mask + range: (NSRange)aRange; + +// Determining Composed Character Sequences +- (NSRange) rangeOfComposedCharacterSequenceAtIndex: (NSUInteger)anIndex; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_2,GS_API_LATEST) +/** Returns a copy of the receiver normalised using the KD form. + */ +- (NSString *) decomposedStringWithCompatibilityMapping; + +/** Returns a copy of the receiver normalised using the D form. + */ +- (NSString *) decomposedStringWithCanonicalMapping; + +/** Returns a copy of the receiver normalised using the KC form. + */ +- (NSString *) precomposedStringWithCompatibilityMapping; + +/** Returns a copy of the receiver normalised using the C form. + */ +- (NSString *) precomposedStringWithCanonicalMapping; +#endif + +// Converting String Contents into a Property List +- (id) propertyList; +- (NSDictionary*) propertyListFromStringsFileFormat; + +// Identifying and Comparing Strings +- (NSComparisonResult) compare: (NSString*)aString; +- (NSComparisonResult) compare: (NSString*)aString + options: (NSUInteger)mask; +- (NSComparisonResult) compare: (NSString*)aString + options: (NSUInteger)mask + range: (NSRange)aRange; +- (BOOL) hasPrefix: (NSString*)aString; +- (BOOL) hasSuffix: (NSString*)aString; +- (BOOL) isEqual: (id)anObject; +- (BOOL) isEqualToString: (NSString*)aString; +- (NSUInteger) hash; + +// Getting a Shared Prefix +- (NSString*) commonPrefixWithString: (NSString*)aString + options: (NSUInteger)mask; + +// Changing Case +- (NSString*) capitalizedString; +- (NSString*) lowercaseString; +- (NSString*) uppercaseString; + +// Getting C Strings +- (const char*) cString; +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4,GS_API_LATEST) && GS_API_VERSION( 10200,GS_API_LATEST) +- (const char*) cStringUsingEncoding: (NSStringEncoding)encoding; +- (BOOL) getCString: (char*)buffer + maxLength: (NSUInteger)maxLength + encoding: (NSStringEncoding)encoding; +- (id) initWithCString: (const char*)byteString + encoding: (NSStringEncoding)encoding; +- (NSUInteger) lengthOfBytesUsingEncoding: (NSStringEncoding)encoding; +- (NSUInteger) maximumLengthOfBytesUsingEncoding: (NSStringEncoding)encoding; +#endif + +#endif +- (NSUInteger) cStringLength; +- (void) getCString: (char*)buffer; +- (void) getCString: (char*)buffer + maxLength: (NSUInteger)maxLength; +- (void) getCString: (char*)buffer + maxLength: (NSUInteger)maxLength + range: (NSRange)aRange + remainingRange: (NSRange*)leftoverRange; + +// Getting Numeric Values +- (float) floatValue; +- (int) intValue; + +// Working With Encodings +- (BOOL) canBeConvertedToEncoding: (NSStringEncoding)encoding; +- (NSData*) dataUsingEncoding: (NSStringEncoding)encoding; +- (NSData*) dataUsingEncoding: (NSStringEncoding)encoding + allowLossyConversion: (BOOL)flag; ++ (NSStringEncoding) defaultCStringEncoding; +- (NSString*) description; +- (NSStringEncoding) fastestEncoding; +- (NSStringEncoding) smallestEncoding; + +/** + * Attempts to complete this string as a path in the filesystem by finding + * a unique completion if one exists and returning it by reference in + * outputName (which must be a non-nil pointer), or if it finds a set of + * completions they are returned by reference in outputArray, if it is non-nil. + * filterTypes can be an array of strings specifying extensions to consider; + * files without these extensions will be ignored and will not constitute + * completions. Returns 0 if no match found, else a positive number that is + * only accurate if outputArray was non-nil. + */ +- (NSUInteger) completePathIntoString: (NSString**)outputName + caseSensitive: (BOOL)flag + matchesIntoArray: (NSArray**)outputArray + filterTypes: (NSArray*)filterTypes; + +/** + * Converts the receiver to a C string path expressed in the character + * encoding appropriate for the local host file system. This string will be + * automatically freed soon after it is returned, so copy it if you need it + * for long.<br /> + * NB. On mingw32 systems the filesystem representation of a path is a 16-bit + * unicode character string, so you should only pass the value returned by + * this method to functions expecting wide characters.<br /> + * This method uses [NSFileManager-fileSystemRepresentationWithPath:] to + * perform the conversion. + */ +- (const GSNativeChar*) fileSystemRepresentation; + +/** + * Converts the receiver to a C string path using the character encoding + * appropriate to the local file system. This string will be stored + * into buffer if it is shorter (number of characters) than size, + * otherwise NO is returned.<br /> + * NB. On mingw32 systems the filesystem representation of a path is a 16-bit + * unicode character string, so the buffer you pass to this method must be + * twice as many bytes as the size (number of characters) you expect to + * receive.<br /> + * This method uses [NSFileManager-fileSystemRepresentationWithPath:] to + * perform the conversion. + */ +- (BOOL) getFileSystemRepresentation: (GSNativeChar*)buffer + maxLength: (NSUInteger)size; + +/** + * Returns a string containing the last path component of the receiver.<br /> + * The path component is the last non-empty substring delimited by the ends + * of the string, or by path separator characters.<br /> + * If the receiver only contains a root part, this method returns it.<br /> + * If there are no non-empty substrings, this returns an empty string.<br /> + * NB. In a windows UNC path, the host and share specification is treated as + * a single path component, even though it contains separators. + * So a string of the form '//host/share' may be returned.<br /> + * Other special cases are apply when the string is the root. + * <example> + * @"foo/bar" produces @"bar" + * @"foo/bar/" produces @"bar" + * @"/foo/bar" produces @"bar" + * @"/foo" produces @"foo" + * @"/" produces @"/" (root is a special case) + * @"" produces @"" + * @"C:/" produces @"C:/" (root is a special case) + * @"C:" produces @"C:" + * @"//host/share/" produces @"//host/share/" (root is a special case) + * @"//host/share" produces @"//host/share" + * </example> + */ +- (NSString*) lastPathComponent; + +/** + * Returns a new string containing the path extension of the receiver.<br /> + * The path extension is a suffix on the last path component which starts + * with the extension separator (a '.') (for example .tiff is the + * pathExtension for /foo/bar.tiff).<br /> + * Returns an empty string if no such extension exists. + * <example> + * @"a.b" produces @"b" + * @"a.b/" produces @"b" + * @"/path/a.ext" produces @"ext" + * @"/path/a." produces @"" + * @"/path/.a" produces @"" (.a is not an extension to a file) + * @".a" produces @"" (.a is not an extension to a file) + * </example> + */ +- (NSString*) pathExtension; + +/** + * Returns a string where a prefix of the current user's home directory is + * abbreviated by '~', or returns the receiver (or an immutable copy) if + * it was not found to have the home directory as a prefix. + */ +- (NSString*) stringByAbbreviatingWithTildeInPath; + +/** + * Returns a new string with the path component given in aString + * appended to the receiver.<br /> + * This removes trailing path separators from the receiver and the root + * part from aString and replaces them with a single slash as a path + * separator.<br /> + * Also condenses any multiple separator sequences in the result into + * single path separators. + * <example> + * @"" with @"file" produces @"file" + * @"path" with @"file" produces @"path/file" + * @"/" with @"file" produces @"/file" + * @"/" with @"file" produces @"/file" + * @"/" with @"/file" produces @"/file" + * @"path with @"C:/file" produces @"path/file" + * </example> + * NB. Do not use this method to modify strings other than filesystem + * paths as the behavior in such cases is undefined ... for instance + * the string may have repeated slashes or slash-dot-slash sequences + * removed. + */ +- (NSString*) stringByAppendingPathComponent: (NSString*)aString; + +/** + * Returns a new string with the path extension given in aString + * appended to the receiver after an extensionSeparator ('.').<br /> + * If the receiver has trailing path separator characters, they are + * stripped before the extension separator is added.<br /> + * If the receiver contains no components after the root, the extension + * cannot be appended (an extension can only be appended to a file name), + * so a copy of the unmodified receiver is returned.<br /> + * An empty string may be used as an extension ... in which case the extension + * separator is appended.<br /> + * This behavior mirrors that of the -stringByDeletingPathExtension method. + * <example> + * @"Mail" with @"app" produces @"Mail.app" + * @"Mail.app" with @"old" produces @"Mail.app.old" + * @"file" with @"" produces @"file." + * @"/" with @"app" produces @"/" (no file name to append to) + * @"" with @"app" produces @"" (no file name to append to) + * </example> + * NB. Do not use this method to modify strings other than filesystem + * paths as the behavior in such cases is undefined ... for instance + * the string may have repeated slashes or slash-dot-slash sequences + * removed. + */ +- (NSString*) stringByAppendingPathExtension: (NSString*)aString; + +/** + * Returns a new string with the last path component (including any final + * path separators) removed from the receiver.<br /> + * A string without a path component other than the root is returned + * without alteration.<br /> + * See -lastPathComponent for a definition of a path component. + * <example> + * @"hello/there" produces @"hello" (a relative path) + * @"hello" produces @"" (a relative path) + * @"/hello" produces @"/" (an absolute unix path) + * @"/" produces @"/" (an absolute unix path) + * @"C:file" produces @"C:" (a relative windows path) + * @"C:" produces @"C:" (a relative windows path) + * @"C:/file" produces @"C:/" (an absolute windows path) + * @"C:/" produces @"C:/" (an absolute windows path) + * @"//host/share/file" produces @"//host/share/" (a UNC path) + * @"//host/share/" produces @"//host/share/" (a UNC path) + * @"//path/file" produces @"//path" (an absolute Unix path) + * </example> + * NB. Do not use this method to modify strings other than filesystem + * paths as the behavior in such cases is undefined ... for instance + * the string may have repeated slashes or slash-dot-slash sequences + * removed. + */ +- (NSString*) stringByDeletingLastPathComponent; + +/** + * Returns a new string with the path extension removed from the receiver.<br /> + * Strips any trailing path separators before checking for the extension + * separator.<br /> + * NB. This method does not consider a string which contains nothing + * between the root part and the extension separator ('.') to be a path + * extension. This mirrors the behavior of the -stringByAppendingPathExtension: + * method. + * <example> + * @"file.ext" produces @"file" + * @"/file.ext" produces @"/file" + * @"/file.ext/" produces @"/file" (trailing path separators are ignored) + * @"/file..ext" produces @"/file." + * @"/file." produces @"/file" + * @"/.ext" produces @"/.ext" (there is no file to strip from) + * @".ext" produces @".ext" (there is no file to strip from) + * </example> + * NB. Do not use this method to modify strings other than filesystem + * paths as the behavior in such cases is undefined ... for instance + * the string may have repeated slashes or slash-dot-slash sequences + * removed. + */ +- (NSString*) stringByDeletingPathExtension; + +/** + * Returns a string created by expanding the initial tilde ('~') and any + * following username to be the home directory of the current user or the + * named user.<br /> + * Returns the receiver or an immutable copy if it was not possible to + * expand it. + */ +- (NSString*) stringByExpandingTildeInPath; + +/** + * First calls -stringByExpandingTildeInPath if necessary.<br /> + * Replaces path string by one in which path components representing symbolic + * links have been replaced by their referents.<br /> + * Removes a leading '/private' if the result is valid.<br /> + * If links cannot be resolved, returns an unmodified copy of the receiver. + */ +- (NSString*) stringByResolvingSymlinksInPath; + +/** + * Returns a standardised form of the receiver, with unnecessary parts + * removed, tilde characters expanded, and symbolic links resolved + * where possible.<br /> + * NB. Refers to the local filesystem to resolve symbolic links in + * absolute paths, and to expand tildes ... so this can't be used for + * general path manipulation.<br /> + * If the string is an invalid path, the unmodified receiver is returned.<br /> + * <p> + * Uses -stringByExpandingTildeInPath to expand tilde expressions.<br /> + * Simplifies '//' and '/./' sequences and removes trailing '/' or '.'.<br /> + * </p> + * <p> + * For absolute paths, uses -stringByResolvingSymlinksInPath to resolve + * any links, then gets rid of '/../' sequences and removes any '/private' + * prefix. + * </p> + */ +- (NSString*) stringByStandardizingPath; + + +// for methods working with decomposed strings +- (int) _baseLength; + +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +/** + * Concatenates the path components in the array and returns the result.<br /> + * This method does not remove empty path components, but does recognize an + * empty initial component as a special case meaning that the string + * returned will begin with a slash. + */ ++ (NSString*) pathWithComponents: (NSArray*)components; + +/** + * Returns YES if the receiver represents an absolute path ...<br /> + * Returns NO otherwise.<br /> + * An absolute path in unix mode is one which begins + * with a slash or tilde.<br /> + * In windows mode a drive specification (eg C:) followed by a slash or + * backslash, is an absolute path, as is any path beginning with a tilde.<br /> + * In any mode a UNC path (//host/share...) is always absolute.<br /> + * In the default gnustep path handling mode, + * the rules are the same as for windows, + * except that a path whose root is a slash denotes an absolute path + * when running on unix and a relative path when running under windows. + */ +- (BOOL) isAbsolutePath; + +/** + * Returns the path components of the receiver separated into an array.<br /> + * If the receiver begins with a root sequence such as the path separator + * character (or a drive specification in windows) then that is used as the + * first element in the array.<br /> + * Empty components are removed.<br /> + * If a trailing path separator (which was not part of the root) was present, + * it is added as the last element in the array. + */ +- (NSArray*) pathComponents; + +/** + * Returns an array of strings made by appending the values in paths + * to the receiver. + */ +- (NSArray*) stringsByAppendingPaths: (NSArray*)paths; + ++ (NSString*) localizedStringWithFormat: (NSString*)format, ... + NS_FORMAT_FUNCTION(1,2); + ++ (id) stringWithString: (NSString*)aString; ++ (id) stringWithContentsOfURL: (NSURL*)url; ++ (id) stringWithUTF8String: (const char*)bytes; +- (id) initWithFormat: (NSString*)format + locale: (NSDictionary*)locale, ... NS_FORMAT_FUNCTION(1,3); +- (id) initWithFormat: (NSString*)format + locale: (NSDictionary*)locale + arguments: (va_list)argList NS_FORMAT_FUNCTION(1,0); +- (id) initWithUTF8String: (const char *)bytes; +- (id) initWithContentsOfURL: (NSURL*)url; +- (NSString*) substringWithRange: (NSRange)aRange; +- (NSComparisonResult) caseInsensitiveCompare: (NSString*)aString; +- (NSComparisonResult) compare: (NSString*)string + options: (NSUInteger)mask + range: (NSRange)compareRange + locale: (id)locale; +- (NSComparisonResult) localizedCompare: (NSString *)string; +- (NSComparisonResult) localizedCaseInsensitiveCompare: (NSString *)string; +- (BOOL) writeToFile: (NSString*)filename + atomically: (BOOL)useAuxiliaryFile; +- (BOOL) writeToURL: (NSURL*)url atomically: (BOOL)atomically; +- (double) doubleValue; ++ (NSStringEncoding*) availableStringEncodings; ++ (NSString*) localizedNameOfStringEncoding: (NSStringEncoding)encoding; +- (void) getLineStart: (NSUInteger *)startIndex + end: (NSUInteger *)lineEndIndex + contentsEnd: (NSUInteger *)contentsEndIndex + forRange: (NSRange)aRange; +- (NSRange) lineRangeForRange: (NSRange)aRange; +- (const char*) lossyCString; +- (NSString*) stringByAddingPercentEscapesUsingEncoding: (NSStringEncoding)e; +- (NSString*) stringByPaddingToLength: (NSUInteger)newLength + withString: (NSString*)padString + startingAtIndex: (NSUInteger)padIndex; +- (NSString*) stringByReplacingPercentEscapesUsingEncoding: (NSStringEncoding)e; +- (NSString*) stringByTrimmingCharactersInSet: (NSCharacterSet*)aSet; +- (const char *)UTF8String; +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_9,GS_API_LATEST) +- (NSString *) stringByAddingPercentEncodingWithAllowedCharacters: (NSCharacterSet *)aSet; +- (NSString *) stringByRemovingPercentEncoding; +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_3,GS_API_LATEST) +/** Not implemented */ +- (void) getParagraphStart: (NSUInteger *)startIndex + end: (NSUInteger *)parEndIndex + contentsEnd: (NSUInteger *)contentsEndIndex + forRange: (NSRange)range; +/** Not implemented */ + - (NSRange) paragraphRangeForRange: (NSRange)range; +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5,GS_API_LATEST) +/** + * Returns YES when scanning the receiver's text from left to right + * finds an initial digit in the range 1-9 or a letter in the set + * ('Y', 'y', 'T', 't').<br /> + * Any trailing characters are ignored.<br /> + * Any leading whitespace or zeros or signs are also ignored.<br /> + * Returns NO if the above conditions are not met. + */ +- (BOOL) boolValue; +- (NSArray *) componentsSeparatedByCharactersInSet: (NSCharacterSet *)separator; +- (NSInteger) integerValue; +- (long long) longLongValue; +/** Not implemented */ +- (NSRange) rangeOfComposedCharacterSequencesForRange: (NSRange)range; +/** Not implemented */ +- (NSRange) rangeOfString: (NSString *)aString + options: (NSStringCompareOptions)mask + range: (NSRange)searchRange + locale: (NSLocale *)locale; + +#endif + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_10,GS_API_LATEST) + +/** + * Returns YES if the receiver contains string, otherwise, NO. + */ +- (BOOL) containsString: (NSString *)string; + +#endif + +#if OS_API_VERSION(GS_API_NONE, GS_API_NONE) ++ (Class) constantStringClass; +#endif /* GS_API_NONE */ + +@end + +@interface NSMutableString : NSString + +// Creating Temporary Strings ++ (id) string; ++ (id) stringWithCharacters: (const unichar*)characters + length: (NSUInteger)length; ++ (id) stringWithCString: (const char*)byteString + length: (NSUInteger)length; ++ (id) stringWithCString: (const char*)byteString; ++ (id) stringWithFormat: (NSString*)format, ... NS_FORMAT_FUNCTION(1,2); ++ (id) stringWithContentsOfFile: (NSString*)path; ++ (NSMutableString*) stringWithCapacity: (NSUInteger)capacity; + +// Initializing Newly Allocated Strings +- (id) initWithCapacity: (NSUInteger)capacity; + +// Modify A String +- (void) appendFormat: (NSString*)format, ... NS_FORMAT_FUNCTION(1,2); +- (void) appendString: (NSString*)aString; +- (void) deleteCharactersInRange: (NSRange)range; +- (void) insertString: (NSString*)aString atIndex: (NSUInteger)loc; +- (void) replaceCharactersInRange: (NSRange)range + withString: (NSString*)aString; +- (NSUInteger) replaceOccurrencesOfString: (NSString*)replace + withString: (NSString*)by + options: (NSUInteger)opts + range: (NSRange)searchRange; +- (void) setString: (NSString*)aString; + +@end + +#ifdef __OBJC_GNUSTEP_RUNTIME_ABI__ +# if __OBJC_GNUSTEP_RUNTIME_ABI__ >= 20 +# define GNUSTEP_NEW_STRING_ABI +# endif +#endif + +/** + * <p>The NXConstantString class is used to hold constant 8-bit character + * string objects produced by the compiler where it sees @"..." in the + * source. The compiler generates the instances of this class - which + * has three instance variables -</p> + * <list> + * <item>a pointer to the class (this is the sole ivar of NSObject)</item> + * <item>a pointer to the 8-bit data</item> + * <item>the length of the string</item> + * </list> + * <p>In older versions of the compiler, the isa variable is always set to + * the NXConstantString class. In newer versions a compiler option was + * added for GNUstep, to permit the isa variable to be set to another + * class, and GNUstep uses this to avoid conflicts with the default + * implementation of NXConstantString in the ObjC runtime library (the + * preprocessor is used to change all occurrences of NXConstantString + * in the source code to NSConstantString).</p> + * <p>Since GNUstep will generally use the GNUstep extension to the + * compiler, you should never refer to the constant string class by + * name, but should use the [NSString+constantStringClass] method to + * get the actual class being used for constant strings.</p> + * What follows is a dummy declaration of the class to keep the compiler + * happy. + */ +@interface NXConstantString : NSString +{ +@public +#ifdef GNUSTEP_NEW_STRING_ABI + /** + * Flags. The low 16 bits are reserved for the compiler, the top 16 for use + * by the Foundation Framework. Currently only the low 2 bits are used, to + * indicate the encoding of the string, with the following values: + * + * 0. ASCII (UTF-8 using only 7-bit characters) + * 1. UTF-8 + * 2. UTF-16 + * 3. UTF-32 + * + */ + uint32_t flags; + /** + * The number of characters (UTF-16 code units) in the string. + */ + uint32_t nxcslen; + /** + * The number of bytes in the string. For fixed-length encodings, this is a + * fixed multiple of nxcslen, but for UTF-8 it can be different. + */ + uint32_t size; + /** + * Hash value. + */ + uint32_t hash; + /** + * Pointer to the byte data of the string. Note that `char*` is the correct + * type only if the low two bits of the flags indicate that this is an ASCII + * or UTF-8 string, otherwise it is a pointer to 16- or 32-bit characters in + * native byte order. + */ + const char * const nxcsptr; +#else + const char * const nxcsptr; + const unsigned int nxcslen; +#endif +} +@end + +#ifdef NeXT_RUNTIME +/** For internal use with NeXT runtime; + needed, until Apple Radar 2870817 is fixed. */ +extern struct objc_class _NSConstantStringClassReference; +#endif + +#if defined(__cplusplus) +} +#endif + +#if !NO_GNUSTEP && !defined(GNUSTEP_BASE_INTERNAL) +#import "../GNUstepBase/NSString+GNUstepBase.h" +#import "../GNUstepBase/NSMutableString+GNUstepBase.h" +#endif + +#endif /* __NSString_h_GNUSTEP_BASE_INCLUDE */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSValue.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSValue.h new file mode 100644 index 00000000000..f194f01a228 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSValue.h @@ -0,0 +1,370 @@ +/* Interface for NSValue for GNUStep + Copyright (C) 1995, 1996 Free Software Foundation, Inc. + + Written by: Adam Fedor <fedor@boulder.colorado.edu> + Created: 1995 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + */ + +#ifndef __NSValue_h_GNUSTEP_BASE_INCLUDE +#define __NSValue_h_GNUSTEP_BASE_INCLUDE +#import "../GNUstepBase/GSVersionMacros.h" + +#import "NSObject.h" +#import "NSGeometry.h" +#import "NSRange.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +@class NSString; + +/** + * The <code>NSValue</code> class can wrap a single primitive value as an + * object so it can be used in the containers and other places where an object + * reference is needed. Once initialized, an <code>NSValue</code> is + * immutable, and there is no <code>NSMutableValue</code> class. You + * initialize it by giving it a pointer to the primitive value, and you should + * be careful this does not get freed until after the <code>NSValue</code> is + * no longer used. + */ +@interface NSValue : NSObject <NSCopying, NSCoding> + +// Allocating and Initializing + +/** + * Create new instance with specified value (a pointer) of given type, which + * is a string code obtainable through the compile-time operator + * <code>@encode(...)</code>. For example: +<example> + NSValue *theValue = [NSValue value: &n withObjCType: @encode(int)]; +</example> + */ ++ (NSValue*) value: (const void*)value withObjCType: (const char*)type; + +/** + * Create new instance holding anObject. This is useful if you want to add + * anObject to a collection such as [NSArray] but don't want it to be retained + * (a weak reference). + */ ++ (NSValue*) valueWithNonretainedObject: (id)anObject; + +/** + * Convenience method to create instance holding an <code>NSPoint</code> + * structure. + */ ++ (NSValue*) valueWithPoint: (NSPoint)point; + +/** + * Convenience method to create instance holding a pointer. Same as + * using <code>@encode(void *)</code> in +value:withObjCType: . + */ ++ (NSValue*) valueWithPointer: (const void*)pointer; + +/** + * Convenience method to create instance holding an <code>NSRange</code> + * structure. + */ ++ (NSValue*) valueWithRange: (NSRange)range; + +/** + * Convenience method to create instance holding an <code>NSRect</code> + * structure. + */ ++ (NSValue*) valueWithRect: (NSRect)rect; + +/** + * Convenience method to create instance holding an <code>NSSize</code> + * structure. + */ ++ (NSValue*) valueWithSize: (NSSize)size; + +#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) +/** + * Synonym for value:withObjCType: . + */ ++ (NSValue*) valueWithBytes: (const void*)value objCType: (const char*)type; + +/** <init/> + * Initialize with value of type, parallel to value:withObjCType: . + */ +- (id) initWithBytes: (const void*)data objCType: (const char*)type; + +/** + * Compares this instance to another <code>NSValue</code>. For equality, + * both contents and declared type of the two values must match. + */ +- (BOOL) isEqualToValue: (NSValue*)other; +#endif /* GS_API_MACOSX */ + +// Accessing Data + +/** + * Copies bytes from the pointer receiver was initialized with into buffer + * pointed to by value. Number of bytes copied is determined by the type. If + * type was a void * pointer or object id, the memory address itself is + * copied. + */ +- (void) getValue: (void*)value; + +/** + * Returns the string <code>@encode(...)</code> compatible type the receiver + * was initialized with. + */ +- (const char*) objCType; + +/** + * If receiver was initialized with an object ID, return it, else raises + * <code>NSInternalInconsistencyException</code>. + */ +- (id) nonretainedObjectValue; + +/** + * If receiver was initialized with a void * pointer, return it, else raises + * <code>NSInternalInconsistencyException</code>. + */ +- (void*) pointerValue; + +/** + * If receiver was initialized with an <code>NSRange</code> value, return it, + * else raises <code>NSInternalInconsistencyException</code>. + */ +- (NSRange) rangeValue; + +/** + * If receiver was initialized with an <code>NSRect</code> value, return it, + * else raises <code>NSInternalInconsistencyException</code>. + */ +- (NSRect) rectValue; + +/** + * If receiver was initialized with an <code>NSSize</code> value, return it, + * else raises <code>NSInternalInconsistencyException</code>. + */ +- (NSSize) sizeValue; + +/** + * If receiver was initialized with an <code>NSPoint</code> value, return it, + * else raises <code>NSInternalInconsistencyException</code>. + */ +- (NSPoint) pointValue; + +@end + +/** + * Subclass of [NSValue] offering convenience methods for initializing from + * and accessing as any C primitive numeric type. On access, the value will + * be type-converted if necessary, using standard C conversion rules. + */ +@interface NSNumber : NSValue <NSCopying,NSCoding> + +// Allocating and Initializing + +/** New instance from boolean value. */ ++ (NSNumber*) numberWithBool: (BOOL)value; +/** New instance from signed char value. */ ++ (NSNumber*) numberWithChar: (signed char)value; +/** New instance from double value. */ ++ (NSNumber*) numberWithDouble: (double)value; +/** New instance from float value. */ ++ (NSNumber*) numberWithFloat: (float)value; +/** New instance from (signed) int value. */ ++ (NSNumber*) numberWithInt: (signed int)value; +/** New instance from (signed) long value. */ ++ (NSNumber*) numberWithLong: (signed long)value; +/** New instance from (signed) long long value. */ ++ (NSNumber*) numberWithLongLong: (signed long long)value; +/** New instance from (signed) short value. */ ++ (NSNumber*) numberWithShort: (signed short)value; +/** New instance from unsigned char value. */ ++ (NSNumber*) numberWithUnsignedChar: (unsigned char)value; +/** New instance from unsigned int value. */ ++ (NSNumber*) numberWithUnsignedInt: (unsigned int)value; +/** New instance from unsigned long value. */ ++ (NSNumber*) numberWithUnsignedLong: (unsigned long)value; +/** New instance from unsigned long long value. */ ++ (NSNumber*) numberWithUnsignedLongLong: (unsigned long long)value; +/** New instance from unsigned short value. */ ++ (NSNumber*) numberWithUnsignedShort: (unsigned short)value; + +/** Initialize from boolean value. */ +- (id) initWithBool: (BOOL)value; +/** Initialize from signed char value. */ +- (id) initWithChar: (signed char)value; +/** Initialize from double value. */ +- (id) initWithDouble: (double)value; +/** Initialize from float value. */ +- (id) initWithFloat: (float)value; +/** Initialize from (signed) int value. */ +- (id) initWithInt: (signed int)value; +/** Initialize from (signed) long value. */ +- (id) initWithLong: (signed long)value; +/** Initialize from (signed) long long value. */ +- (id) initWithLongLong: (signed long long)value; +/** Initialize from (signed) short value. */ +- (id) initWithShort: (signed short)value; +/** Initialize from unsigned char value. */ +- (id) initWithUnsignedChar: (unsigned char)value; +/** Initialize from unsigned int value. */ +- (id) initWithUnsignedInt: (unsigned int)value; +/** Initialize from unsigned long value. */ +- (id) initWithUnsignedLong: (unsigned long)value; +/** Initialize from unsigned long long value. */ +- (id) initWithUnsignedLongLong: (unsigned long long)value; +/** Initialize from unsigned short value. */ +- (id) initWithUnsignedShort: (unsigned short)value; + +// Accessing Data + +/** + * Return value as a BOOL; this will in fact be a char value converted + * if necessary from type initialized with; if you wish to consider anything + * nonzero TRUE do not compare directly to YES, but use <code>'!= NO'</code>. + */ +- (BOOL) boolValue; +/** Returns value as a signed char, converting if necessary. */ +- (signed char) charValue; +/** Returns value as a double, converting if necessary. */ +- (double) doubleValue; +/** Returns value as a float, converting if necessary. */ +- (float) floatValue; +/** Returns value as a (signed) int, converting if necessary. */ +- (signed int) intValue; +/** Returns value as a (signed) long, converting if necessary. */ +- (signed long) longValue; +/** Returns value as a (signed) long long, converting if necessary. */ +- (signed long long) longLongValue; +/** Returns value as a (signed) short, converting if necessary. */ +- (signed short) shortValue; +/** Returns value as an unsigned char, converting if necessary. */ +- (unsigned char) unsignedCharValue; +/** Returns value as an unsigned int, converting if necessary. */ +- (unsigned int) unsignedIntValue; +/** Returns value as an unsigned long, converting if necessary. */ +- (unsigned long) unsignedLongValue; +/** Returns value as an unsigned long long, converting if necessary. */ +- (unsigned long long) unsignedLongLongValue; +/** Returns value as an unsigned short, converting if necessary. */ +- (unsigned short) unsignedShortValue; + +/** Returns -description . */ +- (NSString*) stringValue; + +/** + * Returns the string representation of this number using a non-localised + * conversion (decimal point is '.' irrespective of the locale). + */ +- (NSString*) description; + +/** + * <p> + * Produces a string representation of the number. For a boolean + * this will be either 'true' or 'false'. For other numbers the + * format is produced using the initWithFormat:locale:... method + * of NSString, and the format depends on the type of number as + * follows - + * </p> + * <deflist> + * <term>char</term> + * <desc>%i</desc> + * <term> short</term> + * <desc>%hi</desc> + * <term> int</term> + * <desc>%i</desc> + * <term> long</term> + * <desc>%li</desc> + * <term> long long</term> + * <desc>%lli</desc> + * <term> unsigned char</term> + * <desc>%u</desc> + * <term> unsigned short</term> + * <desc>%hu</desc> + * <term> unsigned int</term> + * <desc>%u</desc> + * <term> unsigned long</term> + * <desc>%lu</desc> + * <term> unsigned long long</term> + * <desc>%llu</desc> + * <term> float</term> + * <desc>%0.7g</desc> + * <term> double</term> + * <desc>%0.16g</desc> + * </deflist> + */ +- (NSString*) descriptionWithLocale: (id)locale; + +/** + * Compares receiver with otherNumber, using C type conversion if necessary, + * and returns <code>NSOrderedAscending</code>, + * <code>NSOrderedDescending</code>, or <code>NSOrderedSame</code> depending + * on whether it is less than, greater than, or equal to otherNumber. + */ +- (NSComparisonResult) compare: (NSNumber*)otherNumber; + +/** + * Returns whether receiver and otherNumber represent the same numerical value. + */ +- (BOOL) isEqualToNumber: (NSNumber*)otherNumber; + + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) +/** Return a number intialised with NSInteger. + */ ++ (NSNumber*) numberWithInteger: (NSInteger)value; +/** Return a number intialised with NSUInteger. + */ ++ (NSNumber*) numberWithUnsignedInteger: (NSUInteger)value; +/** Initialise the receiver with NSInteger content. + */ +- (id) initWithInteger: (NSInteger)value; +/** Initialise the receiver with NSUInteger content. + */ +- (id) initWithUnsignedInteger: (NSUInteger)value; +/** Return the contents of the receiver as NSInteger. + */ +- (NSInteger) integerValue; +/** Return the contents of the receiver as NSUInteger. + */ +- (NSUInteger) unsignedIntegerValue; +#endif + +@end + +#if OS_API_VERSION(GS_API_NONE, GS_API_NONE) + +/** Note: Defines a method that is not in the OpenStep spec, but makes + subclassing easier. */ +@interface NSValue (Subclassing) + +/** Used by value: withObjCType: to determine the concrete subclass to alloc. */ ++ (Class) valueClassWithObjCType: (const char*)type; + +@end +#endif + +#if defined(__cplusplus) +} +#endif + +#if !NO_GNUSTEP && !defined(GNUSTEP_BASE_INTERNAL) +#import "../GNUstepBase/NSNumber+GNUstepBase.h" +#endif + +#endif /* __NSValue_h_GNUSTEP_BASE_INCLUDE */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSZone.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSZone.h new file mode 100644 index 00000000000..21776f65c3b --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSZone.h @@ -0,0 +1,335 @@ +/** Zone memory management. -*- Mode: ObjC -*- + Copyright (C) 1997,1998,1999 Free Software Foundation, Inc. + + Written by: Yoo C. Chung <wacko@laplace.snu.ac.kr> + Date: January 1997 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + + AutogsdocSource: NSZone.m + AutogsdocSource: NSPage.m + + */ + +#ifndef __NSZone_h_GNUSTEP_BASE_INCLUDE +#define __NSZone_h_GNUSTEP_BASE_INCLUDE +#import "../GNUstepBase/GSVersionMacros.h" + +/** + * Primary structure representing an <code>NSZone</code>. Technically it + * consists of a set of function pointers for zone upkeep functions plus some + * other things- +<example> +{ + // Functions for zone. + void *(*malloc)(struct _NSZone *zone, size_t size); + void *(*realloc)(struct _NSZone *zone, void *ptr, size_t size); + void (*free)(struct _NSZone *zone, void *ptr); + void (*recycle)(struct _NSZone *zone); + BOOL (*check)(struct _NSZone *zone); + BOOL (*lookup)(struct _NSZone *zone, void *ptr); + + // Zone statistics (not always maintained). + struct NSZoneStats (*stats)(struct _NSZone *zone); + + size_t gran; // Zone granularity (passed in on initialization) + NSString *name; // Name of zone (default is 'nil') + NSZone *next; // Pointer used for internal management of multiple zones. +}</example> + */ +typedef struct _NSZone NSZone; + +#import "NSObjCRuntime.h" + +@class NSString; + +#if defined(__cplusplus) +extern "C" { +#endif + +struct _NSZone +{ + /* Functions for zone. */ + void *(*malloc)(struct _NSZone *zone, size_t size); + void *(*realloc)(struct _NSZone *zone, void *ptr, size_t size); + void (*free)(struct _NSZone *zone, void *ptr); + void (*recycle)(struct _NSZone *zone); + BOOL (*check)(struct _NSZone *zone); + BOOL (*lookup)(struct _NSZone *zone, void *ptr); + struct NSZoneStats (*stats)(struct _NSZone *zone); + + size_t gran; // Zone granularity + __unsafe_unretained NSString *name; // Name of zone (default is 'nil') + NSZone *next; +}; + +/** + * Creates a new zone of start bytes, which will grow and shrink by + * granularity bytes. If canFree is 0, memory in zone is allocated but + * never freed, meaning allocation will be very fast. The whole zone can + * still be freed with NSRecycleZone(), and you should still call NSZoneFree + * on memory in the zone that is no longer needed, since a count of allocated + * pointers is kept and must reach zero before freeing the zone.<br /> + * If Garbage Collection is enabled, this function does nothing other than + * log a warning and return the same value as the NSDefaultMallocZone() + * function. + */ +GS_EXPORT NSZone* +NSCreateZone (NSUInteger start, NSUInteger gran, BOOL canFree); + +/** Returns the default zone for memory allocation. Memory created in this + * zone is the same as memory allocates using the system malloc() function. + */ +GS_EXPORT NSZone* +NSDefaultMallocZone (void); + +/** + * Searches and finds the zone ptr was allocated from. The speed depends + * upon the number of zones and their size.<br /> + * If Garbage Collection is enabled, this function always returns the + * same as the NSDefaultMallocZone() function. + */ +GS_EXPORT NSZone* +NSZoneFromPointer (void *ptr); + +/** + * Allocates and returns memory for elems items of size bytes, in the + * given zone. Returns NULL if allocation of size 0 requested. Raises + * <code>NSMallocException</code> if not enough free memory in zone to + * allocate and no more can be obtained from system, unless using the + * default zone, in which case NULL is returned.<br /> + * If Garbage Collection is enabled, this function always allocates + * non-scanned, non-collectable memory in the NSDefaultMallocZone() and + * the zone argument is ignored. + */ +GS_EXPORT void* +NSZoneMalloc (NSZone *zone, NSUInteger size); + +/** + * Allocates and returns cleared memory for elems items of size bytes, in the + * given zone. Returns NULL if allocation of size 0 requested. Raises + * <code>NSMallocException</code> if not enough free memory in zone to + * allocate and no more can be obtained from system, unless using the + * default zone, in which case NULL is returned.<br /> + * If Garbage Collection is enabled, this function always allocates + * non-scanned, non-collectable memory in the NSDefaultMallocZone() and + * the zone argument is ignored. + */ +GS_EXPORT void* +NSZoneCalloc (NSZone *zone, NSUInteger elems, NSUInteger bytes); + +/** + * Reallocates the chunk of memory in zone pointed to by ptr to a new one of + * size bytes. Existing contents in ptr are copied over. Raises an + * <code>NSMallocException</code> if insufficient memory is available in the + * zone and no more memory can be obtained from the system, unless using the + * default zone, in which case NULL is returned.<br /> + * If Garbage Collection is enabled, the zone argument is ignored. + */ +GS_EXPORT void* +NSZoneRealloc (NSZone *zone, void *ptr, NSUInteger size); + +/** + * Return memory for an entire zone to system. In fact, this will not be done + * unless all memory in the zone has been explicitly freed (by calls to + * NSZoneFree()). For "non-freeable" zones, the number of NSZoneFree() calls + * must simply equal the number of allocation calls. The default zone, on the + * other hand, cannot be recycled.<br /> + * If Garbage Collection is enabled, this function has not effect. + */ +GS_EXPORT void +NSRecycleZone (NSZone *zone); + +/** + * Frees memory pointed to by ptr (which should have been allocated by a + * previous call to NSZoneMalloc(), NSZoneCalloc(), or NSZoneRealloc()) and + * returns it to zone. Note, if this is a nonfreeable zone, the memory is + * not actually freed, but the count of number of free()s is updated.<br /> + * If Garbage Collection is enabled, the zone argument is ignored and this + * function causes ptr to be deallocated immediately. + */ +GS_EXPORT void +NSZoneFree (NSZone *zone, void *ptr); + +/** + * Sets name of the given zone (useful for debugging and logging). + */ +GS_EXPORT void +NSSetZoneName (NSZone *zone, NSString *name); + +/** + * Returns the name of the given zone (useful for debugging and logging). + */ +GS_EXPORT NSString* +NSZoneName (NSZone *zone); + +#if OS_API_VERSION(GS_API_NONE, GS_API_NONE) + +/** Deprecated ...<br /> + * Checks integrity of a zone. Not defined by OpenStep or OS X. + */ +BOOL +NSZoneCheck (NSZone *zone); + +/** + * <code>NSZoneStats</code> is the structure returned by the NSZoneStats() + * function that summarizes the current usage of a zone. It is similar to + * the structure <em>mstats</em> in the GNU C library. It has 5 fields of + * type <code>size_t</code>- + * <deflist> + * <term><code>bytes_total</code></term> + * <desc> + * This is the total size of memory managed by the zone, in bytes.</desc> + * <term><code>chunks_used</code></term> + * <desc>This is the number of memory chunks in use in the zone.</desc> + * <term><code>bytes_used</code></term> + * <desc>This is the number of bytes in use.</desc> + * <term><code>chunks_free</code></term> + * <desc>This is the number of memory chunks that are not in use.</desc> + * <term><code>bytes_free</code></term> + * <desc> + * This is the number of bytes managed by the zone that are not in use. + * </desc> + * </deflist> + */ +struct NSZoneStats +{ + size_t bytes_total; + size_t chunks_used; + size_t bytes_used; + size_t chunks_free; + size_t bytes_free; +}; + +/** Deprecated ...<br /> + * Obtain statistics about the zone. Implementation emphasis is on + * correctness, not speed. Not defined by OpenStep or OS X. + */ +struct NSZoneStats +NSZoneStats (NSZone *zone); + +/** + * Try to get more memory - the normal process has failed. + * If we can't do anything, just return a null pointer. + * Try to do some logging if possible. + */ +void* +GSOutOfMemory(NSUInteger size, BOOL retry); + +/** + * Called during +initialize to tell the class that instances created + * in future should have the specified instance variable as a weak + * pointer for garbage collection.<br /> + * NB. making a pointer weak does not mean that it is automatically + * zeroed when the object it points to is garbage collected. To get that + * behavior you must asign values to the pointer using the + * GSAssignZeroingWeakPointer() function.<br /> + * This function has no effect if the system is + * not built for garbage collection. + */ +GS_EXPORT void +GSMakeWeakPointer(Class theClass, const char *iVarName); + +/** + * This function must be used to assign a value to a zeroing weak pointer.<br /> + * A zeroing weak pointer is one where, when the garbage collector collects + * the object pointed to, it also clears the weak pointer.<br /> + * Assigning zero (nil) will always succeed and has the effect of telling the + * garbage collector that it no longer needs to track the previously assigned + * object. Apart from that case, a source needs to be garbage collectable for + * this function to work, and using a non-garbage collectable value will + * cause the function to return NO.<br /> + * If the destination object (the weak pointer watching the source object) + * belongs to a chunk of memory which may be collected before the source + * object is collected, it is important that it is finalised and the + * finalisation code assigns zero to the pointer.<br /> + * If garbage collection is not in use, this function performs a simple + * assignment returning YES, unless destination is null in which case it + * returns NO. + */ +GS_EXPORT BOOL +GSAssignZeroingWeakPointer(void **destination, void *source); + +#endif + +GS_EXPORT NSUInteger +NSPageSize (void) __attribute__ ((const)); + +GS_EXPORT NSUInteger +NSLogPageSize (void) __attribute__ ((const)); + +GS_EXPORT NSUInteger +NSRoundDownToMultipleOfPageSize (NSUInteger bytes) __attribute__ ((const)); + +GS_EXPORT NSUInteger +NSRoundUpToMultipleOfPageSize (NSUInteger bytes) __attribute__ ((const)); + +GS_EXPORT NSUInteger +NSRealMemoryAvailable (void); + +GS_EXPORT void* +NSAllocateMemoryPages (NSUInteger bytes); + +GS_EXPORT void +NSDeallocateMemoryPages (void *ptr, NSUInteger bytes); + +GS_EXPORT void +NSCopyMemoryPages (const void *src, void *dest, NSUInteger bytes); + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, OS_API_LATEST) + +enum { + NSScannedOption = (1<<0), + NSCollectorDisabledOption = (1<<1) +}; + +/** Allocate memory. If garbage collection is not enabled this uses the + * default malloc zone and the options are ignored.<br /> + * If garbage collection is enabled, the allocate memory is normally not + * scanned for pointers but is itsself garbage collectable. The options + * argument is a bitmask in which NSScannedOption sets the memory to be + * scanned for pointers by the garbage collector, and + * NSCollectorDisabledOption causes the memory to be excempt from being + * garbage collected itsself.<br /> + * In any case the memory returned is zero'ed. + */ +GS_EXPORT void * +NSAllocateCollectable(NSUInteger size, NSUInteger options); + +/** Reallocate memory to be of a different size and/or to have different + * options settings. The behavior of options is as for + * the NSAllocateCollectable() function. + */ +GS_EXPORT void * +NSReallocateCollectable(void *ptr, NSUInteger size, NSUInteger options); + +#endif + +static inline id NSMakeCollectable(const void *cf) { +#if __has_feature(objc_arc) + return nil; +#else + return (id)cf; // Unimplemented; garbage collection is deprecated. +#endif +} + +#if defined(__cplusplus) +} +#endif + +#endif /* not __NSZone_h_GNUSTEP_BASE_INCLUDE */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GNUstep.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GNUstep.h new file mode 100644 index 00000000000..c3b7f2bd55e --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GNUstep.h @@ -0,0 +1,418 @@ +/* GNUstep.h - macros to make easier to port gnustep apps to macos-x + Copyright (C) 2001 Free Software Foundation, Inc. + + Written by: Nicola Pero <n.pero@mi.flashnet.it> + Date: March, October 2001 + + This file is part of GNUstep. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __GNUSTEP_GNUSTEP_H_INCLUDED_ +#define __GNUSTEP_GNUSTEP_H_INCLUDED_ + +/* The contents of this file are designed to be usable with either + * GNUstep-base or MacOS-X Foundation. + */ + +#ifndef __has_feature +# define __has_feature(x) 0 +#endif + +/* + * __has_extension has slightly different semantics from __has_feature. + * It evaluates to true if the feature is supported by by clang for the + * current compilation unit (language and -f switches), regardless of + * whether it is part of the language standard or just a (non-standard) + * extension. + */ +#ifndef __has_extension +# define __has_extension(x) __has_feature(x) +#endif + +/* + * __has_attribute is the equivalent to __has_feature and __has_extension + * for GNU-style attributes. + */ +#ifndef __has_attribute +# define __has_attribute(x) 0 +#endif + +#if __has_feature(objc_arc) + +#ifndef RETAIN +#define RETAIN(object) (object) +#endif +#ifndef RELEASE +#define RELEASE(object) +#endif +#ifndef AUTORELEASE +#define AUTORELEASE(object) (object) +#endif + +#ifndef TEST_RETAIN +#define TEST_RETAIN(object) (object) +#endif +#ifndef TEST_RELEASE +#define TEST_RELEASE(object) +#endif +#ifndef TEST_AUTORELEASE +#define TEST_AUTORELEASE(object) (object) +#endif + +#ifndef ASSIGN +#define ASSIGN(object,value) object = (value) +#endif +#ifndef ASSIGNCOPY +#define ASSIGNCOPY(object,value) object = [(value) copy] +#endif +#ifndef DESTROY +#define DESTROY(object) object = nil +#endif + +#define IF_NO_GC(X) + +#ifndef ENTER_POOL +#define ENTER_POOL @autoreleasepool{do{ +#endif + +#ifndef LEAVE_POOL +#define LEAVE_POOL }while(0);} +#endif + +#ifndef DEALLOC +#define DEALLOC +#endif + +#else + +#ifndef RETAIN +/** + * Basic retain operation ... calls [NSObject-retain]<br /> + * Deprecated ... pointless on modern processors. + * Simply call the -retain method. + */ +#define RETAIN(object) [(object) retain] +#endif + +#ifndef RELEASE +/** + * Basic release operation ... calls [NSObject-release]<br /> + * Deprecated ... pointless on modern processors. + * Simply call the -release method. + */ +#define RELEASE(object) [(object) release] +#endif + +#ifndef AUTORELEASE +/** + * Basic autorelease operation ... calls [NSObject-autorelease]<br /> + * Deprecated ... pointless on modern processors. + * Simply call the -autorelease method. + */ +#define AUTORELEASE(object) [(object) autorelease] +#endif + +#ifndef TEST_RETAIN +/** + * Tested retain - only invoke the + * objective-c method if the receiver is not nil.<br /> + * Deprecated ... pointless on modern processors. + * Simply call the -retain method. + */ +#define TEST_RETAIN(object) ({\ +id __object = (object); (__object != nil) ? [__object retain] : nil; }) +#endif + +#ifndef TEST_RELEASE +/** + * Tested release - only invoke the + * objective-c method if the receiver is not nil.<br /> + * Deprecated ... pointless on modern processors. + * Simply call the -release method. + */ +#define TEST_RELEASE(object) ({\ +id __object = (object); if (__object != nil) [__object release]; }) +#endif + +#ifndef TEST_AUTORELEASE +/** + * Tested autorelease - only invoke the + * objective-c method if the receiver is not nil.<br /> + * Deprecated ... pointless on modern processors. + * Simply call the -autorelease method. + */ +#define TEST_AUTORELEASE(object) ({\ +id __object = (object); (__object != nil) ? [__object autorelease] : nil; }) +#endif + +#ifndef ASSIGN +/** + * ASSIGN(object,value) assigns the value to the object with + * appropriate retain and release operations.<br /> + * Use this to avoid retain/release errors. + */ +#define ASSIGN(object,value) ({\ + id __object = object; \ + object = [(value) retain]; \ + [__object release]; \ +}) +#endif + +#ifndef ASSIGNCOPY +/** + * ASSIGNCOPY(object,value) assigns a copy of the value to the object + * with release of the original.<br /> + * Use this to avoid retain/release errors. + */ +#define ASSIGNCOPY(object,value) ({\ + id __object = object; \ + object = [(value) copy];\ + [__object release]; \ +}) +#endif + +#ifndef DESTROY +/** + * DESTROY() is a release operation which also sets the variable to be + * a nil pointer for tidiness - we can't accidentally use a DESTROYED + * object later. It also makes sure to set the variable to nil before + * releasing the object - to avoid side-effects of the release trying + * to reference the object being released through the variable. + */ +#define DESTROY(object) ({ \ + id __o = object; \ + object = nil; \ + [__o release]; \ +}) +#endif + +#define IF_NO_GC(X) X + +#ifndef ENTER_POOL +/** + * ENTER_POOL creates an autorelease pool and places subsequent code + * in a do/while loop (executed only once) which can be broken out of + * to reach the point when the pool is drained.<br /> + * The block must be terminated with a corresponding LEAVE_POOL.<br /> + * You should not return from such a block of code (to do so could + * leak an autorelease pool and give objects a longer lifetime than + * they ought to have. If you wish to leave the block of code early, + * you may do so using a 'break' statement. + */ +#define ENTER_POOL {NSAutoreleasePool *_lARP=[NSAutoreleasePool new];do{ +#endif + +#ifndef LEAVE_POOL +/** + * LEAVE_POOL terminates a block of code started with ENTER_POOL. + */ +#define LEAVE_POOL }while(0);[_lARP drain];} +#endif + +#ifndef DEALLOC +/** + * DEALLOC calls the superclass implementation of dealloc, unless + * ARC is in use (in which case it does nothing). + */ +#define DEALLOC [super dealloc]; +#endif +#endif + +#ifndef CREATE_AUTORELEASE_POOL +/** DEPRECATED ... use ENTER_POOL and LEAVE_POOL + */ +#define CREATE_AUTORELEASE_POOL(X) \ + NSAutoreleasePool *X = [NSAutoreleasePool new] +#endif + +#ifndef RECREATE_AUTORELEASE_POOL +/** DEPRECATED ... use ENTER_POOL and LEAVE_POOL + */ +#define RECREATE_AUTORELEASE_POOL(X) \ + DESTROY(X);\ + X = [NSAutoreleasePool new] +#endif + + +/** + * <p> + * This function (macro) is a GNUstep extension. + * </p> + * <p> + * <code>_(@"My string to translate")</code> + * </p> + * <p> + * is basically equivalent to + * </p> + * <p> + * <code>NSLocalizedString(@"My string to translate", @"")</code> + * </p> + * <p> + * It is useful when you need to translate an application + * very quickly, as you just need to enclose all strings + * inside <code>_()</code>. But please note that when you + * use this macro, you are not taking advantage of comments + * for the translator, so consider using + * <code>NSLocalizedString</code> instead when you need a + * comment. + * </p> + * <p>You may define GS_LOCALISATION_BUNDLE_ID to the bundle identifier + * of the bundle which is to provide the localisation information.<br /> + * This can be used when compiling a single file by specifying something like + * '-D GS_LOCALISATION_BUNDLE_ID=$(FRAMEWORK_NAME)' in your make file.<br /> + * If this is not defined, the localisation is provided by your application's + * main bundle exactly like the NSLocalizedString function. + * </p> + * <p>Alternatively you may define GS_LOCALISATION_BUNDLE to be the bundle + * to be used to prvide the localisation information. + * </p> + */ +# define _(X) \ + [GS_LOCALISATION_BUNDLE localizedStringForKey: (X) value: @"" table: nil] + +#if !defined(GS_LOCALISATION_BUNDLE) +# if defined(GS_LOCALISATION_BUNDLE_ID) +# define GS_LOCALISATION_BUNDLE [NSBundle bundleWithIdentifier: \ + GS_LOCALISATION_BUNDLE_ID] +# else +# define GS_LOCALISATION_BUNDLE [NSBundle mainBundle] +# endif +#endif + + + +/** + * <p> + * This function (macro) is a GNUstep extension. + * </p> + * <p> + * <code>__(@"My string to translate")</code> + * </p> + * <p> + * is exactly the same as + * </p> + * <p> + * <code>GSLocalizedStaticString(@"My string to translate", @"")</code> + * </p> + * <p> + * It is useful when you need to translate an application very + * quickly. You would use it as follows for static strings: + * </p> + * <p> + * <code> + * NSString *message = __(@"Hello there"); + * ... more code ... + * NSLog (_(messages)); + * </code> + * </p> + * <p> + * But please note that when you use this macro, you are not + * taking advantage of comments for the translator, so + * consider using <code>GSLocalizedStaticString</code> + * instead when you need a comment. + * </p> + */ +#define __(X) X + +/* The better way for a static string, with a comment - use as follows - + * + * static NSString *string = GSLocalizedStaticString (@"New Game", + * @"Menu Option"); + * + * NSLog (_(string)); + * + * If you need anything more complicated than this, please initialize + * the static strings manually. + */ + +/** + * <p> + * This function (macro) is a GNUstep extensions, and it is used + * to localize static strings. Here is an example of a static + * string: + * </p> + * <p> + * <code> + * NSString *message = @"Hi there"; + * ... some code ... + * NSLog (message); + * </code> + * </p> + * <p> + * This string can not be localized using the standard + * openstep functions/macros. By using this gnustep extension, + * you can localize it as follows: + * </p> + * <p> + * <code> + * NSString *message = GSLocalizedStaticString (@"Hi there", + * @"Greeting"); + * + * ... some code ... + * + * NSLog (NSLocalizedString (message, @"")); + * </code> + * </p> + * <p> + * When the tools generate the + * <code>Localizable.strings</code> file from the source + * code, they will ignore the <code>NSLocalizedString</code> + * call while they will extract the string (and the comment) + * to localize from the <code>GSLocalizedStaticString</code> + * call. + * </p> + * <p> + * When the code is compiled, instead, the + * <code>GSLocalizedStaticString</code> call is ignored (discarded, + * it is a macro which simply expands to <code>key</code>), while + * the <code>NSLocalizedString</code> will actually look up the + * string for translation in the <code>Localizable.strings</code> + * file. + * </p> + * <p> + * Please note that there is currently no macro/function to + * localize static strings using different tables. If you + * need that functionality, you have either to prepare the + * localization tables by hand, or to rewrite your code in + * such a way as not to use static strings. + * </p> + */ +#define GSLocalizedStaticString(key, comment) key + +/** + * To be used inside a method for making sure that a range does not specify + * anything outside the size of an array/string. Raises exception if range + * extends beyond [0,size]. Size must be an unsigned integer (NSUInteger). + */ +#define GS_RANGE_CHECK(RANGE, SIZE) \ + if (RANGE.location > (NSUInteger)SIZE \ + || RANGE.length > ((NSUInteger)SIZE - RANGE.location)) \ + [NSException raise: NSRangeException format: @"in %s, range { %"\ + PRIuPTR ", %" PRIuPTR " } extends beyond size (%" PRIuPTR ")", \ + GSNameFromSelector(_cmd), RANGE.location, RANGE.length, (NSUInteger)SIZE] + +/** Checks whether INDEX is strictly less than OVER (within C array space). + * INDEX and OVER must be unsigned integers (NSUInteger). + */ +#define CHECK_INDEX_RANGE_ERROR(INDEX, OVER) \ +if ((NSUInteger)INDEX >= (NSUInteger)OVER) \ + [NSException raise: NSRangeException \ + format: @"in %s, index %" PRIuPTR " is out of range", \ + GSNameFromSelector(_cmd), (NSUInteger)INDEX] + +#endif /* __GNUSTEP_GNUSTEP_H_INCLUDED_ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GSBlocks.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GSBlocks.h new file mode 100644 index 00000000000..ac4e9c92ea6 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GSBlocks.h @@ -0,0 +1,145 @@ +/** Definitions for block support for GNUStep + Copyright (C) 2011 Free Software Foundation, Inc. + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + + */ + +#ifndef __GSBlocks_h_GNUSTEP_BASE_INCLUDE +#define __GSBlocks_h_GNUSTEP_BASE_INCLUDE + +/* Define the has_feature pseudo-macro for GCC. */ +#ifndef __has_feature +#define __has_feature(x) 0 +#endif + +#ifndef GCC_VERSION +#define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) +#endif + +#if __has_feature(blocks) + +#define BLOCK_SCOPE __block +/** + * Defines a block type. Will work whether or not the compiler natively + * supports blocks. + */ +#define DEFINE_BLOCK_TYPE(name, retTy, argTys, ...) \ +typedef retTy(^name)(argTys, ## __VA_ARGS__) + +#define DEFINE_BLOCK_TYPE_NO_ARGS(name, retTy) \ +typedef retTy(^name)() + +/** + * Calls a block. Works irrespective of whether the compiler supports blocks. + */ +#define CALL_BLOCK(block, args, ...) block(args, ## __VA_ARGS__) + +/** + * Calls a block without arguments. + */ +#define CALL_BLOCK_NO_ARGS(block) block() +#else + +/* Fall-back versions for when the compiler doesn't have native blocks support. + */ +#if (GCC_VERSION >= 3000) + +#define DEFINE_BLOCK_TYPE(name, retTy, argTys, ...) \ + typedef struct {\ + void *isa;\ + int flags;\ + int reserved;\ + retTy (*invoke)(void*, argTys, ## __VA_ARGS__);\ + } *name + +#define DEFINE_BLOCK_TYPE_NO_ARGS(name, retTy) \ + typedef struct {\ + void *isa;\ + int flags;\ + int reserved;\ + retTy (*invoke)(void*);\ + } *name + +#define CALL_BLOCK(block, args, ...) block->invoke(block, args, ## __VA_ARGS__) + +#define CALL_BLOCK_NO_ARGS(block) block->invoke(block) +#define BLOCK_SCOPE + +#else /* GCC_VERSION >= 3000 */ + +#define DEFINE_BLOCK_TYPE(name, retTy, argTys...) \ + typedef struct {\ + void *isa;\ + int flags;\ + int reserved;\ + retTy (*invoke)(void*, argTys);\ + } *name + +#define DEFINE_BLOCK_TYPE_NO_ARGS(name, retTy) \ + typedef struct {\ + void *isa;\ + int flags;\ + int reserved;\ + retTy (*invoke)(void*);\ + } *name + + +#define CALL_BLOCK(block, args...) block->invoke(block, args) +#define CALL_BLOCK_NO_ARGS(block) block->invoke(block) +#define BLOCK_SCOPE +#endif /* GCC_VERSION >= 3000 */ + +#endif /* __has_feature(blocks) */ + +#if __has_include(<objc/blocks_runtime.h>) +# include <objc/blocks_runtime.h> +#else + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * _Block_copy and _Block_release are weakly imported, but can be assumed + * to be available whenever a feature using blocks is accessed + * by an application. + */ + +/* weak attributed supported only with ELF, MINGW is COFF */ +#ifndef __MINGW32__ + +void *_Block_copy(const void *) __attribute__((weak)); +void _Block_release(const void *) __attribute__((weak)); + +#endif /* __MINGW32__ */ + +#ifdef __cplusplus +} +#endif + +#ifndef Block_copy +# define Block_copy(x) ((__typeof(x))_Block_copy((const void *)(x))) +#endif +#ifndef Block_release +# define Block_release(x) _Block_release((const void *)(x)) +#endif + +#endif /* __has_include(<objc/blocks_runtime.h>) */ +#endif /* __GSBlocks_h_GNUSTEP_BASE_INCLUDE */ + diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GSConfig.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GSConfig.h new file mode 100644 index 00000000000..a0e7cc7a409 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GSConfig.h @@ -0,0 +1,462 @@ +/* Machine/OS specific configuration information for GNUstep + + Please NOTE - GSConfig.h is generated by the configure script from the + file GSConfig.h.in - changes/fixes need to be made to the original file, + not to the GSConfig.h generated from it. + + Copyright (C) 1998-2010 Free Software Foundation, Inc. + + Written by: Richard frith-Macdonald <richard@brainstorm.co.uk> + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + */ + +#ifndef included_GSConfig_h +#define included_GSConfig_h + +/* Check the compiler to see if we are building on/for ms-windows. + * Whatever the compiler uses, we want a standard setting of _WIN64 + * to indicate 64bit AND _WIN32 to indicate ms-windows. + * These are defined by gcc, clang, and microsoft compilers anyway. + */ +#if defined(__WIN32__) \ + || defined(__MS_WIN32__) \ + || defined(__MINGW32__) +# if !defined(_WIN32) +# define _WIN32 +# endif +#endif +#if defined(__WIN64__) \ + || defined(__MS_WIN64__) \ + || defined(__MINGW64__) +# if !defined(__WIN64__) +# define __WIN64__ +# endif +# if !defined(_WIN32) +# define _WIN32 +# endif +#endif + +/* Check to see if this is a MINGW build (all we currently support) + */ +#if defined(__MINGW32__) || defined(__MINGW64__) +# if !defined(__MINGW__) +# define __MINGW__ +# endif +#endif + +// Make sure we expose the constants that we use in ObjC++ mode +#ifndef __STDC_CONSTANT_MACROS +#define __STDC_CONSTANT_MACROS 1 +#endif +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#if !defined(NeXT_Foundation_LIBRARY) + +/* An alternate to GS_FAKE_MAIN which forces the user to call the + NSProcessInfo initialization in 'main', GS_FAKE_MAIN must also + be undefined. */ +#if 0 +#define GS_PASS_ARGUMENTS 0 +#endif + +#define GS_FAKE_MAIN 0 +#if GS_FAKE_MAIN + +/* + * NOTE - if GS_FAKE_MAIN (above) is set to 1, this hack applies - and you + * must make sure that this file is included in any file that implements + * the 'main()' function and links with the GNUstep base libarary. + * You should NOT include this file in a program that does not link with + * the base library. + * This file is included automatically in NSObject.h and Foundation.h + * + * The Foundation classe NSProcessInfo need access to the argc, argv, + * and env variables of the main() function. The purpose of this (ugly hack) + * definition is to give the gstep-base library the opportunity to implement + * its own main function with private access to the global vars. The private + * main() implementation (in NSProcessInfo.m) will then call the user defined + * gnustep_base_user_main() function. + * + * The original hack was - + ** Written by: Georg Tuparev, EMBL & Academia Naturalis, + ** Heidelberg, Germany + ** Tuparev@EMBL-Heidelberg.de + ** + ** NOTE! This is very dirty and dangerous trick. I spend several hours + ** on thinking and man pages browsing, but couldn't find better solution. + ** I know that I will spend 666 years in the Computer Hell for writing + ** this hack, and the master devil (Bully Boy) will send me to write + ** Windowz software. + ** BTW, for writing this hack I got personal congratulations from Dennis + ** Ritchie and Bjarne Stroustrup sent me a bunch of flowers and asked me + ** to participate in the standardization committee for C-- v.6.0 as + ** responsible for the new Tab-Overriding-Operator and Scope-Sensitive- + ** Comments ... but this makes my situation even worse ;-) + ** - Georg + * + * On some systems, there are other relatively clean workarounds, if this + * applies to the system you are running on, your configuration script + * should have set GS_FAKE_MAIN to zero, so that this define hack will + * not be used. + */ + +#define main gnustep_base_user_main + +#endif /* GS_FAKE_MAIN */ +#endif + +/* + * Definition to specify if your processor stores words with the most + * significant byte first (like Motorola and SPARC, unlike Intel and VAX). + */ +#define GS_WORDS_BIGENDIAN 0 + +/* + * Size definitions for standard types + */ +#define GS_SIZEOF_SHORT 2 +#define GS_SIZEOF_INT 4 +#define GS_SIZEOF_LONG 8 +#define GS_SIZEOF_LONG_LONG 8 +#define GS_SIZEOF_FLOAT 4 +#define GS_SIZEOF_DOUBLE 8 +#define GS_SIZEOF_VOIDP 8 + +/* + * Size information to be places in bits 5 and 6 of type encoding bytes + * in archives (bits 0 to 4 are used for basic type info and bit 7 is + * used to mark cross-references to previously encoded objects). + */ +#define _GSC_S_SHT _GSC_I16 +#define _GSC_S_INT _GSC_I32 +#define _GSC_S_LNG _GSC_I64 +#define _GSC_S_LNG_LNG _GSC_I64 + +/* + * Type definitions for types with known sizes. + */ +typedef signed char gss8; +typedef unsigned char gsu8; +typedef signed short gss16; +typedef unsigned short gsu16; +typedef signed int gss32; +typedef unsigned int gsu32; +typedef signed long gss64; +typedef unsigned long gsu64; +typedef struct { gsu8 a[16]; } gss128; +typedef struct { gsu8 a[16]; } gsu128; +typedef float gsf32; +typedef double gsf64; + +/* + * Integer type with same size as a pointer + */ +typedef unsigned long gsuaddr; +typedef long gssaddr; +typedef gsuaddr gsaddr; + +/* + * Do we have real 64-bit and 128-bit integers or are we just pretending. + */ +#define GS_HAVE_I64 1 +#define GS_HAVE_I128 0 + +/* + * Ensure some standard types are defined. + */ +#include <inttypes.h> + + + + + + + + + + + +/* + * PTR Limit information replacements for buggy headers + */ +#if 0 +#undef INTPTR_MAX +#define INTPTR_MAX +#undef INTPTR_MIN +#define INTPTR_MIN +#undef UINTPTR_MAX +#define UINTPTR_MAX +#endif + + +/* + * Do we have zlib for file handle compression? + */ +#define USE_ZLIB 1 + +/* + * Do we have the GNU Multiple-precision library for NSDecimal? + */ +//#define USE_GMP 1 +#define USE_GMP 0 + +#ifdef GS_WITH_GC +#undef GS_WITH_GC +#endif +#define GS_WITH_GC 0 + +/* + * Define to say if we use NXConstantString or NSConstantString + */ +#define NXConstantString NSConstantString + + +/* + * Wide unicode character type. + */ +#ifndef UTF32Char +#define UTF32Char uint32_t +#endif + +/* + * Native character type for use in systemcalls etc. + */ + +#if defined(__MINGW__) +# define GSNativeChar uint16_t +#else +# define GSNativeChar char +#endif + +/* + * Types used to avoid exposing pthread header in NSLock.h + * NB. These types should *never* be used except to provide enough space + * in a class layout for the type of data actually used by the pthread + * implementation of the current platform. + */ +typedef struct { + uint8_t dummy[48]; +} gs_cond_t __attribute__((aligned (8))); +typedef struct { + uint8_t dummy[40]; +} gs_mutex_t __attribute__((aligned (8))); + +#define OBJC2RUNTIME 1 +#define BASE_NATIVE_OBJC_EXCEPTIONS 1 +#define GS_NONFRAGILE 0 +#define GS_MIXEDABI 0 +#define GS_USE_LIBXML 0 +#define GS_USE_GNUTLS 0 +#define GS_USE_AVAHI 0 +#define GS_USE_MDNS 0 +#define GS_USE_ICU 0 +#define GS_USE_LIBDISPATCH 0 +#define GS_USE_LIBDISPATCH_RUNLOOP 0 +#define GS_HAVE_OBJC_ROOT_CLASS_ATTR 0 + +#ifndef __has_include +# define __has_include(x) 0 +#endif +#ifndef __has_feature +# define __has_feature(x) 0 +#endif +#ifndef __has_builtin +# define __has_builtin(x) 0 +#endif + +/* + * __has_extension has slightly different semantics from __has_feature. + * It evaluates to true if the feature is supported by by clang for the + * current compilation unit (language and -f switches), regardless of + * whether it is part of the language standard or just a (non-standard) + * extension. + */ +#ifndef __has_extension +# define __has_extension(x) __has_feature(x) +#endif + +#if defined(_WIN32) +#define BOOL WinBOOL +#define __OBJC_BOOL 1 +#include <w32api.h> +#ifndef _WIN32_WINNT +#define _WIN32_WINNT Windows2000 +#endif +#if !defined(WINVER) +#define WINVER Windows2000 +#elif (WINVER < Windows2000) +#undef WINVER +#define WINVER Windows2000 +#endif + +#if defined(__WIN64__) +#include <winsock2.h> +#include <windows.h> +#else +#include <windows.h> +#include <winsock2.h> +#endif + +#undef __OBJC_BOOL +#undef BOOL +#endif + +/* Include the blocks runtime header if it's available (It shouldn't matter + * that this doesn't work on compilers that don't support __has_include(), + * because they also don't support blocks). + */ +#if __has_include(<objc/block_runtime.h>) +# include <objc/block_runtime.h> +#endif + +#ifndef _WIN32 +#include <sys/param.h> /* Hack to get rid of warning in GNU libc 2.0.3. */ +#endif + +/* The following group of lines maintained by the gstep-base configure */ +#define GNUSTEP_BASE_VERSION 1.26.0 +#define GNUSTEP_BASE_MAJOR_VERSION 1 +#define GNUSTEP_BASE_MINOR_VERSION 26 +#define GNUSTEP_BASE_SUBMINOR_VERSION 0 +#define GNUSTEP_BASE_GCC_VERSION 4.0.0 + +/* Do not use the following macros! + */ +#define OBJC_DEP(M) \ + ({ static BOOL beenHere = NO; if (beenHere == NO) {\ + beenHere = YES; fprintf(stderr, "%s:%d %s", __FILE__, __LINE__, (M));}}) + +#define OBJC_MALLOC(VAR, TYPE, NUM) \ + (OBJC_DEP("OBJC_MALLOC is deprecated ... use malloc\n"),(VAR) = (TYPE *) malloc ((unsigned)(NUM)*sizeof(TYPE))) +#define OBJC_VALLOC(VAR, TYPE, NUM) \ + (OBJC_DEP("OBJC_VALLOC is deprecated\n"),(VAR) = (TYPE *) valloc ((unsigned)(NUM)*sizeof(TYPE))) +#define OBJC_ATOMIC_MALLOC(VAR, TYPE, NUM) \ + (OBJC_DEP("OBJC_ATOMIC_MALLOC is deprecated\n"),(VAR) = (TYPE *) malloc ((unsigned)(NUM)*sizeof(TYPE))) +#define OBJC_REALLOC(VAR, TYPE, NUM) \ + (OBJC_DEP("OBJC_REALLOC is deprecated ... use realloc\n"),(VAR) = (TYPE *) realloc ((VAR), (unsigned)(NUM)*sizeof(TYPE))) +#define OBJC_CALLOC(VAR, TYPE, NUM) \ + (OBJC_DEP("OBJC_CALLOC is deprecated ... use calloc\n"),(VAR) = (TYPE *) calloc ((unsigned)(NUM), sizeof(TYPE))) +#define OBJC_FREE(PTR) (OBJC_DEP("OBJC_FREE is deprecated ... use free\n"), free (PTR)) + +#ifndef MAX +#define MAX(a,b) \ + ({__typeof__(a) _MAX_a = (a); __typeof__(b) _MAX_b = (b); \ + _MAX_a > _MAX_b ? _MAX_a : _MAX_b; }) +#endif + +#ifndef MIN +#define MIN(a,b) \ + ({__typeof__(a) _MIN_a = (a); __typeof__(b) _MIN_b = (b); \ + _MIN_a < _MIN_b ? _MIN_a : _MIN_b; }) +#endif + +#ifndef ABS +#define ABS(a) \ + ({__typeof__(a) _ABS_a = (a); \ + _ABS_a < 0 ? -_ABS_a : _ABS_a; }) +#endif + +#ifndef STRINGIFY +#define STRINGIFY(s) XSTRINGIFY(s) +#define XSTRINGIFY(s) #s +#endif + +#ifndef OBJC_STRINGIFY +#define OBJC_STRINGIFY(s) OBJC_XSTRINGIFY(s) +#define OBJC_XSTRINGIFY(s) @#s +#endif + +#ifndef PTR2LONG +#define PTR2LONG(P) (((char*)(P))-(char*)0) +#endif +#ifndef LONG2PTR +#define LONG2PTR(L) (((char*)0)+(L)) +#endif + +#if VSPRINTF_RETURNS_LENGTH +#define VSPRINTF_LENGTH(VSPF_CALL) (VSPF_CALL) +#else +#define VSPRINTF_LENGTH(VSPF_CALL) strlen((VSPF_CALL)) +#endif /* VSPRINTF_RETURNS_LENGTH */ + +#if VASPRINTF_RETURNS_LENGTH +#define VASPRINTF_LENGTH(VASPF_CALL) (VASPF_CALL) +#else +#define VASPRINTF_LENGTH(VASPF_CALL) strlen((VASPF_CALL)) +#endif /* VSPRINTF_RETURNS_LENGTH */ + +/* Evil hack to stop gcc-4.1 complaining about a dealloc method which + * does not call the superclass implementation. + */ +#define GSNOSUPERDEALLOC if (0) [super dealloc] + +#ifndef CF_EXCLUDE_CSTD_HEADERS +#include <sys/types.h> +#include <stdarg.h> +#include <assert.h> +#include <ctype.h> +#include <errno.h> +#include <float.h> +#include <limits.h> +#include <locale.h> +#include <math.h> +#include <setjmp.h> +#include <signal.h> +#include <stddef.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> +#include <stdbool.h> +#endif + +#if !__has_feature(objc_arc) +// NetBSD > 6 defines __weak in cdefs_elf.h +#ifdef __NetBSD__ +#undef __weak +#endif +# if !defined(__weak) +# define __weak +# endif +# if !defined(__strong) +# define __strong +# endif +#endif + +#ifndef __unsafe_unretained +# if !__has_feature(objc_arc) +# define __unsafe_unretained +# endif +#endif +#ifndef __bridge +# if !__has_feature(objc_arc) +# define __bridge +# endif +#endif + +#if __has_builtin(__builtin_unreachable) +# define GS_UNREACHABLE() __builtin_unreachable() +#else +# define GS_UNREACHABLE() abort() +#endif + +#endif /* included_GSConfig_h */ + diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GSObjCRuntime.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GSObjCRuntime.h new file mode 100644 index 00000000000..2088ee2e886 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GSObjCRuntime.h @@ -0,0 +1,631 @@ +/** Interface to ObjC runtime for GNUStep + Copyright (C) 1995, 1997, 2000, 2002, 2003 Free Software Foundation, Inc. + + Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu> + Date: 1995 + Written by: Richard Frith-Macdonald <rfm@gnu.org> + Date: 2002 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + + AutogsdocSource: Additions/GSObjCRuntime.m + + */ + +#ifndef __GSObjCRuntime_h_GNUSTEP_BASE_INCLUDE +#define __GSObjCRuntime_h_GNUSTEP_BASE_INCLUDE + +#import "GSVersionMacros.h" +#import "GSConfig.h" + +#include <stdio.h> + +#if 1 || NeXT_RUNTIME + #include <objc/objc.h> + #include <objc/objc-class.h> + #include <objc/objc-runtime.h> + #ifndef _C_ATOM + #define _C_ATOM '%' + #endif + #define _F_CONST 0x01 + #define _F_IN 0x01 + #define _F_OUT 0x02 + #define _F_INOUT 0x03 + #define _F_BYCOPY 0x04 + #define _F_ONEWAY 0x08 + #define _C_CONST 'r' + #define _C_IN 'n' + #define _C_INOUT 'N' + #define _C_OUT 'o' + #define _C_BYCOPY 'O' + #define _C_ONEWAY 'V' +#else /* GNU Objective C Runtime */ + #include <objc/objc.h> + #if defined (__GNU_LIBOBJC__) + #include <objc/runtime.h> + #else + #include <objc/objc-api.h> + #include <objc/encoding.h> + #endif +#endif + +/* + * Hack for older compiler versions that don't have all defines + * needed in objc-api.h + */ +#ifndef _C_LNG_LNG +#define _C_LNG_LNG 'q' +#endif +#ifndef _C_ULNG_LNG +#define _C_ULNG_LNG 'Q' +#endif + +#if OBJC2RUNTIME +/* We have a real ObjC2 runtime. + */ +#include <objc/runtime.h> +#else +/* We emulate an ObjC2 runtime. + */ +#include <ObjectiveC2/objc/runtime.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +@class NSArray; +@class NSDictionary; +@class NSObject; +@class NSString; +@class NSValue; + +#ifndef YES +#define YES 1 +#endif +#ifndef NO +#define NO 0 +#endif +#ifndef nil +#define nil 0 +#endif + +#if !defined(_C_CONST) +#define _C_CONST 'r' +#endif +#if !defined(_C_IN) +#define _C_IN 'n' +#endif +#if !defined(_C_INOUT) +#define _C_INOUT 'N' +#endif +#if !defined(_C_OUT) +#define _C_OUT 'o' +#endif +#if !defined(_C_BYCOPY) +#define _C_BYCOPY 'O' +#endif +#if !defined(_C_BYREF) +#define _C_BYREF 'R' +#endif +#if !defined(_C_ONEWAY) +#define _C_ONEWAY 'V' +#endif +#if !defined(_C_GCINVISIBLE) +#define _C_GCINVISIBLE '!' +#endif + +/* + * Functions for accessing instance variables directly - + * We can copy an ivar into arbitrary data, + * Get the type encoding for a named ivar, + * and copy a value into an ivar. + */ +GS_EXPORT BOOL +GSObjCFindVariable(id obj, const char *name, + const char **type, unsigned int *size, int *offset); + +GS_EXPORT void +GSObjCGetVariable(id obj, int offset, unsigned int size, void *data); + +GS_EXPORT void +GSObjCSetVariable(id obj, int offset, unsigned int size, const void *data); + +GS_EXPORT NSArray * +GSObjCMethodNames(id obj, BOOL recurse); + +GS_EXPORT NSArray * +GSObjCVariableNames(id obj, BOOL recurse); + +/** + * <p>A Behavior can be seen as a "Protocol with an implementation" or a + * "Class without any instance variables". A key feature of behaviors + * is that they give a degree of multiple inheritance. + * </p> + * <p>Behavior methods, when added to a class, override the class's + * superclass methods, but not the class's methods. + * </p> + * <p>Whan a behavior class is added to a receiver class, not only are the + * methods defined in the behavior class added, but the methods from the + * behavior's class hierarchy are also added (unless already present). + * </p> + * <p>It's not the case that a class adding behaviors from another class + * must have "no instance vars". The receiver class just has to have the + * same layout as the behavior class (optionally with some additional + * ivars after those of the behavior class). + * </p> + * <p>This function provides Behaviors without adding any new syntax to + * the Objective C language. Simply define a class with the methods you + * want to add, then call this function with that class as the behavior + * argument. + * </p> + * <p>This function should be called in the +initialize method of the receiver. + * </p> + * <p>If you add several behaviors to a class, be aware that the order of + * the additions is significant. + * </p> + */ +GS_EXPORT void +GSObjCAddClassBehavior(Class receiver, Class behavior); + +/** + * <p>An Override can be seen as a "category implemented as a separate class + * and manually added to the receiver class under program control, rather + * than automatically added by the compiler/runtime. + * </p> + * <p>Override methods, when added to a receiver class, replace the class's + * class's methods of the same name (or are added if the class did not define + * methods with that name). + * </p> + * <p>It's not the case that a class adding overrides from another class + * must have "no instance vars". The receiver class just has to have the + * same layout as the override class (optionally with some additional + * ivars after those of the override class). + * </p> + * <p>This function provides overrides without adding any new syntax to + * the Objective C language. Simply define a class with the methods you + * want to add, then call this function with that class as the override + * argument. + * </p> + * <p>This function should usually be called in the +initialize method + * of the receiver. + * </p> + * <p>If you add several overrides to a class, be aware that the order of + * the additions is significant. + * </p> + */ +GS_EXPORT void +GSObjCAddClassOverride(Class receiver, Class override); + +/** Turn on (YES), off (NO) or test (-1) behavior debugging. + */ +GS_EXPORT BOOL GSObjCBehaviorDebug(int setget); + +GS_EXPORT NSValue * +GSObjCMakeClass(NSString *name, NSString *superName, NSDictionary *iVars); + +GS_EXPORT void +GSObjCAddClasses(NSArray *classes); + +/** + * Given a NULL terminated list of methods, add them to the class.<br /> + * If the method already exists in a superclass, the new version overrides + * that one, but if the method already exists in the class itsself, the + * new one is quietly ignored (replace==NO) or replaced with the new + * version (if replace==YES).<br /> + * To add class methods, cls should be the metaclass of the class to + * which the methods are being added. + */ +GS_EXPORT void +GSObjCAddMethods(Class cls, Method *list, BOOL replace); + +/* + * Functions for key-value encoding ... they access values in an object + * either by selector or directly, but do so using NSNumber for the + * scalar types of data. + */ +GS_EXPORT id +GSObjCGetVal(NSObject *self, const char *key, SEL sel, + const char *type, unsigned size, int offset); + +GS_EXPORT void +GSObjCSetVal(NSObject *self, const char *key, id val, SEL sel, + const char *type, unsigned size, int offset); + +/* + * This section includes runtime functions + * to query and manipulate the ObjC runtime structures. + * These functions take care to not use ObjC code so + * that they can safely be used in +(void)load implementations + * where applicable. + */ + +/** + * Deprecated ... use objc_getClassList() + */ +GS_EXPORT unsigned int +GSClassList(Class *buffer, unsigned int max, BOOL clearCache); + +/** + * GSObjCClass() is deprecated ... use object_getClass() + */ +GS_EXPORT Class GSObjCClass(id obj); + +/** + * GSObjCSuper() is deprecated ... use class_getSuperclass() + */ +GS_EXPORT Class GSObjCSuper(Class cls); + +/** + * GSObjCIsInstance() is deprecated ... use object_getClass() + * in conjunction with class_isMetaClass() + */ +GS_EXPORT BOOL GSObjCIsInstance(id obj); + +/** + * GSObjCIsClass() is deprecated ... use object_getClass() + * in conjunction with class_isMetaClass() + */ +GS_EXPORT BOOL GSObjCIsClass(Class cls); + +/** + * Test to see if class inherits from another class + * The argument to this function must NOT be nil. + */ +GS_EXPORT BOOL GSObjCIsKindOf(Class cls, Class other); + +/** + * GSClassFromName() is deprecated ... use objc_lookUpClass() + */ +GS_EXPORT Class GSClassFromName(const char *name); + +/** + * GSNameFromClass() is deprecated ... use class_getName() + */ +GS_EXPORT const char *GSNameFromClass(Class cls); + +/** + * GSClassNameFromObject() is deprecated ... use object_getClass() + * in conjunction with class_getName() + */ +GS_EXPORT const char *GSClassNameFromObject(id obj); + +/** + * GSNameFromSelector() is deprecated ... use sel_getName() + */ +GS_EXPORT const char *GSNameFromSelector(SEL sel); + +/** + * GSSelectorFromName() is deprecated ... use sel_getUid() + */ +GS_EXPORT SEL +GSSelectorFromName(const char *name); + +/** + * Return the selector for the specified name and types.<br /> + * Returns a nul pointer if the name is nul.<br /> + * Creates a new selector if necessary.<br /> + * Code must NOT rely on this providing a selector with type information. + */ +GS_EXPORT SEL +GSSelectorFromNameAndTypes(const char *name, const char *types); + +/** + * Return the type information from the specified selector.<br /> + * May return a nul pointer if the selector was a nul pointer or if it + * was not typed (or if the runtime does not support typed selectors).<br /> + * Code must NOT rely on this providing any type information. + */ +GS_EXPORT const char * +GSTypesFromSelector(SEL sel); + +/** + * Compare only the type information ignoring qualifiers, the frame layout + * and register markers. Unlike sel_types_match, this function also + * handles comparisons of types with and without any layout information. + */ +GS_EXPORT BOOL +GSSelectorTypesMatch(const char *types1, const char *types2); + +/** Takes full type information and skips forward to the actual type + * as specified in the _C_... constants. + */ +GS_EXPORT const char * +GSSkipTypeQualifierAndLayoutInfo(const char *types); + +/** + * Returns a protocol object with the corresponding name. + * This function searches the registered classes for any protocol + * with the supplied name. If one is found, it is cached in + * for future requests. If efficiency is a factor then use + * GSRegisterProtocol() to insert a protocol explicitly into the cache + * used by this function. If no protocol is found this function returns + * nil. + */ +GS_EXPORT Protocol * +GSProtocolFromName(const char *name); + +/** + * Registers proto in the cache used by GSProtocolFromName(). + */ +GS_EXPORT void +GSRegisterProtocol(Protocol *proto); + +/** + * A variant of protocol_getMethodDescription which recursively searches + * parent protocols if the requested selector isn't found in the given + * protocol. + * + * Returns a {NULL, NULL} structure if the requested selector couldn't be + * found. + */ +GS_EXPORT struct objc_method_description +GSProtocolGetMethodDescriptionRecursive(Protocol *aProtocol, SEL aSel, BOOL isRequired, BOOL isInstance); + +/* + * Unfortunately the definition of the symbols + * 'Method(_t)', 'MethodList(_t)' and 'IVar(_t)' + * are incompatible between the GNU and NeXT/Apple runtimes. + * We introduce GSMethod, GSMethodList and GSIVar to allow portability. + */ +typedef Method GSMethod; +typedef Ivar GSIVar; + +/** + * Returns the pointer to the method structure + * for the selector in the specified class. + * Depending on searchInstanceMethods, this function searches + * either instance or class methods. + * Depending on searchSuperClassesm this function searches + * either the specified class only or also its superclasses.<br/> + * To obtain the implementation pointer IMP use returnValue->method_imp + * which should be safe across all runtimes.<br/> + * It should be safe to use this function in +load implementations.<br/> + * This function should currently (June 2004) be considered WIP. + * Please follow potential changes (Name, parameters, ...) closely until + * it stabilizes. + */ +GS_EXPORT GSMethod +GSGetMethod(Class cls, SEL sel, + BOOL searchInstanceMethods, + BOOL searchSuperClasses); + +/** + * Deprecated .. does nothing. + */ +GS_EXPORT void +GSFlushMethodCacheForClass (Class cls); + +/** + * Deprecated .. use class_getInstanceVariable() + */ +GS_EXPORT GSIVar +GSCGetInstanceVariableDefinition(Class cls, const char *name); + +/** + * Deprecated .. use class_getInstanceVariable() + */ +GS_EXPORT GSIVar +GSObjCGetInstanceVariableDefinition(Class cls, NSString *name); + +/** + * GSObjCVersion() is deprecated ... use class_getVersion() + */ +GS_EXPORT int GSObjCVersion(Class cls); + +/** + * Quickly return autoreleased data storage area. + */ +GS_EXPORT void * +GSAutoreleasedBuffer(unsigned size); + +/** + * <p>Prints a message to fptr using the format string provided and any + * additional arguments. The format string is interpreted as by + * the NSString formatted initialisers, and understands the '%@' syntax + * for printing an object. + * </p> + * <p>The data is written to the file pointer in the default CString + * encoding if possible, as a UTF8 string otherwise. + * </p> + * <p>This function is recommended for printing general log messages. + * For debug messages use NSDebugLog() and friends. For error logging + * use NSLog(), and for warnings you might consider NSWarnLog(). + * </p> + */ +GS_EXPORT BOOL +GSPrintf (FILE *fptr, NSString *format, ...); + + + +GS_EXPORT NSArray * +GSObjCAllSubclassesOfClass(Class cls); + +GS_EXPORT NSArray * +GSObjCDirectSubclassesOfClass(Class cls); + +/** Function to change the class of the specified instance to newClass. + * This handles memory debugging issues in GNUstep-base and also + * deals with class finalisation issues in a garbage collecting + * environment, so you should use this function rather than attempting + * to swizzle class pointers directly. + */ +GS_EXPORT void +GSClassSwizzle(id instance, Class newClass); + +#if !defined(GS_GNUSTEP_V) || (GS_GNUSTEP_V >= GS_API_ANY && GS_GNUSTEP_V < 011500) +//GS_API_VERSION(GS_API_ANY,011500) + +GS_EXPORT const char * +GSLastErrorStr(long error_id) GS_DEPRECATED_FUNC; + +#endif + + + +#ifndef GS_MAX_OBJECTS_FROM_STACK +/** + * The number of objects to try to get from varargs into an array on + * the stack ... if there are more than this, use the heap. + * NB. This MUST be a multiple of 2 + */ +#define GS_MAX_OBJECTS_FROM_STACK 128 +#endif + +/** + * <p>This is a macro designed to minimise the use of memory allocation and + * deallocation when you need to work with a vararg list of objects.<br /> + * The objects are unpacked from the vararg list into two 'C' arrays and + * then a code fragment you specify is able to make use of them before + * that 'C' array is destroyed. + * </p> + * <p>The firstObject argument is the name of the formal parameter in your + * method or function which precedes the ', ...' denoting variable args. + * </p> + * <p>The code argument is a piece of objective-c code to be executed to + * make use of the objects stored in the 'C' arrays.<br /> + * When this code is called the unsigned integer '__count' will contain the + * number of objects unpacked, the pointer '__objects' will point to + * the first object in each pair, and the pointer '__pairs' will point + * to an array containing the second halves of the pairs of objects + * whose first halves are in '__objects'.<br /> + * This lets you pack a list of the form 'key, value, key, value, ...' + * into an array of keys and an array of values. + * </p> + */ +#define GS_USEIDPAIRLIST(firstObject, code...) ({\ + va_list __ap; \ + unsigned int __max = GS_MAX_OBJECTS_FROM_STACK; \ + unsigned int __count = 0; \ + id __buf[__max]; \ + id *__objects = __buf; \ + id *__pairs = &__objects[__max/2]; \ + id __obj = firstObject; \ + va_start(__ap, firstObject); \ + while (__obj != nil && __count < __max) \ + { \ + if ((__count % 2) == 0) \ + { \ + __objects[__count/2] = __obj; \ + } \ + else \ + { \ + __pairs[__count/2] = __obj; \ + } \ + __obj = va_arg(__ap, id); \ + if (++__count == __max) \ + { \ + while (__obj != nil) \ + { \ + __count++; \ + __obj = va_arg(__ap, id); \ + } \ + } \ + } \ + if ((__count % 2) == 1) \ + { \ + __pairs[__count/2] = nil; \ + __count++; \ + } \ + va_end(__ap); \ + if (__count > __max) \ + { \ + unsigned int __tmp; \ + __objects = (id*)malloc(__count*sizeof(id)); \ + __pairs = &__objects[__count/2]; \ + __objects[0] = firstObject; \ + va_start(__ap, firstObject); \ + for (__tmp = 1; __tmp < __count; __tmp++) \ + { \ + if ((__tmp % 2) == 0) \ + { \ + __objects[__tmp/2] = va_arg(__ap, id); \ + } \ + else \ + { \ + __pairs[__tmp/2] = va_arg(__ap, id); \ + } \ + } \ + va_end(__ap); \ + } \ + code; \ + if (__objects != __buf) free(__objects); \ +}) + +/** + * <p>This is a macro designed to minimise the use of memory allocation and + * deallocation when you need to work with a vararg list of objects.<br /> + * The objects are unpacked from the vararg list into a 'C' array and + * then a code fragment you specify is able to make use of them before + * that 'C' array is destroyed. + * </p> + * <p>The firstObject argument is the name of the formal parameter in your + * method or function which precedes the ', ...' denoting variable args. + * </p> + * <p>The code argument is a piece of objective-c code to be executed to + * make use of the objects stored in the 'C' array.<br /> + * When this code is called the unsigned integer '__count' will contain the + * number of objects unpacked, and the pointer '__objects' will point to + * the unpacked objects, ie. firstObject followed by the vararg arguments + * up to (but not including) the first nil. + * </p> + */ +#define GS_USEIDLIST(firstObject, code...) ({\ + va_list __ap; \ + unsigned int __max = GS_MAX_OBJECTS_FROM_STACK; \ + unsigned int __count = 0; \ + id __buf[__max]; \ + id *__objects = __buf; \ + id __obj = firstObject; \ + va_start(__ap, firstObject); \ + while (__obj != nil && __count < __max) \ + { \ + __objects[__count] = __obj; \ + __obj = va_arg(__ap, id); \ + if (++__count == __max) \ + { \ + while (__obj != nil) \ + { \ + __count++; \ + __obj = va_arg(__ap, id); \ + } \ + } \ + } \ + va_end(__ap); \ + if (__count > __max) \ + { \ + unsigned int __tmp; \ + __objects = (id*)NSZoneMalloc(NSDefaultMallocZone(),__count*sizeof(id)); \ + va_start(__ap, firstObject); \ + __objects[0] = firstObject; \ + for (__tmp = 1; __tmp < __count; __tmp++) \ + { \ + __objects[__tmp] = va_arg(__ap, id); \ + } \ + va_end(__ap); \ + } \ + code; \ + if (__objects != __buf) NSZoneFree (NSDefaultMallocZone(),__objects); \ +}) + + +#ifdef __cplusplus +} +#endif + +#endif /* __GSObjCRuntime_h_GNUSTEP_BASE_INCLUDE */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GSVersionMacros.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GSVersionMacros.h new file mode 100644 index 00000000000..e7cfb5ea880 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/GSVersionMacros.h @@ -0,0 +1,460 @@ +/* GSVersionMacros.h - macros for managing API versioning and visibility + Copyright (C) 2006-2014 Free Software Foundation, Inc. + + Written by: Richard Frith-Macdonald <rfm@gnu.org> + Date: Oct, October 2006 + + This file is part of GNUstep. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __GNUSTEP_GSVERSIONMACROS_H_INCLUDED_ +#define __GNUSTEP_GSVERSIONMACROS_H_INCLUDED_ + +/* By default we defined NO_GNUSTEP to 0 so that we will include extensions. + */ +#if !defined(NO_GNUSTEP) +# define NO_GNUSTEP 0 +#endif + +/* Check consistency of definitions for system compatibility. + */ +#if defined(STRICT_OPENSTEP) +# define GS_OPENSTEP_V 10000 +# undef NO_GNUSTEP +# define NO_GNUSTEP 1 +#elif defined(STRICT_MACOS_X) +# define GS_OPENSTEP_V 100600 +# undef NO_GNUSTEP +# define NO_GNUSTEP 1 +#endif + +/* Define the GS_OSX_ADJUST() macro to adjust OSX style version macros + * to GNUstep style version macros. + */ +#define GS_OSX_ADJUST(V) ((V) >= 10000 ? (V) : ((V)/100*10000 + (V)%100*10)) + +/* Define OSX compatibility version macros if necessary. + */ +#if !defined(MAC_OS_X_VERSION_10_0) +#define MAC_OS_X_VERSION_10_0 1000 +#define MAC_OS_X_VERSION_10_1 1010 +#define MAC_OS_X_VERSION_10_2 1020 +#define MAC_OS_X_VERSION_10_3 1030 +#define MAC_OS_X_VERSION_10_4 1040 +#define MAC_OS_X_VERSION_10_5 1050 +#define MAC_OS_X_VERSION_10_6 1060 +#define MAC_OS_X_VERSION_10_7 1070 +#define MAC_OS_X_VERSION_10_8 1080 +#define MAC_OS_X_VERSION_10_9 1090 +#define MAC_OS_X_VERSION_10_10 1100 +#define MAC_OS_X_VERSION_10_11 1110 +#define MAC_OS_X_VERSION_10_12 1120 +#define MAC_OS_X_VERSION_10_13 1130 +#define MAC_OS_X_VERSION_10_14 1140 +#endif /* MAC_OS_X_VERSION_10_0 */ + +/* Allow MAC_OS_X_VERSION_MAX_ALLOWED to be used in place of GS_OPENSTEP_V + * if GS_OPENSTEP_V is not defined. + */ +#ifndef GS_OPENSTEP_V +#ifdef MAC_OS_X_VERSION_MAX_ALLOWED +#define GS_OPENSTEP_V GS_OSX_ADJUST(MAC_OS_X_VERSION_MAX_ALLOWED) +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ +#endif /* GS_OPENSTEP_V */ + +/* + * NB. The version values below must be integers ... by convention these are + * made up of two digits each for major, minor and subminor version numbers + * (ie each is in the range 00 to 99 though a leading zero in the major + * number is not permitted). + * So for a MacOS-X 10.3.9 release the version number would be 100309 + * + * You may define GS_GNUSTEP_V or GS_OPENSTEP_V to ensure that your + * program only 'sees' the specified varsion of the API. + */ + +/** + * <p>Macro to check a defined GNUstep version number (GS_GNUSTEP_V) against + * the supplied arguments. Returns true if no GNUstep version is specified, + * or if ADD <= version < REM, where ADD is the version + * number at which a feature guarded by the macro was introduced and + * REM is the version number at which it was removed. + * </p> + * <p>The version number arguments are six digit integers where the first + * two digits are the major version number, the second two are the minor + * version number and the last two are the subminor number (all left padded + * with a zero where necessary). However, for convenience you can also + * use the predefined constants ... + * <ref type="macro" id="GS_API_NONE">GS_API_NONE</ref>, + * <ref type="macro" id="GS_API_LATEST">GS_API_LATEST</ref>, + * </p> + * <p>Also see <ref type="macro" id="OS_API_VERSION">OS_API_VERSION</ref> + * </p> + * <p>NB. If you are changing the API (eg adding a new feature) you need + * to control the visibility io the new header file code using<br /> + * <code>#if GS_API_VERSION(ADD,GS_API_LATEST)</code><br /> + * where <code>ADD</code> is the version number of the next minor + * release after the most recent one.<br /> + * As a general principle you should <em>not</em> change the API with + * changing subminor version numbers ... as that tends to confuse + * people (though Apple has sometimes done it). + * </p> + */ +#define GS_API_VERSION(ADD,REM) \ + (!defined(GS_GNUSTEP_V) || (GS_GNUSTEP_V >= ADD && GS_GNUSTEP_V < REM)) + +/** + * <p>Macro to check a defined OpenStep/OPENSTEP/MacOS-X version against the + * supplied arguments. Returns true if no version is specified, or if + * ADD <= version < REM, where ADD is the version + * number at which a feature guarded by the macro was introduced and + * REM is the version number at which it was removed. + * </p> + * <p>The version number arguments are six digit integers where the first + * two digits are the major version number, the second two are the minor + * version number and the last two are the subminor number (all left padded + * with a zero where necessary). However, for convenience you can also + * use any of several predefined constants ... + * <ref type="macro" id="GS_API_NONE">GS_API_NONE</ref>, + * <ref type="macro" id="GS_API_LATEST">GS_API_LATEST</ref>, + * <ref type="macro" id="GS_API_OSSPEC">GS_API_OSSPEC</ref>, + * <ref type="macro" id="GS_API_OPENSTEP">GS_API_OPENSTEP</ref>, + * <ref type="macro" id="GS_API_MACOSX">GS_API_MACOSX</ref> + * </p> + * <p>Also see <ref type="macro" id="GS_API_VERSION">GS_API_VERSION</ref> + * </p> + * <p>For OSX compatibility, this macro also supports the use of Apple's + * symbolic constants for version numbering. Their contants are currently + * four digit values (two digits for the major version, one for the minor, + * and one for the subminor). + * </p> + * <p>The Apple compatibility version macros are currently: + * <ref type="macro" id="MAC_OS_X_VERSION_10_0">MAC_OS_X_VERSION_10_0</ref>, + * <ref type="macro" id="MAC_OS_X_VERSION_10_1">MAC_OS_X_VERSION_10_1</ref>, + * <ref type="macro" id="MAC_OS_X_VERSION_10_2">MAC_OS_X_VERSION_10_2</ref>, + * <ref type="macro" id="MAC_OS_X_VERSION_10_3">MAC_OS_X_VERSION_10_3</ref>, + * <ref type="macro" id="MAC_OS_X_VERSION_10_4">MAC_OS_X_VERSION_10_4</ref>, + * <ref type="macro" id="MAC_OS_X_VERSION_10_5">MAC_OS_X_VERSION_10_5</ref>, + * <ref type="macro" id="MAC_OS_X_VERSION_10_6">MAC_OS_X_VERSION_10_6</ref>, + * <ref type="macro" id="MAC_OS_X_VERSION_10_7">MAC_OS_X_VERSION_10_7</ref>, + * <ref type="macro" id="MAC_OS_X_VERSION_10_8">MAC_OS_X_VERSION_10_8</ref> + * <ref type="macro" id="MAC_OS_X_VERSION_10_9">MAC_OS_X_VERSION_10_9</ref> + * </p> + */ +#define OS_API_VERSION(ADD,REM) \ + (!defined(GS_OPENSTEP_V) \ + || (GS_OPENSTEP_V>=GS_OSX_ADJUST(ADD) && GS_OPENSTEP_V<GS_OSX_ADJUST(REM))) + +/** + * A constant which is the lowest possible version number (0) so that + * when used as the removal version (second argument of the GS_API_VERSION + * or OS_API_VERSION macro) represents a feature which is not present in + * any version.<br /> + * eg.<br /> + * #if <ref type="macro" id="OS_API_VERSION">OS_API_VERSION</ref> + * (GS_API_NONE, GS_API_NONE)<br /> + * denotes code not present in OpenStep/OPENSTEP/MacOS-X + */ +#define GS_API_NONE 0 + +/** + * A constant to represent a feature which is still present in the latest + * version. This is the highest possible version number.<br /> + * eg.<br /> + * #if <ref type="macro" id="OS_API_VERSION">OS_API_VERSION</ref> + * (GS_API_MACOSX, GS_API_LATEST)<br /> + * denotes code present from the initial MacOS-X version onwards. + */ +#define GS_API_LATEST 999999 + +/** + * The version number of the initial OpenStep specification.<br /> + * eg.<br /> + * #if <ref type="macro" id="OS_API_VERSION">OS_API_VERSION</ref> + * (GS_API_OSSPEC, GS_API_LATEST)<br /> + * denotes code present from the OpenStep specification onwards. + */ +#define GS_API_OSSPEC 10000 + +/** + * The version number of the first OPENSTEP implementation.<br /> + * eg.<br /> + * #if <ref type="macro" id="OS_API_VERSION">OS_API_VERSION</ref> + * (GS_API_OPENSTEP, GS_API_LATEST)<br /> + * denotes code present from the initial OPENSTEP version onwards. + */ +#define GS_API_OPENSTEP 40000 + +/** + * The version number of the first MacOS-X implementation.<br /> + * eg.<br /> + * #if <ref type="macro" id="OS_API_VERSION">OS_API_VERSION</ref> + * (GS_API_MACOSX, GS_API_LATEST)<br /> + * denotes code present from the initial MacOS-X version onwards. + */ +#define GS_API_MACOSX 100000 + +/* Allow OSX code comparing MAC_OS_X_VERSION_MAX_ALLOWED with a specific + * version to see if that version is allowed, to always have it allowed + * on GNUstep. + */ +#ifndef MAC_OS_X_VERSION_MAX_ALLOWED +#define MAC_OS_X_VERSION_MAX_ALLOWED GS_API_LATEST +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ + + +#if defined(GNUSTEP_BASE_INTERNAL) +#include "GNUstepBase/GSConfig.h" +#else +#include "GSConfig.h" +#endif + + +#if defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__clang__) +# define GS_GCC_MINREQ(maj, min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +#else +# define GS_GCC_MINREQ(maj, min) 0 +#endif + +#if defined(__clang__) +# define GS_CLANG_MINREQ(maj, min) \ + ((__clang_major__ << 16) + __clang_minor__ >= ((maj) << 16) + (min)) +#else +# define GS_CLANG_MINREQ(maj, min) 0 +#endif + +/* Attribute definitions for attributes which may or may not be supported + * depending on the compiler being used. + * NB we currently expect gcc to be version 4 or later. + * + * The definition should be of the form GS_XXX_CONTEXT where XXX is the + * name of the attribute and CONTEXT is one of FUNC, METH, or IVAR + * depending on where the attribute can be applied. + */ + +#if defined(__clang__) || GS_GCC_MINREQ(3,1) +# define GS_DEPRECATED_FUNC __attribute__ ((deprecated)) +#else +# define GS_DEPRECATED_FUNC +#endif + +#define GS_UNUSED_ARG __attribute__((unused)) + +#define GS_UNUSED_FUNC __attribute__((unused)) + +// FIXME ... what version of gcc? +#if __clang__ +# define GS_UNUSED_IVAR __attribute__((unused)) +#else +# define GS_UNUSED_IVAR +#endif + + + +#ifndef __has_feature +#define __has_feature(x) 0 +#endif + +/* The following is for deciding whether private instance variables + * should be visible ... if we are building with a compiler which + * does not define __has_feature then we know we don't have non-fragile + * ivar support. + * In the header we bracket instance variable declarations in a + * '#if GS_EXPOSE(classname) ... #endif' sequence, so that the variables + * will not be visible to code which uses the library. + * In the source file we define EXPOSE_classname_IVARS to be 1 + * before including the header, so that the ivars are always available + * in the class source itsself + */ + +#if GS_MIXEDABI +# undef GS_NONFRAGILE +# define GS_NONFRAGILE 0 /* Mixed is treated as fragile */ +#else +# if (__has_feature(objc_nonfragile_abi)) +# if !GS_NONFRAGILE +# if defined(GNUSTEP_BASE_INTERNAL) +# error "You are building gnustep-base using the objc-nonfragile-abi but your gnustep-base was not configured to use it." +# endif +# endif +# else +# if GS_NONFRAGILE +# error "Your gnustep-base was configured for the objc-nonfragile-abi but you are not using it now." +# endif +# endif +#endif + +#define GS_EXPOSE(X) (!GS_NONFRAGILE || defined(EXPOSE_##X##_IVARS)) + +/* Static analyser macros: Provide annotations to help the analyser */ +#ifdef __clang__ +# define GS_NORETURN_METHOD __attribute__((__noreturn__)) +#else +# define GS_NORETURN_METHOD +#endif + +#ifndef NS_RETURNS_RETAINED +# if __has_feature(attribute_ns_returns_retained) +# define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) +# else +# define NS_RETURNS_RETAINED +# endif +#endif + +#ifndef NS_RETURNS_NOT_RETAINED +# if __has_feature(attribute_ns_returns_not_retained) +# define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained)) +# else +# define NS_RETURNS_NOT_RETAINED +# endif +#endif + +#ifndef NS_CONSUMED +# if __has_feature(attribute_ns_consumed) +# define NS_CONSUMED __attribute__((ns_consumed)) +# else +# define NS_CONSUMED +# endif +#endif + + +#ifndef NS_CONSUMES_SELF +# if __has_feature(attribute_ns_consumes_self) +# define NS_CONSUMES_SELF __attribute__((ns_consumes_self)) +# else +# define NS_CONSUMES_SELF +# endif +#endif + +#if defined(__clang__) && defined(__OBJC__) +static inline void gs_consumed(id NS_CONSUMED o) GS_UNUSED_FUNC; +static inline void gs_consumed(id NS_CONSUMED GS_UNUSED_ARG o) { return; } +#define GS_CONSUMED(O) gs_consumed(O); +#else +#define GS_CONSUMED(O) +#endif + +/* Include the appropriate header for ObjC2 blocks support if it is in use. + * + * FIXME: "OBJC2RUNTIME" is set to "1" if the runtime supports the ObjC2 + * runtime API, which is unrelated to whether the compiler has blocks + * support or not. + */ +#if __has_feature(blocks) +# if OBJC2RUNTIME +# if defined(__APPLE__) +# include <Block.h> +# else +# include <objc/blocks_runtime.h> +# endif +# else +# include <ObjectiveC2/blocks_runtime.h> +# endif +#endif + +/* Attribute definition for root classes, annotates the interface declaration + * of the class. + */ +#ifndef GS_ROOT_CLASS +# if GS_HAVE_OBJC_ROOT_CLASS_ATTR || __has_feature(attribute_objc_root_class) +# define GS_ROOT_CLASS __attribute__((objc_root_class)) +# else +# define GS_ROOT_CLASS +# endif +#endif + + + +#if defined(GNUSTEP_WITH_DLL) + +#if BUILD_libgnustep_base_DLL +# +# if defined(__MINGW__) + /* On Mingw, the compiler will export all symbols automatically, so + * __declspec(dllexport) is not needed. + */ +# define GS_EXPORT extern +# define GS_DECLARE +# else +# define GS_EXPORT __declspec(dllexport) +# define GS_DECLARE __declspec(dllexport) +# endif +#else +# define GS_EXPORT extern __declspec(dllimport) +# define GS_DECLARE __declspec(dllimport) +#endif + +#else /* GNUSTEP_WITH[OUT]_DLL */ + +# define GS_EXPORT extern +# define GS_DECLARE + +#endif + + +/* Attribute macros compatible with Apple. + */ + +#ifndef NS_FORMAT_ARGUMENT +#if defined(__clang__) || GS_GCC_MINREQ(4,2) +# define NS_FORMAT_ARGUMENT(A) __attribute__((format_arg(A))) +#else +# define NS_FORMAT_ARGUMENT(F,A) +#endif +#endif + +// FIXME ... what version of gcc? +#ifndef NS_FORMAT_FUNCTION +#if __clang__ +# define NS_FORMAT_FUNCTION(F,A) __attribute__((format(__NSString__, F, A))) +#else +# define NS_FORMAT_FUNCTION(F,A) +#endif +#endif + +#ifndef NS_REQUIRES_NIL_TERMINATION +#define NS_REQUIRES_NIL_TERMINATION __attribute__((sentinel)) +#endif + +// FIXME ... what exact version of clang and gcc? +#ifndef UNAVAILABLE_ATTRIBUTE +#if defined(__clang__) || GS_GCC_MINREQ(4,0) +# define UNAVAILABLE_ATTRIBUTE __attribute__((unavailable)) +#else +# define UNAVAILABLE_ATTRIBUTE +#endif +#endif + +/* Check if compiler supports @optional in protocols + */ +#if defined(__clang__) || GS_GCC_MINREQ(4,6) +# define GS_PROTOCOLS_HAVE_OPTIONAL 1 +#else +# define GS_PROTOCOLS_HAVE_OPTIONAL 0 +#endif + +/* Check if compiler supports declared properties + */ +#if defined(__clang__) || GS_GCC_MINREQ(4,6) +# define GS_HAS_DECLARED_PROPERTIES 1 +#else +# define GS_HAS_DECLARED_PROPERTIES 0 +#endif + +#endif /* __GNUSTEP_GSVERSIONMACROS_H_INCLUDED_ */ diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSArray+GNUstepBase.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSArray+GNUstepBase.h new file mode 100644 index 00000000000..c9b595aa2f6 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSArray+GNUstepBase.h @@ -0,0 +1,78 @@ +/** Declaration of extension methods for base additions + + Copyright (C) 2003-2010 Free Software Foundation, Inc. + + Written by: Richard Frith-Macdonald <rfm@gnu.org> + and: Adam Fedor <fedor@gnu.org> + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + +*/ + +#ifndef INCLUDED_NSArray_GNUstepBase_h +#define INCLUDED_NSArray_GNUstepBase_h + +#import "../GNUstepBase/GSVersionMacros.h" +#import "../Foundation/NSArray.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +#if OS_API_VERSION(GS_API_NONE,GS_API_LATEST) + +@interface NSArray (GNUstepBase) + +/** <p>Method for working with sorted arrays - use a binary chop + * to determine the insertion location for an object. If equal objects + * already exist in the array, they will be located immediately before + * the insertion position. + * </p> + * <p>The comparator function takes two items as arguments, the first is the + * item to be added, the second is the item already in the array. + * The function should return NSOrderedAscending if the item to be + * added is 'less than' the item in the array, NSOrderedDescending + * if it is greater, and NSOrderedSame if it is equal. + * </p> + */ +- (NSUInteger) insertionPosition: (id)item + usingFunction: (NSComparisonResult (*)(id, id, void *))sorter + context: (void *)context; + +/* <p>Method for working with sorted arrays - use a binary chop + * to determine the insertion location for an object. If equal objects + * already exist in the array, they will be located immediately before + * the insertion position. + * </p> + * <p>The selector identifies a method returning NSOrderedAscending if + * the receiver is 'less than' the argument, and NSOrderedDescending if + * it is greate. + * </p> + */ +- (NSUInteger) insertionPosition: (id)item + usingSelector: (SEL)comp; +@end + +#endif /* OS_API_VERSION */ + +#if defined(__cplusplus) +} +#endif + +#endif /* INCLUDED_NSArray_GNUstepBase_h */ + diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSMutableString+GNUstepBase.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSMutableString+GNUstepBase.h new file mode 100644 index 00000000000..b3f71909c0c --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSMutableString+GNUstepBase.h @@ -0,0 +1,57 @@ +/** Declaration of extension methods for base additions + + Copyright (C) 2003-2010 Free Software Foundation, Inc. + + Written by: Richard Frith-Macdonald <rfm@gnu.org> + and: Adam Fedor <fedor@gnu.org> + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + +*/ + +#ifndef INCLUDED_NSMutableString_GNUstepBase_h +#define INCLUDED_NSMutableString_GNUstepBase_h + +#import "GSVersionMacros.h" +#import "../Foundation/NSString.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +#if OS_API_VERSION(GS_API_NONE,GS_API_LATEST) + +@interface NSMutableString (GNUstepBase) +- (void) deleteSuffix: (NSString*)suffix; +- (void) deletePrefix: (NSString*)prefix; +- (NSString*) immutableProxy; +- (void) replaceString: (NSString*)replace + withString: (NSString*)by; +- (void) trimLeadSpaces; +- (void) trimTailSpaces; +- (void) trimSpaces; +@end + +#endif /* OS_API_VERSION */ + +#if defined(__cplusplus) +} +#endif + +#endif /* INCLUDED_NSMutableString_GNUstepBase_h */ + diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSNumber+GNUstepBase.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSNumber+GNUstepBase.h new file mode 100644 index 00000000000..1bed065303b --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSNumber+GNUstepBase.h @@ -0,0 +1,56 @@ +/** Declaration of extension methods for base additions + + Copyright (C) 2003-2010 Free Software Foundation, Inc. + + Written by: Richard Frith-Macdonald <rfm@gnu.org> + and: Adam Fedor <fedor@gnu.org> + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + +*/ + +#ifndef INCLUDED_NSNumber_GNUstepBase_h +#define INCLUDED_NSNumber_GNUstepBase_h + +#import "GSVersionMacros.h" +#import "../Foundation/NSValue.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +#if OS_API_VERSION(GS_API_NONE,GS_API_LATEST) + +@interface NSNumber(GNUstepBase) +/** + * Parses string as a <code>double</code>, <code>int</code>, or <code>unsigned + * int</code> depending on what characters are present. Uses + * <code>atof</code> and <code>atoi</code> which don't report errors, so be + * careful if the string might contain an invalid value. + */ ++ (NSValue*) valueFromString: (NSString *)string; +@end + +#endif /* OS_API_VERSION */ + +#if defined(__cplusplus) +} +#endif + +#endif /* INCLUDED_NSNumber_GNUstepBase_h */ + diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSObject+GNUstepBase.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSObject+GNUstepBase.h new file mode 100644 index 00000000000..d3b2574341b --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSObject+GNUstepBase.h @@ -0,0 +1,242 @@ +/** Declaration of extension methods for base additions + + Copyright (C) 2003-2010 Free Software Foundation, Inc. + + Written by: Richard Frith-Macdonald <rfm@gnu.org> + and: Adam Fedor <fedor@gnu.org> + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + +*/ + +#ifndef INCLUDED_NSObject_GNUstepBase_h +#define INCLUDED_NSObject_GNUstepBase_h + +#import "GSVersionMacros.h" +#import "../Foundation/NSObject.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +#if OS_API_VERSION(GS_API_NONE,GS_API_LATEST) + +@class NSHashTable; + +@interface NSObject (GNUstepBase) + +/** + WARNING: The -compare: method for NSObject is deprecated + due to subclasses declaring the same selector with + conflicting signatures. + Comparision of arbitrary objects is not just meaningless + but also dangerous as most concrete implementations + expect comparable objects as arguments often accessing + instance variables directly. + This method will be removed in a future release. +*/ +- (NSComparisonResult) compare: (id)anObject; + +/** For backward compatibility only ... use class_isMetaClass() on the + * class of the receiver instead. + */ +- (BOOL) isInstance; + +/** DEPRECATED ... do not use. + * Transmutes the receiver into an immutable version of the same object + * and returns the result.<br /> + * If the receiver is not a mutable object or cannot be simply transmuted, + * then this method either returns the receiver unchanged or, + * if the force flag is set to YES, returns an autoreleased copy of the + * receiver.<br /> + * Mutable classes should override this default implementation.<br /> + * This method is used in methods which are declared to return immutable + * objects (eg. an NSArray), but which create and build mutable ones + * internally. + */ +- (id) makeImmutableCopyOnFail: (BOOL)force; + +/** Transmutes the receiver into an immutable version of the same object. + * Returns YES if the receiver has become immutable, NO otherwise.<br /> + * The default implementation returns NO.<br /> + * Mutable classes which have an immutable counterpart they can efficiently + * change into, should override to transmute themselves and return YES.<br /> + * Immutable classes should override this to simply return YES with no + * further action.<br /> + * This method is used in methods which are declared to return immutable + * objects (eg. an NSArray), but which create and build mutable ones + * internally. + */ +- (BOOL) makeImmutable; + +/** + * Message sent when an implementation wants to explicitly exclude a method + * (but cannot due to compiler constraint), and wants to make sure it is not + * called by mistake. Default implementation raises an exception at runtime. + */ +- (id) notImplemented: (SEL)aSel GS_NORETURN_METHOD; + +/** + * Message sent when an implementation wants to explicitly require a subclass + * to implement a method (but cannot at compile time since there is no + * <code>abstract</code> keyword in Objective-C). Default implementation + * raises an exception at runtime to alert developer that he/she forgot to + * override a method. + */ +- (id) subclassResponsibility: (SEL)aSel GS_NORETURN_METHOD; + +/** + * Message sent when an implementation wants to explicitly exclude a method + * (but cannot due to compiler constraint) and forbid that subclasses + * implement it. Default implementation raises an exception at runtime. If a + * subclass <em>does</em> implement this method, however, the superclass's + * implementation will not be called, so this is not a perfect mechanism. + */ +- (id) shouldNotImplement: (SEL)aSel GS_NORETURN_METHOD; + +@end + +/** This is an informal protocol ... classes may implement the method to + * report how much memory is used by the instance and any objects it acts + * as a container for. + */ +@interface NSObject(MemoryFootprint) +/* This method returns the memory usage of the receiver, excluding any + * objects already present in the exclude table.<br /> + * The argument is a hash table configured to hold non-retained pointer + * objects and is used to inform the receiver that its size should not + * be counted again if it's already in the table.<br /> + * The NSObject implementation returns zero if the receiver is in the + * table, but otherwise adds itself to the table and returns its memory + * footprint (the sum of all of its instance variables, but not any + * memory pointed to by those variables).<br /> + * Subclasses should override this method by calling the superclass + * implementation, and either return the result (if it was zero) or + * return that value plus the sizes of any memory owned by the receiver + * (eg found by calling the same method on objects pointed to by the + * receiver's instance variables). + */ +- (NSUInteger) sizeInBytesExcluding: (NSHashTable*)exclude; +@end + +/** This is an informal protocol ... classes may implement the method and + * register themselves to have it called on process exit. + */ +@interface NSObject(GSAtExit) +/** This method is called on exit for any class which implements it and which + * has called +registerAtExit to register it to be called.<br /> + * The order in which methods for different classes is called is the reverse + * of the order in which the classes were registered, but it's best to assume + * the method can not depend on any other class being in a usable state + * at the point when the method is called (rather like +load).<br /> + * Typical use would be to release memory occupied by class data structures + * so that memory usage analysis software will not think the memory has + * been leaked. + */ ++ (void) atExit; +@end + +/** Category for methods handling leaked memory cleanup on exit of process + * (for use when debugging memory leaks).<br /> + * You enable this by calling the +setShouldCleanUp: method (done implicitly + * by gnustep-base if the GNUSTEP_SHOULD_CLEAN_UP environment variable is + * set to YES).<br /> + * Your class then has two options for performing cleanup when the process + * ends: + * <p>1. Use the +leak: method to register objects which are simply to be + * retained until the process ends, and then either ignored or released + * depending on the cleanup setting in force. This mechanism is simple + * and should be sufficient for many classes. + * </p> + * <p>2. Implement a +atExit method to be run when the process ends and, + * within your +initialize implementation, call +shouldCleanUp to determine + * whether cleanup should be done, and if it returns YES then call + * +registerAtExit to have your +atExit method called when the process + * terminates. + * </p> + * <p>The order in which 'leaked' objects are released and +atExit methods + * are called on process exist is the reverse of the order in which they + * werse set up suing this API. + * </p> + */ +@interface NSObject(GSCleanup) + + +/** This method simply retains its argument so that it will never be + * deallocated during normal operation, but keeps track of it so that + * it is released during process exit if cleanup is enabled.<br /> + * Returns its argument. + */ ++ (id) NS_RETURNS_RETAINED leak: (id)anObject; + +/** This method retains the object at *anAddress so that it will never be + * deallocated during normal operation, but keeps track of the address + * so that the object is released and the address is zeroed during process + * exit if cleanup is enabled.<br /> + * Returns the object at *anAddress. + */ ++ (id) NS_RETURNS_RETAINED leakAt: (id*)anAddress; + +/** Sets the receiver to have its +atExit method called at the point when + * the process terminates.<br /> + * Returns YES on success and NO on failure (if the class does not implement + * the method or if it is already registered to call it).<br /> + * Implemented as a call to +registerAtExit: with the selector for the +atExit + * method as its argument. + */ ++ (BOOL) registerAtExit; + +/** Sets the receiver to have the specified method called at the point when + * the process terminates.<br /> + * Returns YES on success and NO on failure (if the class does not implement + * the method ir if it is already registered to call it). + */ ++ (BOOL) registerAtExit: (SEL)aSelector; + +/** Specifies the default cleanup behavior on process exit ... the value + * returned by the NSObject implementation of the +shouldClanUp method.<br /> + * Calling this method with a YES argument implicitly calls the +enableAtExit + * method as well.<br /> + * The GNUstep Base library calls this method with the value obtained from + * the GNUSTEP_SHOULD_CLEAN_UP environment variable when NSObject is + * initialised. + */ ++ (void) setShouldCleanUp: (BOOL)aFlag; + +/** Returns a flag indicating whether the receiver should clean up + * its data structures etc at process exit.<br /> + * The NSObject implementation returns the value set by the +setShouldCleanUp: + * method but subclasses may override this. + */ ++ (BOOL) shouldCleanUp; + +@end + +/* Macro to take an autoreleased object and either make it immutable or + * create an autoreleased copy of the original. + */ +#define GS_IMMUTABLE(O) ([O makeImmutable] == YES ? O : AUTORELEASE([O copy])) + +#endif /* OS_API_VERSION */ + +#if defined(__cplusplus) +} +#endif + +#endif /* INCLUDED_NSObject_GNUstepBase_h */ + diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSString+GNUstepBase.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSString+GNUstepBase.h new file mode 100644 index 00000000000..48633cde5d7 --- /dev/null +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/GNUstepBase/NSString+GNUstepBase.h @@ -0,0 +1,105 @@ +/** Declaration of extension methods for base additions + + Copyright (C) 2003-2010 Free Software Foundation, Inc. + + Written by: Richard Frith-Macdonald <rfm@gnu.org> + and: Adam Fedor <fedor@gnu.org> + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + +*/ + +#ifndef INCLUDED_NSString_GNUstepBase_h +#define INCLUDED_NSString_GNUstepBase_h + +#import "GSVersionMacros.h" +#import "../Foundation/NSString.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +#if OS_API_VERSION(GS_API_NONE,GS_API_LATEST) + +/** + * Provides some additional (non-standard) utility methods. + */ +@interface NSString (GNUstepBase) + +/** + * Alternate way to invoke <code>stringWithFormat</code> if you have or wish + * to build an explicit <code>va_list</code> structure. + */ ++ (id) stringWithFormat: (NSString*)format + arguments: (va_list)argList NS_FORMAT_FUNCTION(1,0); + +/** + * Returns a string formed by removing the prefix string from the + * receiver. Raises an exception if the prefix is not present. + */ +- (NSString*) stringByDeletingPrefix: (NSString*)prefix; + +/** + * Returns a string formed by removing the suffix string from the + * receiver. Raises an exception if the suffix is not present. + */ +- (NSString*) stringByDeletingSuffix: (NSString*)suffix; + +/** + * Returns a string formed by removing leading white space from the + * receiver. + */ +- (NSString*) stringByTrimmingLeadSpaces; + +/** + * Returns a string formed by removing trailing white space from the + * receiver. + */ +- (NSString*) stringByTrimmingTailSpaces; + +/** + * Returns a string formed by removing both leading and trailing + * white space from the receiver. + */ +- (NSString*) stringByTrimmingSpaces; + +/** + * Returns a string in which any (and all) occurrences of + * replace in the receiver have been replaced with by. + * Returns the receiver if replace + * does not occur within the receiver. NB. an empty string is + * not considered to exist within the receiver. + */ +- (NSString*) stringByReplacingString: (NSString*)replace + withString: (NSString*)by; + +/** + * An obsolete name for -substringWithRange: ... deprecated. + */ +- (NSString*) substringFromRange: (NSRange)aRange; + +@end + +#endif /* OS_API_VERSION */ + +#if defined(__cplusplus) +} +#endif + +#endif /* INCLUDED_NSString_GNUstepBase_h */ + diff --git a/gcc/testsuite/objc.dg/encode-7-next-64bit.m b/gcc/testsuite/objc.dg/encode-7-next-64bit.m index 4a418fc92b1..5686cb4c537 100644 --- a/gcc/testsuite/objc.dg/encode-7-next-64bit.m +++ b/gcc/testsuite/objc.dg/encode-7-next-64bit.m @@ -9,10 +9,11 @@ #include <stdbool.h> #include <string.h> #include <stdlib.h> -#include <Foundation/NSObject.h> +#include <stdio.h> +#include "../objc-obj-c++-shared/F-NSObject.h" +#include "../objc-obj-c++-shared/CF-CFString.h" #include "../objc-obj-c++-shared/runtime.h" -extern int printf(char *,...); void CHECK_IF(const char *s1, const char *s2) { if (strcmp(s1,s2) != 0) { diff --git a/gcc/testsuite/objc.dg/headers.m b/gcc/testsuite/objc.dg/headers.m index 355c2cf3c60..e628199f0cc 100644 --- a/gcc/testsuite/objc.dg/headers.m +++ b/gcc/testsuite/objc.dg/headers.m @@ -2,6 +2,7 @@ // test in libstdc++-v3). Author: Loren J. Rittle <ljrittle@acm.org>. // { dg-options "-Wall -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wshadow" } // { dg-do compile } +/* { dg-xfail-if "PR90709" { *-*-darwin1[4-9]* } { "-fnext-runtime" } { "" } } */ #ifdef __NEXT_RUNTIME__ #include <Foundation/NSString.h> diff --git a/gcc/testsuite/objc.dg/image-info.m b/gcc/testsuite/objc.dg/image-info.m index 09329130a73..b2effe5dc86 100644 --- a/gcc/testsuite/objc.dg/image-info.m +++ b/gcc/testsuite/objc.dg/image-info.m @@ -7,7 +7,7 @@ /* { dg-skip-if "NeXT-only" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { dg-options "-freplace-objc-classes" } */ -#include <Foundation/NSObject.h> +#include "../objc-obj-c++-shared/F-NSObject.h" extern void abort(void); #define CHECK_IF(expr) if(!(expr)) abort(); diff --git a/gcc/testsuite/objc.dg/instancetype-0.m b/gcc/testsuite/objc.dg/instancetype-0.m new file mode 100644 index 00000000000..32cafdf314c --- /dev/null +++ b/gcc/testsuite/objc.dg/instancetype-0.m @@ -0,0 +1,30 @@ +/* Contributed by Iain Sandoe <iain@sandoe.co.uk>, May 2019. */ +/* { dg-do compile } */ + +/* Basic check of parsing instancetype. */ + +extern id class_createInstance (id, int); +extern id class_getSuperclass (id); + +@interface MyObject +{ + Class isa; +} ++ (instancetype)alloc; +- (instancetype)init; ++ (instancetype)initialize; ++ (instancetype)factoryMethodA; ++ (id)factoryMethodB; ++ (Class) class; ++ (Class) superclass; +@end + +@implementation MyObject ++ (instancetype)alloc { return class_createInstance (self, 0); } +- (instancetype)init { return self; } ++ (instancetype)initialize { return self; } ++ (instancetype)factoryMethodA { return [[[self class] alloc] init]; } ++ (id)factoryMethodB { return [[[self class] alloc] init]; } ++ (Class) class { return self; } ++ (Class) superclass { return class_getSuperclass (self); } +@end diff --git a/gcc/testsuite/objc.dg/isa-field-1.m b/gcc/testsuite/objc.dg/isa-field-1.m index 4501d01a11e..a786ec3deb5 100644 --- a/gcc/testsuite/objc.dg/isa-field-1.m +++ b/gcc/testsuite/objc.dg/isa-field-1.m @@ -1,5 +1,7 @@ /* Ensure there are no bizarre difficulties with accessing the 'isa' field of objects. */ /* { dg-do compile } */ +/* The use of isa is deprecated, but we still want to test that it works. */ +/* { dg-additional-options "-Wno-deprecated-declarations" } */ #include "../objc-obj-c++-shared/TestsuiteObject.h" #include "../objc-obj-c++-shared/runtime.h" diff --git a/gcc/testsuite/objc.dg/method-6.m b/gcc/testsuite/objc.dg/method-6.m index 35676b18f06..a90c7634da7 100644 --- a/gcc/testsuite/objc.dg/method-6.m +++ b/gcc/testsuite/objc.dg/method-6.m @@ -5,12 +5,12 @@ /* { dg-options "-Wstrict-selector-match" } */ #ifdef __NEXT_RUNTIME__ -#include <Foundation/NSObject.h> -#define OBJECT NSObject +# include "../objc-obj-c++-shared/F-NSObject.h" +# define OBJECT NSObject #else -#include <objc/Object.h> -#include <objc/Protocol.h> -#define OBJECT Object +# include <objc/Object.h> +# include <objc/Protocol.h> +# define OBJECT Object #endif @interface Base diff --git a/gcc/testsuite/objc.dg/no-extra-load.m b/gcc/testsuite/objc.dg/no-extra-load.m index f5e1d74563d..35bd1daf661 100644 --- a/gcc/testsuite/objc.dg/no-extra-load.m +++ b/gcc/testsuite/objc.dg/no-extra-load.m @@ -1,7 +1,7 @@ /* { dg-do compile { target *-*-darwin* } } */ /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ -#include <Foundation/NSObject.h> +#include "../objc-obj-c++-shared/F-NSObject.h" main() { [NSObject new]; } /* { dg-final { scan-assembler-not "L_objc_msgSend\\\$non_lazy_ptr" } } */ diff --git a/gcc/testsuite/objc.dg/objc-foreach-4.m b/gcc/testsuite/objc.dg/objc-foreach-4.m index 4d902f55882..c8dc074b267 100644 --- a/gcc/testsuite/objc.dg/objc-foreach-4.m +++ b/gcc/testsuite/objc.dg/objc-foreach-4.m @@ -5,9 +5,9 @@ /* { dg-skip-if "No NeXT fast enum. pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */ /* { dg-additional-options "-framework Foundation" { target { *-*-darwin* } } } */ -#include <Foundation/NSString.h> -#include <Foundation/NSAutoreleasePool.h> -#include <Foundation/NSArray.h> +#include "../objc-obj-c++-shared/F-NSString.h" +#include "../objc-obj-c++-shared/F-NSAutoreleasePool.h" +#include "../objc-obj-c++-shared/F-NSArray.h" // gcc -o foo foo.m -framework Foundation diff --git a/gcc/testsuite/objc.dg/objc-foreach-5.m b/gcc/testsuite/objc.dg/objc-foreach-5.m index 7113a7ac262..e02bd7aa06d 100644 --- a/gcc/testsuite/objc.dg/objc-foreach-5.m +++ b/gcc/testsuite/objc.dg/objc-foreach-5.m @@ -4,8 +4,9 @@ /* { dg-skip-if "No NeXT fast enum. pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */ /* { dg-additional-options "-framework Foundation" { target { *-*-darwin* } } } */ -#include <Foundation/NSArray.h> -#include <Foundation/NSAutoreleasePool.h> +#include "../objc-obj-c++-shared/F-NSArray.h" +#include "../objc-obj-c++-shared/F-NSAutoreleasePool.h" +#include "../objc-obj-c++-shared/F-NSValue.h" NSArray * createTestVictim(unsigned capacity) { NSMutableArray * arr = [[NSMutableArray alloc] initWithCapacity:capacity]; diff --git a/gcc/testsuite/objc.dg/objc-gc-4.m b/gcc/testsuite/objc.dg/objc-gc-4.m index 747da4d5199..96c32788dfe 100644 --- a/gcc/testsuite/objc.dg/objc-gc-4.m +++ b/gcc/testsuite/objc.dg/objc-gc-4.m @@ -3,6 +3,7 @@ /* Contributed by Ziemowit Laski <zlaski@apple.com> */ /* { dg-do compile } */ +/* { dg-skip-if "GC API is an error from Darwin16." { *-*-darwin1[6-8]* } { "-fnext-runtime" } { "" } } */ /* { dg-options "-fobjc-gc" } */ /* { dg-prune-output "cc1obj: warning: '-fobjc-gc' is ignored for '-fgnu-runtime'" } */ diff --git a/gcc/testsuite/objc.dg/proto-lossage-7.m b/gcc/testsuite/objc.dg/proto-lossage-7.m index b32cfd8a0dd..118a130fd9e 100644 --- a/gcc/testsuite/objc.dg/proto-lossage-7.m +++ b/gcc/testsuite/objc.dg/proto-lossage-7.m @@ -3,7 +3,7 @@ /* { dg-do compile } */ #ifdef __NEXT_RUNTIME__ -#include <Foundation/NSObject.h> +#include "../objc-obj-c++-shared/F-NSObject.h" #define OBJECT NSObject #else #include <objc/Object.h> diff --git a/gcc/testsuite/objc.dg/strings/const-cfstring-2.m b/gcc/testsuite/objc.dg/strings/const-cfstring-2.m index 14ae68c6c50..effe7f57bdc 100644 --- a/gcc/testsuite/objc.dg/strings/const-cfstring-2.m +++ b/gcc/testsuite/objc.dg/strings/const-cfstring-2.m @@ -8,8 +8,8 @@ /* { dg-skip-if "NeXT only" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { dg-options "-mconstant-cfstrings -Wnonportable-cfstrings" } */ -#import <Foundation/NSString.h> -#import <CoreFoundation/CFString.h> +#include "../../objc-obj-c++-shared/F-NSString.h" +#include "../../objc-obj-c++-shared/CF-CFString.h" #ifndef __CONSTANT_CFSTRINGS__ #error The -fconstant-cfstrings option is not functioning properly diff --git a/gcc/testsuite/objc.dg/strings/const-cfstring-5.m b/gcc/testsuite/objc.dg/strings/const-cfstring-5.m index 98bb7c5bddc..762afb6b1ba 100644 --- a/gcc/testsuite/objc.dg/strings/const-cfstring-5.m +++ b/gcc/testsuite/objc.dg/strings/const-cfstring-5.m @@ -6,7 +6,7 @@ /* { dg-skip-if "NeXT only" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { dg-options "-mconstant-cfstrings" } */ -#include <Foundation/NSObject.h> +#include "../../objc-obj-c++-shared/F-NSObject.h" @interface Foo: NSObject { char *cString; diff --git a/gcc/testsuite/objc.dg/strings/const-str-12b.m b/gcc/testsuite/objc.dg/strings/const-str-12b.m index d0dfb668ea9..e04f0f66660 100644 --- a/gcc/testsuite/objc.dg/strings/const-str-12b.m +++ b/gcc/testsuite/objc.dg/strings/const-str-12b.m @@ -6,11 +6,11 @@ /* { dg-options "-mno-constant-cfstrings -fconstant-string-class=Foo" { target *-*-darwin* } } */ #ifdef __NEXT_RUNTIME__ -#include <Foundation/NSObject.h> -#define OBJECT NSObject +# include "../../objc-obj-c++-shared/F-NSObject.h" +# define OBJECT NSObject #else -#include <objc/Object.h> -#define OBJECT Object +# include <objc/Object.h> +# define OBJECT Object #endif #include "../../objc-obj-c++-shared/objc-test-suite-types.h" diff --git a/gcc/testsuite/objc.dg/stubify-1.m b/gcc/testsuite/objc.dg/stubify-1.m index 91bf73a14f7..641595ccfe4 100644 --- a/gcc/testsuite/objc.dg/stubify-1.m +++ b/gcc/testsuite/objc.dg/stubify-1.m @@ -4,7 +4,7 @@ /* { dg-do compile { target *-*-darwin* } } */ /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { dg-require-effective-target ilp32 } */ -/* { dg-options "-Os -mdynamic-no-pic -mmacosx-version-min=10.4" } */ +/* { dg-options "-Os -mdynamic-no-pic -mmacosx-version-min=10.4 -msymbol-stubs" } */ typedef struct objc_object { } *id ; int x = 41 ; @@ -28,8 +28,8 @@ extern int bogonic (int, int, int) ; } @end -/* { dg-final { scan-assembler-not "\(bl|call\)\[ \t\]+_objc_msgSend\n" } } */ -/* { dg-final { scan-assembler "\(bl|call\)\[ \t\]+L_objc_msgSend\\\$stub\n" } } */ -/* { dg-final { scan-assembler-not "\(bl|call\)\[ \t\]+_bogonic\n" } } */ -/* { dg-final { scan-assembler "\(bl|call\)\[ \t\]+L_bogonic\\\$stub\n" } } */ -/* { dg-final { scan-assembler-not "\\\$non_lazy_ptr" } } */ +/* { dg-final { scan-assembler-not {(bl|call)[ \t]+_objc_msgSend\n} } } */ +/* { dg-final { scan-assembler {(bl|call)[ \t]+L_objc_msgSend\$stub\n} } } */ +/* { dg-final { scan-assembler-not {(bl|call)[ \t]+_bogonic\n} } } */ +/* { dg-final { scan-assembler {(bl|call)[ \t]+L_bogonic\$stub\n} } } */ +/* { dg-final { scan-assembler-not {\$non_lazy_ptr} } } */ diff --git a/gcc/testsuite/objc.dg/stubify-2.m b/gcc/testsuite/objc.dg/stubify-2.m index eaf4b964e4b..2930e46fc13 100644 --- a/gcc/testsuite/objc.dg/stubify-2.m +++ b/gcc/testsuite/objc.dg/stubify-2.m @@ -1,10 +1,10 @@ /* All calls must be properly stubified, m32 only. */ /* Testcase extracted from TextEdit:Document.m. */ -/* { dg-do compile { target powerpc*-*-darwin* } } */ +/* { dg-do compile { target *-*-darwin* } } */ /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { dg-require-effective-target ilp32 } */ -/* { dg-options "-mdynamic-no-pic -fdump-rtl-jump -mmacosx-version-min=10.4" } */ +/* { dg-options "-mdynamic-no-pic -mmacosx-version-min=10.4 -msymbol-stubs" } */ typedef struct objc_object { } *id ; int x = 41 ; @@ -30,4 +30,9 @@ extern int bogonic (int, int, int) ; /* Any symbol_ref of an un-stubified objc_msgSend is an error; look for "objc_msgSend" in quotes, without the $stub suffix. */ -/* { dg-final { scan-rtl-dump-not "symbol_ref.*\"objc_msgSend\"" "jump" } } */ + +/* { dg-final { scan-assembler-not {(bl|call)[ \t]+_objc_msgSend\n} } } */ +/* { dg-final { scan-assembler {(bl|call)[ \t]+L_objc_msgSend\$stub\n} } } */ +/* { dg-final { scan-assembler-not {(bl|call)[ \t]+_bogonic\n} } } */ +/* { dg-final { scan-assembler {(bl|call)[ \t]+L_bogonic\$stub\n} } } */ +/* { dg-final { scan-assembler-not {\$non_lazy_ptr} } } */ diff --git a/gcc/testsuite/objc.dg/symtab-1.m b/gcc/testsuite/objc.dg/symtab-1.m index 04d747dbce1..e6e0b613923 100644 --- a/gcc/testsuite/objc.dg/symtab-1.m +++ b/gcc/testsuite/objc.dg/symtab-1.m @@ -4,7 +4,7 @@ /* { dg-do compile { target { *-*-darwin* } } } */ /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ -#include <Foundation/NSObject.h> +#include "../objc-obj-c++-shared/F-NSObject.h" @interface Base: NSObject - (void)setValues; diff --git a/gcc/testsuite/objc.dg/torture/strings/const-cfstring-1.m b/gcc/testsuite/objc.dg/torture/strings/const-cfstring-1.m index 7e989156419..a9c0ab666f1 100644 --- a/gcc/testsuite/objc.dg/torture/strings/const-cfstring-1.m +++ b/gcc/testsuite/objc.dg/torture/strings/const-cfstring-1.m @@ -13,8 +13,8 @@ Well, we don't implement writable ones at this juncture. */ /* { dg-options "-mconstant-cfstrings -framework Cocoa -Wl,-w" { target *-*-darwin[123]* } } */ -#import <Foundation/NSString.h> -#import <CoreFoundation/CFString.h> +#include "../../../objc-obj-c++-shared/F-NSString.h" +#include "../../../objc-obj-c++-shared/CF-CFString.h" #include <stdlib.h> void printOut(NSString *str) { diff --git a/gcc/testsuite/objc.dg/torture/strings/const-str-10.m b/gcc/testsuite/objc.dg/torture/strings/const-str-10.m index 120bcd94c7b..6565dc20007 100644 --- a/gcc/testsuite/objc.dg/torture/strings/const-str-10.m +++ b/gcc/testsuite/objc.dg/torture/strings/const-str-10.m @@ -6,7 +6,8 @@ /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */ -#include <Foundation/NSObject.h> +#include "../../../objc-obj-c++-shared/F-NSObject.h" +#include <stdlib.h> #include "../../../objc-obj-c++-shared/runtime.h" /* For NEXT_OBJC_USE_NEW_INTERFACE. */ @interface NSString: NSObject diff --git a/gcc/testsuite/objc.dg/torture/strings/const-str-11.m b/gcc/testsuite/objc.dg/torture/strings/const-str-11.m index 4c3f9eac893..2bdb1531e1d 100644 --- a/gcc/testsuite/objc.dg/torture/strings/const-str-11.m +++ b/gcc/testsuite/objc.dg/torture/strings/const-str-11.m @@ -7,7 +7,7 @@ /* { dg-options "-fconstant-string-class=XStr" } */ /* { dg-options "-mno-constant-cfstrings -fconstant-string-class=XStr" { target *-*-darwin* } } */ -#include <Foundation/NSObject.h> +#include "../../../objc-obj-c++-shared/F-NSObject.h" #include "../../../objc-obj-c++-shared/runtime.h" /* For NEXT_OBJC_USE_NEW_INTERFACE. */ @interface XString: NSObject { diff --git a/gcc/testsuite/objc.dg/torture/strings/const-str-9.m b/gcc/testsuite/objc.dg/torture/strings/const-str-9.m index d65aa01c044..966ea5e498d 100644 --- a/gcc/testsuite/objc.dg/torture/strings/const-str-9.m +++ b/gcc/testsuite/objc.dg/torture/strings/const-str-9.m @@ -5,7 +5,7 @@ /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */ -#include <Foundation/NSObject.h> +#include "../../../objc-obj-c++-shared/F-NSObject.h" #include "../../../objc-obj-c++-shared/runtime.h" /* For NEXT_OBJC_USE_NEW_INTERFACE. */ @interface NSConstantString: NSObject { diff --git a/gcc/testsuite/objc.dg/zero-link-1.m b/gcc/testsuite/objc.dg/zero-link-1.m index 812267bc376..e1148deb4a7 100644 --- a/gcc/testsuite/objc.dg/zero-link-1.m +++ b/gcc/testsuite/objc.dg/zero-link-1.m @@ -5,7 +5,7 @@ /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { dg-options "-fzero-link" } */ -#include <Foundation/NSObject.h> +#include "../objc-obj-c++-shared/F-NSObject.h" extern void abort(void); #define CHECK_IF(expr) if(!(expr)) abort(); diff --git a/gcc/testsuite/objc.dg/zero-link-2.m b/gcc/testsuite/objc.dg/zero-link-2.m index 3bfe84d021d..19100919b3c 100644 --- a/gcc/testsuite/objc.dg/zero-link-2.m +++ b/gcc/testsuite/objc.dg/zero-link-2.m @@ -5,7 +5,7 @@ /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { dg-options "-fno-zero-link" } */ -#include <Foundation/NSObject.h> +#include "../objc-obj-c++-shared/F-NSObject.h" extern void abort(void); #define CHECK_IF(expr) if(!(expr)) abort(); diff --git a/gcc/testsuite/objc.dg/zero-link-3.m b/gcc/testsuite/objc.dg/zero-link-3.m index 18f21db4e65..0c77c095d4d 100644 --- a/gcc/testsuite/objc.dg/zero-link-3.m +++ b/gcc/testsuite/objc.dg/zero-link-3.m @@ -7,12 +7,12 @@ /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ #ifdef __NEXT_RUNTIME__ -#include <Foundation/NSObject.h> -#define OBJECT NSObject +# include "../objc-obj-c++-shared/F-NSObject.h" +# define OBJECT NSObject #else -#include <objc/Object.h> -#include <objc/Protocol.h> -#define OBJECT Object +# include <objc/Object.h> +# include <objc/Protocol.h> +# define OBJECT Object #endif extern void abort(void); |