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

            Bug ID: 44692
           Summary: clang reports error from macro for wrong line
           Product: clang
           Version: 9.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: schopf....@gmail.com
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org,
                    neeil...@live.com, richard-l...@metafoo.co.uk

Compiling the attached code produces a misleading error message because the
indicated line is wrong.

Steps to reproduce:

1. Compile this code:

#define ALL_COMMANDS \
CMD(Play) \
CMD(Stop)

struct base {
        virtual int Play() = 0;
};

struct foo : public base {
        #define CMD(a)  \
                int a() override {      \
                        return 0;       \
                }

        ALL_COMMANDS
};

Actual result:

test.cpp:15:2: error: only virtual member functions can be marked 'override'
        ALL_COMMANDS
        ^
test.cpp:2:11: note: expanded from macro 'ALL_COMMANDS'
CMD(Play) \
          ^
test.cpp:11:11: note: expanded from macro '\
CMD'
                int a() override {      \
                        ^
1 error generated.

Expected result:

The actual error comes from line 3, which is CMD(Stop), and not line 2. This
can be very misleading when trying to fix the error.

This also happens with the latest trunk: https://godbolt.org/z/DUrFwo

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

Reply via email to