return;
}
- SourceLocation Open = E->getSourceRange().getBegin();
- SourceLocation Close = PP.getLocForEndOfToken(E->getSourceRange().getEnd());
-
Diag(Loc, diagnostic) << E->getSourceRange();
if (IsOrAssign)
Diag(Loc, diag::note_condition_assign_to_comparison)
<< FixItHint::CreateReplacement(Loc, "==");
- Diag(Loc, diag::note_condition_assign_silence)
- << FixItHint::CreateInsertion(Open, "(")
- << FixItHint::CreateInsertion(Close, ")");
+ SourceLocation Open = E->getSourceRange().getBegin();
+ SourceLocation Close = E->getSourceRange().getEnd();
+ if (!Open.isMacroID() && !Close.isMacroID()) {
+ SourceLocation LocForEndOfToken = PP.getLocForEndOfToken(Close);
+ Diag(Loc, diag::note_condition_assign_silence)
+ << FixItHint::CreateInsertion(Open, "(")
+ << FixItHint::CreateInsertion(LocForEndOfToken, ")");
+ }
}
/// \brief Redundant parentheses over an equality comparison can indicate
--- /dev/null
+// RUN: %clang_cc1 -pedantic -fixit -x c %s
+// rdar://9091893
+
+#define va_arg(ap, type) __builtin_va_arg(ap, type)
+typedef __builtin_va_list va_list;
+
+void myFunc() {
+ va_list values;
+
+ int value;
+
+ while (value = va_arg(values, int)) { // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+ // expected-note {{use '==' to turn this assignment into an equality comparison}}
+ }
+}