forked from OSchip/llvm-project
parent
93e87652f2
commit
f24fcff65e
|
@ -142,6 +142,8 @@ DIAG(err_expected_semi_after_expr, ERROR,
|
|||
"expected ';' after expression")
|
||||
DIAG(err_expected_semi_after_method_proto, ERROR,
|
||||
"expected ';' after method prototype")
|
||||
DIAG(err_expected_semi_after_static_assert, ERROR,
|
||||
"expected ';' after static_assert")
|
||||
DIAG(err_expected_semi_for, ERROR,
|
||||
"expected ';' in 'for' statement specifier")
|
||||
DIAG(err_expected_colon_after, ERROR,
|
||||
|
|
|
@ -884,6 +884,15 @@ public:
|
|||
virtual void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, DeclTy *Method) {
|
||||
}
|
||||
|
||||
virtual DeclTy *ActOnStaticAssertDeclaration(SourceLocation LParenLoc,
|
||||
ExprArg AssertExpr,
|
||||
SourceLocation CommaLoc,
|
||||
ExprArg AssertMessageExpr,
|
||||
SourceLocation RParenLoc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//===------------------------- C++ Expressions --------------------------===//
|
||||
|
||||
/// ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const}_cast's.
|
||||
|
|
|
@ -989,6 +989,7 @@ private:
|
|||
DeclTy *ParseUsingDirectiveOrDeclaration(unsigned Context);
|
||||
DeclTy *ParseUsingDirective(unsigned Context, SourceLocation UsingLoc);
|
||||
DeclTy *ParseUsingDeclaration(unsigned Context, SourceLocation UsingLoc);
|
||||
DeclTy *ParseStaticAssertDeclaration();
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// C++ 9: classes [class] and C structs/unions.
|
||||
|
|
|
@ -225,6 +225,7 @@ void Parser::FuzzyParseMicrosoftDeclSpec() {
|
|||
/// [C++] namespace-definition
|
||||
/// [C++] using-directive
|
||||
/// [C++] using-declaration [TODO]
|
||||
// [C++0x] static_assert-declaration
|
||||
/// others... [FIXME]
|
||||
///
|
||||
Parser::DeclTy *Parser::ParseDeclaration(unsigned Context) {
|
||||
|
@ -236,6 +237,8 @@ Parser::DeclTy *Parser::ParseDeclaration(unsigned Context) {
|
|||
return ParseNamespace(Context);
|
||||
case tok::kw_using:
|
||||
return ParseUsingDirectiveOrDeclaration(Context);
|
||||
case tok::kw_static_assert:
|
||||
return ParseStaticAssertDeclaration();
|
||||
default:
|
||||
return ParseSimpleDeclaration(Context);
|
||||
}
|
||||
|
|
|
@ -217,6 +217,55 @@ Parser::DeclTy *Parser::ParseUsingDeclaration(unsigned Context,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/// ParseStaticAssertDeclaration - Parse C++0x static_assert-declaratoion.
|
||||
///
|
||||
/// static_assert-declaration:
|
||||
/// static_assert ( constant-expression , string-literal ) ;
|
||||
///
|
||||
Parser::DeclTy *Parser::ParseStaticAssertDeclaration() {
|
||||
assert(Tok.is(tok::kw_static_assert) && "Not a static_assert declaration");
|
||||
SourceLocation StaticAssertLoc = ConsumeToken();
|
||||
|
||||
if (Tok.isNot(tok::l_paren)) {
|
||||
Diag(Tok, diag::err_expected_lparen);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SourceLocation LParenLoc = ConsumeParen();
|
||||
|
||||
OwningExprResult AssertExpr(ParseConstantExpression());
|
||||
if (AssertExpr.isInvalid()) {
|
||||
SkipUntil(tok::semi);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (Tok.isNot(tok::comma)) {
|
||||
Diag(Tok, diag::err_expected_comma);
|
||||
SkipUntil(tok::semi);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SourceLocation CommaLoc = ConsumeToken();
|
||||
|
||||
if (Tok.isNot(tok::string_literal)) {
|
||||
Diag(Tok, diag::err_expected_string_literal);
|
||||
SkipUntil(tok::semi);
|
||||
return 0;
|
||||
}
|
||||
|
||||
OwningExprResult AssertMessage(ParseStringLiteralExpression());
|
||||
if (AssertMessage.isInvalid())
|
||||
return 0;
|
||||
|
||||
SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc);
|
||||
|
||||
ExpectAndConsume(tok::semi, diag::err_expected_semi_after_static_assert);
|
||||
|
||||
return Actions.ActOnStaticAssertDeclaration(LParenLoc, move(AssertExpr),
|
||||
CommaLoc, move(AssertMessage),
|
||||
RParenLoc);
|
||||
}
|
||||
|
||||
/// ParseClassName - Parse a C++ class-name, which names a class. Note
|
||||
/// that we only check that the result names a type; semantic analysis
|
||||
/// will need to verify that the type names a class. The result is
|
||||
|
@ -568,7 +617,7 @@ AccessSpecifier Parser::getAccessSpecifierIfPresent() const
|
|||
/// function-definition ';'[opt]
|
||||
/// ::[opt] nested-name-specifier template[opt] unqualified-id ';'[TODO]
|
||||
/// using-declaration [TODO]
|
||||
/// [C++0x] static_assert-declaration [TODO]
|
||||
/// [C++0x] static_assert-declaration
|
||||
/// template-declaration [TODO]
|
||||
/// [GNU] '__extension__' member-declaration
|
||||
///
|
||||
|
@ -588,6 +637,10 @@ AccessSpecifier Parser::getAccessSpecifierIfPresent() const
|
|||
/// '=' constant-expression
|
||||
///
|
||||
Parser::DeclTy *Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS) {
|
||||
// static_assert-declaration
|
||||
if (Tok.is(tok::kw_static_assert))
|
||||
return ParseStaticAssertDeclaration();
|
||||
|
||||
// Handle: member-declaration ::= '__extension__' member-declaration
|
||||
if (Tok.is(tok::kw___extension__)) {
|
||||
// __extension__ silences extension warnings in the subexpression.
|
||||
|
|
|
@ -29,7 +29,7 @@ using namespace clang;
|
|||
/// namespace-alias-definition
|
||||
/// using-declaration
|
||||
/// using-directive
|
||||
/// [C++0x] static_assert-declaration [TODO]
|
||||
/// [C++0x] static_assert-declaration
|
||||
///
|
||||
/// asm-definition:
|
||||
/// 'asm' '(' string-literal ')' ';'
|
||||
|
@ -46,9 +46,6 @@ using namespace clang;
|
|||
/// 'using' 'namespace' '::'[opt] nested-name-specifier[opt]
|
||||
/// namespace-name ';'
|
||||
///
|
||||
/// [C++0x] static_assert-declaration: [TODO]
|
||||
/// [C++0x] static_assert '(' constant-expression ',' string-literal ')' ';'
|
||||
///
|
||||
bool Parser::isCXXDeclarationStatement() {
|
||||
switch (Tok.getKind()) {
|
||||
// asm-definition
|
||||
|
@ -59,6 +56,9 @@ bool Parser::isCXXDeclarationStatement() {
|
|||
// using-directive
|
||||
case tok::kw_using:
|
||||
return true;
|
||||
case tok::kw_static_assert:
|
||||
// static_assert-declaration
|
||||
return true;
|
||||
default:
|
||||
// simple-declaration
|
||||
return isCXXSimpleDeclaration();
|
||||
|
|
|
@ -408,6 +408,7 @@ Parser::DeclTy *Parser::ParseExternalDeclaration() {
|
|||
case tok::kw_typedef:
|
||||
case tok::kw_template:
|
||||
case tok::kw_export: // As in 'export template'
|
||||
case tok::kw_static_assert:
|
||||
// A function definition cannot start with a these keywords.
|
||||
return ParseDeclaration(Declarator::FileContext);
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue