diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-05-03 22:36:05 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-05-03 22:36:05 +0000 |
commit | 53202857c60214d80950a975e6e52aebf30bd16a (patch) | |
tree | f23ac777abab782b0a6aa0cae83a769e66a69e7a /lib/AST/Expr.cpp | |
parent | c0d600c83a91b200616616f3982553c0ff42fcf3 (diff) |
PR2524: downgrade taking address of expression of type 'void' to an
extension warning.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70805 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Expr.cpp')
-rw-r--r-- | lib/AST/Expr.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 19d67bb7f8..13d2a1be3f 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -603,18 +603,26 @@ static bool DeclCanBeLvalue(const NamedDecl *Decl, ASTContext &Ctx) { /// - reference type [C++ [expr]] /// Expr::isLvalueResult Expr::isLvalue(ASTContext &Ctx) const { + assert(!TR->isReferenceType() && "Expressions can't have reference type."); + + isLvalueResult Res = isLvalueInternal(Ctx); + if (Res != LV_Valid || Ctx.getLangOptions().CPlusPlus) + return Res; + // first, check the type (C99 6.3.2.1). Expressions with function // type in C are not lvalues, but they can be lvalues in C++. - if (!Ctx.getLangOptions().CPlusPlus && TR->isFunctionType()) + if (TR->isFunctionType()) return LV_NotObjectType; // Allow qualified void which is an incomplete type other than void (yuck). if (TR->isVoidType() && !Ctx.getCanonicalType(TR).getCVRQualifiers()) return LV_IncompleteVoidType; - assert(!TR->isReferenceType() && "Expressions can't have reference type."); + return LV_Valid; +} - // the type looks fine, now check the expression +// Check whether the expression can be sanely treated like an l-value +Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const { switch (getStmtClass()) { case StringLiteralClass: // C99 6.5.1p4 case ObjCEncodeExprClass: // @encode behaves like its string in every way. @@ -754,8 +762,6 @@ Expr::isLvalueResult Expr::isLvalue(ASTContext &Ctx) const { return LV_Valid; case PredefinedExprClass: return LV_Valid; - case VAArgExprClass: - return LV_NotObjectType; case CXXDefaultArgExprClass: return cast<CXXDefaultArgExpr>(this)->getExpr()->isLvalue(Ctx); case CXXConditionDeclExprClass: |