aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/cplusplus/ASTMatch0.cpp
diff options
context:
space:
mode:
authorWang Hoi <wanghoi@126.com>2014-05-05 22:56:15 +0800
committerNikolai Kosjar <nikolai.kosjar@digia.com>2014-06-17 16:23:23 +0200
commitc56b999ffff249d4cb7dc7e8026a3297b63ff56d (patch)
tree007d1f5208cd7e03fdc2eceb4cefe3dd4a12ded8 /src/libs/3rdparty/cplusplus/ASTMatch0.cpp
parentd70485180a676c3d97108bb87ec1c32223ee0f2b (diff)
C: Parser: Support parsing of c99 designated initializers
In case: int a[6] = { [4] = 29, [2] = 15 }; struct point { int x, y; }; struct point p = { .y = 3, .x = 2 }; Grammar change when c99 language feature is enabled: old grammar: braced-init-list :: '{' initializer-list '}' new grammar: braced-init-list :: '{' designated-initializer-list '}' designated-initializer-list :: designated-initializer (',' designated-initializer )* designated-initializer :: designator* initializer-clause designator :: '.' identifier | '[' constant-expression ']' Task-number: QTCREATORBUG-1902 Change-Id: Ib99d6f553f8d0f50ba3eff86f3a2e86d73372426 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
Diffstat (limited to 'src/libs/3rdparty/cplusplus/ASTMatch0.cpp')
-rw-r--r--src/libs/3rdparty/cplusplus/ASTMatch0.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libs/3rdparty/cplusplus/ASTMatch0.cpp b/src/libs/3rdparty/cplusplus/ASTMatch0.cpp
index 69e3daf615..efeb2c57e0 100644
--- a/src/libs/3rdparty/cplusplus/ASTMatch0.cpp
+++ b/src/libs/3rdparty/cplusplus/ASTMatch0.cpp
@@ -1192,3 +1192,19 @@ bool BracedInitializerAST::match0(AST *pattern, ASTMatcher *matcher)
return false;
}
+bool DesignatorAST::match0(AST *pattern, ASTMatcher *matcher)
+{
+ if (DesignatorAST *_other = pattern->asDesignator())
+ return matcher->match(this, _other);
+
+ return false;
+}
+
+bool DesignatedInitializerAST::match0(AST *pattern, ASTMatcher *matcher)
+{
+ if (DesignatedInitializerAST *_other = pattern->asDesignatedInitializer())
+ return matcher->match(this, _other);
+
+ return false;
+}
+