<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 16, 2016 at 10:01 PM, Ryan Yee via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">ryee88 updated this revision to Diff 48149.<br>
ryee88 added a comment.<br>
<br>
Keeping the number of test files to a minimum makes sense.<br>
<br>
Couldn't find an existing test for this diagnostic.</blockquote><div><br></div><div>That would be a bit surprising - if you want to see if you can find one, one way would be to add an "assert(false)" in where the diagnostic is emitted, and see which test cases fail - see if any look useful. They might not be testing tnhe whole diagnostic text, etc, but could be expanded to do so.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> I did find a cxx-reference.cpp that tests reference diagnostics so this seems like a reasonable location for this new test.<br>
<span class=""><br>
<br>
<a href="http://reviews.llvm.org/D16949" rel="noreferrer" target="_blank">http://reviews.llvm.org/D16949</a><br>
<br>
Files:<br>
include/clang/Basic/DiagnosticSemaKinds.td<br>
lib/Sema/SemaOverload.cpp<br>
</span> test/Parser/cxx-reference.cpp<br>
<br>
Index: test/Parser/cxx-reference.cpp<br>
===================================================================<br>
--- test/Parser/cxx-reference.cpp<br>
+++ test/Parser/cxx-reference.cpp<br>
@@ -24,3 +24,29 @@<br>
#if __cplusplus <= 199711L<br>
// expected-warning@-2 {{rvalue references are a C++11 extension}}<br>
#endif<br>
+<br>
+namespace PointerVsReferenceSuggestion{<br>
+ class A;<br>
+<br>
+ void f0(A *a); // expected-note {{candidate function not viable: cannot convert argument of incomplete type 'PointerVsReferenceSuggestion::A' to 'PointerVsReferenceSuggestion::A *' for 1st argument; take the address of the argument with &}}<br>
+ void f1(A &a) {<br>
<span class="">+ f0(a); // expected-error {{no matching function for call to 'f0'}}<br>
+ }<br>
+<br>
</span>+ void f2(A &a); // expected-note {{candidate function not viable: cannot convert argument of incomplete type 'PointerVsReferenceSuggestion::A *' to 'PointerVsReferenceSuggestion::A &' for 1st argument; dereference the argument with *}}<br>
+ void f3(A *a) {<br>
<span class="">+ f2(a); // expected-error {{no matching function for call to 'f2'}}<br>
+ }<br>
+<br>
</span>+ class B {};<br>
+<br>
+ void f4(B *b); // expected-note {{candidate function not viable: no known conversion from 'PointerVsReferenceSuggestion::B' to 'PointerVsReferenceSuggestion::B *' for 1st argument; take the address of the argument with &}}<br>
+ void f5(B &b) {<br>
+ f4(b); // expected-error {{no matching function for call to 'f4'}}<br>
+ }<br>
+<br>
+ void f6(B &b); // expected-note {{candidate function not viable: no known conversion from 'PointerVsReferenceSuggestion::B *' to 'PointerVsReferenceSuggestion::B &' for 1st argument; dereference the argument with *}}<br>
+ void f7(B *b) {<br>
+ f6(b); // expected-error {{no matching function for call to 'f6'}}<br>
+ }<br>
+}<br>
<div class="HOEnZb"><div class="h5">Index: lib/Sema/SemaOverload.cpp<br>
===================================================================<br>
--- lib/Sema/SemaOverload.cpp<br>
+++ lib/Sema/SemaOverload.cpp<br>
@@ -9104,10 +9104,13 @@<br>
if (const PointerType *PTy = TempFromTy->getAs<PointerType>())<br>
TempFromTy = PTy->getPointeeType();<br>
if (TempFromTy->isIncompleteType()) {<br>
+ // Emit the generic diagnostic and, optionally, add the hints to it.<br>
S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_conv_incomplete)<br>
<< (unsigned) FnKind << FnDesc<br>
<< (FromExpr ? FromExpr->getSourceRange() : SourceRange())<br>
- << FromTy << ToTy << (unsigned) isObjectArgument << I+1;<br>
+ << FromTy << ToTy << (unsigned) isObjectArgument << I+1<br>
+ << (unsigned) (Cand->Fix.Kind);<br>
+<br>
MaybeEmitInheritedConstructorNote(S, Fn);<br>
return;<br>
}<br>
Index: include/clang/Basic/DiagnosticSemaKinds.td<br>
===================================================================<br>
--- include/clang/Basic/DiagnosticSemaKinds.td<br>
+++ include/clang/Basic/DiagnosticSemaKinds.td<br>
@@ -3189,7 +3189,12 @@<br>
"function (the implicit move assignment operator)|"<br>
"constructor (inherited)}0%1 "<br>
"not viable: cannot convert argument of incomplete type "<br>
- "%diff{$ to $|to parameter type}2,3">;<br>
+ "%diff{$ to $|to parameter type}2,3 for "<br>
+ "%select{%ordinal5 argument|object argument}4"<br>
+ "%select{|; dereference the argument with *|"<br>
+ "; take the address of the argument with &|"<br>
+ "; remove *|"<br>
+ "; remove &}6">;<br>
def note_ovl_candidate_bad_list_argument : Note<"candidate "<br>
"%select{function|function|constructor|"<br>
"function |function |constructor |"<br>
<br>
<br>
</div></div><br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div></div>