template<typename T> union point { T vec __attribute__((__vector_size__((sizeof(T)<<1)))); struct { T x,y; }; }; error: '__vector_size__' attribute requires an integer constant T vec __attribute__((__vector_size__((sizeof(T)<<1)))); ^ ~~~~~~~~~~~~~~
We should generalize the handling of dependent expressions from the alignment attributes to deal with this case too.
I hit the same issue. typedef double __attribute__( ( vector_size( 64 ) ) ) float64x8_v0_t; typedef double __attribute__( ( vector_size( 32 * 2 ) ) ) float64x8_v1_t; typedef double __attribute__( ( vector_size( sizeof(double) * 8 ) ) ) float64x8_v2_t; template<typename T, int N> struct Traits { typedef T __attribute__( ( vector_size( N*sizeof(T) ) ) ) type; // the following fails }; test.cc:13:30: error: 'vector_size' attribute requires an integer constant typedef T __attribute__( ( vector_size( N*sizeof(T) ) ) ) type; Any updates?
(In reply to comment #1) > We should generalize the handling of dependent expressions from the > alignment attributes to deal with this case too. Richard, as far as I know, alignment attributes only appertain to variables or typedefs (which both have AST nodes). I don't think we can generalize this approach for vector_size attribute as it appertains to types (which do not have AST nodes). What about creating a new property for VectorType that would state that this vector type is dependent (dependent vector types are vector types with dependent base types and/or dependent size expressions)? It seems to be somewhat more appropriate to me. What do you think?
This seems to be fixed on 7.0 ? I can still reproduce the issue with both versions above on a clang 6.0.0 from a Ubuntu 18.04.2 but I don't have this issue anymore on a clang 7.0.1 from an up to date ArchLinux.
And as a workaround on older version. The solution from https://stackoverflow.com/a/48377726/904262 seems to work if you can use a typedef. The resulting vector type seems to have the correct layout and C++ name mangling so I assume it's the correct type...
*** This bug has been marked as a duplicate of bug 15730 ***