added GNU complex keywords
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Tue, 18 Mar 2008 13:42:29 +0000 (13:42 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Tue, 18 Mar 2008 13:42:29 +0000 (13:42 +0000)
implemented MS __noop

[r18977]

parser.c
parsetest/MS/noop.c [new file with mode: 0644]
tokens.inc

index eff7f25..8478953 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -4815,6 +4815,44 @@ end_error:
        return create_invalid_expression();
 }
 
+/**
+ * Parse a microsoft __noop expression.
+ */
+static expression_t *parse_noop_expression(void) {
+       source_position_t source_position = HERE;
+       eat(T___noop);
+
+       if (token.type == '(') {
+               /* parse arguments */
+               eat('(');
+               add_anchor_token(')');
+               add_anchor_token(',');
+
+               if(token.type != ')') {
+                       while(true) {
+                               (void)parse_assignment_expression();
+                               if(token.type != ',')
+                                       break;
+                               next_token();
+                       }
+               }
+       }
+       rem_anchor_token(',');
+       rem_anchor_token(')');
+       expect(')');
+
+       /* the result is a (int)0 */
+       expression_t *cnst         = allocate_expression_zero(EXPR_CONST);
+       cnst->base.source_position = source_position;
+       cnst->base.type            = type_int;
+       cnst->conste.v.int_value   = 0;
+
+       return cnst;
+
+end_error:
+       return create_invalid_expression();
+}
+
 /**
  * Parses a primary expression.
  */
@@ -4853,6 +4891,7 @@ static expression_t *parse_primary_expression(void)
                case T__assume:                  return parse_assume();
 
                case '(':                        return parse_brace_expression();
+               case T___noop:                   return parse_noop_expression();
        }
 
        errorf(HERE, "unexpected token %K, expected an expression", &token);
diff --git a/parsetest/MS/noop.c b/parsetest/MS/noop.c
new file mode 100644 (file)
index 0000000..d3ed78c
--- /dev/null
@@ -0,0 +1,3 @@
+int test(int a, int b) {
+       return __noop(a+b, a, b);
+}
index 6c0e2cf..d5144e0 100644 (file)
@@ -47,8 +47,6 @@ S(_ALL, void)
 S(_ALL, while)
 
 S(_C99|_GNUC, _Bool)
-S(_C99|_GNUC, _Complex)
-S(_C99|_GNUC, _Imaginary)
 S(_GNUC, __thread)
 S(_GNUC, __extension__)
 S(_GNUC, __builtin_classify_type)
@@ -76,6 +74,10 @@ S(_MS, __FUNCSIG__)
 S(_MS, __FUNCDNAME__)
 #undef S
 
+T(_C99|_GNUC, _Complex,       "_Complex",)
+T(_GNUC,      __complex__,    "__complex__",            = T__Complex)
+T(_GNUC,      __complex,      "__complex",              = T__Complex)
+T(_C99|_GNUC, _Imaginary,     "_Imaginary",)
 T(_GNUC,      __real__,       "__real__",)
 T(_GNUC,      __real,         "__real",                 = T___real__)
 T(_GNUC,      __imag__,       "__imag__",)
@@ -135,6 +137,7 @@ T(_MS,      _declspec,        "_declspec",)
 T(_MS,      __declspec,       "__declspec",              = T__declspec)
 T(_MS,      _based,            "_based",)
 T(_MS,      __based,          "__based",                 = T__based)
+T(_MS,      __noop,           "__noop",)
 
 T(_MS,      __ptr32,          "__ptr32",)
 T(_MS,      __ptr64,          "__ptr64",)