r252827 - Add diagnostics which fall under [dcl.spec.concept]p5
Nathan Wilson via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 11 15:53:35 PST 2015
Author: nwilson
Date: Wed Nov 11 17:53:35 2015
New Revision: 252827
URL: http://llvm.org/viewvc/llvm-project?rev=252827&view=rev
Log:
Add diagnostics which fall under [dcl.spec.concept]p5
Summary: Diagnose when a function concept declaration has parameter(s)
Reviewers: rsmith, faisalv, aaron.ballman, hubert.reinterpretcast
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D14352
Added:
cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=252827&r1=252826&r2=252827&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Nov 11 17:53:35 2015
@@ -1994,6 +1994,8 @@ def err_function_concept_exception_spec
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<
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=252827&r1=252826&r2=252827&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Nov 11 17:53:35 2015
@@ -7607,6 +7607,13 @@ Sema::ActOnFunctionDeclarator(Scope *S,
} 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) || (FPT->isVariadic()))
+ Diag(NewFD->getLocation(), diag::err_function_concept_with_params);
}
// C++ Concepts TS [dcl.spec.concept]p2: Every concept definition is
Added: cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp?rev=252827&view=auto
==============================================================================
--- cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp (added)
+++ cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp Wed Nov 11 17:53:35 2015
@@ -0,0 +1,13 @@
+// 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}}
+
+template<typename... Ts>
+concept bool fcpp(Ts... ts) { return true; } // expected-error {{function concept cannot have any parameters}}
+
+template<typename T>
+concept bool fcpva(...) { return true; } // expected-error {{function concept cannot have any parameters}}
More information about the cfe-commits
mailing list