[PATCH] D11916: [CONCEPTS] Add diagnostic; invalid tag when concept specified
Nathan Wilson via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 14 16:20:29 PDT 2015
This revision was automatically updated to reflect the committed changes.
Closed by commit rL245123: [CONCEPTS] Add diagnostic; invalid tag when concept specified (authored by nwilson).
Changed prior to commit:
http://reviews.llvm.org/D11916?vs=31957&id=32200#toc
Repository:
rL LLVM
http://reviews.llvm.org/D11916
Files:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1969,7 +1969,7 @@
"use __attribute__((visibility(\"hidden\"))) attribute instead">;
// C++ Concepts TS
-def err_concept_decl_non_template : Error<
+def err_concept_wrong_decl_kind : Error<
"'concept' can only appear on the definition of a function template or variable template">;
def err_concept_decls_may_only_appear_in_namespace_scope : Error<
"concept declarations may only appear in namespace scope">;
Index: cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp
===================================================================
--- cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp
+++ cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp
@@ -23,3 +23,13 @@
template<typename T>
concept bool D6; // expected-error {{variable concept declaration must be initialized}}
+// Tag
+concept class CC1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+concept struct CS1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+concept union CU1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+concept enum CE1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+template <typename T> concept class TCC1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+template <typename T> concept struct TCS1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+template <typename T> concept union TCU1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+
+concept bool; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -3662,6 +3662,14 @@
return TagD;
}
+ if (DS.isConceptSpecified()) {
+ // C++ Concepts TS [dcl.spec.concept]p1: A concept definition refers to
+ // either a function concept and its definition or a variable concept and
+ // its initializer.
+ Diag(DS.getConceptSpecLoc(), diag::err_concept_wrong_decl_kind);
+ return TagD;
+ }
+
DiagnoseFunctionSpecifiers(DS);
if (DS.isFriendSpecified()) {
@@ -4865,7 +4873,7 @@
// template, declared in namespace scope
if (!TemplateParamLists.size()) {
Diag(D.getDeclSpec().getConceptSpecLoc(),
- diag::err_concept_decl_non_template);
+ diag:: err_concept_wrong_decl_kind);
return nullptr;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11916.32200.patch
Type: text/x-patch
Size: 3064 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150814/57b2a387/attachment-0001.bin>
More information about the cfe-commits
mailing list