aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaChecking.cpp16
-rw-r--r--test/Sema/format-strings.c7
2 files changed, 14 insertions, 9 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 62f45f5c91..769705419e 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -2423,8 +2423,8 @@ CheckPrintfHandler::HandlePrintfSpecifier(const analyze_printf::PrintfSpecifier
S.PDiag(diag::warn_printf_conversion_argument_type_mismatch)
<< ATR.getRepresentativeTypeName(S.Context) << Ex->getType()
<< Ex->getSourceRange(),
- getLocationOfByte(CS.getStart()),
- /*IsStringLocation*/true,
+ Ex->getLocStart(),
+ /*IsStringLocation*/false,
getSpecifierRange(startSpecifier, specifierLen),
FixItHint::CreateReplacement(
getSpecifierRange(startSpecifier, specifierLen),
@@ -2436,8 +2436,8 @@ CheckPrintfHandler::HandlePrintfSpecifier(const analyze_printf::PrintfSpecifier
<< ATR.getRepresentativeTypeName(S.Context) << Ex->getType()
<< getSpecifierRange(startSpecifier, specifierLen)
<< Ex->getSourceRange(),
- getLocationOfByte(CS.getStart()),
- true,
+ Ex->getLocStart(),
+ /*IsStringLocation*/false,
getSpecifierRange(startSpecifier, specifierLen));
}
}
@@ -2591,8 +2591,8 @@ bool CheckScanfHandler::HandleScanfSpecifier(
S.PDiag(diag::warn_printf_conversion_argument_type_mismatch)
<< ATR.getRepresentativeTypeName(S.Context) << Ex->getType()
<< Ex->getSourceRange(),
- getLocationOfByte(CS.getStart()),
- /*IsStringLocation*/true,
+ Ex->getLocStart(),
+ /*IsStringLocation*/false,
getSpecifierRange(startSpecifier, specifierLen),
FixItHint::CreateReplacement(
getSpecifierRange(startSpecifier, specifierLen),
@@ -2602,8 +2602,8 @@ bool CheckScanfHandler::HandleScanfSpecifier(
S.PDiag(diag::warn_printf_conversion_argument_type_mismatch)
<< ATR.getRepresentativeTypeName(S.Context) << Ex->getType()
<< Ex->getSourceRange(),
- getLocationOfByte(CS.getStart()),
- /*IsStringLocation*/true,
+ Ex->getLocStart(),
+ /*IsStringLocation*/false,
getSpecifierRange(startSpecifier, specifierLen));
}
}
diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c
index afc9e9720c..5c30849059 100644
--- a/test/Sema/format-strings.c
+++ b/test/Sema/format-strings.c
@@ -502,8 +502,13 @@ void pr9751() {
printf("%a", (long double)0); // expected-warning{{format specifies type 'double' but the argument has type 'long double'}}
// Test braced char[] initializers.
- const char kFormat18[] = { "%lld" }; // expected-note{{format string is defined here}}}
+ const char kFormat18[] = { "%lld" }; // expected-note{{format string is defined here}}
printf(kFormat18, 0); // expected-warning{{format specifies type}}
+
+ // Make sure we point at the offending argument rather than the format string.
+ const char kFormat19[] = "%d"; // expected-note{{format string is defined here}}
+ printf(kFormat19,
+ 0.0); // expected-warning{{format specifies}}
}
// PR 9466: clang: doesn't know about %Lu, %Ld, and %Lx