aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land.
LGTM aside from the formatting nit. ================ Comment at: clang/lib/Sema/SemaExpr.cpp:15252-15257 + if (getLangOpts().HLSL) { + if (Opc == UO_AddrOf) + return ExprError(Diag(OpLoc, diag::err_hlsl_operator_unsupported) << 0); + if (Opc == UO_Deref) + return ExprError(Diag(OpLoc, diag::err_hlsl_operator_unsupported) << 1); + } ---------------- beanz wrote: > aaron.ballman wrote: > > How should this interplay with overloaded operators on user-defined types? > > Is that case allowed so long as it doesn't form a pointer or a reference? > > (We should add test coverage for that.) > So, the "correct" end goal is that we don't support overloading those > operators. We have a few limitations on which operators we allow overloading > for, generally any operators that in normal use return references or > pointers, we don't allow you to overload. > > That said, I wrote some test code to see where this falls over with my > current change: > > ``` > struct Fish { > struct Fins { > int Left; > int Right; > }; > int X; > int operator *() { > return X; > } > > Fins operator ->() { > return Fins(); > } > }; > > int gone_fishing() { > Fish F; > int Result = *F; // works... and is consistent with DXC > Result += F->Left; // error: member reference type 'Fish::Fins' is not a > pointer > return Result; > } > ``` > > In the existing compiler we produce an error on definition of operators that > aren't supported. I'd like to handle improving the diagnostics for those > operators that way in a later patch if that is okay. > > The `.*` and `.->` operators I couldn't get errors to actually trigger > because I couldn't think of a way to write them that wasn't dependent on > getting a member pointer, which errors and causes the remaining expression to > not be checked. > In the existing compiler we produce an error on definition of operators that > aren't supported. I'd like to handle improving the diagnostics for those > operators that way in a later patch if that is okay. That's fine by me. > The .* and .-> operators I couldn't get errors to actually trigger because I > couldn't think of a way to write them that wasn't dependent on getting a > member pointer, which errors and causes the remaining expression to not be > checked. Perfect, I couldn't find a way either, we can punt on that until we find a concrete issue. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D123167/new/ https://reviews.llvm.org/D123167 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits