tahonermann added inline comments.
================ Comment at: clang/test/Sema/anonymous-struct-union.c:137-140 + // It's the access path that picks up the qualifiers, not the direct + // declaration of the field itself. So 'i' and 'j' are both 'int'. + _Static_assert(_Generic(x.i, int : 1, default : 0), "i is not int?"); + _Static_assert(_Generic(x.j, int : 1, default : 0), "j is not int?"); ---------------- aaron.ballman wrote: > tahonermann wrote: > > Top-level cv-qualifiers are ignored in generic selection expressions, so > > I'm not sure what these assertions are intended to ensure. > I think this is the second time I've been caught by that. I keep expecting > that the "no two associations can use compatible types" to make that > situation an error. > > I almost wonder if we should give a warning in cases where an association > type is qualified (or is an array/function type rather than a decayed > pointer)? I was surprised when I first learned of this behavior too; it hobbles the utility of generic selection expressions in some cases. A warning like you suggest does seem appropriate. I'm not aware of any way in which a cv-qualified or non-decayed association type can be used in any useful manner (other than to show that a compiler is not behaving properly). If there is such a use, I would be interested in knowing what it is! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D125167/new/ https://reviews.llvm.org/D125167 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits