[PATCH] D14352: Add diagnostics which fall under [dcl.spec.concept]p5
Nathan Wilson via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 4 15:10:16 PST 2015
nwilson created this revision.
nwilson added reviewers: rsmith, faisalv, hubert.reinterpretcast, aaron.ballman.
nwilson added a subscriber: cfe-commits.
Diagnose when a function concept declaration has parameter(s)
http://reviews.llvm.org/D14352
Files:
include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDecl.cpp
test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
===================================================================
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template<typename T>
+concept bool fcpv(void) { return true; }
+
+template<typename T>
+concept bool fcpi(int i = 0) { return true; } // expected-error {{function concept cannot have any parameters}}
Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7569,6 +7569,13 @@
} else {
Context.adjustExceptionSpec(NewFD, EST_BasicNoexcept);
}
+
+ // C++ Concepts TS [dcl.spec.concept]p5: A function concept has the
+ // following restrictions:
+ // — The declaration’s parameter list shall be equivalent to an empty
+ // parameter list.
+ if (FPT->getNumParams() > 0)
+ Diag(NewFD->getLocation(), diag::err_function_concept_with_params);
}
// C++ Concepts TS [dcl.spec.concept]p2: Every concept definition is
Index: include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -1990,6 +1990,8 @@
def err_concept_decl_invalid_specifiers : Error<
"%select{variable|function}0 concept cannot be declared "
"'%select{thread_local|inline|friend|constexpr}1'">;
+def err_function_concept_with_params : Error<
+ "function concept cannot have any parameters">;
// C++11 char16_t/char32_t
def warn_cxx98_compat_unicode_type : Warning<
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14352.39267.patch
Type: text/x-patch
Size: 1775 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151104/1066c6b4/attachment.bin>
More information about the cfe-commits
mailing list