[PATCH] D123167: [HLSL] Pointers are unsupported in HLSL

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 14 06:08:25 PDT 2022


aaron.ballman added inline comments.


================
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11579-11584
+def err_hlsl_pointers_unsupported : Error<"%select{pointers|references}0 are "
+                                          "unsupported in HLSL">;
+
+def err_hlsl_operator_unsupported : Error<"the %select{address of (&)|"
+                                           "dereference (*)|arrow (->)}0 "
+                                           "operator is unsupported in HLSL">;
----------------
Should we be adding `.*` and `->*` to the list of unsupported operators? (Hmmm, or can we never get to those operators because we can't form the base expression anyway?)


================
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);
+  }
----------------
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.)


================
Comment at: clang/lib/Sema/SemaExprMember.cpp:1739-1740
 
+  if (getLangOpts().HLSL && IsArrow)
+    return ExprError(Diag(OpLoc, diag::err_hlsl_operator_unsupported) << 2);
+
----------------
Same question here for overloaded operators.


================
Comment at: clang/test/SemaHLSL/prohibit_reference.hlsl:4
+int& bark(int); // expected-error {{references are unsupported in HLSL}}
+void meow(int&); // expected-error {{references are unsupported in HLSL}}
+
----------------
void chirp(int &&); // error


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123167/new/

https://reviews.llvm.org/D123167



More information about the cfe-commits mailing list