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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |nathan at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
With:

struct AVX
{
    static constexpr const char*const target = "avx"; 
};

constexpr const char *get_target (const char *x) { return x; }

template<class T>
[[gnu::target(get_target (T::target))]]
void test() {}

void f() {
    test<AVX>();
}

what the backend gets is just that <nop_expr <addr_expr <string_cst "avx">>>.
Perhaps we could have some helper function which would look through this and
perhaps handle even the case of a const variable with DECL_INITIAL, and use it
in all the backends for target attribute and perhaps plenty of other attributes
that take STRING_CSTs, like no_sanitize, error, warning, scalar_storage_order,
section, alias, ifunc, visibility, tls_model, simd, deprecated attributes to
just name a few attributes that expect STRING_CST arguments.  The question is
if we should do it in each attribute handler or if the C++ FE should do it to
the attribute args first (look through these cases); depends if any attribute
actually can have a useful VAR_DECL or NOP_EXPR or ADDR_EXPR argument...

In any case, too late for GCC8...

Reply via email to