diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-06-19 23:52:42 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-06-19 23:52:42 +0000 |
commit | c9c02ed8f499f005b5a8e68f1ecd87401f90daa9 (patch) | |
tree | 003b2f568adda31fe1d7fe677e48f2ed126f4dc5 /clang/lib/Parse/ParseExpr.cpp | |
parent | 724f825f96ab44280a5864e67e8151a7792e393d (diff) | |
download | bcm5719-llvm-c9c02ed8f499f005b5a8e68f1ecd87401f90daa9.tar.gz bcm5719-llvm-c9c02ed8f499f005b5a8e68f1ecd87401f90daa9.zip |
Keep track of when declarations are "used" according to C and
C++. This logic is required to trigger implicit instantiation of
function templates and member functions of class templates, which will
be implemented separately.
This commit includes support for -Wunused-parameter, printing warnings
for named parameters that are not used within a function/Objective-C
method/block. Fixes <rdar://problem/6505209>.
llvm-svn: 73797
Diffstat (limited to 'clang/lib/Parse/ParseExpr.cpp')
-rw-r--r-- | clang/lib/Parse/ParseExpr.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index 3fee78bb719..4a07d05650b 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -276,6 +276,11 @@ Parser::ParseAssignmentExprWithObjCMessageExprStart(SourceLocation LBracLoc, Parser::OwningExprResult Parser::ParseConstantExpression() { + // C++ [basic.def.odr]p2: + // An expression is potentially evaluated unless it appears where an + // integral constant expression is required (see 5.19) [...]. + EnterUnevaluatedOperand Unevaluated(Actions); + OwningExprResult LHS(ParseCastExpression(false)); if (LHS.isInvalid()) return move(LHS); @@ -971,8 +976,15 @@ Parser::ParseExprAfterTypeofSizeofAlignof(const Token &OpTok, Diag(Tok,diag::err_expected_lparen_after_id) << OpTok.getIdentifierInfo(); return ExprError(); } + + // C++0x [expr.sizeof]p1: + // [...] The operand is either an expression, which is an unevaluated + // operand (Clause 5) [...] + // + // The GNU typeof and alignof extensions also behave as unevaluated + // operands. + EnterUnevaluatedOperand Unevaluated(Actions); Operand = ParseCastExpression(true/*isUnaryExpression*/); - } else { // If it starts with a '(', we know that it is either a parenthesized // type-name, or it is a unary-expression that starts with a compound @@ -980,6 +992,14 @@ Parser::ParseExprAfterTypeofSizeofAlignof(const Token &OpTok, // expression. ParenParseOption ExprType = CastExpr; SourceLocation LParenLoc = Tok.getLocation(), RParenLoc; + + // C++0x [expr.sizeof]p1: + // [...] The operand is either an expression, which is an unevaluated + // operand (Clause 5) [...] + // + // The GNU typeof and alignof extensions also behave as unevaluated + // operands. + EnterUnevaluatedOperand Unevaluated(Actions); Operand = ParseParenExpression(ExprType, true/*stopIfCastExpr*/, CastTy, RParenLoc); CastRange = SourceRange(LParenLoc, RParenLoc); |