[PATCH] D11027: [CONCEPTS] Creating Diagnostics for ill-formed function concept declaration

Hubert Tong hubert.reinterpretcast at gmail.com
Thu Jul 9 06:50:04 PDT 2015


hubert.reinterpretcast added inline comments.

================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1964
@@ +1963,3 @@
+def err_concept_decls_may_only_appear_in_global_scope : Error<
+  "function and variable concept declarations may only appear in global scope">;
+def err_function_concept_not_defined : Error<
----------------
Perhaps s/function and variable concept/concept/; see Aaron's response for further changes.

================
Comment at: lib/Sema/SemaDecl.cpp:4887
@@ +4886,3 @@
+      Diag(D.getIdentifierLoc(),
+	   diag::err_concept_decls_may_only_appear_in_global_scope);
+      return nullptr;
----------------
There seems to be an indenting issue caused by a tab character here.

================
Comment at: lib/Sema/SemaDecl.cpp:7455
@@ +7454,3 @@
+    if (isConcept) {
+      // We are checking that the function concept declaration is a definition
+      if (!D.isFunctionDefinition()) {
----------------
Since the quote from the relevant part of the Standard has been moved elsewhere, it makes sense to quote it again up to the "function template" part.

================
Comment at: test/SemaCXX/cxx-concept-declaration.cpp:2
@@ +1,3 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template<typename T> concept bool D1(); // expected-error {{can only declare a function concept with its definition}}
----------------
Aaron suggested that we have acceptance testing for concepts in a namespace scope other than the global one.

================
Comment at: test/SemaCXX/cxx-concept-declaration.cpp:7
@@ +6,2 @@
+  template<typename T> concept bool D1() { return true; } // expected-error {{function and variable concept declarations may only appear in global scope}}
+};
----------------
Since we now cover variable cases for the scope check as well, we should have a test for it.


http://reviews.llvm.org/D11027







More information about the cfe-commits mailing list