This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++] mechanical PATCH to rename constant_expression_p


As discussed in the thread about PR 13243.  There are constant-expressions
other than integral constant-expressions, and if we're only looking for the
latter we should use names that indicate that.

Tested x86_64-pc-linux-gnu, applied to trunk.

2003-12-18  Jason Merrill  <jason@redhat.com>

	* parser.c, pt.c, semantics.c: Rename constant_expression_p
	to integral_constant_expression_p.

*** parser.c.~1~	2003-12-18 11:41:18.000000000 -0500
--- parser.c	2003-12-18 11:34:43.000000000 -0500
*************** typedef struct cp_parser GTY(())
*** 1218,1234 ****
    
    /* TRUE if we are parsing an integral constant-expression.  See
       [expr.const] for a precise definition.  */
!   bool constant_expression_p;
  
    /* TRUE if we are parsing an integral constant-expression -- but a
       non-constant expression should be permitted as well.  This flag
       is used when parsing an array bound so that GNU variable-length
       arrays are tolerated.  */
!   bool allow_non_constant_expression_p;
  
    /* TRUE if ALLOW_NON_CONSTANT_EXPRESSION_P is TRUE and something has
       been seen that makes the expression non-constant.  */
!   bool non_constant_expression_p;
  
    /* TRUE if we are parsing the argument to "__offsetof__".  */
    bool in_offsetof_p;
--- 1218,1234 ----
    
    /* TRUE if we are parsing an integral constant-expression.  See
       [expr.const] for a precise definition.  */
!   bool integral_constant_expression_p;
  
    /* TRUE if we are parsing an integral constant-expression -- but a
       non-constant expression should be permitted as well.  This flag
       is used when parsing an array bound so that GNU variable-length
       arrays are tolerated.  */
!   bool allow_non_integral_constant_expression_p;
  
    /* TRUE if ALLOW_NON_CONSTANT_EXPRESSION_P is TRUE and something has
       been seen that makes the expression non-constant.  */
!   bool non_integral_constant_expression_p;
  
    /* TRUE if we are parsing the argument to "__offsetof__".  */
    bool in_offsetof_p;
*************** static void cp_parser_check_for_definiti
*** 1712,1718 ****
    (tree, int);
  static void cp_parser_check_for_invalid_template_id
    (cp_parser *, tree);
! static tree cp_parser_non_constant_expression
    (const char *);
  static bool cp_parser_diagnose_invalid_type_name
    (cp_parser *);
--- 1712,1718 ----
    (tree, int);
  static void cp_parser_check_for_invalid_template_id
    (cp_parser *, tree);
! static tree cp_parser_non_integral_constant_expression
    (const char *);
  static bool cp_parser_diagnose_invalid_type_name
    (cp_parser *);
*************** cp_parser_check_for_invalid_template_id 
*** 1915,1921 ****
     constant-expression.  Returns ERROR_MARK_NODE.  */
  
  static tree
! cp_parser_non_constant_expression (const char *thing)
  {
    error ("%s cannot appear in a constant-expression", thing);
    return error_mark_node;
--- 1915,1921 ----
     constant-expression.  Returns ERROR_MARK_NODE.  */
  
  static tree
! cp_parser_non_integral_constant_expression (const char *thing)
  {
    error ("%s cannot appear in a constant-expression", thing);
    return error_mark_node;
*************** cp_parser_new (void)
*** 2229,2237 ****
    parser->default_arg_ok_p = true;
    
    /* We are not parsing a constant-expression.  */
!   parser->constant_expression_p = false;
!   parser->allow_non_constant_expression_p = false;
!   parser->non_constant_expression_p = false;
  
    /* We are not parsing offsetof.  */
    parser->in_offsetof_p = false;
--- 2229,2237 ----
    parser->default_arg_ok_p = true;
    
    /* We are not parsing a constant-expression.  */
!   parser->integral_constant_expression_p = false;
!   parser->allow_non_integral_constant_expression_p = false;
!   parser->non_integral_constant_expression_p = false;
  
    /* We are not parsing offsetof.  */
    parser->in_offsetof_p = false;
*************** cp_parser_primary_expression (cp_parser 
*** 2458,2468 ****
  	      return error_mark_node;
  	    }
  	  /* Pointers cannot appear in constant-expressions.  */
! 	  if (parser->constant_expression_p)
  	    {
! 	      if (!parser->allow_non_constant_expression_p)
! 		return cp_parser_non_constant_expression ("`this'");
! 	      parser->non_constant_expression_p = true;
  	    }
  	  return finish_this_expr ();
  
--- 2458,2468 ----
  	      return error_mark_node;
  	    }
  	  /* Pointers cannot appear in constant-expressions.  */
! 	  if (parser->integral_constant_expression_p)
  	    {
! 	      if (!parser->allow_non_integral_constant_expression_p)
! 		return cp_parser_non_integral_constant_expression ("`this'");
! 	      parser->non_integral_constant_expression_p = true;
  	    }
  	  return finish_this_expr ();
  
*************** cp_parser_primary_expression (cp_parser 
*** 2505,2515 ****
  	    cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'");
  	    /* Using `va_arg' in a constant-expression is not
  	       allowed.  */
! 	    if (parser->constant_expression_p)
  	      {
! 		if (!parser->allow_non_constant_expression_p)
! 		  return cp_parser_non_constant_expression ("`va_arg'");
! 		parser->non_constant_expression_p = true;
  	      }
  	    return build_x_va_arg (expression, type);
  	  }
--- 2505,2515 ----
  	    cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'");
  	    /* Using `va_arg' in a constant-expression is not
  	       allowed.  */
! 	    if (parser->integral_constant_expression_p)
  	      {
! 		if (!parser->allow_non_integral_constant_expression_p)
! 		  return cp_parser_non_integral_constant_expression ("`va_arg'");
! 		parser->non_integral_constant_expression_p = true;
  	      }
  	    return build_x_va_arg (expression, type);
  	  }
*************** cp_parser_primary_expression (cp_parser 
*** 2613,2621 ****
  	
  	decl = finish_id_expression (id_expression, decl, parser->scope, 
  				     idk, qualifying_class,
! 				     parser->constant_expression_p,
! 				     parser->allow_non_constant_expression_p,
! 				     &parser->non_constant_expression_p,
  				     &error_msg);
  	if (error_msg)
  	  cp_parser_error (parser, error_msg);
--- 2613,2621 ----
  	
  	decl = finish_id_expression (id_expression, decl, parser->scope, 
  				     idk, qualifying_class,
! 				     parser->integral_constant_expression_p,
! 				     parser->allow_non_integral_constant_expression_p,
! 				     &parser->non_integral_constant_expression_p,
  				     &error_msg);
  	if (error_msg)
  	  cp_parser_error (parser, error_msg);
*************** cp_parser_postfix_expression (cp_parser 
*** 3426,3443 ****
  
  	/* Only type conversions to integral or enumeration types
  	   can be used in constant-expressions.  */
! 	if (parser->constant_expression_p
  	    && !dependent_type_p (type)
  	    && !INTEGRAL_OR_ENUMERATION_TYPE_P (type)
  	    /* A cast to pointer or reference type is allowed in the
  	       implementation of "offsetof".  */
  	    && !(parser->in_offsetof_p && POINTER_TYPE_P (type)))
  	  {
! 	    if (!parser->allow_non_constant_expression_p)
! 	      return (cp_parser_non_constant_expression 
  		      ("a cast to a type other than an integral or "
  		       "enumeration type"));
! 	    parser->non_constant_expression_p = true;
  	  }
  
  	switch (keyword)
--- 3426,3443 ----
  
  	/* Only type conversions to integral or enumeration types
  	   can be used in constant-expressions.  */
! 	if (parser->integral_constant_expression_p
  	    && !dependent_type_p (type)
  	    && !INTEGRAL_OR_ENUMERATION_TYPE_P (type)
  	    /* A cast to pointer or reference type is allowed in the
  	       implementation of "offsetof".  */
  	    && !(parser->in_offsetof_p && POINTER_TYPE_P (type)))
  	  {
! 	    if (!parser->allow_non_integral_constant_expression_p)
! 	      return (cp_parser_non_integral_constant_expression 
  		      ("a cast to a type other than an integral or "
  		       "enumeration type"));
! 	    parser->non_integral_constant_expression_p = true;
  	  }
  
  	switch (keyword)
*************** cp_parser_postfix_expression (cp_parser 
*** 3676,3687 ****
  	    idk = CP_ID_KIND_NONE;
  	    /* Array references are not permitted in
  	       constant-expressions.  */
! 	    if (parser->constant_expression_p)
  	      {
! 		if (!parser->allow_non_constant_expression_p)
  		  postfix_expression 
! 		    = cp_parser_non_constant_expression ("an array reference");
! 		parser->non_constant_expression_p = true;
  	      }
  	  }
  	  break;
--- 3676,3687 ----
  	    idk = CP_ID_KIND_NONE;
  	    /* Array references are not permitted in
  	       constant-expressions.  */
! 	    if (parser->integral_constant_expression_p)
  	      {
! 		if (!parser->allow_non_integral_constant_expression_p)
  		  postfix_expression 
! 		    = cp_parser_non_integral_constant_expression ("an array reference");
! 		parser->non_integral_constant_expression_p = true;
  	      }
  	  }
  	  break;
*************** cp_parser_postfix_expression (cp_parser 
*** 3701,3715 ****
  	    
  	    /* Function calls are not permitted in
  	       constant-expressions.  */
! 	    if (parser->constant_expression_p)
  	      {
! 		if (!parser->allow_non_constant_expression_p)
  		  {
  		    postfix_expression 
! 		      = cp_parser_non_constant_expression ("a function call");
  		    break;
  		  }
! 		parser->non_constant_expression_p = true;
  	      }
  
  	    koenig_p = false;
--- 3701,3715 ----
  	    
  	    /* Function calls are not permitted in
  	       constant-expressions.  */
! 	    if (parser->integral_constant_expression_p)
  	      {
! 		if (!parser->allow_non_integral_constant_expression_p)
  		  {
  		    postfix_expression 
! 		      = cp_parser_non_integral_constant_expression ("a function call");
  		    break;
  		  }
! 		parser->non_integral_constant_expression_p = true;
  	      }
  
  	    koenig_p = false;
*************** cp_parser_postfix_expression (cp_parser 
*** 3891,3906 ****
  	       operator.  */
  	    parser->context->object_type = NULL_TREE;
  	    /* These operators may not appear in constant-expressions.  */
! 	    if (parser->constant_expression_p
  		/* The "->" operator is allowed in the implementation
  		   of "offsetof".  */
  		&& !(parser->in_offsetof_p && token_type == CPP_DEREF))
  	      {
! 		if (!parser->allow_non_constant_expression_p)
  		  postfix_expression 
! 		    = (cp_parser_non_constant_expression 
  		       (token_type == CPP_DEREF ? "'->'" : "`.'"));
! 		parser->non_constant_expression_p = true;
  	      }
  	  }
  	  break;
--- 3891,3906 ----
  	       operator.  */
  	    parser->context->object_type = NULL_TREE;
  	    /* These operators may not appear in constant-expressions.  */
! 	    if (parser->integral_constant_expression_p
  		/* The "->" operator is allowed in the implementation
  		   of "offsetof".  */
  		&& !(parser->in_offsetof_p && token_type == CPP_DEREF))
  	      {
! 		if (!parser->allow_non_integral_constant_expression_p)
  		  postfix_expression 
! 		    = (cp_parser_non_integral_constant_expression 
  		       (token_type == CPP_DEREF ? "'->'" : "`.'"));
! 		parser->non_integral_constant_expression_p = true;
  	      }
  	  }
  	  break;
*************** cp_parser_postfix_expression (cp_parser 
*** 3914,3925 ****
  	    = finish_increment_expr (postfix_expression, 
  				     POSTINCREMENT_EXPR);
  	  /* Increments may not appear in constant-expressions.  */
! 	  if (parser->constant_expression_p)
  	    {
! 	      if (!parser->allow_non_constant_expression_p)
  		postfix_expression 
! 		  = cp_parser_non_constant_expression ("an increment");
! 	      parser->non_constant_expression_p = true;
  	    }
  	  idk = CP_ID_KIND_NONE;
  	  break;
--- 3914,3925 ----
  	    = finish_increment_expr (postfix_expression, 
  				     POSTINCREMENT_EXPR);
  	  /* Increments may not appear in constant-expressions.  */
! 	  if (parser->integral_constant_expression_p)
  	    {
! 	      if (!parser->allow_non_integral_constant_expression_p)
  		postfix_expression 
! 		  = cp_parser_non_integral_constant_expression ("an increment");
! 	      parser->non_integral_constant_expression_p = true;
  	    }
  	  idk = CP_ID_KIND_NONE;
  	  break;
*************** cp_parser_postfix_expression (cp_parser 
*** 3933,3944 ****
  	    = finish_increment_expr (postfix_expression, 
  				     POSTDECREMENT_EXPR);
  	  /* Decrements may not appear in constant-expressions.  */
! 	  if (parser->constant_expression_p)
  	    {
! 	      if (!parser->allow_non_constant_expression_p)
  		postfix_expression 
! 		  = cp_parser_non_constant_expression ("a decrement");
! 	      parser->non_constant_expression_p = true;
  	    }
  	  idk = CP_ID_KIND_NONE;
  	  break;
--- 3933,3944 ----
  	    = finish_increment_expr (postfix_expression, 
  				     POSTDECREMENT_EXPR);
  	  /* Decrements may not appear in constant-expressions.  */
! 	  if (parser->integral_constant_expression_p)
  	    {
! 	      if (!parser->allow_non_integral_constant_expression_p)
  		postfix_expression 
! 		  = cp_parser_non_integral_constant_expression ("a decrement");
! 	      parser->non_integral_constant_expression_p = true;
  	    }
  	  idk = CP_ID_KIND_NONE;
  	  break;
*************** cp_parser_unary_expression (cp_parser *p
*** 4323,4333 ****
  	  abort ();
  	}
  
!       if (non_constant_p && parser->constant_expression_p)
  	{
! 	  if (!parser->allow_non_constant_expression_p)
! 	    return cp_parser_non_constant_expression (non_constant_p);
! 	  parser->non_constant_expression_p = true;
  	}
  
        return expression;
--- 4323,4333 ----
  	  abort ();
  	}
  
!       if (non_constant_p && parser->integral_constant_expression_p)
  	{
! 	  if (!parser->allow_non_integral_constant_expression_p)
! 	    return cp_parser_non_integral_constant_expression (non_constant_p);
! 	  parser->non_integral_constant_expression_p = true;
  	}
  
        return expression;
*************** cp_parser_cast_expression (cp_parser *pa
*** 4740,4754 ****
  
  	  /* Only type conversions to integral or enumeration types
  	     can be used in constant-expressions.  */
! 	  if (parser->constant_expression_p
  	      && !dependent_type_p (type)
  	      && !INTEGRAL_OR_ENUMERATION_TYPE_P (type))
  	    {
! 	      if (!parser->allow_non_constant_expression_p)
! 		return (cp_parser_non_constant_expression 
  			("a casts to a type other than an integral or "
  			 "enumeration type"));
! 	      parser->non_constant_expression_p = true;
  	    }
  	  /* Perform the cast.  */
  	  expr = build_c_cast (type, expr);
--- 4740,4754 ----
  
  	  /* Only type conversions to integral or enumeration types
  	     can be used in constant-expressions.  */
! 	  if (parser->integral_constant_expression_p
  	      && !dependent_type_p (type)
  	      && !INTEGRAL_OR_ENUMERATION_TYPE_P (type))
  	    {
! 	      if (!parser->allow_non_integral_constant_expression_p)
! 		return (cp_parser_non_integral_constant_expression 
  			("a casts to a type other than an integral or "
  			 "enumeration type"));
! 	      parser->non_integral_constant_expression_p = true;
  	    }
  	  /* Perform the cast.  */
  	  expr = build_c_cast (type, expr);
*************** cp_parser_assignment_expression (cp_pars
*** 5102,5112 ****
  	      rhs = cp_parser_assignment_expression (parser);
  	      /* An assignment may not appear in a
  		 constant-expression.  */
! 	      if (parser->constant_expression_p)
  		{
! 		  if (!parser->allow_non_constant_expression_p)
! 		    return cp_parser_non_constant_expression ("an assignment");
! 		  parser->non_constant_expression_p = true;
  		}
  	      /* Build the assignment expression.  */
  	      expr = build_x_modify_expr (expr, 
--- 5102,5112 ----
  	      rhs = cp_parser_assignment_expression (parser);
  	      /* An assignment may not appear in a
  		 constant-expression.  */
! 	      if (parser->integral_constant_expression_p)
  		{
! 		  if (!parser->allow_non_integral_constant_expression_p)
! 		    return cp_parser_non_integral_constant_expression ("an assignment");
! 		  parser->non_integral_constant_expression_p = true;
  		}
  	      /* Build the assignment expression.  */
  	      expr = build_x_modify_expr (expr, 
*************** cp_parser_expression (cp_parser* parser)
*** 5245,5256 ****
        /* Consume the `,'.  */
        cp_lexer_consume_token (parser->lexer);
        /* A comma operator cannot appear in a constant-expression.  */
!       if (parser->constant_expression_p)
  	{
! 	  if (!parser->allow_non_constant_expression_p)
  	    expression 
! 	      = cp_parser_non_constant_expression ("a comma operator");
! 	  parser->non_constant_expression_p = true;
  	}
      }
  
--- 5245,5256 ----
        /* Consume the `,'.  */
        cp_lexer_consume_token (parser->lexer);
        /* A comma operator cannot appear in a constant-expression.  */
!       if (parser->integral_constant_expression_p)
  	{
! 	  if (!parser->allow_non_integral_constant_expression_p)
  	    expression 
! 	      = cp_parser_non_integral_constant_expression ("a comma operator");
! 	  parser->non_integral_constant_expression_p = true;
  	}
      }
  
*************** cp_parser_constant_expression (cp_parser
*** 5272,5280 ****
  			       bool allow_non_constant_p,
  			       bool *non_constant_p)
  {
!   bool saved_constant_expression_p;
!   bool saved_allow_non_constant_expression_p;
!   bool saved_non_constant_expression_p;
    tree expression;
  
    /* It might seem that we could simply parse the
--- 5272,5280 ----
  			       bool allow_non_constant_p,
  			       bool *non_constant_p)
  {
!   bool saved_integral_constant_expression_p;
!   bool saved_allow_non_integral_constant_expression_p;
!   bool saved_non_integral_constant_expression_p;
    tree expression;
  
    /* It might seem that we could simply parse the
*************** cp_parser_constant_expression (cp_parser
*** 5295,5308 ****
       will fold this operation to an INTEGER_CST for `3'.  */
  
    /* Save the old settings.  */
!   saved_constant_expression_p = parser->constant_expression_p;
!   saved_allow_non_constant_expression_p 
!     = parser->allow_non_constant_expression_p;
!   saved_non_constant_expression_p = parser->non_constant_expression_p;
    /* We are now parsing a constant-expression.  */
!   parser->constant_expression_p = true;
!   parser->allow_non_constant_expression_p = allow_non_constant_p;
!   parser->non_constant_expression_p = false;
    /* Although the grammar says "conditional-expression", we parse an
       "assignment-expression", which also permits "throw-expression"
       and the use of assignment operators.  In the case that
--- 5295,5308 ----
       will fold this operation to an INTEGER_CST for `3'.  */
  
    /* Save the old settings.  */
!   saved_integral_constant_expression_p = parser->integral_constant_expression_p;
!   saved_allow_non_integral_constant_expression_p 
!     = parser->allow_non_integral_constant_expression_p;
!   saved_non_integral_constant_expression_p = parser->non_integral_constant_expression_p;
    /* We are now parsing a constant-expression.  */
!   parser->integral_constant_expression_p = true;
!   parser->allow_non_integral_constant_expression_p = allow_non_constant_p;
!   parser->non_integral_constant_expression_p = false;
    /* Although the grammar says "conditional-expression", we parse an
       "assignment-expression", which also permits "throw-expression"
       and the use of assignment operators.  In the case that
*************** cp_parser_constant_expression (cp_parser
*** 5314,5325 ****
       constant.  */
    expression = cp_parser_assignment_expression (parser);
    /* Restore the old settings.  */
!   parser->constant_expression_p = saved_constant_expression_p;
!   parser->allow_non_constant_expression_p 
!     = saved_allow_non_constant_expression_p;
    if (allow_non_constant_p)
!     *non_constant_p = parser->non_constant_expression_p;
!   parser->non_constant_expression_p = saved_non_constant_expression_p;
  
    return expression;
  }
--- 5314,5325 ----
       constant.  */
    expression = cp_parser_assignment_expression (parser);
    /* Restore the old settings.  */
!   parser->integral_constant_expression_p = saved_integral_constant_expression_p;
!   parser->allow_non_integral_constant_expression_p 
!     = saved_allow_non_integral_constant_expression_p;
    if (allow_non_constant_p)
!     *non_constant_p = parser->non_integral_constant_expression_p;
!   parser->non_integral_constant_expression_p = saved_non_integral_constant_expression_p;
  
    return expression;
  }
*************** cp_parser_sizeof_operand (cp_parser* par
*** 14419,14425 ****
    static const char *format;
    tree expr = NULL_TREE;
    const char *saved_message;
!   bool saved_constant_expression_p;
  
    /* Initialize FORMAT the first time we get here.  */
    if (!format)
--- 14419,14425 ----
    static const char *format;
    tree expr = NULL_TREE;
    const char *saved_message;
!   bool saved_integral_constant_expression_p;
  
    /* Initialize FORMAT the first time we get here.  */
    if (!format)
*************** cp_parser_sizeof_operand (cp_parser* par
*** 14438,14445 ****
  
    /* The restrictions on constant-expressions do not apply inside
       sizeof expressions.  */
!   saved_constant_expression_p = parser->constant_expression_p;
!   parser->constant_expression_p = false;
  
    /* Do not actually evaluate the expression.  */
    ++skip_evaluation;
--- 14438,14445 ----
  
    /* The restrictions on constant-expressions do not apply inside
       sizeof expressions.  */
!   saved_integral_constant_expression_p = parser->integral_constant_expression_p;
!   parser->integral_constant_expression_p = false;
  
    /* Do not actually evaluate the expression.  */
    ++skip_evaluation;
*************** cp_parser_sizeof_operand (cp_parser* par
*** 14486,14492 ****
    free ((char *) parser->type_definition_forbidden_message);
    /* And restore the old one.  */
    parser->type_definition_forbidden_message = saved_message;
!   parser->constant_expression_p = saved_constant_expression_p;
  
    return expr;
  }
--- 14486,14492 ----
    free ((char *) parser->type_definition_forbidden_message);
    /* And restore the old one.  */
    parser->type_definition_forbidden_message = saved_message;
!   parser->integral_constant_expression_p = saved_integral_constant_expression_p;
  
    return expr;
  }
*** pt.c.~1~	2003-12-18 11:41:18.000000000 -0500
--- pt.c	2003-12-18 11:34:43.000000000 -0500
*************** tsubst_copy_and_build (tree t, 
*** 8052,8058 ****
  	tree decl;
  	cp_id_kind idk;
  	tree qualifying_class;
! 	bool non_constant_expression_p;
  	const char *error_msg;
  
  	if (IDENTIFIER_TYPENAME_P (t))
--- 8052,8058 ----
  	tree decl;
  	cp_id_kind idk;
  	tree qualifying_class;
! 	bool non_integral_constant_expression_p;
  	const char *error_msg;
  
  	if (IDENTIFIER_TYPENAME_P (t))
*************** tsubst_copy_and_build (tree t, 
*** 8072,8080 ****
  	decl = finish_id_expression (t, decl, NULL_TREE,
  				     &idk,
  				     &qualifying_class,
! 				     /*constant_expression_p=*/false,
! 				     /*allow_non_constant_expression_p=*/false,
! 				     &non_constant_expression_p,
  				     &error_msg);
  	if (error_msg)
  	  error (error_msg);
--- 8072,8080 ----
  	decl = finish_id_expression (t, decl, NULL_TREE,
  				     &idk,
  				     &qualifying_class,
! 				     /*integral_constant_expression_p=*/false,
! 				     /*allow_non_integral_constant_expression_p=*/false,
! 				     &non_integral_constant_expression_p,
  				     &error_msg);
  	if (error_msg)
  	  error (error_msg);
*** semantics.c.~1~	2003-12-18 11:41:18.000000000 -0500
--- semantics.c	2003-12-16 22:03:24.000000000 -0500
*************** finish_id_expression (tree id_expression
*** 2324,2332 ****
  		      tree scope,
  		      cp_id_kind *idk,
  		      tree *qualifying_class,
! 		      bool constant_expression_p,
! 		      bool allow_non_constant_expression_p,
! 		      bool *non_constant_expression_p,
  		      const char **error_msg)
  {
    /* Initialize the output parameters.  */
--- 2324,2332 ----
  		      tree scope,
  		      cp_id_kind *idk,
  		      tree *qualifying_class,
! 		      bool integral_constant_expression_p,
! 		      bool allow_non_integral_constant_expression_p,
! 		      bool *non_integral_constant_expression_p,
  		      const char **error_msg)
  {
    /* Initialize the output parameters.  */
*************** finish_id_expression (tree id_expression
*** 2399,2412 ****
        *idk = CP_ID_KIND_NONE;
        if (TREE_CODE (decl) == TEMPLATE_PARM_INDEX)
  	decl = TEMPLATE_PARM_DECL (decl);
!       if (constant_expression_p 
  	  && !INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (decl))) 
  	{
! 	  if (!allow_non_constant_expression_p)
  	    error ("template parameter `%D' of type `%T' is not allowed in "
  		   "an integral constant expression because it is not of "
  		   "integral or enumeration type", decl, TREE_TYPE (decl));
! 	  *non_constant_expression_p = true;
  	}
        return DECL_INITIAL (decl);
      }
--- 2399,2412 ----
        *idk = CP_ID_KIND_NONE;
        if (TREE_CODE (decl) == TEMPLATE_PARM_INDEX)
  	decl = TEMPLATE_PARM_DECL (decl);
!       if (integral_constant_expression_p 
  	  && !INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (decl))) 
  	{
! 	  if (!allow_non_integral_constant_expression_p)
  	    error ("template parameter `%D' of type `%T' is not allowed in "
  		   "an integral constant expression because it is not of "
  		   "integral or enumeration type", decl, TREE_TYPE (decl));
! 	  *non_integral_constant_expression_p = true;
  	}
        return DECL_INITIAL (decl);
      }
*************** finish_id_expression (tree id_expression
*** 2510,2517 ****
  	      /* Since this name was dependent, the expression isn't
  		 constant -- yet.  No error is issued because it might
  		 be constant when things are instantiated.  */
! 	      if (constant_expression_p)
! 		*non_constant_expression_p = true;
  	      if (TYPE_P (scope) && dependent_type_p (scope))
  		return build_nt (SCOPE_REF, scope, id_expression);
  	      else if (TYPE_P (scope) && DECL_P (decl))
--- 2510,2517 ----
  	      /* Since this name was dependent, the expression isn't
  		 constant -- yet.  No error is issued because it might
  		 be constant when things are instantiated.  */
! 	      if (integral_constant_expression_p)
! 		*non_integral_constant_expression_p = true;
  	      if (TYPE_P (scope) && dependent_type_p (scope))
  		return build_nt (SCOPE_REF, scope, id_expression);
  	      else if (TYPE_P (scope) && DECL_P (decl))
*************** finish_id_expression (tree id_expression
*** 2527,2534 ****
  	  /* Since this name was dependent, the expression isn't
  	     constant -- yet.  No error is issued because it might be
  	     constant when things are instantiated.  */
! 	  if (constant_expression_p)
! 	    *non_constant_expression_p = true;
  	  *idk = CP_ID_KIND_UNQUALIFIED_DEPENDENT;
  	  return id_expression;
  	}
--- 2527,2534 ----
  	  /* Since this name was dependent, the expression isn't
  	     constant -- yet.  No error is issued because it might be
  	     constant when things are instantiated.  */
! 	  if (integral_constant_expression_p)
! 	    *non_integral_constant_expression_p = true;
  	  *idk = CP_ID_KIND_UNQUALIFIED_DEPENDENT;
  	  return id_expression;
  	}
*************** finish_id_expression (tree id_expression
*** 2536,2542 ****
        /* Only certain kinds of names are allowed in constant
         expression.  Enumerators and template parameters 
         have already been handled above.  */
!       if (constant_expression_p)
  	{
  	    /* Const variables or static data members of integral or
  	      enumeration types initialized with constant expressions
--- 2536,2542 ----
        /* Only certain kinds of names are allowed in constant
         expression.  Enumerators and template parameters 
         have already been handled above.  */
!       if (integral_constant_expression_p)
  	{
  	    /* Const variables or static data members of integral or
  	      enumeration types initialized with constant expressions
*************** finish_id_expression (tree id_expression
*** 2548,2559 ****
  	    ;
  	  else
  	    {
! 	      if (!allow_non_constant_expression_p)
  		{
  		  error ("`%D' cannot appear in a constant-expression", decl);
  		  return error_mark_node;
  		}
! 	      *non_constant_expression_p = true;
  	    }
  	}
        
--- 2548,2559 ----
  	    ;
  	  else
  	    {
! 	      if (!allow_non_integral_constant_expression_p)
  		{
  		  error ("`%D' cannot appear in a constant-expression", decl);
  		  return error_mark_node;
  		}
! 	      *non_integral_constant_expression_p = true;
  	    }
  	}
        

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]