[cfe-commits] r165283 - in /cfe/trunk: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp test/Sema/parentheses.cpp

Matt Beaumont-Gay matthewbg at google.com
Thu Oct 18 18:16:32 PDT 2012


A little belated bikeshed-painting...

On Thu, Oct 4, 2012 at 5:41 PM, David Blaikie <dblaikie at gmail.com> wrote:
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=165283&r1=165282&r2=165283&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Oct  4 19:41:03 2012
> @@ -3863,6 +3863,11 @@
>  def note_logical_and_in_logical_or_silence : Note<
>    "place parentheses around the '&&' expression to silence this warning">;
>
> +def warn_addition_in_bitshift : Warning<
> +  "'%0' within '%1'">, InGroup<ShiftOpParentheses>;

I have a hard time understanding what problem this warning is trying
to explain. Maybe we could phrase it like our other shift operator
precedence warning:
operator '?:' has lower precedence than '<<'; '<<' will be evaluated
first [-Werror,-Wparentheses]

> +def note_addition_in_bitshift_silence : Note<
> +  "place parentheses around the '%0' expression to silence this warning">;
> +
>  def warn_self_assignment : Warning<
>    "explicitly assigning a variable of type %0 to itself">,
>    InGroup<SelfAssignment>, DefaultIgnore;
>
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=165283&r1=165282&r2=165283&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Oct  4 19:41:03 2012
> @@ -8570,6 +8570,20 @@
>    }
>  }
>
> +static void DiagnoseAdditionInShift(Sema &S, SourceLocation OpLoc,
> +                                    Expr *SubExpr, StringRef shift) {
> +  if (BinaryOperator *Bop = dyn_cast<BinaryOperator>(SubExpr)) {
> +    if (Bop->getOpcode() == BO_Add || Bop->getOpcode() == BO_Sub) {

Also, out of curiosity, why not warn on multiply/divide/mod?

-Matt



More information about the cfe-commits mailing list