<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 10, 2015 at 10:46 AM, Nathan Wilson <span dir="ltr"><<a href="mailto:nwilson20@gmail.com" target="_blank">nwilson20@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">nwilson updated this revision to Diff 29446.<br>
nwilson added a comment.<br>
<br>
As suggested by Aaron, modify phrasing of err_invalid_constexpr_var_decl<br></blockquote><div><br></div><div>Aaron - fyi, I fixed this comment I made in Phab, but I guess an updated email wasn't sent. This is what it correctly says now:</div><div><span style="color:rgb(0,0,0);font-family:'Segoe UI','Segoe UI Web Regular','Segoe UI Symbol','Helvetica Neue',Helvetica,Arial,sans-serif;font-size:13px;line-height:18.8500003814697px">As suggested by Aaron, modify phrasing of err_function_concept_not_defined</span><br style="color:rgb(0,0,0);font-family:'Segoe UI','Segoe UI Web Regular','Segoe UI Symbol','Helvetica Neue',Helvetica,Arial,sans-serif;font-size:13px;line-height:18.8500003814697px"></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Remove redundant comment for concept declaration being definition<br>
<span class=""><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=F6EVw7VIIrZvWWQTU37SfIgV8Lvk002tRT6xb3Yknok&s=ZtktDjunVBzFZvBBG62Igo6o2Rc9DZn_x5sOGcjUnGw&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>
</span>@@ -0,0 +1,17 @@<br>
<span class="">+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s<br>
+<br>
</span>+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 {{function concept declaration must be a definition}}<br>
+<br>
+struct B {<br>
+  template<typename T> concept bool D2() { return true; } // expected-error {{concept declarations may only appear in namespace scope}}<br>
+};<br>
+<br>
+struct C {<br>
+  template<typename T> static concept bool D3 = true; // expected-error {{concept declarations may only appear in namespace scope}}<br>
<span class="">+};<br>
Index: lib/Sema/SemaDecl.cpp<br>
===================================================================<br>
--- lib/Sema/SemaDecl.cpp<br>
+++ lib/Sema/SemaDecl.cpp<br>
</span><span class="">@@ -4878,6 +4878,17 @@<br>
   if (getLangOpts().CPlusPlus)<br>
     CheckExtraCXXDefaultArguments(D);<br>
<br>
+  if (D.getDeclSpec().isConceptSpecified()) {<br>
</span><span class="">+    // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be<br>
+    // applied only to the definition of a function template or variable<br>
+    // template, declared in namespace scope<br>
</span><span class="">+    if (!DC->getRedeclContext()->isFileContext()) {<br>
+      Diag(D.getIdentifierLoc(),<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>
</span>@@ -7223,6 +7234,7 @@<br>
<span class="">     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>
</span>@@ -7439,6 +7451,20 @@<br>
<span class="">         Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_constexpr_dtor);<br>
     }<br>
<br>
+    if (isConcept) {<br>
+      // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be<br>
</span>+      // applied only to the definition of a function template...<br>
<span class="">+      if (!D.isFunctionDefinition()) {<br>
+        Diag(D.getDeclSpec().getConceptSpecLoc(),<br>
+             diag::err_function_concept_not_defined);<br>
+        NewFD->setInvalidDecl();<br>
+      }<br>
+<br>
</span>+      // C++ Concepts TS [dcl.spec.concept]p2: Every concept definition is<br>
<span class="">+      // implicity defined to be a constexpr declaration (implicitly inline)<br>
+      NewFD->setImplicitlyInline();<br>
+    }<br>
+<br>
     // If __module_private__ was specified, mark the function 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>
</span>+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>
+  "function concept declaration must be a definition">;<br>
<div class=""><div class="h5">+<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>
<br>
</div></div></blockquote></div><br></div></div>