Message ID | CANq5SyvPthg96k36012Bqc7umigwMhJug1EWe-pUbUnHKPye3g@mail.gmail.com |
---|---|
State | New |
Headers | show |
Hi, On 08/20/2014 08:56 PM, Andrew Sutton wrote: > + return VAR_P (decl) > + && DECL_LANG_SPECIFIC (decl) > + && DECL_DECLARED_CONCEPT_P (decl); this is brittle from the formatting point of view. Please double check in detail what I'm going to say, but I think that in such cases you simply want to wrap the whole thing in round parentheses. Paolo.
> On 08/20/2014 08:56 PM, Andrew Sutton wrote: >> >> + return VAR_P (decl) >> + && DECL_LANG_SPECIFIC (decl) >> + && DECL_DECLARED_CONCEPT_P (decl); > > this is brittle from the formatting point of view. Please double check in > detail what I'm going to say, but I think that in such cases you simply want > to wrap the whole thing in round parentheses. Sorry, did you just mean to wrap the entire conjunction in parens? I'm trying to find the formatting guidelines to check, but not succeeding at the moment. Andrew
Hi Andrew, On 08/20/2014 11:08 PM, Andrew Sutton wrote: >> On 08/20/2014 08:56 PM, Andrew Sutton wrote: >>> + return VAR_P (decl) >>> + && DECL_LANG_SPECIFIC (decl) >>> + && DECL_DECLARED_CONCEPT_P (decl); >> this is brittle from the formatting point of view. Please double check in >> detail what I'm going to say, but I think that in such cases you simply want >> to wrap the whole thing in round parentheses. > Sorry, did you just mean to wrap the entire conjunction in parens? I'm > trying to find the formatting guidelines to check, but not succeeding > at the moment. Yes, I meant the whole conjunction, sorry about my sloppy language. In terms of GNU coding standards: http://www.gnu.org/prep/standards/standards.html#Formatting toward the end of the section, for example. Paolo.
Index: gcc/cp/decl.c =================================================================== --- gcc/cp/decl.c (revision 214239) +++ gcc/cp/decl.c (working copy) @@ -6259,6 +6259,16 @@ value_dependent_init_p (tree init) return false; } +// Returns true if a DECL is VAR_DECL with the concept specifier. Note +// that not all variables are decl-lang-specific. +static inline bool +is_concept_var (tree decl) +{ + return VAR_P (decl) + && DECL_LANG_SPECIFIC (decl) + && DECL_DECLARED_CONCEPT_P (decl); +} + /* Finish processing of a declaration; install its line number and initial value. If the length of an array type is not known before, @@ -6435,6 +6445,8 @@ cp_finish_decl (tree decl, tree init, bo init = NULL_TREE; release_tree_vector (cleanups); } + else if (!init && is_concept_var (decl)) + error ("variable concept has no initializer"); else if (!DECL_PRETTY_FUNCTION_P (decl)) { /* Deduce array size even if the initializer is dependent. */ @@ -8264,9 +8276,17 @@ grokvardecl (tree type, else DECL_INTERFACE_KNOWN (decl) = 1; - // Mark the variable as a concept. + // Check that the variable can be safely declared as a concept. if (conceptp) - DECL_DECLARED_CONCEPT_P (decl) = true; + { + if (!processing_template_decl) + { + error ("a non-template variable cannot be %<concept%>"); + return NULL_TREE; + } + else + DECL_DECLARED_CONCEPT_P (decl) = true; + } // Handle explicit specializations and instantiations of variable templates. if (orig_declarator)