user3279954
user3279954

Reputation: 586

Clang compiler option to treat exception specification lax error as warning

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;
}

Upvotes: 0

Views: 533

Answers (1)

valiano
valiano

Reputation: 18541

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.

Upvotes: 2

Related Questions