[PATCH] D106030: [Clang] add support for error+warning fn attrs

Nick Desaulniers via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 13 14:24:51 PDT 2021


nickdesaulniers added inline comments.


================
Comment at: clang/lib/Sema/SemaDecl.cpp:3368
+      Diag(Old->getLocation(), diag::note_previous_declaration);
+      New->dropAttr<InternalLinkageAttr>();
+    }
----------------
Should be dropping `ErrorAttr`.


================
Comment at: clang/test/Sema/attr-error.c:26
+
+__attribute__((error("foo"), warning("foo"))) // expected-error {{'warning' and 'error' attributes are not compatible}}
+int
----------------
aaron.ballman wrote:
> Can you also add a test for:
> ```
> __attribute__((error("foo"))) int bad5(void); // expected-note {{conflicting attribute is here}}
> __attribute__((warning("foo"))) int bad5(void); // expected-error {{'warning' and 'error' attributes are not compatible}}
> ```
Ah, that exposes the case you discussed above:
> I think you need to follow the attribute merge pattern used in SemaDecl.cpp.

So I did a relatively larger refactor to support that. Doing so required me to make this an InheritableAttr. PTAL


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106030



More information about the llvm-commits mailing list