[PATCH] D124487: [HLSL] Adjust access specifier behavior

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 27 11:16:08 PDT 2022

aaron.ballman added inline comments.

Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:1603
+def ext_hlsl_access_specifiers : ExtWarn<
+  "access specifiers are a clang HLSL extension">;
This also needs to go into a warning group.

Comment at: clang/lib/Parse/ParseDeclCXX.cpp:3517-3519
+  // HLSL: In HLSL members of a class are public by default.
   AccessSpecifier CurAS;
+  if (TagType == DeclSpec::TST_class && !getLangOpts().HLSL)
Gross. 🤮

Comment at: clang/lib/Sema/SemaDeclCXX.cpp:2504-2507
+  // In HLSL, unspecified class access is public rather than private.
+  if (getLangOpts().HLSL && Class->getTagKind() == TTK_Class &&
+      Access == AS_none)
+    Access = AS_public;

Comment at: clang/test/ParserHLSL/access_specifiers.hlsl:4-5
+class Doggo {
+  // expected-note at +1 {{member is declared here}}
+  int legs;
+// expected-warning at +1 {{access specifiers are a clang HLSL extension}}
(It's generally easier to maintain tests when the expected check lines are directly on the impacted line rather than using offsets to it. Same applies through the rest of the test. NB: we don't care about 80 col limits in tests.)

  rG LLVM Github Monorepo



More information about the cfe-commits mailing list