diff options
author | Chris Lattner <sabre@nondot.org> | 2008-02-02 20:20:10 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-02-02 20:20:10 +0000 |
commit | 35080844d3e634c7c1b2875f476ab5f697eece61 (patch) | |
tree | eeb387d19b7a0fa38a23140cffa41e63f89982fa | |
parent | 3b1ae004d0ee88fc029dad876ec5695f178ef3f6 (diff) |
Implement support for __extension__ which silences extwarnings in its
scope. This is part of the fix for PR1966
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46669 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | Parse/ParseExpr.cpp | 14 | ||||
-rw-r--r-- | test/Sema/exprs.c | 11 |
2 files changed, 23 insertions, 2 deletions
diff --git a/Parse/ParseExpr.cpp b/Parse/ParseExpr.cpp index 09f588aeec..67ce5f1a54 100644 --- a/Parse/ParseExpr.cpp +++ b/Parse/ParseExpr.cpp @@ -567,13 +567,23 @@ Parser::ExprResult Parser::ParseCastExpression(bool isUnaryExpression) { case tok::tilde: // unary-expression: '~' cast-expression case tok::exclaim: // unary-expression: '!' cast-expression case tok::kw___real: // unary-expression: '__real' cast-expression [GNU] - case tok::kw___imag: // unary-expression: '__imag' cast-expression [GNU] + case tok::kw___imag: { // unary-expression: '__imag' cast-expression [GNU] + SourceLocation SavedLoc = ConsumeToken(); + Res = ParseCastExpression(false); + if (!Res.isInvalid) + Res = Actions.ActOnUnaryOp(SavedLoc, SavedKind, Res.Val); + return Res; + } + case tok::kw___extension__:{//unary-expression:'__extension__' cast-expr [GNU] - // FIXME: Extension should silence extwarns in subexpressions. + // __extension__ silences extension warnings in the subexpression. + bool SavedExtWarn = Diags.getWarnOnExtensions(); + Diags.setWarnOnExtensions(false); SourceLocation SavedLoc = ConsumeToken(); Res = ParseCastExpression(false); if (!Res.isInvalid) Res = Actions.ActOnUnaryOp(SavedLoc, SavedKind, Res.Val); + Diags.setWarnOnExtensions(SavedExtWarn); return Res; } case tok::kw_sizeof: // unary-expression: 'sizeof' unary-expression diff --git a/test/Sema/exprs.c b/test/Sema/exprs.c new file mode 100644 index 0000000000..0175877287 --- /dev/null +++ b/test/Sema/exprs.c @@ -0,0 +1,11 @@ +// RUN: clang %s -verify -pedantic -fsyntax-only + +// PR1966 +_Complex double test1() { + return __extension__ 1.0if; +} + +_Complex double test2() { + return 1.0if; // expected-warning {{imaginary constants are an extension}} +} + |