diff options
author | Abramo Bagnara <abramo.bagnara@gmail.com> | 2010-10-15 07:51:18 +0000 |
---|---|---|
committer | Abramo Bagnara <abramo.bagnara@gmail.com> | 2010-10-15 07:51:18 +0000 |
commit | b9eb35ced8369c8c8479efc17712faaf34e16c56 (patch) | |
tree | e0fce78481a89f6f96778e939f209c68ba549426 | |
parent | 84a8e0a846d658d784090c4f378cc1c6c6b0ef3f (diff) |
Treat __extension__ like ParenExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116569 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/Expr.cpp | 62 | ||||
-rw-r--r-- | test/Parser/expressions.c | 3 |
2 files changed, 50 insertions, 15 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 98f0656ad1..92e7119445 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -1554,10 +1554,19 @@ Expr::CanThrowResult Expr::CanThrow(ASTContext &C) const { Expr* Expr::IgnoreParens() { Expr* E = this; - while (ParenExpr* P = dyn_cast<ParenExpr>(E)) - E = P->getSubExpr(); - - return E; + while (true) { + if (ParenExpr* P = dyn_cast<ParenExpr>(E)) { + E = P->getSubExpr(); + continue; + } + if (UnaryOperator* P = dyn_cast<UnaryOperator>(E)) { + if (P->getOpcode() == UO_Extension) { + E = P->getSubExpr(); + continue; + } + } + return E; + } } /// IgnoreParenCasts - Ignore parentheses and casts. Strip off any ParenExpr @@ -1565,24 +1574,42 @@ Expr* Expr::IgnoreParens() { Expr *Expr::IgnoreParenCasts() { Expr *E = this; while (true) { - if (ParenExpr *P = dyn_cast<ParenExpr>(E)) + if (ParenExpr* P = dyn_cast<ParenExpr>(E)) { E = P->getSubExpr(); - else if (CastExpr *P = dyn_cast<CastExpr>(E)) + continue; + } + if (CastExpr *P = dyn_cast<CastExpr>(E)) { E = P->getSubExpr(); - else - return E; + continue; + } + if (UnaryOperator* P = dyn_cast<UnaryOperator>(E)) { + if (P->getOpcode() == UO_Extension) { + E = P->getSubExpr(); + continue; + } + } + return E; } } Expr *Expr::IgnoreParenImpCasts() { Expr *E = this; while (true) { - if (ParenExpr *P = dyn_cast<ParenExpr>(E)) + if (ParenExpr *P = dyn_cast<ParenExpr>(E)) { E = P->getSubExpr(); - else if (ImplicitCastExpr *P = dyn_cast<ImplicitCastExpr>(E)) + continue; + } + if (ImplicitCastExpr *P = dyn_cast<ImplicitCastExpr>(E)) { E = P->getSubExpr(); - else - return E; + continue; + } + if (UnaryOperator* P = dyn_cast<UnaryOperator>(E)) { + if (P->getOpcode() == UO_Extension) { + E = P->getSubExpr(); + continue; + } + } + return E; } } @@ -1607,9 +1634,9 @@ Expr *Expr::IgnoreParenNoopCasts(ASTContext &Ctx) { continue; } - if ((E->getType()->isPointerType() || + if ((E->getType()->isPointerType() || E->getType()->isIntegralType(Ctx)) && - (SE->getType()->isPointerType() || + (SE->getType()->isPointerType() || SE->getType()->isIntegralType(Ctx)) && Ctx.getTypeSize(E->getType()) == Ctx.getTypeSize(SE->getType())) { E = SE; @@ -1617,6 +1644,13 @@ Expr *Expr::IgnoreParenNoopCasts(ASTContext &Ctx) { } } + if (UnaryOperator* P = dyn_cast<UnaryOperator>(E)) { + if (P->getOpcode() == UO_Extension) { + E = P->getSubExpr(); + continue; + } + } + return E; } } diff --git a/test/Parser/expressions.c b/test/Parser/expressions.c index ffc5c83a0a..6015e918a3 100644 --- a/test/Parser/expressions.c +++ b/test/Parser/expressions.c @@ -39,7 +39,8 @@ void test_sizeof(){ // PR3418 int test_leading_extension() { - __extension__ (*(char*)0) = 1; + __extension__ (*(char*)0) = 1; // expected-warning {{indirection of non-volatile null pointer}} \ + // expected-note {{consider using __builtin_trap}} return 0; } |