https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115240

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
DEF_C99_C90RES_BUILTIN (BUILT_IN_EXPF, "expf", BT_FN_FLOAT_FLOAT,
ATTR_MATHFN_FPROUNDING_ERRNO)


/* Define an attribute list for math functions that are normally
   "impure" because some of them may write into global memory for
   `errno'.  If !flag_errno_math, we can possibly use "pure" or
   "const" depending on whether we care about FP rounding.  */
#undef ATTR_MATHFN_FPROUNDING_ERRNO
#define ATTR_MATHFN_FPROUNDING_ERRNO (flag_errno_math ? \
        (flag_rounding_math ? ATTR_ERRNOPURE_NOTHROW_LEAF_LIST \
         : ATTR_ERRNOCONST_NOTHROW_LEAF_LIST) : ATTR_MATHFN_FPROUNDING)


//   DEF_ATTR_TREE_LIST (ENUM, PURPOSE, VALUE, CHAIN)

DEF_ATTR_TREE_LIST (ATTR_ERRNOCONST_NOTHROW_LEAF_LIST, ATTR_FNSPEC,\
                        ATTR_LIST_STRERRNOC, ATTR_NOTHROW_LEAF_LIST)
// [[gnu::fn spec(".C")]
DEF_ATTR_TREE_LIST (ATTR_ERRNOPURE_NOTHROW_LEAF_LIST, ATTR_FNSPEC,\
                        ATTR_LIST_STRERRNOP, ATTR_NOTHROW_LEAF_LIST)


DEF_ATTR_TREE_LIST (ATTR_NOTHROW_LEAF_LIST, ATTR_LEAF, ATTR_NULL,
ATTR_NOTHROW_LIST) // [[gnu::leaf,gnu::nothrow]]

DEF_ATTR_FOR_STRING (STRERRNOC, ".C")
DEF_ATTR_IDENT (ATTR_FNSPEC, "fn spec")


by default it selects: ATTR_ERRNOCONST_NOTHROW_LEAF_LIST

Note the "fn spec" here is a special internal definition which is defined as:
   character 0  specifies properties of return values as follows:
...
     '.'        specifies that nothing is known.
   character 1  specifies additional function properties
...
     'c' or 'C' specifies that function is const except for described side
                effects.
...
   The uppercase letter in addition specifies that function clobbers errno.

GCC knows that exp only can clobbers errno here and num can't be errno so it
treats it as a const function in this case.

Reply via email to