diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 7f7410a20084..d37c8e9266e9 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -6792,7 +6792,7 @@ def warn_taking_address_of_packed_member : Warning< "taking address of packed member %0 of class or structure %q1 may result in an unaligned pointer value">, InGroup>; def warn_param_mismatched_alignment : Warning< - "passing %0-byte aligned argument to %1-byte aligned parameter %2 of %3 may result in an unaligned pointer access">, + "passing %0-byte aligned argument to %1-byte aligned parameter %2%select{| of %4}3 may result in an unaligned pointer access">, InGroup>; def err_objc_object_assignment : Error< diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 147f50aeed97..bf458f914c11 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -4887,7 +4887,7 @@ void Sema::CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl, if (ArgAlign < ParamAlign) Diag(Loc, diag::warn_param_mismatched_alignment) << (int)ArgAlign.getQuantity() << (int)ParamAlign.getQuantity() - << ParamName << FDecl; + << ParamName << (FDecl != nullptr) << FDecl; } /// Handles the checks for format strings, non-POD arguments to vararg diff --git a/clang/test/CodeGen/typedef_alignment_mismatch_warning.cpp b/clang/test/CodeGen/typedef_alignment_mismatch_warning.cpp index 9bc1d19843f3..1e6888de60e6 100644 --- a/clang/test/CodeGen/typedef_alignment_mismatch_warning.cpp +++ b/clang/test/CodeGen/typedef_alignment_mismatch_warning.cpp @@ -282,3 +282,7 @@ void test10() { auto *UA4ptr = new UsingAligned4(11); new (UA4ptr) UsingAligned4(12); } + +void testFunctionPointerArray(void (*fptr[10])(Aligned8Int *), Aligned2Int* src) { + fptr[0](src); // expected-warning {{passing 2-byte aligned argument to 8-byte aligned parameter 1 may result in an unaligned pointer access}} +}