Skip to content

Commit f66adb7

Browse files
committed
1 parent fccabce commit f66adb7

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
@@ -6860,7 +6860,7 @@ def warn_taking_address_of_packed_member : Warning<
68606860
"taking address of packed member %0 of class or structure %q1 may result in an unaligned pointer value">,
68616861
InGroup<DiagGroup<"address-of-packed-member">>;
68626862
def warn_param_mismatched_alignment : Warning<
6863-
"passing %0-byte aligned argument to %1-byte aligned parameter %2 of %3 may result in an unaligned pointer access">,
6863+
"passing %0-byte aligned argument to %1-byte aligned parameter %2%select{| of %4}3 may result in an unaligned pointer access">,
68646864
InGroup<DiagGroup<"align-mismatch">>;
68656865

68666866
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
@@ -5204,7 +5204,7 @@ void Sema::CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
52045204
if (ArgAlign < ParamAlign)
52055205
Diag(Loc, diag::warn_param_mismatched_alignment)
52065206
<< (int)ArgAlign.getQuantity() << (int)ParamAlign.getQuantity()
5207-
<< ParamName << FDecl;
5207+
<< ParamName << (FDecl != nullptr) << FDecl;
52085208
}
52095209

52105210
/// 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)