git: 7785cdd1f9a8 - stable/12 - Reapply r360852 (by cem):

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Wed, 22 Dec 2021 10:05:46 UTC
The branch stable/12 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=7785cdd1f9a82966cc8cee4f4a50ab438f392139

commit 7785cdd1f9a82966cc8cee4f4a50ab438f392139
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2020-08-06 19:23:00 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2021-12-22 09:58:23 +0000

    Reapply r360852 (by cem):
    
    clang: Reject %n for __attribute__((format(__freebsd_kprintf__)))
    
    A follow-up to r360849.
    
    Reported by:    imp
    Reviewed by:    emaste, imp
    Differential Revision:  https://reviews.freebsd.org/D24786
    
    (cherry picked from commit ec280e9ec4b825ae73cdeccffeb8e72ce7dcc99d)
---
 contrib/llvm-project/clang/lib/AST/PrintfFormatString.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/llvm-project/clang/lib/AST/PrintfFormatString.cpp b/contrib/llvm-project/clang/lib/AST/PrintfFormatString.cpp
index f3ac181214ac..0de2b112fb8a 100644
--- a/contrib/llvm-project/clang/lib/AST/PrintfFormatString.cpp
+++ b/contrib/llvm-project/clang/lib/AST/PrintfFormatString.cpp
@@ -317,8 +317,8 @@ static PrintfSpecifierResult ParsePrintfSpecifier(FormatStringHandler &H,
     case 'g': k = ConversionSpecifier::gArg; break;
     case 'i': k = ConversionSpecifier::iArg; break;
     case 'n':
-      // Not handled, but reserved in OpenCL.
-      if (!LO.OpenCL)
+      // Not handled, but reserved in OpenCL and FreeBSD kernel.
+      if (!LO.OpenCL && !isFreeBSDKPrintf)
         k = ConversionSpecifier::nArg;
       break;
     case 'o': k = ConversionSpecifier::oArg; break;