Bug 1123459 - Add an informational note to the diagnostic explaining to use the explicit keyword; r=jrmuizel

This commit is contained in:
Ehsan Akhgari 2015-01-19 16:35:35 -05:00
parent 2d9e6659e7
commit 739a4dfd9f
2 changed files with 6 additions and 3 deletions

View File

@ -241,7 +241,10 @@ public:
}
unsigned ctorID = Diag.getDiagnosticIDs()->getCustomDiagID(
DiagnosticIDs::Error, "bad implicit conversion constructor for %0");
unsigned noteID = Diag.getDiagnosticIDs()->getCustomDiagID(
DiagnosticIDs::Note, "consider adding the explicit keyword to the constructor");
Diag.Report(ctor->getLocation(), ctorID) << d->getDeclName();
Diag.Report(ctor->getLocation(), noteID);
}
}

View File

@ -1,9 +1,9 @@
#define MOZ_IMPLICIT __attribute__((annotate("moz_implicit")))
struct Foo {
Foo(int); // expected-error {{bad implicit conversion constructor for 'Foo'}}
Foo(int, char=0); // expected-error {{bad implicit conversion constructor for 'Foo'}}
Foo(...); // expected-error {{bad implicit conversion constructor for 'Foo'}}
Foo(int); // expected-error {{bad implicit conversion constructor for 'Foo'}} expected-note {{consider adding the explicit keyword to the constructor}}
Foo(int, char=0); // expected-error {{bad implicit conversion constructor for 'Foo'}} expected-note {{consider adding the explicit keyword to the constructor}}
Foo(...); // expected-error {{bad implicit conversion constructor for 'Foo'}} expected-note {{consider adding the explicit keyword to the constructor}}
Foo(int, unsigned);
Foo(Foo&);
Foo(const Foo&);