public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c++: Remove LOOKUP_CONSTINIT.
@ 2020-09-11  2:15 Marek Polacek
  2020-09-11 14:57 ` Nathan Sidwell
  0 siblings, 1 reply; 3+ messages in thread
From: Marek Polacek @ 2020-09-11  2:15 UTC (permalink / raw)
  To: GCC Patches, Jason Merrill

Since we now have DECL_DECLARED_CONSTINIT_P, we no longer need
LOOKUP_CONSTINIT.

Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?

gcc/cp/ChangeLog:

	* cp-tree.h (LOOKUP_CONSTINIT): Remove.
	(LOOKUP_REWRITTEN): Adjust.
	* decl.c (duplicate_decls): Set DECL_DECLARED_CONSTINIT_P.
	(check_initializer): Use DECL_DECLARED_CONSTINIT_P instead of
	LOOKUP_CONSTINIT.
	(cp_finish_decl): Don't set DECL_DECLARED_CONSTINIT_P.  Use
	DECL_DECLARED_CONSTINIT_P instead of LOOKUP_CONSTINIT.
	(grokdeclarator): Set DECL_DECLARED_CONSTINIT_P.
	* decl2.c (grokfield): Don't handle LOOKUP_CONSTINIT.
	* parser.c (cp_parser_decomposition_declaration): Remove
	LOOKUP_CONSTINIT handling.
	(cp_parser_init_declarator): Likewise.
	* pt.c (tsubst_expr): Likewise.
	(instantiate_decl): Likewise.
	* typeck2.c (store_init_value): Use DECL_DECLARED_CONSTINIT_P instead
	of LOOKUP_CONSTINIT.
---
 gcc/cp/cp-tree.h |  4 +---
 gcc/cp/decl.c    | 13 +++++++------
 gcc/cp/decl2.c   |  3 ---
 gcc/cp/parser.c  |  9 ++-------
 gcc/cp/pt.c      |  8 ++------
 gcc/cp/typeck2.c |  2 +-
 6 files changed, 13 insertions(+), 26 deletions(-)

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index b166475b5f1..5923574a7aa 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -5598,13 +5598,11 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, TYPENAME_FLAG };
 #define LOOKUP_DELEGATING_CONS (LOOKUP_NO_NON_INTEGRAL << 1)
 /* Allow initialization of a flexible array members.  */
 #define LOOKUP_ALLOW_FLEXARRAY_INIT (LOOKUP_DELEGATING_CONS << 1)
-/* Require constant initialization of a non-constant variable.  */
-#define LOOKUP_CONSTINIT (LOOKUP_ALLOW_FLEXARRAY_INIT << 1)
 /* We're looking for either a rewritten comparison operator candidate or the
    operator to use on the former's result.  We distinguish between the two by
    knowing that comparisons other than == and <=> must be the latter, as must
    a <=> expression trying to rewrite to <=> without reversing.  */
-#define LOOKUP_REWRITTEN (LOOKUP_CONSTINIT << 1)
+#define LOOKUP_REWRITTEN (LOOKUP_ALLOW_FLEXARRAY_INIT << 1)
 /* Reverse the order of the two arguments for comparison rewriting.  First we
    swap the arguments in add_operator_candidates, then we swap the conversions
    in add_candidate (so that they correspond to the original order of the
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index f1b7fbaa75b..79afdeeb055 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -2312,6 +2312,8 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
 	    |= DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (olddecl);
 	  DECL_DECLARED_CONSTEXPR_P (newdecl)
 	    |= DECL_DECLARED_CONSTEXPR_P (olddecl);
+	  DECL_DECLARED_CONSTINIT_P (newdecl)
+	    |= DECL_DECLARED_CONSTINIT_P (olddecl);
 
 	  /* Merge the threadprivate attribute from OLDDECL into NEWDECL.  */
 	  if (DECL_LANG_SPECIFIC (olddecl)
@@ -6884,7 +6886,7 @@ check_initializer (tree decl, tree init, int flags, vec<tree, va_gc> **cleanups)
 	      flags |= LOOKUP_ALREADY_DIGESTED;
 	    }
 	  else if (DECL_DECLARED_CONSTEXPR_P (decl)
-		   || (flags & LOOKUP_CONSTINIT))
+		   || DECL_DECLARED_CONSTINIT_P (decl))
 	    {
 	      /* Declared constexpr or constinit, but no suitable initializer;
 		 massage init appropriately so we can pass it into
@@ -7675,10 +7677,6 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
 	  DECL_INITIAL (decl) = NULL_TREE;
 	}
 
-      /* Handle `constinit' on variable templates.  */
-      if (flags & LOOKUP_CONSTINIT)
-	DECL_DECLARED_CONSTINIT_P (decl) = true;
-
       /* Generally, initializers in templates are expanded when the
 	 template is instantiated.  But, if DECL is a variable constant
 	 then it can be used in future constant expressions, so its value
@@ -7782,7 +7780,7 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
       /* [dcl.constinit]/1 "The constinit specifier shall be applied
 	 only to a declaration of a variable with static or thread storage
 	 duration."  */
-      if ((flags & LOOKUP_CONSTINIT)
+      if (DECL_DECLARED_CONSTINIT_P (decl)
 	  && !(dk == dk_thread || dk == dk_static))
 	{
 	  error_at (DECL_SOURCE_LOCATION (decl),
@@ -13832,6 +13830,9 @@ grokdeclarator (const cp_declarator *declarator,
     /* Set constexpr flag on vars (functions got it in grokfndecl).  */
     if (constexpr_p && VAR_P (decl))
       DECL_DECLARED_CONSTEXPR_P (decl) = true;
+    /* And the constinit flag (which only applies to variables).  */
+    else if (constinit_p && VAR_P (decl))
+      DECL_DECLARED_CONSTINIT_P (decl) = true;
 
     /* Record constancy and volatility on the DECL itself .  There's
        no need to do this when processing a template; we'll do this
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 50a042e8070..fd48a212787 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -994,9 +994,6 @@ grokfield (const cp_declarator *declarator,
   else
     flags = LOOKUP_IMPLICIT;
 
-  if (decl_spec_seq_has_spec_p (declspecs, ds_constinit))
-    flags |= LOOKUP_CONSTINIT;
-
   switch (TREE_CODE (value))
     {
     case VAR_DECL:
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 916ea6cd910..fed16895b42 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -14096,12 +14096,9 @@ cp_parser_decomposition_declaration (cp_parser *parser,
 
       if (decl != error_mark_node)
 	{
-	  int flags = (decl_spec_seq_has_spec_p (decl_specifiers, ds_constinit)
-		       ? LOOKUP_CONSTINIT : 0);
 	  cp_maybe_mangle_decomp (decl, prev, v.length ());
 	  cp_finish_decl (decl, initializer, non_constant_p, NULL_TREE,
-			  (is_direct_init ? LOOKUP_NORMAL : LOOKUP_IMPLICIT)
-			  | flags);
+			  (is_direct_init ? LOOKUP_NORMAL : LOOKUP_IMPLICIT));
 	  cp_finish_decomp (decl, prev, v.length ());
 	}
     }
@@ -21018,8 +21015,6 @@ cp_parser_init_declarator (cp_parser* parser,
      declarations.  */
   if (!member_p && decl && decl != error_mark_node && !range_for_decl_p)
     {
-      int cf = (decl_spec_seq_has_spec_p (decl_specifiers, ds_constinit)
-		? LOOKUP_CONSTINIT : 0);
       cp_finish_decl (decl,
 		      initializer, !is_non_constant_init,
 		      asm_specification,
@@ -21028,7 +21023,7 @@ cp_parser_init_declarator (cp_parser* parser,
 			 `explicit' constructor is OK.  Otherwise, an
 			 `explicit' constructor cannot be used.  */
 		      ((is_direct_init || !is_initialized)
-		       ? LOOKUP_NORMAL : LOOKUP_IMPLICIT) | cf);
+		       ? LOOKUP_NORMAL : LOOKUP_IMPLICIT));
     }
   else if ((cxx_dialect != cxx98) && friend_p
 	   && decl && TREE_CODE (decl) == FUNCTION_DECL)
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 30c6735dede..0f52a9ed77d 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -18103,10 +18103,7 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
 		       now.  */
 		    predeclare_vla (decl);
 
-		    bool constinit_p
-		      = VAR_P (decl) && DECL_DECLARED_CONSTINIT_P (decl);
-		    cp_finish_decl (decl, init, const_init, NULL_TREE,
-				    constinit_p ? LOOKUP_CONSTINIT : 0);
+		    cp_finish_decl (decl, init, const_init, NULL_TREE, 0);
 
 		    if (ndecl != error_mark_node)
 		      cp_finish_decomp (ndecl, first, cnt);
@@ -25758,8 +25755,7 @@ instantiate_decl (tree d, bool defer_ok, bool expl_inst_class_mem_p)
         push_nested_class (DECL_CONTEXT (d));
 
       const_init = DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (code_pattern);
-      int flags = (DECL_DECLARED_CONSTINIT_P (d) ? LOOKUP_CONSTINIT : 0);
-      cp_finish_decl (d, init, const_init, NULL_TREE, flags);
+      cp_finish_decl (d, init, const_init, NULL_TREE, 0);
 
       if (enter_context)
         pop_nested_class ();
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index b95f112a744..e259a4201be 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -920,7 +920,7 @@ store_init_value (tree decl, tree init, vec<tree, va_gc>** cleanups, int flags)
 	  /* [dcl.constinit]/2 "If a variable declared with the constinit
 	     specifier has dynamic initialization, the program is
 	     ill-formed."  */
-	  if (flags & LOOKUP_CONSTINIT)
+	  if (DECL_DECLARED_CONSTINIT_P (decl))
 	    {
 	      error_at (location_of (decl),
 			"%<constinit%> variable %qD does not have a constant "

base-commit: b7028f060c6760b336b416897412e327ded12ab5
-- 
2.26.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] c++: Remove LOOKUP_CONSTINIT.
  2020-09-11  2:15 [PATCH] c++: Remove LOOKUP_CONSTINIT Marek Polacek
@ 2020-09-11 14:57 ` Nathan Sidwell
  2020-09-11 15:05   ` Marek Polacek
  0 siblings, 1 reply; 3+ messages in thread
From: Nathan Sidwell @ 2020-09-11 14:57 UTC (permalink / raw)
  To: Marek Polacek, GCC Patches, Jason Merrill

On 9/10/20 10:15 PM, Marek Polacek via Gcc-patches wrote:
> Since we now have DECL_DECLARED_CONSTINIT_P, we no longer need
> LOOKUP_CONSTINIT.
> 
> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?

looks good, thanks for noticing.  BTW, you now have
 >       /* Set constexpr flag on vars (functions got it in grokfndecl).  */
 >       if (constexpr_p && VAR_P (decl))
 >         DECL_DECLARED_CONSTEXPR_P (decl) = true;
 > +    /* And the constinit flag (which only applies to variables).  */
 > +    else if (constinit_p && VAR_P (decl))
 > +      DECL_DECLARED_CONSTINIT_P (decl) = true;

might that be clearer as
if (VAR_P (decl))
   {  constexpr stuff constinit stuff }

?  Ok either way

> 
> gcc/cp/ChangeLog:
> 
> 	* cp-tree.h (LOOKUP_CONSTINIT): Remove.
> 	(LOOKUP_REWRITTEN): Adjust.
> 	* decl.c (duplicate_decls): Set DECL_DECLARED_CONSTINIT_P.
> 	(check_initializer): Use DECL_DECLARED_CONSTINIT_P instead of
> 	LOOKUP_CONSTINIT.
> 	(cp_finish_decl): Don't set DECL_DECLARED_CONSTINIT_P.  Use
> 	DECL_DECLARED_CONSTINIT_P instead of LOOKUP_CONSTINIT.
> 	(grokdeclarator): Set DECL_DECLARED_CONSTINIT_P.
> 	* decl2.c (grokfield): Don't handle LOOKUP_CONSTINIT.
> 	* parser.c (cp_parser_decomposition_declaration): Remove
> 	LOOKUP_CONSTINIT handling.
> 	(cp_parser_init_declarator): Likewise.
> 	* pt.c (tsubst_expr): Likewise.
> 	(instantiate_decl): Likewise.
> 	* typeck2.c (store_init_value): Use DECL_DECLARED_CONSTINIT_P instead
> 	of LOOKUP_CONSTINIT.
> ---
>   gcc/cp/cp-tree.h |  4 +---
>   gcc/cp/decl.c    | 13 +++++++------
>   gcc/cp/decl2.c   |  3 ---
>   gcc/cp/parser.c  |  9 ++-------
>   gcc/cp/pt.c      |  8 ++------
>   gcc/cp/typeck2.c |  2 +-
>   6 files changed, 13 insertions(+), 26 deletions(-)
> 
> diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
> index b166475b5f1..5923574a7aa 100644
> --- a/gcc/cp/cp-tree.h
> +++ b/gcc/cp/cp-tree.h
> @@ -5598,13 +5598,11 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, TYPENAME_FLAG };
>   #define LOOKUP_DELEGATING_CONS (LOOKUP_NO_NON_INTEGRAL << 1)
>   /* Allow initialization of a flexible array members.  */
>   #define LOOKUP_ALLOW_FLEXARRAY_INIT (LOOKUP_DELEGATING_CONS << 1)
> -/* Require constant initialization of a non-constant variable.  */
> -#define LOOKUP_CONSTINIT (LOOKUP_ALLOW_FLEXARRAY_INIT << 1)
>   /* We're looking for either a rewritten comparison operator candidate or the
>      operator to use on the former's result.  We distinguish between the two by
>      knowing that comparisons other than == and <=> must be the latter, as must
>      a <=> expression trying to rewrite to <=> without reversing.  */
> -#define LOOKUP_REWRITTEN (LOOKUP_CONSTINIT << 1)
> +#define LOOKUP_REWRITTEN (LOOKUP_ALLOW_FLEXARRAY_INIT << 1)
>   /* Reverse the order of the two arguments for comparison rewriting.  First we
>      swap the arguments in add_operator_candidates, then we swap the conversions
>      in add_candidate (so that they correspond to the original order of the
> diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
> index f1b7fbaa75b..79afdeeb055 100644
> --- a/gcc/cp/decl.c
> +++ b/gcc/cp/decl.c
> @@ -2312,6 +2312,8 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
>   	    |= DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (olddecl);
>   	  DECL_DECLARED_CONSTEXPR_P (newdecl)
>   	    |= DECL_DECLARED_CONSTEXPR_P (olddecl);
> +	  DECL_DECLARED_CONSTINIT_P (newdecl)
> +	    |= DECL_DECLARED_CONSTINIT_P (olddecl);
>   
>   	  /* Merge the threadprivate attribute from OLDDECL into NEWDECL.  */
>   	  if (DECL_LANG_SPECIFIC (olddecl)
> @@ -6884,7 +6886,7 @@ check_initializer (tree decl, tree init, int flags, vec<tree, va_gc> **cleanups)
>   	      flags |= LOOKUP_ALREADY_DIGESTED;
>   	    }
>   	  else if (DECL_DECLARED_CONSTEXPR_P (decl)
> -		   || (flags & LOOKUP_CONSTINIT))
> +		   || DECL_DECLARED_CONSTINIT_P (decl))
>   	    {
>   	      /* Declared constexpr or constinit, but no suitable initializer;
>   		 massage init appropriately so we can pass it into
> @@ -7675,10 +7677,6 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
>   	  DECL_INITIAL (decl) = NULL_TREE;
>   	}
>   
> -      /* Handle `constinit' on variable templates.  */
> -      if (flags & LOOKUP_CONSTINIT)
> -	DECL_DECLARED_CONSTINIT_P (decl) = true;
> -
>         /* Generally, initializers in templates are expanded when the
>   	 template is instantiated.  But, if DECL is a variable constant
>   	 then it can be used in future constant expressions, so its value
> @@ -7782,7 +7780,7 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
>         /* [dcl.constinit]/1 "The constinit specifier shall be applied
>   	 only to a declaration of a variable with static or thread storage
>   	 duration."  */
> -      if ((flags & LOOKUP_CONSTINIT)
> +      if (DECL_DECLARED_CONSTINIT_P (decl)
>   	  && !(dk == dk_thread || dk == dk_static))
>   	{
>   	  error_at (DECL_SOURCE_LOCATION (decl),
> @@ -13832,6 +13830,9 @@ grokdeclarator (const cp_declarator *declarator,
>       /* Set constexpr flag on vars (functions got it in grokfndecl).  */
>       if (constexpr_p && VAR_P (decl))
>         DECL_DECLARED_CONSTEXPR_P (decl) = true;
> +    /* And the constinit flag (which only applies to variables).  */
> +    else if (constinit_p && VAR_P (decl))
> +      DECL_DECLARED_CONSTINIT_P (decl) = true;
>   
>       /* Record constancy and volatility on the DECL itself .  There's
>          no need to do this when processing a template; we'll do this
> diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
> index 50a042e8070..fd48a212787 100644
> --- a/gcc/cp/decl2.c
> +++ b/gcc/cp/decl2.c
> @@ -994,9 +994,6 @@ grokfield (const cp_declarator *declarator,
>     else
>       flags = LOOKUP_IMPLICIT;
>   
> -  if (decl_spec_seq_has_spec_p (declspecs, ds_constinit))
> -    flags |= LOOKUP_CONSTINIT;
> -
>     switch (TREE_CODE (value))
>       {
>       case VAR_DECL:
> diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
> index 916ea6cd910..fed16895b42 100644
> --- a/gcc/cp/parser.c
> +++ b/gcc/cp/parser.c
> @@ -14096,12 +14096,9 @@ cp_parser_decomposition_declaration (cp_parser *parser,
>   
>         if (decl != error_mark_node)
>   	{
> -	  int flags = (decl_spec_seq_has_spec_p (decl_specifiers, ds_constinit)
> -		       ? LOOKUP_CONSTINIT : 0);
>   	  cp_maybe_mangle_decomp (decl, prev, v.length ());
>   	  cp_finish_decl (decl, initializer, non_constant_p, NULL_TREE,
> -			  (is_direct_init ? LOOKUP_NORMAL : LOOKUP_IMPLICIT)
> -			  | flags);
> +			  (is_direct_init ? LOOKUP_NORMAL : LOOKUP_IMPLICIT));
>   	  cp_finish_decomp (decl, prev, v.length ());
>   	}
>       }
> @@ -21018,8 +21015,6 @@ cp_parser_init_declarator (cp_parser* parser,
>        declarations.  */
>     if (!member_p && decl && decl != error_mark_node && !range_for_decl_p)
>       {
> -      int cf = (decl_spec_seq_has_spec_p (decl_specifiers, ds_constinit)
> -		? LOOKUP_CONSTINIT : 0);
>         cp_finish_decl (decl,
>   		      initializer, !is_non_constant_init,
>   		      asm_specification,
> @@ -21028,7 +21023,7 @@ cp_parser_init_declarator (cp_parser* parser,
>   			 `explicit' constructor is OK.  Otherwise, an
>   			 `explicit' constructor cannot be used.  */
>   		      ((is_direct_init || !is_initialized)
> -		       ? LOOKUP_NORMAL : LOOKUP_IMPLICIT) | cf);
> +		       ? LOOKUP_NORMAL : LOOKUP_IMPLICIT));
>       }
>     else if ((cxx_dialect != cxx98) && friend_p
>   	   && decl && TREE_CODE (decl) == FUNCTION_DECL)
> diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
> index 30c6735dede..0f52a9ed77d 100644
> --- a/gcc/cp/pt.c
> +++ b/gcc/cp/pt.c
> @@ -18103,10 +18103,7 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
>   		       now.  */
>   		    predeclare_vla (decl);
>   
> -		    bool constinit_p
> -		      = VAR_P (decl) && DECL_DECLARED_CONSTINIT_P (decl);
> -		    cp_finish_decl (decl, init, const_init, NULL_TREE,
> -				    constinit_p ? LOOKUP_CONSTINIT : 0);
> +		    cp_finish_decl (decl, init, const_init, NULL_TREE, 0);
>   
>   		    if (ndecl != error_mark_node)
>   		      cp_finish_decomp (ndecl, first, cnt);
> @@ -25758,8 +25755,7 @@ instantiate_decl (tree d, bool defer_ok, bool expl_inst_class_mem_p)
>           push_nested_class (DECL_CONTEXT (d));
>   
>         const_init = DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (code_pattern);
> -      int flags = (DECL_DECLARED_CONSTINIT_P (d) ? LOOKUP_CONSTINIT : 0);
> -      cp_finish_decl (d, init, const_init, NULL_TREE, flags);
> +      cp_finish_decl (d, init, const_init, NULL_TREE, 0);
>   
>         if (enter_context)
>           pop_nested_class ();
> diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
> index b95f112a744..e259a4201be 100644
> --- a/gcc/cp/typeck2.c
> +++ b/gcc/cp/typeck2.c
> @@ -920,7 +920,7 @@ store_init_value (tree decl, tree init, vec<tree, va_gc>** cleanups, int flags)
>   	  /* [dcl.constinit]/2 "If a variable declared with the constinit
>   	     specifier has dynamic initialization, the program is
>   	     ill-formed."  */
> -	  if (flags & LOOKUP_CONSTINIT)
> +	  if (DECL_DECLARED_CONSTINIT_P (decl))
>   	    {
>   	      error_at (location_of (decl),
>   			"%<constinit%> variable %qD does not have a constant "
> 
> base-commit: b7028f060c6760b336b416897412e327ded12ab5
> 


-- 
Nathan Sidwell

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] c++: Remove LOOKUP_CONSTINIT.
  2020-09-11 14:57 ` Nathan Sidwell
@ 2020-09-11 15:05   ` Marek Polacek
  0 siblings, 0 replies; 3+ messages in thread
From: Marek Polacek @ 2020-09-11 15:05 UTC (permalink / raw)
  To: Nathan Sidwell; +Cc: GCC Patches, Jason Merrill

On Fri, Sep 11, 2020 at 10:57:21AM -0400, Nathan Sidwell wrote:
> On 9/10/20 10:15 PM, Marek Polacek via Gcc-patches wrote:
> > Since we now have DECL_DECLARED_CONSTINIT_P, we no longer need
> > LOOKUP_CONSTINIT.
> > 
> > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
> 
> looks good, thanks for noticing.  BTW, you now have
> >       /* Set constexpr flag on vars (functions got it in grokfndecl).  */
> >       if (constexpr_p && VAR_P (decl))
> >         DECL_DECLARED_CONSTEXPR_P (decl) = true;
> > +    /* And the constinit flag (which only applies to variables).  */
> > +    else if (constinit_p && VAR_P (decl))
> > +      DECL_DECLARED_CONSTINIT_P (decl) = true;
> 
> might that be clearer as
> if (VAR_P (decl))
>   {  constexpr stuff constinit stuff }
> 
> ?  Ok either way

Agreed, it'd be nicer to factor VAR_P out.  I'll make that change.

Thanks,
Marek


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-11 15:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-11  2:15 [PATCH] c++: Remove LOOKUP_CONSTINIT Marek Polacek
2020-09-11 14:57 ` Nathan Sidwell
2020-09-11 15:05   ` Marek Polacek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).