forked from OSchip/llvm-project
simplify some other code for __extension__ processing.
llvm-svn: 57807
This commit is contained in:
parent
f02ef3e6d4
commit
1ff6e73651
|
@ -13,6 +13,7 @@
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "clang/Parse/Parser.h"
|
#include "clang/Parse/Parser.h"
|
||||||
|
#include "ExtensionRAIIObject.h"
|
||||||
#include "clang/Basic/Diagnostic.h"
|
#include "clang/Basic/Diagnostic.h"
|
||||||
#include "clang/Basic/SourceManager.h"
|
#include "clang/Basic/SourceManager.h"
|
||||||
#include "clang/Parse/DeclSpec.h"
|
#include "clang/Parse/DeclSpec.h"
|
||||||
|
@ -364,9 +365,8 @@ Parser::StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
|
||||||
ConsumeToken();
|
ConsumeToken();
|
||||||
|
|
||||||
// __extension__ silences extension warnings in the subexpression.
|
// __extension__ silences extension warnings in the subexpression.
|
||||||
bool SavedExtWarn = Diags.getWarnOnExtensions();
|
ExtensionRAIIObject O(Diags); // Use RAII to do this.
|
||||||
Diags.setWarnOnExtensions(false);
|
|
||||||
|
|
||||||
// If this is the start of a declaration, parse it as such.
|
// If this is the start of a declaration, parse it as such.
|
||||||
if (isDeclarationStatement()) {
|
if (isDeclarationStatement()) {
|
||||||
// FIXME: Save the __extension__ on the decl as a node somehow.
|
// FIXME: Save the __extension__ on the decl as a node somehow.
|
||||||
|
@ -374,13 +374,10 @@ Parser::StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
|
||||||
DeclTy *Res = ParseDeclaration(Declarator::BlockContext);
|
DeclTy *Res = ParseDeclaration(Declarator::BlockContext);
|
||||||
// FIXME: Pass in the right location for the end of the declstmt.
|
// FIXME: Pass in the right location for the end of the declstmt.
|
||||||
R = Actions.ActOnDeclStmt(Res, DeclStart, DeclStart);
|
R = Actions.ActOnDeclStmt(Res, DeclStart, DeclStart);
|
||||||
|
|
||||||
Diags.setWarnOnExtensions(SavedExtWarn);
|
|
||||||
} else {
|
} else {
|
||||||
// Otherwise this was a unary __extension__ marker. Parse the
|
// Otherwise this was a unary __extension__ marker. Parse the
|
||||||
// subexpression and add the __extension__ unary op.
|
// subexpression and add the __extension__ unary op.
|
||||||
ExprResult Res = ParseCastExpression(false);
|
ExprResult Res = ParseCastExpression(false);
|
||||||
Diags.setWarnOnExtensions(SavedExtWarn);
|
|
||||||
|
|
||||||
if (Res.isInvalid) {
|
if (Res.isInvalid) {
|
||||||
SkipUntil(tok::semi);
|
SkipUntil(tok::semi);
|
||||||
|
@ -392,7 +389,8 @@ Parser::StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
|
||||||
if (Res.isInvalid)
|
if (Res.isInvalid)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Eat the semicolon at the end of stmt and convert the expr into a stmt.
|
// Eat the semicolon at the end of stmt and convert the expr into a
|
||||||
|
// statement.
|
||||||
ExpectAndConsume(tok::semi, diag::err_expected_semi_after_expr);
|
ExpectAndConsume(tok::semi, diag::err_expected_semi_after_expr);
|
||||||
R = Actions.ActOnExprStmt(Res.Val);
|
R = Actions.ActOnExprStmt(Res.Val);
|
||||||
}
|
}
|
||||||
|
|
|
@ -344,6 +344,7 @@ Parser::DeclTy *Parser::ParseExternalDeclaration() {
|
||||||
case tok::kw___extension__: {
|
case tok::kw___extension__: {
|
||||||
// __extension__ silences extension warnings in the subexpression.
|
// __extension__ silences extension warnings in the subexpression.
|
||||||
ExtensionRAIIObject O(Diags); // Use RAII to do this.
|
ExtensionRAIIObject O(Diags); // Use RAII to do this.
|
||||||
|
ConsumeToken();
|
||||||
return ParseExternalDeclaration();
|
return ParseExternalDeclaration();
|
||||||
}
|
}
|
||||||
case tok::kw_asm: {
|
case tok::kw_asm: {
|
||||||
|
|
Loading…
Reference in New Issue