clang defines __weak as if -fobjc-gc were specified

This is with a clang built from trunk head a couple of days ago.

When clang is run without objc-gc mode,
clang defines the symbol __weak as if -fobjc-gc were specified,
clang defines the symbol __strong as empty.

Here are two commands, the first shows the clang symbols,
the second shows the warning when a source file wants to define
__strong and __weak itself.

$ echo | clang -E - -dM | egrep “strong|weak”

#define __strong
#define __weak attribute((objc_gc(weak)))

$ clang -E - <<EOF
#define __strong
#define __weak
EOF
:2:9: warning: ‘__weak’ macro redefined
#define __weak
^
:158:9: note: previous definition is here
#define __weak attribute((objc_gc(weak)))
^

1 warning generated.

__weak is always defined for use in blocks. It is unfortunate though that it is def’ed to
objc_gc(weak) though. But for the purpose of use, it doesn’t really matter.

  • Fariborz