Commit e1b793e7 by Basile Starynkevitch Committed by Basile Starynkevitch

gengtype.c: Reindented.


2010-09-24  Basile Starynkevitch  <basile@starynkevitch.net>

	* gcc/gengtype.c: Reindented.

	* gcc/gengtype.h: Reindented.

	* gcc/gengtype-parse.c: Reindented.

From-SVN: r164604
parent 1d0804d4
2010-09-24 Basile Starynkevitch <basile@starynkevitch.net>
* gengtype.c: Reindented.
* gengtype.h: Reindented.
* gengtype-parse.c: Reindented.
2010-09-24 Jan Hubicka <jh@suse.cz> 2010-09-24 Jan Hubicka <jh@suse.cz>
PR tree-optimization/45738 PR tree-optimization/45738
/* Process source files and output type information. /* Process source files and output type information.
Copyright (C) 2006, 2007 Free Software Foundation, Inc. Copyright (C) 2006, 2007 Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later Software Foundation; either version 3, or (at your option) any later
version. version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details. for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */ <http://www.gnu.org/licenses/>. */
#include "bconfig.h" #include "bconfig.h"
#include "system.h" #include "system.h"
...@@ -199,7 +199,7 @@ string_seq (void) ...@@ -199,7 +199,7 @@ string_seq (void)
l1 = strlen (s1); l1 = strlen (s1);
l2 = strlen (s2); l2 = strlen (s2);
buf = XRESIZEVEC (char, CONST_CAST(char *, s1), l1 + l2 + 1); buf = XRESIZEVEC (char, CONST_CAST (char *, s1), l1 + l2 + 1);
memcpy (buf + l1, s2, l2 + 1); memcpy (buf + l1, s2, l2 + 1);
XDELETE (CONST_CAST (char *, s2)); XDELETE (CONST_CAST (char *, s2));
s1 = buf; s1 = buf;
...@@ -222,7 +222,7 @@ typedef_name (void) ...@@ -222,7 +222,7 @@ typedef_name (void)
require (','); require (',');
c2 = require (ID); c2 = require (ID);
require (')'); require (')');
r = concat ("VEC_", c1, "_", c2, (char *)0); r = concat ("VEC_", c1, "_", c2, (char *) 0);
free (CONST_CAST (char *, c1)); free (CONST_CAST (char *, c1));
free (CONST_CAST (char *, c2)); free (CONST_CAST (char *, c2));
return r; return r;
...@@ -239,10 +239,18 @@ consume_balanced (int opener, int closer) ...@@ -239,10 +239,18 @@ consume_balanced (int opener, int closer)
for (;;) for (;;)
switch (token ()) switch (token ())
{ {
default: advance (); break; default:
case '(': consume_balanced ('(',')'); break; advance ();
case '[': consume_balanced ('[',']'); break; break;
case '{': consume_balanced ('{','}'); break; case '(':
consume_balanced ('(', ')');
break;
case '[':
consume_balanced ('[', ']');
break;
case '{':
consume_balanced ('{', '}');
break;
case '}': case '}':
case ']': case ']':
...@@ -272,12 +280,22 @@ consume_until_semi (bool immediate) ...@@ -272,12 +280,22 @@ consume_until_semi (bool immediate)
for (;;) for (;;)
switch (token ()) switch (token ())
{ {
case ';': advance (); return; case ';':
default: advance (); break; advance ();
return;
default:
advance ();
break;
case '(': consume_balanced ('(',')'); break; case '(':
case '[': consume_balanced ('[',']'); break; consume_balanced ('(', ')');
case '{': consume_balanced ('{','}'); break; break;
case '[':
consume_balanced ('[', ']');
break;
case '{':
consume_balanced ('{', '}');
break;
case '}': case '}':
case ']': case ']':
...@@ -304,13 +322,25 @@ consume_until_comma_or_semi (bool immediate) ...@@ -304,13 +322,25 @@ consume_until_comma_or_semi (bool immediate)
for (;;) for (;;)
switch (token ()) switch (token ())
{ {
case ',': advance (); return true; case ',':
case ';': advance (); return false; advance ();
default: advance (); break; return true;
case ';':
advance ();
return false;
default:
advance ();
break;
case '(': consume_balanced ('(',')'); break; case '(':
case '[': consume_balanced ('[',']'); break; consume_balanced ('(', ')');
case '{': consume_balanced ('{','}'); break; break;
case '[':
consume_balanced ('[', ']');
break;
case '{':
consume_balanced ('{', '}');
break;
case '}': case '}':
case ']': case ']':
...@@ -405,7 +435,7 @@ nestedptr_optvalue (options_p prev) ...@@ -405,7 +435,7 @@ nestedptr_optvalue (options_p prev)
| PTR_ALIAS type_optvalue | PTR_ALIAS type_optvalue
| PARAM_IS type_optvalue | PARAM_IS type_optvalue
| NESTED_PTR nestedptr_optvalue | NESTED_PTR nestedptr_optvalue
*/ */
static options_p static options_p
option (options_p prev) option (options_p prev)
{ {
...@@ -426,8 +456,7 @@ option (options_p prev) ...@@ -426,8 +456,7 @@ option (options_p prev)
return nestedptr_optvalue (prev); return nestedptr_optvalue (prev);
default: default:
parse_error ("expected an option keyword, have %s", parse_error ("expected an option keyword, have %s", print_cur_token ());
print_cur_token ());
advance (); advance ();
return create_option (prev, "", ""); return create_option (prev, "", "");
} }
...@@ -615,7 +644,7 @@ declarator (type_p ty, const char **namep, options_p *optsp) ...@@ -615,7 +644,7 @@ declarator (type_p ty, const char **namep, options_p *optsp)
Knows that such declarations must end with a close brace (or, Knows that such declarations must end with a close brace (or,
erroneously, at EOF). erroneously, at EOF).
*/ */
static pair_p static pair_p
struct_field_seq (void) struct_field_seq (void)
{ {
...@@ -674,7 +703,7 @@ struct_field_seq (void) ...@@ -674,7 +703,7 @@ struct_field_seq (void)
Returns a partial type; under some conditions (notably Returns a partial type; under some conditions (notably
"struct foo GTY((...)) thing;") it may write an options "struct foo GTY((...)) thing;") it may write an options
structure to *OPTSP. structure to *OPTSP.
*/ */
static type_p static type_p
type (options_p *optsp, bool nested) type (options_p *optsp, bool nested)
{ {
...@@ -698,7 +727,8 @@ type (options_p *optsp, bool nested) ...@@ -698,7 +727,8 @@ type (options_p *optsp, bool nested)
/* GTY annotations follow attribute syntax /* GTY annotations follow attribute syntax
GTY_BEFORE_ID is for union/struct declarations GTY_BEFORE_ID is for union/struct declarations
GTY_AFTER_ID is for variable declarations. */ GTY_AFTER_ID is for variable declarations. */
enum { enum
{
NO_GTY, NO_GTY,
GTY_BEFORE_ID, GTY_BEFORE_ID,
GTY_AFTER_ID GTY_AFTER_ID
...@@ -760,7 +790,7 @@ type (options_p *optsp, bool nested) ...@@ -760,7 +790,7 @@ type (options_p *optsp, bool nested)
s = xasprintf ("anonymous:%s:%d", lexer_line.file, lexer_line.line); s = xasprintf ("anonymous:%s:%d", lexer_line.file, lexer_line.line);
if (token () == '{') if (token () == '{')
consume_balanced ('{','}'); consume_balanced ('{', '}');
return create_scalar_type (s); return create_scalar_type (s);
default: default:
...@@ -864,7 +894,7 @@ extern_or_static (void) ...@@ -864,7 +894,7 @@ extern_or_static (void)
static void static void
def_vec (void) def_vec (void)
{ {
bool is_scalar = (token() == DEFVEC_I); bool is_scalar = (token () == DEFVEC_I);
const char *type; const char *type;
require2 (DEFVEC_OP, DEFVEC_I); require2 (DEFVEC_OP, DEFVEC_I);
......
/* Process source files and output type information. /* Process source files and output type information.
Copyright (C) 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc. Copyright (C) 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later Software Foundation; either version 3, or (at your option) any later
version. version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details. for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */ <http://www.gnu.org/licenses/>. */
#ifndef GCC_GENGTYPE_H #ifndef GCC_GENGTYPE_H
#define GCC_GENGTYPE_H #define GCC_GENGTYPE_H
/* A file position, mostly for error messages. /* A file position, mostly for error messages.
The FILE element may be compared using pointer equality. */ The FILE element may be compared using pointer equality. */
struct fileloc { struct fileloc
{
const char *file; const char *file;
int line; int line;
}; };
...@@ -39,10 +40,12 @@ extern struct fileloc lexer_line; ...@@ -39,10 +40,12 @@ extern struct fileloc lexer_line;
/* Print an error message. */ /* Print an error message. */
extern void error_at_line extern void error_at_line
(const struct fileloc *pos, const char *msg, ...) ATTRIBUTE_PRINTF_2; (const struct fileloc *pos, const char *msg, ...) ATTRIBUTE_PRINTF_2;
/* Like asprintf, but calls fatal() on out of memory. */ /* Like asprintf, but calls fatal() on out of memory. */
extern char *xasprintf(const char *, ...) ATTRIBUTE_PRINTF_1; extern char *
xasprintf (const char *, ...)
ATTRIBUTE_PRINTF_1;
/* Constructor routines for types. */ /* Constructor routines for types. */
extern void do_typedef (const char *s, type_p t, struct fileloc *pos); extern void do_typedef (const char *s, type_p t, struct fileloc *pos);
...@@ -55,11 +58,14 @@ extern type_p find_structure (const char *s, int isunion); ...@@ -55,11 +58,14 @@ extern type_p find_structure (const char *s, int isunion);
extern type_p create_scalar_type (const char *name); extern type_p create_scalar_type (const char *name);
extern type_p create_pointer (type_p t); extern type_p create_pointer (type_p t);
extern type_p create_array (type_p t, const char *len); extern type_p create_array (type_p t, const char *len);
extern options_p create_option (options_p, const char *name, const void *info); extern options_p create_option (options_p, const char *name,
const void *info);
extern options_p create_nested_ptr_option (options_p, type_p t, extern options_p create_nested_ptr_option (options_p, type_p t,
const char *from, const char *to); const char *from,
extern pair_p create_field_at (pair_p next, type_p type, const char *name, const char *to);
options_p opt, struct fileloc *pos); extern pair_p create_field_at (pair_p next, type_p type,
const char *name, options_p opt,
struct fileloc *pos);
extern pair_p nreverse_pairs (pair_p list); extern pair_p nreverse_pairs (pair_p list);
extern type_p adjust_field_type (type_p, options_p); extern type_p adjust_field_type (type_p, options_p);
extern void note_variable (const char *s, type_p t, options_p o, extern void note_variable (const char *s, type_p t, options_p o,
...@@ -77,7 +83,8 @@ extern void parse_file (const char *name); ...@@ -77,7 +83,8 @@ extern void parse_file (const char *name);
extern bool hit_error; extern bool hit_error;
/* Token codes. */ /* Token codes. */
enum { enum
{
EOF_TOKEN = 0, EOF_TOKEN = 0,
/* Per standard convention, codes in the range (0, UCHAR_MAX] /* Per standard convention, codes in the range (0, UCHAR_MAX]
...@@ -109,5 +116,5 @@ enum { ...@@ -109,5 +116,5 @@ enum {
/* print_token assumes that any token >= FIRST_TOKEN_WITH_VALUE may have /* print_token assumes that any token >= FIRST_TOKEN_WITH_VALUE may have
a meaningful value to be printed. */ a meaningful value to be printed. */
FIRST_TOKEN_WITH_VALUE = PARAM_IS FIRST_TOKEN_WITH_VALUE = PARAM_IS
}; };
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment