efriedma added inline comments.
================ Comment at: clang/lib/AST/ExprConstant.cpp:4267 + bool IsConstant = CLETy.isConstant(Info.Ctx); + if (!IsConstant && CLETy->isArrayType()) { + Info.FFDiag(Conv); ---------------- serge-sans-paille wrote: > efriedma wrote: > > Is the "isArrayType()" check here necessary? > Yeah, otherwise we have an issue with > > ``` > typedef __attribute__(( ext_vector_type(4) )) float float4; > float4 foo = (float4){ 1.0, 2.0, 3.0, 4.0 }; > ``` > > error: cannot compile this static initializer yet Hmm, I see... in C++, the compound literal rules are weird. C compound literals are lvalues, but C++ ones are not. So normally, we don't allow taking the address of a compound literal or any of its members. But if it's an array, somehow different rules (what rules?) apply. If you can add a comment explaining what's going on here, maybe it's okay? I'm tempted to say we should reject the testcase, though. For example, in the following, it doesn't really make sense to reject the first variable, but accept the second. ``` typedef int arr[2]; constexpr int *x = arr{1}; constexpr int *y = (arr){1}; ``` ------ Can you add a testcase involving an array of structs with a "mutable" member? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124038/new/ https://reviews.llvm.org/D124038 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits