Opened 2 years ago

Closed 2 years ago

#65998 closed defect (fixed)

legacy-support @1.0.7: error: restrict requires a pointer or reference

Reported by: kencu (Ken) Owned by: kencu (Ken)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: cjones051073 (Chris Jones)
Port: legacy-support, legacy-support-devel

Description

trying to run the macports-legacy-support test suite with a newer compiler such as gcc-7 or clang-7.0 fails:

gcc-mp-7 -c -Iinclude -Os -Wall -fPIC src/macports_legacy_realpath.c -o src/macports_legacy_realpath.dl.o
gcc-mp-7 -c -Iinclude -Os -Wall -fPIC src/macports_legacy_realpath.c -o src/macports_legacy_realpath.dl.o
src/macports_legacy_realpath.c:27:1: error: invalid use of 'restrict'
 char *realpath(const char __restrict *stringsearch, char __restrict *buffer)
 ^~~~
src/macports_legacy_realpath.c:27:1: error: invalid use of 'restrict'
src/macports_legacy_realpath.c: In function 'realpath':
src/macports_legacy_realpath.c:29:5: error: invalid use of 'restrict'
     char *(*real_realpath)(const char __restrict *, char __restrict *);
     ^~~~
src/macports_legacy_realpath.c:29:5: error: invalid use of 'restrict'
src/macports_legacy_realpath.c: At top level:
src/macports_legacy_realpath.c:52:1: error: invalid use of 'restrict'
 char *macports_legacy_realpath(const char __restrict *stringsearch, char __restrict *buffer) { return realpath(stringsearch, buffer); }
 ^~~~
src/macports_legacy_realpath.c:52:1: error: invalid use of 'restrict'
make: *** [src/macports_legacy_realpath.dl.o] Error 1
clang-mp-7.0 -c -Iinclude -Os -Wall -fPIC src/macports_legacy_realpath.c -o src/macports_legacy_realpath.dl.o
clang-mp-7.0 -c -Iinclude -Os -Wall -fPIC src/macports_legacy_realpath.c -o src/macports_legacy_realpath.dl.o
src/macports_legacy_realpath.c:27:27: error: restrict requires a pointer or reference ('char' is invalid)
char *realpath(const char __restrict *stringsearch, char __restrict *buffer)
                          ^
/usr/include/sys/cdefs.h:177:20: note: expanded from macro '__restrict'
#define __restrict      restrict
                        ^
src/macports_legacy_realpath.c:27:58: error: restrict requires a pointer or reference ('char' is invalid)
char *realpath(const char __restrict *stringsearch, char __restrict *buffer)
                                                         ^
/usr/include/sys/cdefs.h:177:20: note: expanded from macro '__restrict'
#define __restrict      restrict
                        ^
src/macports_legacy_realpath.c:29:39: error: restrict requires a pointer or reference ('char' is invalid)
    char *(*real_realpath)(const char __restrict *, char __restrict *);
                                      ^
/usr/include/sys/cdefs.h:177:20: note: expanded from macro '__restrict'
#define __restrict      restrict
                        ^
src/macports_legacy_realpath.c:29:58: error: restrict requires a pointer or reference ('char' is invalid)
    char *(*real_realpath)(const char __restrict *, char __restrict *);
                                                         ^
/usr/include/sys/cdefs.h:177:20: note: expanded from macro '__restrict'
#define __restrict      restrict
                        ^
src/macports_legacy_realpath.c:52:43: error: restrict requires a pointer or reference ('char' is invalid)
char *macports_legacy_realpath(const char __restrict *stringsearch, char __restrict *buffer) { return realpath(stringsearch, buffer); }
                                          ^
/usr/include/sys/cdefs.h:177:20: note: expanded from macro '__restrict'
#define __restrict      restrict
                        ^
src/macports_legacy_realpath.c:52:74: error: restrict requires a pointer or reference ('char' is invalid)
char *macports_legacy_realpath(const char __restrict *stringsearch, char __restrict *buffer) { return realpath(stringsearch, buffer); }
                                                                         ^
/usr/include/sys/cdefs.h:177:20: note: expanded from macro '__restrict'
#define __restrict      restrict
                        ^
6 errors generated.
make: *** [src/macports_legacy_realpath.dl.o] Error 1

steps to reproduce (on 10.5 Intel):

cd /Users/Shared
git clone https://github.com/macports/macports-legacy-support.git
cd macports-legacy-support
CC=clang-mp-7.0 CXX=clang++-mp-7.0  make check

some other syntax is needed for the restrict keyword it seems, although it does work with gcc-4.2.

Change History (4)

comment:1 Changed 2 years ago by jmroot (Joshua Root)

Putting a qualifier in the middle of a type specifier does seem questionably valid. I would think you should write either __restrict char *buffer or char * __restrict buffer, not char __restrict *buffer.

comment:2 Changed 2 years ago by jmroot (Joshua Root)

Though of course restrict only makes sense on pointers, so since the thing pointed to is not itself a pointer, only char * __restrict buffer is applicable. And indeed that's exactly what the declaration of realpath in the system headers uses.

comment:3 Changed 2 years ago by kencu (Ken)

thank you, that looks right. will try tomorrow.

comment:4 Changed 2 years ago by kencu (Ken)

Owner: set to kencu
Resolution: fixed
Status: newclosed

In 070b63433b8332d900ef9d4dcff16689af9c4ab2/macports-legacy-support (master):

fix errors with newer compilers

closes: #65998

test_sincos generates warnings if stdio.h is included before math.h

Note: See TracTickets for help on using tickets.