* c-exp.y (DOTDOTDOT): New token.
authorTom Tromey <tromey@redhat.com>
Fri, 6 Jul 2012 14:48:48 +0000 (14:48 +0000)
committerTom Tromey <tromey@redhat.com>
Fri, 6 Jul 2012 14:48:48 +0000 (14:48 +0000)
(func_mod, exp): Use parameter_typelist.
(parameter_typelist): New production.
(tokentab3): Add "..." token.
* eval.c (make_params): Handle varargs.
* gdbtypes.c (lookup_function_type_with_arguments): Handle
varargs.
testsuite
* gdb.base/whatis.exp: Add test.

gdb/ChangeLog
gdb/c-exp.y
gdb/eval.c
gdb/gdbtypes.c
gdb/parse.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/whatis.exp

index 650b6f76cc2258f0eaf75942fd155470ff668da8..16e795c8883062834e1a96ee8374c6c687a021f6 100644 (file)
@@ -1,3 +1,13 @@
+2012-07-06  Tom Tromey  <tromey@redhat.com>
+
+       * c-exp.y (DOTDOTDOT): New token.
+       (func_mod, exp): Use parameter_typelist.
+       (parameter_typelist): New production.
+       (tokentab3): Add "..." token.
+       * eval.c (make_params): Handle varargs.
+       * gdbtypes.c (lookup_function_type_with_arguments): Handle
+       varargs.
+
 2012-07-06  Tom Tromey  <tromey@redhat.com>
 
        PR exp/9608:
index 8890f74555f1d4465a7c115b86b25ee1e2fcacc3..14fd53d232b797e7967db3a16de478b5ea5e6760 100644 (file)
@@ -170,7 +170,7 @@ static struct stoken operator_stoken (const char *);
 %type <voidval> exp exp1 type_exp start variable qualified_name lcurly
 %type <lval> rcurly
 %type <tval> type typebase
-%type <tvec> nonempty_typelist func_mod
+%type <tvec> nonempty_typelist func_mod parameter_typelist
 /* %type <bval> block */
 
 /* Fancy type parsing.  */
@@ -254,6 +254,8 @@ static struct stoken operator_stoken (const char *);
 %type <bval> block
 %left COLONCOLON
 
+%token DOTDOTDOT
+
 \f
 %%
 
@@ -440,7 +442,7 @@ arglist     :       arglist ',' exp   %prec ABOVE_COMMA
                        { arglist_len++; }
        ;
 
-exp     :       exp '(' nonempty_typelist ')' const_or_volatile
+exp     :       exp '(' parameter_typelist ')' const_or_volatile
                        { int i;
                          VEC (type_ptr) *type_list = $3;
                          struct type *type_elt;
@@ -1025,7 +1027,7 @@ array_mod:        '[' ']'
 
 func_mod:      '(' ')'
                        { $$ = NULL; }
-       |       '(' nonempty_typelist ')'
+       |       '(' parameter_typelist ')'
                        { $$ = $2; }
        ;
 
@@ -1223,6 +1225,15 @@ typename:        TYPENAME
                }
        ;
 
+parameter_typelist:
+               nonempty_typelist
+       |       nonempty_typelist ',' DOTDOTDOT
+                       {
+                         VEC_safe_push (type_ptr, $1, NULL);
+                         $$ = $1;
+                       }
+       ;
+
 nonempty_typelist
        :       type
                {
@@ -1942,7 +1953,8 @@ static const struct token tokentab3[] =
   {
     {">>=", ASSIGN_MODIFY, BINOP_RSH, 0},
     {"<<=", ASSIGN_MODIFY, BINOP_LSH, 0},
-    {"->*", ARROW_STAR, BINOP_END, 1}
+    {"->*", ARROW_STAR, BINOP_END, 1},
+    {"...", DOTDOTDOT, BINOP_END, 0}
   };
 
 static const struct token tokentab2[] =
index 3d434066767d82142a7d9561dccee043a7541284..13f997f5b127c87650ab9acaa18b22a4340bfc5f 100644 (file)
@@ -769,6 +769,11 @@ make_params (int num_types, struct type **param_types)
   TYPE_CODE (type) = TYPE_CODE_METHOD;
   TYPE_VPTR_FIELDNO (type) = -1;
   TYPE_CHAIN (type) = type;
+  if (num_types > 0 && param_types[num_types - 1] == NULL)
+    {
+      --num_types;
+      TYPE_VARARGS (type) = 1;
+    }
   TYPE_NFIELDS (type) = num_types;
   TYPE_FIELDS (type) = (struct field *)
     TYPE_ZALLOC (type, sizeof (struct field) * num_types);
index bcc2edf70e6fac62153800ab7608a2ff76121ffa..cb25e71fc7c5c5d02727290ea4196b70573176b2 100644 (file)
@@ -463,7 +463,8 @@ lookup_function_type (struct type *type)
 }
 
 /* Given a type TYPE and argument types, return the appropriate
-   function type.  */
+   function type.  If the final type in PARAM_TYPES is NULL, make a
+   varargs function.  */
 
 struct type *
 lookup_function_type_with_arguments (struct type *type,
@@ -473,6 +474,12 @@ lookup_function_type_with_arguments (struct type *type,
   struct type *fn = make_function_type (type, (struct type **) 0);
   int i;
 
+  if (nparams > 0 && param_types[nparams - 1] == NULL)
+    {
+      --nparams;
+      TYPE_VARARGS (fn) = 1;
+    }
+
   TYPE_NFIELDS (fn) = nparams;
   TYPE_FIELDS (fn) = TYPE_ZALLOC (fn, nparams * sizeof (struct field));
   for (i = 0; i < nparams; ++i)
index 897002d91154aa34b0cf04161a6e36c72701c083..529c517c25e612486575390ba4da5b113095f214 100644 (file)
@@ -1555,7 +1555,8 @@ type_stack_cleanup (void *arg)
 }
 
 /* Push a function type with arguments onto the global type stack.
-   LIST holds the argument types.  */
+   LIST holds the argument types.  If the final item in LIST is NULL,
+   then the function will be varargs.  */
 
 void
 push_typelist (VEC (type_ptr) *list)
index 6a297e2dad779503d7876d01808c4e6cd64f23f6..fdc921d709630120111357b9f8078dc88b15f962 100644 (file)
@@ -1,3 +1,7 @@
+2012-07-06  Tom Tromey  <tromey@redhat.com>
+
+       * gdb.base/whatis.exp: Add test.
+
 2012-07-06  Tom Tromey  <tromey@redhat.com>
 
        * gdb.base/whatis.exp: Add regression test.
index 336901d78e292ec89a5635471825be016342da07..9365485367bdc9fa8e33e91c757bb26204091fc1 100644 (file)
@@ -495,3 +495,7 @@ gdb_test "whatis char (*(*)())\[23\]" \
 gdb_test "whatis int (*)(int, int)" \
     "type = int \\(\\*\\)\\(int, int\\)" \
     "whatis applied to pointer to function taking int,int and returning int"
+
+gdb_test "whatis int (*)(const int *, ...)" \
+    "type = int \\(\\*\\)\\(const int \\*, \\.\\.\\.\\)" \
+    "whatis applied to pointer to function taking const int ptr and varargs and returning int"
This page took 0.119766 seconds and 4 git commands to generate.