C++: Recognize C++11 constexpr

Change-Id: Iac8ba58404284f0d90fd5a3640eb9ccd7e98058d
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
Leandro Melo
2011-11-18 11:40:23 +01:00
parent fbd47e25ee
commit 9f73c5848b
3 changed files with 25 additions and 1 deletions

View File

@@ -945,7 +945,7 @@ static inline int classify8(const char *s, bool q, bool x) {
return T_IDENTIFIER; return T_IDENTIFIER;
} }
static inline int classify9(const char *s, bool q, bool) { static inline int classify9(const char *s, bool q, bool x) {
if (s[0] == '_') { if (s[0] == '_') {
if (s[1] == '_') { if (s[1] == '_') {
if (s[2] == 'c') { if (s[2] == 'c') {
@@ -965,6 +965,25 @@ static inline int classify9(const char *s, bool q, bool) {
} }
} }
} }
else if (x && s[0] == 'c') {
if (s[1] == 'o') {
if (s[2] == 'n') {
if (s[3] == 's') {
if (s[4] == 't') {
if (s[5] == 'e') {
if (s[6] == 'x') {
if (s[7] == 'p') {
if (s[8] == 'r') {
return T_CONSTEXPR;
}
}
}
}
}
}
}
}
}
else if (s[0] == 'n') { else if (s[0] == 'n') {
if (s[1] == 'a') { if (s[1] == 'a') {
if (s[2] == 'm') { if (s[2] == 'm') {

View File

@@ -3413,6 +3413,10 @@ bool Parser::lookAtStorageClassSpecifier() const
case T_MUTABLE: case T_MUTABLE:
case T_TYPEDEF: case T_TYPEDEF:
return true; return true;
case T_CONSTEXPR:
if (_cxx0xEnabled)
return true;
// fall-through
default: default:
return false; return false;
} }

View File

@@ -111,6 +111,7 @@ enum Kind {
T_CLASS, T_CLASS,
T_CONST, T_CONST,
T_CONST_CAST, T_CONST_CAST,
T_CONSTEXPR,
T_CONTINUE, T_CONTINUE,
T_DEFAULT, T_DEFAULT,
T_DELETE, T_DELETE,