[PATCH] Add gnu::diagnose_as attribute

Jason Merrill jason@redhat.com
Tue Jun 15 15:51:20 GMT 2021


On 6/11/21 6:01 AM, Matthias Kretz wrote:
> How can we make progress here? I could try to produce some "Tony Tables" of
> diagnostic output of my modified stdx::simd. I believe it's a major
> productivity boost to see abbreviated / "obfuscated" diagnostics *out-of-the
> box* (with the possibility to opt-out). Actually, it already *is* a
> productivity boost to me. Understanding diagnostics has improved from
> 
> "1. ooof, I'm not going to read this, let me rather guess what the issue was
> 2. sh** I have to read it
> 3. several minutes later: I finally found the five words to understand the
> problem; I could use a break"
> 
> to
> 
> "1. right, let me check that"

That's great.

> For reference I'll attach my stdx::simd diagnose_as patch.
> 
> We could also talk about extending the feature to provide more information
> about the diagnose_as substition. E.g. print a list of all diagnose_as
> substitutions, which were used, at the end of the output stream. Or simpler,
> print "note: some identifiers were simplified, use -fno-diagnostics-use-
> aliases to see their real names".

Or perhaps before the first use of a name that doesn't correspond to a 
source-level name.

> On Tuesday, 1 June 2021 21:12:18 CEST Jason Merrill wrote:
>>> Right, but then two of my design goals can't be met:
>>>
>>> 1. Diagnostics have an improved signal-to-noise ratio out of the box.
>>>
>>> 2. We can use replacement names that are not valid identifiers.
>>
>> This is the basic disconnect: I think that these goals are
>> contradictory, and that replacement names that are not valid identifiers
>> will just confuse users that don't know about them.
>>
>> If a user sees stdx::foo in a diagnostic and then tries to refer to
>> stdx::foo and gets an error, the diagnostic is not more helpful than one
>> that uses the fully qualified name.
>>
>> Jonathan, David, any thoughts on this issue?

> -struct _Scalar;
> +  struct [[__gnu__::__diagnose_as__("scalar")]] _Scalar;

>  template <int _Np>
> -  struct _Fixed;
> +  struct [[__gnu__::__diagnose_as__("fixed_size")]] _Fixed;

Thes two could be the variant of the attribute without an explicit 
string, attached to the alias-declaration.

> +using __sse [[__gnu__::__diagnose_as__("[SSE]")]] = _VecBuiltin<16>;
> +using __avx [[__gnu__::__diagnose_as__("[AVX]")]] = _VecBuiltin<32>;
> +using __avx512 [[__gnu__::__diagnose_as__("[AVX512]")]] = _VecBltnBtmsk<64>;
> +  using __odr_helper [[__gnu__::__diagnose_as__("[ODR helper]")]]

These [] names seem like minimal improvements over the __ names that you 
would get from the attribute without an explicit string.

> +	inline namespace parallelism_v2 [[__gnu__::__diagnose_as__("std\u2093")]] {

This could go on std::experimental itself, along with my proposed change 
to hide inline namespaces by default (with a note similar to the one above).

Jason



More information about the Gcc-patches mailing list