Index: lib/Sema/SemaExpr.cpp
===================================================================
--- lib/Sema/SemaExpr.cpp	(revision 195464)
+++ lib/Sema/SemaExpr.cpp	(working copy)
@@ -3303,6 +3303,50 @@
                                              << ICE->getSubExpr()->getType();
 }
 
+/// \brief Warns if sizeof expression has a binary operation or contains a
+/// sizeof.
+static void warnOnSizeofOnExpression(Sema &S, Expr *E) {
+  if (S.isSFINAEContext())
+      return;
+
+  if(E->HasSideEffects(S.getASTContext()))
+    return;
+
+  const FunctionDecl *FD = S.getCurFunctionDecl();
+  if(FD && FD->isFunctionTemplateSpecialization())
+    return;
+
+  if (const BinaryOperator *Binop =
+      dyn_cast<BinaryOperator>(E->IgnoreParens())) {
+    if (!Binop->isMultiplicativeOp() &&
+        !Binop->isAdditiveOp())
+      return;
+
+    if (Binop->getLHS()->getType()->isArrayType() ||
+        Binop->getLHS()->getType()->isAnyPointerType() ||
+        Binop->getRHS()->getType()->isArrayType() ||
+        Binop->getRHS()->getType()->isAnyPointerType())
+      return;
+
+    // Don't warn if expression is based on macro.
+    if ((Binop->getLHS()->getExprLoc().isMacroID()) ||
+        (Binop->getRHS()->getExprLoc().isMacroID()))
+      return;
+
+    SourceRange DiagRange(Binop->getLHS()->getLocStart(),
+        Binop->getRHS()->getLocEnd());
+    S.Diag(Binop->getOperatorLoc(), diag::warn_sizeof_bin_op) << DiagRange;
+  } else if (const UnaryExprOrTypeTraitExpr *UnaryExpr =
+      dyn_cast<UnaryExprOrTypeTraitExpr>(E->IgnoreParens())) {
+    if (UnaryExpr->getKind() != UETT_SizeOf)
+      return;
+
+    SourceRange DiagRange(UnaryExpr->getLocStart(),
+        UnaryExpr->getLocEnd());
+    S.Diag(UnaryExpr->getOperatorLoc(), diag::warn_sizeof_sizeof) << DiagRange;
+  }
+}
+
 /// \brief Check the constrains on expression operands to unary type expression
 /// and type traits.
 ///
@@ -3365,6 +3409,8 @@
       warnOnSizeofOnArrayDecay(*this, BO->getOperatorLoc(), BO->getType(),
                                BO->getRHS());
     }
+
+    warnOnSizeofOnExpression(*this, E);
   }
 
   return false;
Index: include/clang/Basic/DiagnosticGroups.td
===================================================================
--- include/clang/Basic/DiagnosticGroups.td	(revision 195464)
+++ include/clang/Basic/DiagnosticGroups.td	(working copy)
@@ -268,6 +268,8 @@
 def : DiagGroup<"synth">;
 def SizeofArrayArgument : DiagGroup<"sizeof-array-argument">;
 def SizeofArrayDecay : DiagGroup<"sizeof-array-decay">;
+def SizeofOnExpression : DiagGroup<"sizeof-on-expression">;
+
 def SizeofPointerMemaccess : DiagGroup<"sizeof-pointer-memaccess">;
 def StaticInInline : DiagGroup<"static-in-inline">;
 def StaticLocalInInline : DiagGroup<"static-local-in-inline">;
Index: include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- include/clang/Basic/DiagnosticSemaKinds.td	(revision 195464)
+++ include/clang/Basic/DiagnosticSemaKinds.td	(working copy)
@@ -4329,6 +4329,14 @@
   "sizeof on pointer operation will return size of %0 instead of %1">,
   InGroup<SizeofArrayDecay>;
 
+def warn_sizeof_bin_op : Warning<
+  "using sizeof() on an expression with an operator may yield unexpected results">,
+  InGroup<SizeofOnExpression>;
+
+def warn_sizeof_sizeof : Warning<
+  "using sizeof() on sizeof() may yield unexpected results.">,
+  InGroup<SizeofOnExpression>;
+  
 def err_sizeof_nonfragile_interface : Error<
   "application of '%select{alignof|sizeof}1' to interface %0 is "
   "not supported on this architecture and platform">;
Index: test/SemaCXX/sizeofonexpression.cpp
===================================================================
--- test/SemaCXX/sizeofonexpression.cpp	(revision 0)
+++ test/SemaCXX/sizeofonexpression.cpp	(working copy)
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T, typename RESULT, 
+    typename ARG1, typename ARG2, typename ARG3>
+class DoesDebug
+{
+    template <typename U, RESULT (U::*)(ARG1, ARG2, ARG3)> struct Check;
+    template <typename U> static char checkFn(Check<U, &U::Debug> *);
+    template <typename U> static int checkFn(...);
+public:
+    enum { Exist = sizeof(checkFn<T>(0)) == sizeof(char) }; // no-warning
+
+    int binOp() {
+      return sizeof(checkFn<T>(0)+1);
+    } // no-warning
+
+    int sizeofsizeof() {
+      return sizeof(sizeof(checkFn<T>(0)));
+    } // no-warning
+};
+class A {
+public:
+  A(): a(1) { }
+  A(int p) : a(sizeof(p + 1)) { } // expected-warning{{using sizeof() on an expression with an operator may yield unexpected results}}
+  int a;
+};
+
+void f()
+{
+  int bb = 0;
+  int b = sizeof(bb + 1); // expected-warning{{using sizeof() on an expression with an operator may yield unexpected results}}
+}
Index: test/SemaCXX/decl-expr-ambiguity.cpp
===================================================================
--- test/SemaCXX/decl-expr-ambiguity.cpp	(revision 195464)
+++ test/SemaCXX/decl-expr-ambiguity.cpp	(working copy)
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -Wno-int-to-pointer-cast -fsyntax-only -verify -pedantic-errors %s
-// RUN: %clang_cc1 -Wno-int-to-pointer-cast -fsyntax-only -verify -pedantic-errors -x objective-c++ %s
+// RUN: %clang_cc1 -Wno-sizeof-on-expression -Wno-int-to-pointer-cast -fsyntax-only -verify -pedantic-errors %s
+// RUN: %clang_cc1 -Wno-sizeof-on-expression -Wno-int-to-pointer-cast -fsyntax-only -verify -pedantic-errors -x objective-c++ %s
 
 void f() {
   int a;
Index: test/Sema/sizeofonexpression.c
===================================================================
--- test/Sema/sizeofonexpression.c	(revision 0)
+++ test/Sema/sizeofonexpression.c	(working copy)
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#define DEF (1+2)
+
+struct s {
+  int xx;
+  int yy;
+};
+
+int SizeofStructExpression(struct s p) {
+  return sizeof(sizeof(p) + 1);  // expected-warning{{using sizeof() on an expression with an operator may yield unexpected results}}
+}
+
+int SizeofStructMemberExpression(struct s p) {
+  return sizeof(p.xx * p.yy); // expected-warning{{using sizeof() on an expression with an operator may yield unexpected results}}
+}
+
+int SizeofLiteralExpression() {
+  return sizeof(2 + 1);  // expected-warning{{using sizeof() on an expression with an operator may yield unexpected results}}
+}
+
+int SizeofRefExpression() {
+  int x = 1, y = 2;
+  return sizeof(x / y);  // expected-warning{{using sizeof() on an expression with an operator may yield unexpected results}}
+}
+
+int SizeofDefine() {
+  return sizeof(DEF);
+} // no-warning
+
+int SizeofDefineExpression() {
+  return sizeof(DEF + 2);
+} // no-warning
+
+int SizeofDefineExpression2() {
+  return sizeof(2 - DEF);
+} // no-warning
+
+int SizeofFunctionCallExpression() {
+  return sizeof(SizeofDefine() - 1);
+} // no-warning
+
+int SizeofSizeof() {
+  return sizeof(sizeof(1)); // expected-warning{{using sizeof() on sizeof() may yield unexpected results}}
+}
+
+int SizeofComparison() {
+  return sizeof(1+1) == 1; // expected-warning{{using sizeof() on an expression with an operator may yield unexpected results}}
+}
Index: test/Sema/exprs.c
===================================================================
--- test/Sema/exprs.c	(revision 195464)
+++ test/Sema/exprs.c	(working copy)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -Wno-sizeof-on-expression -verify -pedantic -fsyntax-only
 
 // PR 8876 - don't warn about trivially unreachable null derefs.  Note that
 // we put this here because the reachability analysis only kicks in for
