<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 10, 2015 at 9:44 AM, 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"><div class="HOEnZb"><div class="h5">On Fri, Jul 10, 2015 at 10:34 AM, Nathan Wilson <<a href="mailto:nwilson20@gmail.com">nwilson20@gmail.com</a>> wrote:<br>
><br>
><br>
> On Fri, Jul 10, 2015 at 8:52 AM, Hubert Tong<br>
> <<a href="mailto:hubert.reinterpretcast@gmail.com">hubert.reinterpretcast@gmail.com</a>> wrote:<br>
>><br>
>> On Fri, Jul 10, 2015 at 8:30 AM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>><br>
>> wrote:<br>
>>><br>
>>> Tiny nits, otherwise LGTM, but please wait for Richard to also sign off.<br>
>><br>
>> Same from my end.<br>
>><br>
>>><br>
>>><br>
>>> On Fri, Jul 10, 2015 at 12:21 AM, Nathan Wilson <<a href="mailto:nwilson20@gmail.com">nwilson20@gmail.com</a>><br>
>>> wrote:<br>
>>> > nwilson updated this revision to Diff 29426.<br>
>>> > nwilson added a comment.<br>
>>> ><br>
>>> > Update phrasing for concept declaration scope diagnostic<br>
>>> > Fix indentation issue<br>
>>> > Update comments for function declaration being a definition<br>
>>> > Adding acceptance tests for concepts in namespace scope and adding<br>
>>> > diagnostic test for variable concept not being in namespace scope<br>
>>> ><br>
>>> ><br>
>>> > <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D11027&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=BBa1IhYguvkrpaEtNTL1rmPZG_Wv9gwmcPRYcDFJtxI&s=Z1VFfG2-t_fF8w-FSlx1XvrH7qNdWnVmxFowoCDAHl4&e=" rel="noreferrer" target="_blank">http://reviews.llvm.org/D11027</a><br>
>>> ><br>
>>> > 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>
>>> > --- /dev/null<br>
>>> > +++ test/SemaCXX/cxx-concept-declaration.cpp<br>
>>> > @@ -0,0 +1,17 @@<br>
>>> > +// RUN: %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s<br>
>>> > +<br>
>>> > +namespace A {<br>
>>> > + template<typename T> concept bool C1() { return true; }<br>
>>> > +<br>
>>> > + template<typename T> concept bool C2 = true;<br>
>>> > +}<br>
>>> > +<br>
>>> > +template<typename T> concept bool D1(); // expected-error {{can only<br>
>>> > declare a function concept with its definition}}<br>
>>> > +<br>
>>> > +struct B {<br>
>>> > + template<typename T> concept bool D2() { return true; } //<br>
>>> > expected-error {{concept declarations may only appear in namespace scope}}<br>
>>> > +};<br>
>>> > +<br>
>>> > +struct C {<br>
>>> > + template<typename T> static concept bool D3 = true; //<br>
>>> > expected-error {{concept declarations may only appear in namespace scope}}<br>
>>> > +};<br>
>>> > Index: lib/Sema/SemaDecl.cpp<br>
>>> > ===================================================================<br>
>>> > --- lib/Sema/SemaDecl.cpp<br>
>>> > +++ lib/Sema/SemaDecl.cpp<br>
>>> > @@ -4878,6 +4878,17 @@<br>
>>> > if (getLangOpts().CPlusPlus)<br>
>>> > CheckExtraCXXDefaultArguments(D);<br>
>>> ><br>
>>> > + if (D.getDeclSpec().isConceptSpecified()) {<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>
>>><br>
>>> Missing a period.<br>
>>><br>
>>> > + if (!DC->getRedeclContext()->isFileContext()) {<br>
>>> > + Diag(D.getIdentifierLoc(),<br>
>>> > +<br>
>>> > diag::err_concept_decls_may_only_appear_in_namespace_scope);<br>
>>> > + return nullptr;<br>
>>> > + }<br>
>>> > + }<br>
>>> > +<br>
>>> > NamedDecl *New;<br>
>>> ><br>
>>> > bool AddToScope = true;<br>
>>> > @@ -7223,6 +7234,7 @@<br>
>>> > bool isVirtual = D.getDeclSpec().isVirtualSpecified();<br>
>>> > bool isExplicit = D.getDeclSpec().isExplicitSpecified();<br>
>>> > bool isConstexpr = D.getDeclSpec().isConstexprSpecified();<br>
>>> > + bool isConcept = D.getDeclSpec().isConceptSpecified();<br>
>>> > isFriend = D.getDeclSpec().isFriendSpecified();<br>
>>> > if (isFriend && !isInline && D.isFunctionDefinition()) {<br>
>>> > // C++ [class.friend]p5<br>
>>> > @@ -7439,6 +7451,21 @@<br>
>>> > Diag(D.getDeclSpec().getConstexprSpecLoc(),<br>
>>> > diag::err_constexpr_dtor);<br>
>>> > }<br>
>>> ><br>
>>> > + if (isConcept) {<br>
>>> > + // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier<br>
>>> > shall be<br>
>>> > + // applied only to the definition of a function template<br>
>>> > + // (we are checking that the declaration is indeed a definition)<br>
>>><br>
>>> Missing a period.<br>
>><br>
>> I think ellipsis is appropriate. Also, the parenthesized part is redundant<br>
>> now.<br>
><br>
><br>
> Yeah, I was attempting to be explicit, but I guess the code does that. I can<br>
> make the change.<br>
>><br>
>><br>
>>><br>
>>><br>
>>> > + if (!D.isFunctionDefinition()) {<br>
>>> > + Diag(D.getDeclSpec().getConceptSpecLoc(),<br>
>>> > + diag::err_function_concept_not_defined);<br>
>>> > + NewFD->setInvalidDecl();<br>
>>> > + }<br>
>>> > +<br>
>>> > + // C++ Concepts TS [dcl.spec.concept]p2: Every concept<br>
>>> > definition is<br>
>>> > + // implicity defined to be a constexpr declaration (implicitly<br>
>>> > inline)<br>
>>> > + NewFD->setImplicitlyInline();<br>
>>> > + }<br>
>>> > +<br>
>>> > // If __module_private__ was specified, mark the function<br>
>>> > accordingly.<br>
>>> > if (D.getDeclSpec().isModulePrivateSpecified()) {<br>
>>> > if (isFunctionTemplateSpecialization) {<br>
>>> > Index: include/clang/Basic/DiagnosticSemaKinds.td<br>
>>> > ===================================================================<br>
>>> > --- include/clang/Basic/DiagnosticSemaKinds.td<br>
>>> > +++ include/clang/Basic/DiagnosticSemaKinds.td<br>
>>> > @@ -1959,6 +1959,12 @@<br>
>>> > def note_private_extern : Note<<br>
>>> > "use __attribute__((visibility(\"hidden\"))) attribute instead">;<br>
>>> ><br>
>>> > +// C++ Concepts TS<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>
>>> > + "can only declare a function concept with its definition">;<br>
>>><br>
>>> This reads slightly strange to me. We have another diagnostic that we<br>
>>> could steal wording from:<br>
>>><br>
>>> def err_invalid_constexpr_var_decl : Error<<br>
>>> "constexpr variable declaration must be a definition">;<br>
>>><br>
>>> So perhaps "function concept declaration must be a definition"?<br>
>><br>
>> That sounds good.<br>
><br>
><br>
> Okay, that works. Do you guys have any issue with the name:<br>
> err_function_concept_not_defined<br>
><br>
> Or, would something like this be more appropriate?:<br>
> err_invalid_concept_function_decl<br>
<br>
</div></div>I prefer err_invalid_concept_function_decl.<br></blockquote><div><br></div><div>Hmm, well, I'm leaning to what Hubert said about it being a bit too generic since there are other places where a name like this would be applicable (declared returning type not being bool, non empty parameter list, ...)</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
~Aaron<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
><br>
>><br>
>><br>
>>><br>
>>><br>
>>> > +<br>
>>> > // C++11 char16_t/char32_t<br>
>>> > def warn_cxx98_compat_unicode_type : Warning<<br>
>>> > "'%0' type specifier is incompatible with C++98">,<br>
>>><br>
>>> ~Aaron<br>
>>><br>
>>> ><br>
>>> ><br>
>>> ><br>
>>> > _______________________________________________<br>
>>> > cfe-commits mailing list<br>
>>> > <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>
</div></div></blockquote></div><br></div></div>