[PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

Nathan Wilson via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 27 19:44:59 PST 2015


nwilson added inline comments.

================
Comment at: include/clang/AST/DeclTemplate.h:836
@@ -835,2 +835,3 @@
 
+  bool IsConcept : 1;
 protected:
----------------
rsmith wrote:
> This might make more sense on `TemplateDecl`, since we also want this flag for `VarTemplateDecl`s. In any case, please use some existing spare bit for this rather than making all `FunctionTemplateDecl`s 8 bytes larger by putting it here.
@rsmith - Yeah, I originally thought to put it in TemplateDecl but reconsidered since ClassTemplateDecls would get it as well . However, I guess by making TemplateDecl::TemplatedDecl an IntPointerPair that concern is irrelevant.

@faisalv - Thanks for the info and suggestion! This helped with Richard's suggestion (below). FYI - It looks like that IntPointerPair, InstantiatedFromMember, is for explicit specializations, and the pointer to CommonBase (Common) is null for a function concept's primary template declaration. 


================
Comment at: include/clang/AST/DeclTemplate.h:986
@@ +985,3 @@
+  bool isConcept() const { return IsConcept; }
+  void setConcept(bool IC) { IsConcept = IC; }
+
----------------
rsmith wrote:
> Do we need a setter for this? (Can it change after the decl is constructed?)
The setter is used below when we see that `concept` is specified on the declaration. So, it wouldn't be initialized (or set)  to true when the decl is constructed.  Or, do you have a different opinion on where to set `IsConcept` to true such as how `IsConstExpr` is initialized in FunctionDecls being passed as a param in the constructor? 

================
Comment at: lib/Sema/SemaDecl.cpp:7727
@@ +7726,3 @@
+        Diag(D.getDeclSpec().getConceptSpecLoc(),
+             diag::err_concept_specified_specialization) << 1;
+      }
----------------
Thanks for the suggestion. I'll go with TemplatedDecl and see what you guys think.


http://reviews.llvm.org/D13357





More information about the cfe-commits mailing list