gecko-dev/build/clang-plugin/tests/TestExplicitOperatorBool.cpp
Ehsan Akhgari 399276d5fc Bug 1153348 - Add an analysis to prohibit operator bools which aren't marked as either explicit or MOZ_IMPLICIT; r=jrmuizel
This is the counterpart to the existing analysis to catch
constructors which aren't marked as either explicit or
MOZ_IMPLICIT.
2015-04-21 21:40:49 -04:00

12 lines
332 B
C++

#define MOZ_IMPLICIT __attribute__((annotate("moz_implicit")))
struct Bad {
operator bool(); // expected-error {{bad implicit conversion operator for 'Bad'}} expected-note {{consider adding the explicit keyword to 'operator bool'}}
};
struct Good {
explicit operator bool();
};
struct Okay {
MOZ_IMPLICIT operator bool();
};