Submitted by:
Reviewed by:
Some minor cleanup (comments, spec refs, simplied some expressions).

llvm-svn: 39444
This commit is contained in:
Steve Naroff 2007-05-14 18:14:51 +00:00
parent 475cca0d1a
commit 5dd642eb4a
3 changed files with 11 additions and 15 deletions

View File

@ -135,23 +135,19 @@ bool Expr::isLvalue() {
if (TR->isIncompleteType() && TR->isVoidType())
return false;
// now, check the expression
// the type looks fine, now check the expression
switch (getStmtClass()) {
case StringLiteralClass: // C99 6.5.1p4
return true;
case ArraySubscriptExprClass:
case ArraySubscriptExprClass: // C99 6.5.3p4 (e1[e2] == (*((e1)+(e2))))
return true;
case DeclRefExprClass: // C99 6.5.1p2
const DeclRefExpr *d = cast<DeclRefExpr>(this);
return isa<VarDecl>(d->getDecl());
return isa<VarDecl>(cast<DeclRefExpr>(this)->getDecl());
case MemberExprClass: // C99 6.5.2.3p4
const MemberExpr *m = cast<MemberExpr>(this);
if (m->isArrow())
return true;
return m->getBase()->isLvalue();
return m->isArrow() ? true : m->getBase()->isLvalue();
case UnaryOperatorClass: // C99 6.5.3p4
const UnaryOperator *u = cast<UnaryOperator>(this);
return u->getOpcode() == UnaryOperator::Deref;
return cast<UnaryOperator>(this)->getOpcode() == UnaryOperator::Deref;
case ParenExprClass: // C99 6.5.1p5
return cast<ParenExpr>(this)->getSubExpr()->isLvalue();
default:

View File

@ -780,9 +780,9 @@ static Decl *getPrimaryDeclaration(Expr *e) {
QualType Sema::CheckAddressOfOperand(Expr *op, SourceLocation OpLoc) {
Decl *dcl = getPrimaryDeclaration(op);
if (!op->isLvalue()) { //
if (dcl && isa<FunctionDecl>(dcl))
; // C99 6.5.3.2p1: Allow function designators.
if (!op->isLvalue()) { // C99 6.5.3.2p1
if (dcl && isa<FunctionDecl>(dcl)) // allow function designators
;
else {
Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof);
return QualType();

View File

@ -780,9 +780,9 @@ static Decl *getPrimaryDeclaration(Expr *e) {
QualType Sema::CheckAddressOfOperand(Expr *op, SourceLocation OpLoc) {
Decl *dcl = getPrimaryDeclaration(op);
if (!op->isLvalue()) { //
if (dcl && isa<FunctionDecl>(dcl))
; // C99 6.5.3.2p1: Allow function designators.
if (!op->isLvalue()) { // C99 6.5.3.2p1
if (dcl && isa<FunctionDecl>(dcl)) // allow function designators
;
else {
Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof);
return QualType();