<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 24, 2015 at 2:43 PM, Aaron Ballman <span dir="ltr"><<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Fri, Jul 24, 2015 at 3:43 PM, Hubert Tong<br>
<<a href="mailto:hubert.reinterpretcast@gmail.com">hubert.reinterpretcast@gmail.com</a>> wrote:<br>
> Thanks Aaron for copying the similar messages here. I'd still like the use<br>
> "definition of", but with Aaron's suggestion as the base.<br>
> I considered using plural nouns instead of singular ones to match the<br>
> existing messages better, but the result was clunky.<br>
><br>
> "'concept' can only appear on the definition of a function template or<br>
> variable template"<br>
<br>
</span>Perfect!<br></blockquote><div><br></div><div>Thanks guys. I'll update the patch.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
~Aaron<br>
<br>
><br>
> On Fri, Jul 24, 2015 at 3:37 PM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>><br>
> wrote:<br>
>><br>
>> On Fri, Jul 24, 2015 at 3:27 PM, Nathan Wilson <<a href="mailto:nwilson20@gmail.com">nwilson20@gmail.com</a>><br>
>> wrote:<br>
>> ><br>
>> ><br>
>> > On Fri, Jul 24, 2015 at 2:14 PM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>><br>
>> > wrote:<br>
>> >><br>
>> >> On Fri, Jul 24, 2015 at 2:43 PM, Nathan Wilson <<a href="mailto:nwilson20@gmail.com">nwilson20@gmail.com</a>><br>
<span class="">>> >> wrote:<br>
>> >> > nwilson created this revision.<br>
>> >> > nwilson added reviewers: rsmith, faisalv, fraggamuffin,<br>
>> >> > hubert.reinterpretcast.<br>
>> >> > nwilson added a subscriber: cfe-commits.<br>
>> >> ><br>
>> >> > Adding diagnostic for concepts declared as non template (function or<br>
>> >> > variable)<br>
>> >> ><br>
>> >> > <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D11490&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=spcJ40dj7XemadE2NsLdlCHk5PqCzcciWVCmfIfvlpI&s=f_6zr57ibS-lEEcgYrysfeQyDgSSUtjAE9Q5Lz8q9JQ&e=" rel="noreferrer" target="_blank">http://reviews.llvm.org/D11490</a><br>
>> >><br>
>> >> ><br>
</span><div><div class="h5">>> >> > Files:<br>
>> >> >   include/clang/Basic/DiagnosticSemaKinds.td<br>
>> >> >   lib/Sema/SemaDecl.cpp<br>
>> >> >   test/SemaCXX/cxx-concept-declaration.cpp<br>
>> >> ><br>
>> >> > Index: test/SemaCXX/cxx-concept-declaration.cpp<br>
>> >> > ===================================================================<br>
>> >> > --- test/SemaCXX/cxx-concept-declaration.cpp<br>
>> >> > +++ test/SemaCXX/cxx-concept-declaration.cpp<br>
>> >> > @@ -15,3 +15,7 @@<br>
>> >> >  struct C {<br>
>> >> >    template<typename T> static concept bool D3 = true; //<br>
>> >> > expected-error<br>
>> >> > {{concept declarations may only appear in namespace scope}}<br>
>> >> >  };<br>
>> >> > +<br>
>> >> > +concept bool D4() { return true; } // expected-error {{concept can<br>
>> >> > only<br>
>> >> > be applied to a function or variable template definition}}<br>
>> >> > +<br>
>> >> > +concept bool D5 = true; // expected-error {{concept can only be<br>
>> >> > applied<br>
>> >> > to a function or variable template definition}}<br>
>> >> > Index: lib/Sema/SemaDecl.cpp<br>
>> >> > ===================================================================<br>
>> >> > --- lib/Sema/SemaDecl.cpp<br>
>> >> > +++ lib/Sema/SemaDecl.cpp<br>
>> >> > @@ -4865,6 +4865,12 @@<br>
>> >> >      // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier<br>
>> >> > shall be<br>
>> >> >      // applied only to the definition of a function template or<br>
>> >> > variable<br>
>> >> >      // template, declared in namespace scope<br>
>> >> > +    if (!TemplateParamLists.size()) {<br>
>> >> > +      Diag(D.getDeclSpec().getConceptSpecLoc(),<br>
>> >> > +           diag::err_concept_decl_non_template);<br>
>> >> > +      return nullptr;<br>
>> >> > +    }<br>
>> >> > +<br>
>> >> >      if (!DC->getRedeclContext()->isFileContext()) {<br>
>> >> >        Diag(D.getIdentifierLoc(),<br>
>> >> ><br>
>> >> > diag::err_concept_decls_may_only_appear_in_namespace_scope);<br>
>> >> > Index: include/clang/Basic/DiagnosticSemaKinds.td<br>
>> >> > ===================================================================<br>
>> >> > --- include/clang/Basic/DiagnosticSemaKinds.td<br>
>> >> > +++ include/clang/Basic/DiagnosticSemaKinds.td<br>
>> >> > @@ -1966,6 +1966,8 @@<br>
>> >> >    "use __attribute__((visibility(\"hidden\"))) attribute instead">;<br>
>> >> ><br>
>> >> >  // C++ Concepts TS<br>
>> >> > +def err_concept_decl_non_template : Error<<br>
>> >> > +  "concept can only be applied to a function or variable template<br>
>> >> > definition">;<br>
>> >><br>
>> >> Since we are using "concept" as a grammar term, I think we want to<br>
>> >> quote it. Similar diagnostics suggest phrasing like:<br>
>> >><br>
>> >> "'concept' can only appear on a function template or variable template<br>
>> >> definition"<br>
>> >><br>
>> >> This also reduces some ambiguity over how "function or variable<br>
>> >> template"<br>
>> >> binds.<br>
>> >><br>
>> >> ~Aaron<br>
>> ><br>
>> ><br>
>> > May we apply both this suggestion and Hubert's? So it would be:<br>
>> ><br>
>> > "the 'concept' specifier may only be applied to the definition of a<br>
>> > function<br>
>> > or variable template"<br>
>><br>
>> I don't have a strong preference, but I think "specifier may only be"<br>
>> is kind of wordy without adding much value. For comparison:<br>
>><br>
>> def err_inline_non_function : Error<<br>
>>   "'inline' can only appear on functions">;<br>
>> def err_noreturn_non_function : Error<<br>
>>   "'_Noreturn' can only appear on functions">;<br>
>> def err_virtual_non_function : Error<<br>
>>   "'virtual' can only appear on non-static member functions">;<br>
>> def err_explicit_non_function : Error<<br>
>>   "'explicit' can only appear on non-static member functions">;<br>
>><br>
>> ~Aaron<br>
>><br>
>> ><br>
>> >><br>
>> >><br>
>> >> >  def err_concept_decls_may_only_appear_in_namespace_scope : Error<<br>
>> >> >    "concept declarations may only appear in namespace scope">;<br>
>> >> >  def err_function_concept_not_defined : Error<<br>
>> >> ><br>
>> >> ><br>
>> >> ><br>
>> >> > _______________________________________________<br>
>> >> > cfe-commits mailing list<br>
</div></div>>> >> > <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
>> >> > <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
>> >> ><br>
>> ><br>
>> ><br>
><br>
><br>
</blockquote></div><br></div></div>