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

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 6 12:39:01 PDT 2022


aaron.ballman added a comment.

I think you're going to need semantic restrictions as well as parsing restrictions because of type deduction. Even if you don't support templates (yet), there's still `auto`, `decltype`, `__typeof__`, and `__auto_type` (I probably missed some, lol) to worry about.

Also... can HLSL be combined with Objective-C mode (do we have to worry about their pointers as well)?



================
Comment at: clang/test/ParserHLSL/parse_pointer.hlsl:10
+  int Y;
+};
+
----------------



================
Comment at: clang/test/ParserHLSL/parse_pointer.hlsl:12
+
+void woof(int Foo::*Member); // expected-error {{pointers are unsupported in HLSL}}
+
----------------
I am proud of you for this test case, because I was going to ask for it. :-D


================
Comment at: clang/test/ParserHLSL/parse_pointer.hlsl:23
+  return F->X;
+}
----------------
Here are a few more fun test cases (which may require semantic tests instead of parsing tests):
```
void func();

void devilish_language(auto look_ma_no_pointers); // templates get you the same effects as well

void test() {
  int x;
  devilish_language(&x); // I presume we want this to be diagnosed
  devilish_language(func); // I think you wanted this to not be diagnosed?
  devilish_language("oh no, not array decay!"); // Same here as function decay?

  auto but_but_but = "please, stop Aaron!" + 0; // Uhhh... is the addition okay but the declaration bad?

  int array[2];
  *(&array[0] + 1) = 12; // Maaaayybbbe this is fine?
}
```
(Thing for you to double-check: do any targets predefine macros that expand to a pointer? I checked InitPreprocessor.cpp and things looked fine there, but I didn't check targets.)


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



================
Comment at: clang/test/ParserHLSL/parse_reference.hlsl:18
+  return F.X;
+}
----------------
Similar extra tests involving type deduction as the pointer tests.


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