[llvm-bugs] [Bug 44692] New: clang reports error from macro for wrong line

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jan 28 01:03:13 PST 2020


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: unassignedclangbugs at nondot.org
          Reporter: schopf.dan at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200128/b237652f/attachment.html>


More information about the llvm-bugs mailing list