[cfe-commits] r39442 - in /cfe/cfe/trunk: AST/Sema.cpp AST/Sema.h AST/SemaExpr.cpp Sema/Sema.cpp Sema/Sema.h Sema/SemaExpr.cpp include/clang/Basic/DiagnosticKinds.def
Steve Naroff
snaroff at apple.com
Wed Jul 11 09:44:27 PDT 2007
Author: snaroff
Date: Wed Jul 11 11:44:27 2007
New Revision: 39442
URL: http://llvm.org/viewvc/llvm-project?rev=39442&view=rev
Log:
Bug #:
Submitted by:
Reviewed by:
Two bug fixes to CheckIncrementDecrementOperand:
- removed "constantOne" usage and simply use Context.IntTy.
- fix the last constraint check...the lvalue test needs to be on the
expression, not the type! (duh).
Modified:
cfe/cfe/trunk/AST/Sema.cpp
cfe/cfe/trunk/AST/Sema.h
cfe/cfe/trunk/AST/SemaExpr.cpp
cfe/cfe/trunk/Sema/Sema.cpp
cfe/cfe/trunk/Sema/Sema.h
cfe/cfe/trunk/Sema/SemaExpr.cpp
cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def
Modified: cfe/cfe/trunk/AST/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/Sema.cpp?rev=39442&r1=39441&r2=39442&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/Sema.cpp (original)
+++ cfe/cfe/trunk/AST/Sema.cpp Wed Jul 11 11:44:27 2007
@@ -20,7 +20,6 @@
Sema::Sema(Preprocessor &pp, ASTContext &ctxt, std::vector<Decl*> &prevInGroup)
: PP(pp), Context(ctxt), CurFunctionDecl(0), LastInGroupList(prevInGroup) {
- constantOne = new IntegerLiteral(1, ctxt.IntTy);
}
//===----------------------------------------------------------------------===//
Modified: cfe/cfe/trunk/AST/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/Sema.h?rev=39442&r1=39441&r2=39442&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/Sema.h (original)
+++ cfe/cfe/trunk/AST/Sema.h Wed Jul 11 11:44:27 2007
@@ -50,9 +50,6 @@
/// all but the last decl will be entered into this. This is used by the
/// ASTStreamer.
std::vector<Decl*> &LastInGroupList;
-
- /// Constant for "1"
- IntegerLiteral *constantOne;
public:
Sema(Preprocessor &pp, ASTContext &ctxt, std::vector<Decl*> &prevInGroup);
Modified: cfe/cfe/trunk/AST/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/SemaExpr.cpp?rev=39442&r1=39441&r2=39442&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/SemaExpr.cpp (original)
+++ cfe/cfe/trunk/AST/SemaExpr.cpp Wed Jul 11 11:44:27 2007
@@ -726,8 +726,7 @@
}
QualType Sema::CheckIncrementDecrementOperand(Expr *op, SourceLocation OpLoc) {
- QualType resType = UsualArithmeticConversions(op->getType(),
- constantOne->getType());
+ QualType resType = UsualArithmeticConversions(op->getType(), Context.IntTy);
assert(!resType.isNull() && "no type for increment/decrement expression");
// C99 6.5.2.4p1
@@ -741,11 +740,10 @@
Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement, resType);
return QualType();
}
- // At this point, we know we have a real or pointer type. As a result, the
- // following predicate is overkill (i.e. it will check for types we know we
- // don't have in this context). Nevertheless, we model the C99 spec closely.
- if (!resType.isModifiableLvalue()) {
- Diag(OpLoc, diag::err_typecheck_not_modifiable, resType);
+ // At this point, we know we have a real or pointer type. Now make sure
+ // the operand is a modifiable lvalue.
+ if (!op->isModifiableLvalue()) {
+ Diag(OpLoc, diag::err_typecheck_invalid_lvalue_incr_decr);
return QualType();
}
return resType;
Modified: cfe/cfe/trunk/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/Sema.cpp?rev=39442&r1=39441&r2=39442&view=diff
==============================================================================
--- cfe/cfe/trunk/Sema/Sema.cpp (original)
+++ cfe/cfe/trunk/Sema/Sema.cpp Wed Jul 11 11:44:27 2007
@@ -20,7 +20,6 @@
Sema::Sema(Preprocessor &pp, ASTContext &ctxt, std::vector<Decl*> &prevInGroup)
: PP(pp), Context(ctxt), CurFunctionDecl(0), LastInGroupList(prevInGroup) {
- constantOne = new IntegerLiteral(1, ctxt.IntTy);
}
//===----------------------------------------------------------------------===//
Modified: cfe/cfe/trunk/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/Sema.h?rev=39442&r1=39441&r2=39442&view=diff
==============================================================================
--- cfe/cfe/trunk/Sema/Sema.h (original)
+++ cfe/cfe/trunk/Sema/Sema.h Wed Jul 11 11:44:27 2007
@@ -50,9 +50,6 @@
/// all but the last decl will be entered into this. This is used by the
/// ASTStreamer.
std::vector<Decl*> &LastInGroupList;
-
- /// Constant for "1"
- IntegerLiteral *constantOne;
public:
Sema(Preprocessor &pp, ASTContext &ctxt, std::vector<Decl*> &prevInGroup);
Modified: cfe/cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/SemaExpr.cpp?rev=39442&r1=39441&r2=39442&view=diff
==============================================================================
--- cfe/cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/cfe/trunk/Sema/SemaExpr.cpp Wed Jul 11 11:44:27 2007
@@ -726,8 +726,7 @@
}
QualType Sema::CheckIncrementDecrementOperand(Expr *op, SourceLocation OpLoc) {
- QualType resType = UsualArithmeticConversions(op->getType(),
- constantOne->getType());
+ QualType resType = UsualArithmeticConversions(op->getType(), Context.IntTy);
assert(!resType.isNull() && "no type for increment/decrement expression");
// C99 6.5.2.4p1
@@ -741,11 +740,10 @@
Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement, resType);
return QualType();
}
- // At this point, we know we have a real or pointer type. As a result, the
- // following predicate is overkill (i.e. it will check for types we know we
- // don't have in this context). Nevertheless, we model the C99 spec closely.
- if (!resType.isModifiableLvalue()) {
- Diag(OpLoc, diag::err_typecheck_not_modifiable, resType);
+ // At this point, we know we have a real or pointer type. Now make sure
+ // the operand is a modifiable lvalue.
+ if (!op->isModifiableLvalue()) {
+ Diag(OpLoc, diag::err_typecheck_invalid_lvalue_incr_decr);
return QualType();
}
return resType;
Modified: cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=39442&r1=39441&r2=39442&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def Wed Jul 11 11:44:27 2007
@@ -529,8 +529,8 @@
"no member named '%s'")
DIAG(err_typecheck_illegal_increment_decrement, ERROR,
"cannot modify value of type '%s'")
-DIAG(err_typecheck_not_modifiable, ERROR,
- "cannot modify read-only value of type '%s'")
+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 '%s'")
DIAG(err_typecheck_decl_incomplete_type, ERROR,
More information about the cfe-commits
mailing list