Skip to content

Commit 30010bf

Browse files
authored
Merge pull request #3489 from apple/eng/alex-july-picks43
pick https://reviews.llvm.org/D109402
2 parents 374252f + 3d5a368 commit 30010bf

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6840,7 +6840,7 @@ def warn_taking_address_of_packed_member : Warning<
68406840
"taking address of packed member %0 of class or structure %q1 may result in an unaligned pointer value">,
68416841
InGroup<DiagGroup<"address-of-packed-member">>;
68426842
def warn_param_mismatched_alignment : Warning<
6843-
"passing %0-byte aligned argument to %1-byte aligned parameter %2 of %3 may result in an unaligned pointer access">,
6843+
"passing %0-byte aligned argument to %1-byte aligned parameter %2%select{| of %4}3 may result in an unaligned pointer access">,
68446844
InGroup<DiagGroup<"align-mismatch">>;
68456845

68466846
def err_objc_object_assignment : Error<

clang/lib/Sema/SemaChecking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5160,7 +5160,7 @@ void Sema::CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
51605160
if (ArgAlign < ParamAlign)
51615161
Diag(Loc, diag::warn_param_mismatched_alignment)
51625162
<< (int)ArgAlign.getQuantity() << (int)ParamAlign.getQuantity()
5163-
<< ParamName << FDecl;
5163+
<< ParamName << (FDecl != nullptr) << FDecl;
51645164
}
51655165

51665166
/// Handles the checks for format strings, non-POD arguments to vararg

clang/test/CodeGen/typedef_alignment_mismatch_warning.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,3 +282,7 @@ void test10() {
282282
auto *UA4ptr = new UsingAligned4(11);
283283
new (UA4ptr) UsingAligned4(12);
284284
}
285+
286+
void testFunctionPointerArray(void (*fptr[10])(Aligned8Int *), Aligned2Int* src) {
287+
fptr[0](src); // expected-warning {{passing 2-byte aligned argument to 8-byte aligned parameter 1 may result in an unaligned pointer access}}
288+
}

0 commit comments

Comments
 (0)