[llvm-bugs] [Bug 36596] New: -Winconsistent-missing-override does not fire on overriding "virtual void bar() final"
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Mar 4 16:21:57 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=36596
Bug ID: 36596
Summary: -Winconsistent-missing-override does not fire on
overriding "virtual void bar() final"
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: arthur.j.odwyer at gmail.com
CC: llvm-bugs at lists.llvm.org
Note: This bug is similar to
https://bugs.llvm.org/show_bug.cgi?id=32079
except that I am adding the "virtual" keyword to Roman's example in order to
deflect Alexander's objection. This bug is also similar to
https://bugs.llvm.org/show_bug.cgi?id=21051
In fact I believe that fixing this bug could enable you to close 21051 as
no-longer-interesting.
Test case:
struct S {
virtual void foo();
virtual void bar();
};
struct T : public S {
VIRTUAL void foo() override;
VIRTUAL void NAME() final;
};
Compile with `-DVIRTUAL= -DNAME=bar`. This is the "best practice, no bug" case,
and naturally it gives no diagnostic.
Compile with `-DVIRTUAL= -DNAME=baz`. This is the "best practice, buggy" case.
Clang correctly diagnoses: "only virtual member functions can be marked
'final'."
Compile with `-DVIRTUAL=virtual -DNAME=baz`. This is the "bad practice, buggy"
case. Clang does not give any diagnostic, because the code seems to have a
reasonable interpretation.
Compile with `-DVIRTUAL=virtual -DNAME=bar`. This is the "bad practice, no bug"
case. Clang does not give any diagnostic.
In this fourth and last scenario, I would prefer Clang to give the diagnostic
"'bar' overrides a member function but is not marked 'override'
[-Winconsistent-missing-override]", because of the danger presented by typoing
the name of this function (replacing "bar" with "baz" silently changes the
meaning of the program).
--
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/20180305/36929b59/attachment.html>
More information about the llvm-bugs
mailing list