Clang compiler option to treat exception specification lax error as warning

524 views Asked by At

Is there a way to treat exception mismatch error as warning in clang?

source_file.cpp:12:18: error: exception specification of overriding function is more lax than base version virtual void Func(){}

I am getting error with google mock for functions that specify exception specifier. Looking at https://github.com/google/googletest/pull/681 and other reported issue, not sure if this will get fixed in google mock, so at least for test code if possible I would like to disable this.

//clang 3.8.0
#include <iostream>

struct A
{
    virtual void Func() throw() {}
};
struct B : public A
{
    virtual void Func(){}
};

int main()
{
    B b;  
    return 0;
}
1

There are 1 answers

0
valiano On BEST ANSWER

Yes, using the -fms-extensions command line option.
MSVC only warns about this, so with clang MSVC compatibility mode, the code will compile, and the error will be replaced with an equivalent warning.

More about MSVC compatibility mode in clang documentation, here.