]> granicus.if.org Git - clang/commitdiff
implement a fixme by making warnings for ++/-- on non-modifiable-lvalues better.
authorChris Lattner <sabre@nondot.org>
Tue, 18 Nov 2008 01:26:17 +0000 (01:26 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 18 Nov 2008 01:26:17 +0000 (01:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59484 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticKinds.def
lib/Sema/SemaExpr.cpp
test/SemaCXX/decl-expr-ambiguity.cpp

index d427e69ac7724a169f9f9716804e3ec87533347f..81f30e4540af629f5de89379f46d91e73f095592 100644 (file)
@@ -1086,8 +1086,6 @@ DIAG(err_typecheck_no_member, ERROR,
      "no member named '%0'")
 DIAG(err_typecheck_illegal_increment_decrement, ERROR,
      "cannot modify value of type '%0'")
-DIAG(err_typecheck_invalid_lvalue_incr_decr, ERROR,
-     "invalid lvalue in increment/decrement expression")
 DIAG(err_typecheck_arithmetic_incomplete_type, ERROR,
      "arithmetic on pointer to incomplete type '%0'")
 DIAG(err_typecheck_decl_incomplete_type, ERROR,
index 1abc5a31df7f3cfcbece6f76870cffed0db1d45d..61b6f7e577e6200da5edc39716dbeb842f5d0818 100644 (file)
@@ -2368,7 +2368,7 @@ static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S) {
   }
 
   if (NeedType)
-    S.Diag(Loc, Diag, E->getType().getAsString(), SR);
+    S.Diag(Loc, Diag, E->getType().getAsString(), E->getSourceRange());
   else
     S.Diag(Loc, Diag, E->getSourceRange());
   return true;
@@ -2463,13 +2463,8 @@ QualType Sema::CheckIncrementDecrementOperand(Expr *op, SourceLocation OpLoc) {
   }
   // At this point, we know we have a real, complex or pointer type. 
   // Now make sure the operand is a modifiable lvalue.
-  Expr::isModifiableLvalueResult mlval = op->isModifiableLvalue(Context);
-  if (mlval != Expr::MLV_Valid) {
-    // FIXME: emit a more precise diagnostic...
-    Diag(OpLoc, diag::err_typecheck_invalid_lvalue_incr_decr,
-         op->getSourceRange());
+  if (CheckForModifiableLvalue(op, OpLoc, *this))
     return QualType();
-  }
   return resType;
 }
 
index 5a76b933425e914f74122d87cf1fb9b744327325..1d690606583c121c1b9717a24002ad4c5898aac2 100644 (file)
@@ -7,8 +7,8 @@ void f() {
 
   // Expressions.
   T(a)->m = 7;
-  int(a)++; // expected-error {{invalid lvalue in increment/decrement expression}}
-  __extension__ int(a)++; // expected-error {{invalid lvalue in increment/decrement expression}}
+  int(a)++; // expected-error {{expression is not assignable}}
+  __extension__ int(a)++; // expected-error {{expression is not assignable}}
   typeof(int)(a,5)<<a; // expected-error {{function-style cast to a builtin type can only take one argument}}
   void(a), ++a; // expected-warning {{statement was disambiguated as expression}} expected-warning {{expression result unused}}
   if (int(a)+1) {}