added __FUNCSIG__ and __FUNCDNAME__
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Tue, 18 Mar 2008 01:44:21 +0000 (01:44 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Tue, 18 Mar 2008 01:44:21 +0000 (01:44 +0000)
[r18969]

parser.c
tokens.inc

index 95810ad..037084f 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -297,6 +297,8 @@ static size_t get_expression_struct_size(expression_kind_t kind)
                [EXPR_CLASSIFY_TYPE]           = sizeof(classify_type_expression_t),
                [EXPR_FUNCTION]                = sizeof(string_literal_expression_t),
                [EXPR_PRETTY_FUNCTION]         = sizeof(string_literal_expression_t),
+               [EXPR_FUNCSIG]                 = sizeof(string_literal_expression_t),
+               [EXPR_FUNCDNAME]               = sizeof(string_literal_expression_t),
                [EXPR_BUILTIN_SYMBOL]          = sizeof(builtin_symbol_expression_t),
                [EXPR_BUILTIN_CONSTANT_P]      = sizeof(builtin_constant_expression_t),
                [EXPR_BUILTIN_PREFETCH]        = sizeof(builtin_prefetch_expression_t),
@@ -4456,7 +4458,6 @@ static expression_t *parse_function_keyword(void)
 static expression_t *parse_pretty_function_keyword(void)
 {
        eat(T___PRETTY_FUNCTION__);
-       /* TODO */
 
        if (current_function == NULL) {
                errorf(HERE, "'__PRETTY_FUNCTION__' used outside of a function");
@@ -4468,6 +4469,34 @@ static expression_t *parse_pretty_function_keyword(void)
        return expression;
 }
 
+static expression_t *parse_funcsig_keyword(void)
+{
+       next_token();
+
+       if (current_function == NULL) {
+               errorf(HERE, "'__FUNCSIG__' used outside of a function");
+       }
+
+       expression_t *expression = allocate_expression_zero(EXPR_FUNCSIG);
+       expression->base.type    = type_char_ptr;
+
+       return expression;
+}
+
+static expression_t *parse_funcdname_keyword(void)
+{
+       next_token();
+
+       if (current_function == NULL) {
+               errorf(HERE, "'__FUNCDNAME__' used outside of a function");
+       }
+
+       expression_t *expression = allocate_expression_zero(EXPR_FUNCDNAME);
+       expression->base.type    = type_char_ptr;
+
+       return expression;
+}
+
 static designator_t *parse_designator(void)
 {
        designator_t *result    = allocate_ast_zero(sizeof(result[0]));
@@ -4799,6 +4828,8 @@ static expression_t *parse_primary_expression(void)
                case T___FUNCTION__:
                case T___func__:                 return parse_function_keyword();
                case T___PRETTY_FUNCTION__:      return parse_pretty_function_keyword();
+               case T___FUNCSIG__:              return parse_funcsig_keyword();
+               case T___FUNCDNAME__:            return parse_funcdname_keyword();
                case T___builtin_offsetof:       return parse_offsetof();
                case T___builtin_va_start:       return parse_va_start();
                case T___builtin_va_arg:         return parse_va_arg();
index 8f24e5d..6c0e2cf 100644 (file)
@@ -72,6 +72,8 @@ S(_GNUC, __builtin_prefetch)
 S(_GNUC, __PRETTY_FUNCTION__)
 S(_ALL, __FUNCTION__)
 S(_C99, __func__)
+S(_MS, __FUNCSIG__)
+S(_MS, __FUNCDNAME__)
 #undef S
 
 T(_GNUC,      __real__,       "__real__",)