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]

Re: PATCH c++/19628


> + /* Test whether DECL is a builtin that may appear in a
> +    constant-expression. */
> + bool builtin_is_constant_p (tree decl)
> + {
> +   /* At present BUILT_IN_CONSTANT_P is the only builtin we're allowing
> +      in constant-expressions.  We may want to add other builtins
> later. */
> +   return TREE_CODE (decl) == FUNCTION_DECL
> +     && DECL_IS_BUILTIN (decl)
> +     && DECL_FUNCTION_CODE (decl) == BUILT_IN_CONSTANT_P;
> + }
> +
> +

DECL_FUNCTION_CODE is overloaded, so the test

  DECL_FUNCTION_CODE (decl) == BUILT_IN_CONSTANT_P

can be true for another builtin (typically coming from the MD file).


I should have documented this when I spotted the problem on SPARC.  Is the 
following wording good enough?

Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.681
diff -u -p -r1.681 tree.h
--- tree.h      26 Jan 2005 15:20:51 -0000      1.681
+++ tree.h      29 Jan 2005 10:09:23 -0000
@@ -2000,8 +2000,10 @@ struct tree_binfo GTY (())
    that describes the status of this function.  */
 #define DECL_STRUCT_FUNCTION(NODE) (FUNCTION_DECL_CHECK (NODE)->decl.u2.f)

-/* For FUNCTION_DECL, if it is built-in,
-   this identifies which built-in operation it is.  */
+/* For FUNCTION_DECL, if it is built-in, this identifies which built-in
+   operation it is.  Note, however, that this field is overloaded, with
+   DECL_BUILT_IN_CLASS as the discriminant, so the latter must always be
+   checked before any access to the former.  */
 #define DECL_FUNCTION_CODE(NODE) (FUNCTION_DECL_CHECK (NODE)->decl.u1.f)

 /* The DECL_VINDEX is used for FUNCTION_DECLS in two different ways.


-- 
Eric Botcazou


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