def : DiagGroup<"cast-qual">;
def : DiagGroup<"char-align">;
def Comment : DiagGroup<"comment">;
-def Conversion : DiagGroup<"conversion">;
def : DiagGroup<"declaration-after-statement">;
def : DiagGroup<"disabled-optimization">;
def : DiagGroup<"discard-qual">;
// Aggregation warning settings.
+// -Wconversion has its own warnings, but we split this one out for
+// legacy reasons.
+def Conversion : DiagGroup<"conversion",
+ [DiagGroup<"shorten-64-to-32">]>;
def Unused : DiagGroup<"unused",
[UnusedArgument, UnusedFunction, UnusedLabel,
def warn_impcast_integer_precision : Warning<
"implicit cast loses integer precision: %0 to %1">,
InGroup<DiagGroup<"conversion">>, DefaultIgnore;
+def warn_impcast_integer_64_32 : Warning<
+ "implicit cast loses integer precision: %0 to %1">,
+ InGroup<DiagGroup<"shorten-64-to-32">>, DefaultIgnore;
def warn_attribute_ignored_for_field_of_type : Warning<
"%0 attribute ignored for field of type %1">;
if (IsExprValueWithinWidth(S.Context, E, TargetWidth))
return;
+ // People want to build with -Wshorten-64-to-32 and not -Wconversion
+ // and by god we'll let them.
+ if (SourceWidth == 64 && TargetWidth == 32)
+ return DiagnoseImpCast(S, E, T, diag::warn_impcast_integer_64_32);
return DiagnoseImpCast(S, E, T, diag::warn_impcast_integer_precision);
}
--- /dev/null
+// RUN: clang-cc -fsyntax-only -verify -Wshorten-64-to-32 -triple x86_64-apple-darwin %s
+
+int test0(long v) {
+ return v; // expected-warning {{implicit cast loses integer precision}}
+}