[cfe-commits] r59484 - in /cfe/trunk: include/clang/Basic/DiagnosticKinds.def lib/Sema/SemaExpr.cpp test/SemaCXX/decl-expr-ambiguity.cpp
Chris Lattner
sabre at nondot.org
Mon Nov 17 17:26:17 PST 2008
Author: lattner
Date: Mon Nov 17 19:26:17 2008
New Revision: 59484
URL: http://llvm.org/viewvc/llvm-project?rev=59484&view=rev
Log:
implement a fixme by making warnings for ++/-- on non-modifiable-lvalues better.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticKinds.def
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=59484&r1=59483&r2=59484&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Mon Nov 17 19:26:17 2008
@@ -1086,8 +1086,6 @@
"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,
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=59484&r1=59483&r2=59484&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Nov 17 19:26:17 2008
@@ -2368,7 +2368,7 @@
}
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 @@
}
// 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;
}
Modified: cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp?rev=59484&r1=59483&r2=59484&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp (original)
+++ cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp Mon Nov 17 19:26:17 2008
@@ -7,8 +7,8 @@
// 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) {}
More information about the cfe-commits
mailing list