https://bugs.llvm.org/show_bug.cgi?id=45245

            Bug ID: 45245
           Summary: Optional Parameter Argument Preprocessor trick fails
                    for objc_method_family (init) methods
           Product: clang
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]

Created attachment 23256
  --> https://bugs.llvm.org/attachment.cgi?id=23256&action=edit
Code for repro case.

There is a "trick" described at
https://stackoverflow.com/questions/3046889/optional-parameters-with-c-macros
for doing optional parameters with c macros.

It is used by the popular https://ocmock.org/ library.

Unfortunately it seems to generate a warning for unused-value that it shouldn't
generate when used with an objc_method_family (init) from within an objc method
implementation.

To repro:

Xcode 11.3 (or Xcode 11.4b3)

clang -Werror -Wunused-value -fobjc-arc main.m

Expected Result: Clean compile
Actual Result:

main.m:30:13: error: expression result unused [-Werror,-Wunused-value]
  OCMVerify([object init]);
            ^~~~~~~~~~~~~
main.m:12:64: note: expanded from macro 'OCMVerify'
#define OCMVerify(...) _OCMVerify_X(,##__VA_ARGS__, _OCMVerify(__VA_ARGS__))
                                                               ^~~~~~~~~~~
main.m:8:5: note: expanded from macro '_OCMVerify'
    invocation; \
    ^~~~~~~~~~
main.m:11:39: note: expanded from macro '_OCMVerify_X'
#define _OCMVerify_X(x,A,FUNC, ...)   FUNC

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to