[clang] [Parser][BoundsSafety] Print attribute as macro if it's system defined (PR #107619)

Yeoul Na via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 9 17:19:37 PDT 2024


================
@@ -14,12 +16,26 @@ void Func() {
   auto NODEREF auto_i2 = i; // expected-warning{{'noderef' can only be used on an array or pointer type}}
 }
 
+// The diagnostic message is hard-coded as 'noderef' so using a system macro doesn't change the behavior
+void Func_system_macro() {
+  int _SYS_NODEREF i; // expected-warning{{'noderef' can only be used on an array or pointer type}}
+  int _SYS_NODEREF *i_ptr;
+
+  auto _SYS_NODEREF *auto_i_ptr2 = i_ptr;
+  auto _SYS_NODEREF auto_i2 = i; // expected-warning{{'noderef' can only be used on an array or pointer type}}
+}
+
+
 // Added test for fix for P41835
 #define _LIBCPP_FLOAT_ABI __attribute__((pcs("aapcs")))
 struct A {
   _LIBCPP_FLOAT_ABI int operator()() throw(); // expected-warning{{'pcs' calling convention is not supported for this target}}
 };
 
+struct A_system_macro {
+  _SYS_LIBCPP_FLOAT_ABI int operator()() throw(); // expected-warning{{'_SYS_LIBCPP_FLOAT_ABI' calling convention is not supported for this target}}
----------------
rapidsna wrote:

> if we're always pointing the caret at the attribute itself so we get an 'expanded from macro' note, that seems fine.

@zygoloid I just added some file checks here (411e3435873bad900e84309d90fe13f6085b3a1a) to verify that.

https://github.com/llvm/llvm-project/pull/107619


More information about the cfe-commits mailing list