[clang] regression in clang 21: -Wmissing-noreturn is emitted for virtual methods (original) (raw)

Sometimes I feel like I'm the only one in town to compile with -Weverything...

Test source:

#include

struct Base { virtual ~Base () = default;

virtual void foo () {
    throw std::runtime_error("this base method does not return");
}

};

Compile:

$ clang++ -std=c++23 -Wmissing-noreturn -c test.cxx 
test.cxx:6:18: warning: function 'foo' could be declared with attribute 'noreturn' [-Wmissing-noreturn]
    6 |     virtual void foo () {
      |                  ^
1 warning generated.

This warning is obviously spurious: Base::foo does indeed not return, but a derived method may return.

The warning is emitted by clang 21.1.4. It did not occur with clang 20.x.++