1992-02-13 23:21:26 +01:00
|
|
|
|
/* Process declarations and variables for C compiler.
|
2001-01-02 08:00:49 +01:00
|
|
|
|
Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
2001, 2002, 2003 Free Software Foundation, Inc.
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
Makefile.in, [...]: replace "GNU CC" with "GCC".
* Makefile.in, alias.c, basic-block.h, bb-reorder.c, bitmap.c,
bitmap.h, builtin-types.def, builtins.c, builtins.def,
c-aux-info.c, c-common.c, c-common.def, c-common.h,
c-convert.c, c-decl.c, c-dump.c, c-dump.h, c-errors.c,
c-format.c, c-lang.c, c-lex.c, c-lex.h, c-parse.in,
c-pragma.c, c-pragma.h, c-semantics.c, c-tree.h, c-typeck.c,
caller-save.c, calls.c, collect2.c, collect2.h, combine.c,
conditions.h, config.gcc, configure.frag, configure.in,
conflict.c, convert.c, convert.h, cppspec.c, crtstuff.c,
cse.c, cselib.c, cselib.h, dbxout.c, dbxout.h, defaults.h,
dependence.c, df.c, df.h, diagnostic.c, diagnostic.h,
doloop.c, dominance.c, dwarf.h, dwarf2.h, dwarf2asm.c,
dwarf2asm.h, dwarf2out.c, dwarf2out.h, dwarfout.c,
emit-rtl.c, errors.c, errors.h, except.c, except.h,
exgettext, explow.c, expmed.c, expr.c, expr.h, final.c,
fixproto, flags.h, flow.c, fold-const.c, fp-test.c,
function.c, function.h, gbl-ctors.h, gcc.c, gcc.h, gcc.hlp,
gccspec.c, gcov-io.h, gcse.c, genattr.c, genattrtab.c,
gencheck.c, gencodes.c, genconfig.c, genemit.c,
genextract.c, genflags.c, gengenrtl.c, genmultilib,
genopinit.c, genoutput.c, genpeep.c, genrecog.c,
gensupport.c, gensupport.h, ggc-callbacks.c, ggc-common.c,
ggc-none.c, ggc-page.c, ggc-simple.c, ggc.h, global.c,
graph.c, graph.h, gthr-aix.h, gthr-dce.h, gthr-posix.h,
gthr-rtems.h, gthr-single.h, gthr-solaris.h, gthr-vxworks.h,
gthr-win32.h, gthr.h, haifa-sched.c, halfpic.c, halfpic.h,
hard-reg-set.h, hwint.h, ifcvt.c, input.h, insn-addr.h,
integrate.c, integrate.h, jump.c, lcm.c, libgcc2.c,
libgcc2.h, lists.c, local-alloc.c, loop.c, loop.h,
machmode.def, machmode.h, main.c, mbchar.c, mbchar.h,
mips-tdump.c, mips-tfile.c, mklibgcc.in, mkmap-flat.awk,
mkmap-symver.awk, optabs.c, output.h, params.c, params.def,
params.h, predict.c, predict.def, predict.h, prefix.c,
prefix.h, print-rtl.c, print-tree.c, profile.c, protoize.c,
read-rtl.c, real.c, real.h, recog.c, recog.h, reg-stack.c,
regclass.c, regmove.c, regrename.c, regs.h, reload.c,
reload.h, reload1.c, reorg.c, resource.c, resource.h, rtl.c,
rtl.def, rtl.h, rtlanal.c, sbitmap.c, sbitmap.h,
sched-deps.c, sched-ebb.c, sched-int.h, sched-rgn.c,
sched-vis.c, sdbout.c, sdbout.h, sibcall.c, simplify-rtx.c,
ssa-ccp.c, ssa-dce.c, ssa.c, ssa.h, stmt.c, stor-layout.c,
stringpool.c, system.h, timevar.c, timevar.def, timevar.h,
tlink.c, toplev.c, toplev.h, tree.c, tree.def, tree.h,
tsystem.h, unroll.c, unwind-dw2-fde.c, unwind-dw2-fde.h,
unwind-dw2.c, unwind-pe.h, unwind-sjlj.c, unwind.h,
unwind.inc, varasm.c, varray.c, varray.h, xcoffout.c,
xcoffout.h: replace "GNU CC" with "GCC".
From-SVN: r45105
2001-08-22 16:35:51 +02:00
|
|
|
|
This file is part of GCC.
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
Makefile.in, [...]: replace "GNU CC" with "GCC".
* Makefile.in, alias.c, basic-block.h, bb-reorder.c, bitmap.c,
bitmap.h, builtin-types.def, builtins.c, builtins.def,
c-aux-info.c, c-common.c, c-common.def, c-common.h,
c-convert.c, c-decl.c, c-dump.c, c-dump.h, c-errors.c,
c-format.c, c-lang.c, c-lex.c, c-lex.h, c-parse.in,
c-pragma.c, c-pragma.h, c-semantics.c, c-tree.h, c-typeck.c,
caller-save.c, calls.c, collect2.c, collect2.h, combine.c,
conditions.h, config.gcc, configure.frag, configure.in,
conflict.c, convert.c, convert.h, cppspec.c, crtstuff.c,
cse.c, cselib.c, cselib.h, dbxout.c, dbxout.h, defaults.h,
dependence.c, df.c, df.h, diagnostic.c, diagnostic.h,
doloop.c, dominance.c, dwarf.h, dwarf2.h, dwarf2asm.c,
dwarf2asm.h, dwarf2out.c, dwarf2out.h, dwarfout.c,
emit-rtl.c, errors.c, errors.h, except.c, except.h,
exgettext, explow.c, expmed.c, expr.c, expr.h, final.c,
fixproto, flags.h, flow.c, fold-const.c, fp-test.c,
function.c, function.h, gbl-ctors.h, gcc.c, gcc.h, gcc.hlp,
gccspec.c, gcov-io.h, gcse.c, genattr.c, genattrtab.c,
gencheck.c, gencodes.c, genconfig.c, genemit.c,
genextract.c, genflags.c, gengenrtl.c, genmultilib,
genopinit.c, genoutput.c, genpeep.c, genrecog.c,
gensupport.c, gensupport.h, ggc-callbacks.c, ggc-common.c,
ggc-none.c, ggc-page.c, ggc-simple.c, ggc.h, global.c,
graph.c, graph.h, gthr-aix.h, gthr-dce.h, gthr-posix.h,
gthr-rtems.h, gthr-single.h, gthr-solaris.h, gthr-vxworks.h,
gthr-win32.h, gthr.h, haifa-sched.c, halfpic.c, halfpic.h,
hard-reg-set.h, hwint.h, ifcvt.c, input.h, insn-addr.h,
integrate.c, integrate.h, jump.c, lcm.c, libgcc2.c,
libgcc2.h, lists.c, local-alloc.c, loop.c, loop.h,
machmode.def, machmode.h, main.c, mbchar.c, mbchar.h,
mips-tdump.c, mips-tfile.c, mklibgcc.in, mkmap-flat.awk,
mkmap-symver.awk, optabs.c, output.h, params.c, params.def,
params.h, predict.c, predict.def, predict.h, prefix.c,
prefix.h, print-rtl.c, print-tree.c, profile.c, protoize.c,
read-rtl.c, real.c, real.h, recog.c, recog.h, reg-stack.c,
regclass.c, regmove.c, regrename.c, regs.h, reload.c,
reload.h, reload1.c, reorg.c, resource.c, resource.h, rtl.c,
rtl.def, rtl.h, rtlanal.c, sbitmap.c, sbitmap.h,
sched-deps.c, sched-ebb.c, sched-int.h, sched-rgn.c,
sched-vis.c, sdbout.c, sdbout.h, sibcall.c, simplify-rtx.c,
ssa-ccp.c, ssa-dce.c, ssa.c, ssa.h, stmt.c, stor-layout.c,
stringpool.c, system.h, timevar.c, timevar.def, timevar.h,
tlink.c, toplev.c, toplev.h, tree.c, tree.def, tree.h,
tsystem.h, unroll.c, unwind-dw2-fde.c, unwind-dw2-fde.h,
unwind-dw2.c, unwind-pe.h, unwind-sjlj.c, unwind.h,
unwind.inc, varasm.c, varray.c, varray.h, xcoffout.c,
xcoffout.h: replace "GNU CC" with "GCC".
From-SVN: r45105
2001-08-22 16:35:51 +02:00
|
|
|
|
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
|
|
|
|
|
Software Foundation; either version 2, or (at your option) any later
|
|
|
|
|
version.
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
Makefile.in, [...]: replace "GNU CC" with "GCC".
* Makefile.in, alias.c, basic-block.h, bb-reorder.c, bitmap.c,
bitmap.h, builtin-types.def, builtins.c, builtins.def,
c-aux-info.c, c-common.c, c-common.def, c-common.h,
c-convert.c, c-decl.c, c-dump.c, c-dump.h, c-errors.c,
c-format.c, c-lang.c, c-lex.c, c-lex.h, c-parse.in,
c-pragma.c, c-pragma.h, c-semantics.c, c-tree.h, c-typeck.c,
caller-save.c, calls.c, collect2.c, collect2.h, combine.c,
conditions.h, config.gcc, configure.frag, configure.in,
conflict.c, convert.c, convert.h, cppspec.c, crtstuff.c,
cse.c, cselib.c, cselib.h, dbxout.c, dbxout.h, defaults.h,
dependence.c, df.c, df.h, diagnostic.c, diagnostic.h,
doloop.c, dominance.c, dwarf.h, dwarf2.h, dwarf2asm.c,
dwarf2asm.h, dwarf2out.c, dwarf2out.h, dwarfout.c,
emit-rtl.c, errors.c, errors.h, except.c, except.h,
exgettext, explow.c, expmed.c, expr.c, expr.h, final.c,
fixproto, flags.h, flow.c, fold-const.c, fp-test.c,
function.c, function.h, gbl-ctors.h, gcc.c, gcc.h, gcc.hlp,
gccspec.c, gcov-io.h, gcse.c, genattr.c, genattrtab.c,
gencheck.c, gencodes.c, genconfig.c, genemit.c,
genextract.c, genflags.c, gengenrtl.c, genmultilib,
genopinit.c, genoutput.c, genpeep.c, genrecog.c,
gensupport.c, gensupport.h, ggc-callbacks.c, ggc-common.c,
ggc-none.c, ggc-page.c, ggc-simple.c, ggc.h, global.c,
graph.c, graph.h, gthr-aix.h, gthr-dce.h, gthr-posix.h,
gthr-rtems.h, gthr-single.h, gthr-solaris.h, gthr-vxworks.h,
gthr-win32.h, gthr.h, haifa-sched.c, halfpic.c, halfpic.h,
hard-reg-set.h, hwint.h, ifcvt.c, input.h, insn-addr.h,
integrate.c, integrate.h, jump.c, lcm.c, libgcc2.c,
libgcc2.h, lists.c, local-alloc.c, loop.c, loop.h,
machmode.def, machmode.h, main.c, mbchar.c, mbchar.h,
mips-tdump.c, mips-tfile.c, mklibgcc.in, mkmap-flat.awk,
mkmap-symver.awk, optabs.c, output.h, params.c, params.def,
params.h, predict.c, predict.def, predict.h, prefix.c,
prefix.h, print-rtl.c, print-tree.c, profile.c, protoize.c,
read-rtl.c, real.c, real.h, recog.c, recog.h, reg-stack.c,
regclass.c, regmove.c, regrename.c, regs.h, reload.c,
reload.h, reload1.c, reorg.c, resource.c, resource.h, rtl.c,
rtl.def, rtl.h, rtlanal.c, sbitmap.c, sbitmap.h,
sched-deps.c, sched-ebb.c, sched-int.h, sched-rgn.c,
sched-vis.c, sdbout.c, sdbout.h, sibcall.c, simplify-rtx.c,
ssa-ccp.c, ssa-dce.c, ssa.c, ssa.h, stmt.c, stor-layout.c,
stringpool.c, system.h, timevar.c, timevar.def, timevar.h,
tlink.c, toplev.c, toplev.h, tree.c, tree.def, tree.h,
tsystem.h, unroll.c, unwind-dw2-fde.c, unwind-dw2-fde.h,
unwind-dw2.c, unwind-pe.h, unwind-sjlj.c, unwind.h,
unwind.inc, varasm.c, varray.c, varray.h, xcoffout.c,
xcoffout.h: replace "GNU CC" with "GCC".
From-SVN: r45105
2001-08-22 16:35:51 +02:00
|
|
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
|
for more details.
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
Makefile.in, [...]: replace "GNU CC" with "GCC".
* Makefile.in, alias.c, basic-block.h, bb-reorder.c, bitmap.c,
bitmap.h, builtin-types.def, builtins.c, builtins.def,
c-aux-info.c, c-common.c, c-common.def, c-common.h,
c-convert.c, c-decl.c, c-dump.c, c-dump.h, c-errors.c,
c-format.c, c-lang.c, c-lex.c, c-lex.h, c-parse.in,
c-pragma.c, c-pragma.h, c-semantics.c, c-tree.h, c-typeck.c,
caller-save.c, calls.c, collect2.c, collect2.h, combine.c,
conditions.h, config.gcc, configure.frag, configure.in,
conflict.c, convert.c, convert.h, cppspec.c, crtstuff.c,
cse.c, cselib.c, cselib.h, dbxout.c, dbxout.h, defaults.h,
dependence.c, df.c, df.h, diagnostic.c, diagnostic.h,
doloop.c, dominance.c, dwarf.h, dwarf2.h, dwarf2asm.c,
dwarf2asm.h, dwarf2out.c, dwarf2out.h, dwarfout.c,
emit-rtl.c, errors.c, errors.h, except.c, except.h,
exgettext, explow.c, expmed.c, expr.c, expr.h, final.c,
fixproto, flags.h, flow.c, fold-const.c, fp-test.c,
function.c, function.h, gbl-ctors.h, gcc.c, gcc.h, gcc.hlp,
gccspec.c, gcov-io.h, gcse.c, genattr.c, genattrtab.c,
gencheck.c, gencodes.c, genconfig.c, genemit.c,
genextract.c, genflags.c, gengenrtl.c, genmultilib,
genopinit.c, genoutput.c, genpeep.c, genrecog.c,
gensupport.c, gensupport.h, ggc-callbacks.c, ggc-common.c,
ggc-none.c, ggc-page.c, ggc-simple.c, ggc.h, global.c,
graph.c, graph.h, gthr-aix.h, gthr-dce.h, gthr-posix.h,
gthr-rtems.h, gthr-single.h, gthr-solaris.h, gthr-vxworks.h,
gthr-win32.h, gthr.h, haifa-sched.c, halfpic.c, halfpic.h,
hard-reg-set.h, hwint.h, ifcvt.c, input.h, insn-addr.h,
integrate.c, integrate.h, jump.c, lcm.c, libgcc2.c,
libgcc2.h, lists.c, local-alloc.c, loop.c, loop.h,
machmode.def, machmode.h, main.c, mbchar.c, mbchar.h,
mips-tdump.c, mips-tfile.c, mklibgcc.in, mkmap-flat.awk,
mkmap-symver.awk, optabs.c, output.h, params.c, params.def,
params.h, predict.c, predict.def, predict.h, prefix.c,
prefix.h, print-rtl.c, print-tree.c, profile.c, protoize.c,
read-rtl.c, real.c, real.h, recog.c, recog.h, reg-stack.c,
regclass.c, regmove.c, regrename.c, regs.h, reload.c,
reload.h, reload1.c, reorg.c, resource.c, resource.h, rtl.c,
rtl.def, rtl.h, rtlanal.c, sbitmap.c, sbitmap.h,
sched-deps.c, sched-ebb.c, sched-int.h, sched-rgn.c,
sched-vis.c, sdbout.c, sdbout.h, sibcall.c, simplify-rtx.c,
ssa-ccp.c, ssa-dce.c, ssa.c, ssa.h, stmt.c, stor-layout.c,
stringpool.c, system.h, timevar.c, timevar.def, timevar.h,
tlink.c, toplev.c, toplev.h, tree.c, tree.def, tree.h,
tsystem.h, unroll.c, unwind-dw2-fde.c, unwind-dw2-fde.h,
unwind-dw2.c, unwind-pe.h, unwind-sjlj.c, unwind.h,
unwind.inc, varasm.c, varray.c, varray.h, xcoffout.c,
xcoffout.h: replace "GNU CC" with "GCC".
From-SVN: r45105
2001-08-22 16:35:51 +02:00
|
|
|
|
along with GCC; see the file COPYING. If not, write to the Free
|
|
|
|
|
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
|
02111-1307, USA. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* Process declarations and symbol lookup for C front end.
|
|
|
|
|
Also constructs types; the standard scalar types at initialization,
|
|
|
|
|
and structure, union, array and enum types when they are declared. */
|
|
|
|
|
|
|
|
|
|
/* ??? not all decl nodes are given the most useful possible
|
|
|
|
|
line numbers. For example, the CONST_DECLs for enum values. */
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
Major cutover to using system.h:
* Makefile.in (alias.o, bitmap.o, c-aux-info.o, c-common.o,
c-decl.o, c-iterate.o, c-lang.o, c-lex.o, c-pragma.o, c-typeck.o,
caller-save.o, calls.o, collect2.o, combine.o, cse.o, dbxout.o,
dwarf2out.o, dwarfout.o, emit-rtl.o, except.o, explow.o, expmed.o,
expr.o, final.o, flow.o, function.o, getpwd.o, global.o,
integrate.o, jump.o, local-alloc.o, loop.o, optabs.o, pexecute.o,
prefix.o, print-rtl.o, print-tree.o, profile.o, real.o, recog.o,
reg-stack.o, regclass.o, regmove.o, reload.o, reload1.o, reorg.o,
rtl.o, rtlanal.o, sdbout.o, stmt.o, stor-layout.o, stupid.o,
tlink.o, toplev.o, tree.o, unroll.o, varasm.o, xcoffout.o): Depend
on system.h.
* alias.c, bitmap.c, c-aux-info.c, c-common.c, c-decl.c,
c-iterate.c, c-lang.c, c-lex.c, c-pragma.c, c-typeck.c,
caller-save.c, calls.c, collect2.c, combine.c, cse.c, dbxout.c,
dwarf2out.c, dwarfout.c, emit-rtl.c, except.c, explow.c, expmed.c,
expr.c, final.c, flow.c, function.c, gcc.c, getpwd.c, global.c,
integrate.c, jump.c, local-alloc.c, loop.c, optabs.c, pexecute.c,
prefix.c, print-rtl.c, print-tree.c, profile.c, real.c, recog.c,
reg-stack.c, regclass.c, regmove.c, reload.c, reload1.c, reorg.c,
rtl.c, rtlanal.c, sched.c, sdbout.c, stmt.c, stor-layout.c,
stupid.c, tlink.c, toplev.c, tree.c, unroll.c, varasm.c,
xcoffout.c: Include system.h. Organize include ordering so
that stdarg/varargs comes before other system headers. Remove
spurious casts of functions assured of a prototype in system.h.
From-SVN: r18726
1998-03-20 15:58:42 +01:00
|
|
|
|
#include "system.h"
|
2002-12-16 19:23:00 +01:00
|
|
|
|
#include "coretypes.h"
|
|
|
|
|
#include "tm.h"
|
2000-06-29 19:31:03 +02:00
|
|
|
|
#include "intl.h"
|
1992-02-13 23:21:26 +01:00
|
|
|
|
#include "tree.h"
|
2001-10-05 06:20:27 +02:00
|
|
|
|
#include "tree-inline.h"
|
Makefile.in (c-decl.o): Depend on rtl.h and expr.h.
* Makefile.in (c-decl.o): Depend on rtl.h and expr.h.
* alias.c (struct alias_entry): alias_set is HOST_WIDE_INT.
(REG_BASE_VALUE): Remove unneeded cast to unsigned.
(get_alias_set_entry): ALIAS_SET arg is HOST_WIDE_INT.
(find_base_decl): New function, from c_find_base_decl in c-common.c.
(new_alias_set): Moved from tree.c; return is HOST_WIDE_INT.
(get_alias_set): Likewise.
Major rework to do more things and allow language-specific code
to just handle special-cases.
(record_alias_subset): Args are HOST_WIDE_INT.
(record_component_alias): Local vars are HOST_WIDE_INT.
Don't handle COMPLEX_EXPR.
(get_varargs_alias_set): Moved from builtins.c.
(get_frame_alias_set): New function.
* builtins.c (expand_builtin_return_address): Use frame alias set.
(expand_builtin_setjmp, expand_builtin_longjmp): Use alias set
for setjmp buffer.
(get_memory_rtx): Rework to use set_mem_attributes.
(get_varargs_alias_set): Deleted from here.
* c-common.c (c_apply_type_quals_to_decl): Alias sets now HOST_WIDE_INT.
(c_find_base_decl): Deleted from here.
(c_get_alias_set): Remove many cases and rework to just handle
C-specific cases.
* c-common.h (c_get_alias_set): Returns HOST_WIDE_INT.
* c-decl.c (rtl.h, expr.h): Now included.
(init_decl_processing): Call record_component_aliases on array types.
(grokdeclarator): Likewise.
Set TREE_ADDRESSABLE for all fields that are not bitfields.
* c-typeck.c (common_type): Call record_component_aliases for array.
* caller-save.c (setup_save_areas): Rework register loop for unsigned.
Set all save areas to the frame alias set.
* calls.c (initialie_argument_information): Call set_mem_attributes.
(compute_argument_addresses, expand_call): Likewise.
* explow.c (set_mem_attributes): New function.
(stabilize): Use MEM_COPY_ATTRIBUTES and force_reg.
* expr.c (struct move_by_pieces): Remove {to,from}_{struct,readonly}.
LEN and OFFSET now HOST_WIDE_INT.
(clear_by_pieces): Similar changes.
(move_by_pieces): LEN now HOST_WIDE_INT; don't set deleted fields.
(move_by_pieces_ninsns): Now returns unsigned HOST_WIDE_INT.
(move_by_pieces_1): Don't use deleted fields, use MEM_COPY_ATTRIBUTES.
(clear_by_pieces_1): Likewise.
(emit_push_insn): Call set_mem_attributes.
(expand_expr, case INDIRECT_REF): Likewise.
(expand_expr, case VAR_DECL): Call change_address.
* expr.h (ADD_PARM_SIZE, SUB_PARM_SIZE): Use host_integerp and
tree_low_cst.
(get_varargs_alias_set, get_frame_alias_set): New decls.
(record_base_value, record_alias_subset, lang_get_alias_set): Likewise.
(new_alias_set, set_mem_attributes): Likewse.
* function.c (struct temp_slot): ALIAS_SET is HOST_WIDE_INT.
(assign_stack_temp_for_type): Likewise.
Can split slot even if alias set since can copy.
Set MEM_ALIAS_SET and MEM_SET_IN_STRUCT_P.
(assign_temp): Use host_integerp and tree_low_cst.
(put_var_into_stack): Properly handle SAVE_EXPR.
(put_addressof_into_stack): Likewise.
(assign_parms): Call set_mem_attributes.
Delete #if 0 code.
(fix_lexical_address): Put reference to chain into frame alias set.
(expand_function_start): Call set_mem_attributes.
* integrate.c (expand_inline_function): Likewise.
* recog.c (adj_offsettable_operand): Use MEM_COPY_ATTRIBUTES.
* regmove.c (try_apply_stack_adjustment): Likewise.
* reload.c (push_reload, make_memloc): Likewise.
* reload1.c (alter_reg): Make alias sets for spilled pseudos.
* rtl.def (MEM): Update comment.
* rtl.h (MEM_ALIAS_SET): Now uses XCWINT.
(move_by_pieces): Change length to HOST_WIDE_INT.
(record_base_value, record_alias_subset): Delete from here.
* stmt.c (expand_decl): Call set_mem_attributes.
* stor-layout.c (finish_record_layout): Call record_component_aliases.i
* toplev.c (compile_file): Call init_alias_once earlier.
* tree.c (lang_get_alias_set, get_alias_set, new_alias_set): Deleted
from here: now in alias.c.
* tree.h (struct tree_type): alias_set is HOST_WIDE_INT.
(struct tree_decl): Likewise.
(get_alias_set, new_alias_set, lang_get_alias_set): Deleted from here.
* varasm.c (make_function_rtl, make_decl_rtl): Call set_mem_attributes.
(output_constant_def, force_const_mem): Likewise.
* cp/Makefile.in (decl.o): Include ../expr.h.
* cp/decl.c (expr.h): Include.
(init_decl_processing): Call record_component_aliases for arrays.
(grokdeclarator): Likewise.
Set TREE_ADDRESSABLE for fields that aren't bitfields.
* cp/tree.c (build_cplus_array_type_1): Call record_component_aliases.
From-SVN: r34308
2000-05-31 22:01:57 +02:00
|
|
|
|
#include "rtl.h"
|
1992-02-13 23:21:26 +01:00
|
|
|
|
#include "flags.h"
|
1999-08-09 16:00:21 +02:00
|
|
|
|
#include "function.h"
|
1994-12-30 13:59:51 +01:00
|
|
|
|
#include "output.h"
|
Makefile.in (c-decl.o): Depend on rtl.h and expr.h.
* Makefile.in (c-decl.o): Depend on rtl.h and expr.h.
* alias.c (struct alias_entry): alias_set is HOST_WIDE_INT.
(REG_BASE_VALUE): Remove unneeded cast to unsigned.
(get_alias_set_entry): ALIAS_SET arg is HOST_WIDE_INT.
(find_base_decl): New function, from c_find_base_decl in c-common.c.
(new_alias_set): Moved from tree.c; return is HOST_WIDE_INT.
(get_alias_set): Likewise.
Major rework to do more things and allow language-specific code
to just handle special-cases.
(record_alias_subset): Args are HOST_WIDE_INT.
(record_component_alias): Local vars are HOST_WIDE_INT.
Don't handle COMPLEX_EXPR.
(get_varargs_alias_set): Moved from builtins.c.
(get_frame_alias_set): New function.
* builtins.c (expand_builtin_return_address): Use frame alias set.
(expand_builtin_setjmp, expand_builtin_longjmp): Use alias set
for setjmp buffer.
(get_memory_rtx): Rework to use set_mem_attributes.
(get_varargs_alias_set): Deleted from here.
* c-common.c (c_apply_type_quals_to_decl): Alias sets now HOST_WIDE_INT.
(c_find_base_decl): Deleted from here.
(c_get_alias_set): Remove many cases and rework to just handle
C-specific cases.
* c-common.h (c_get_alias_set): Returns HOST_WIDE_INT.
* c-decl.c (rtl.h, expr.h): Now included.
(init_decl_processing): Call record_component_aliases on array types.
(grokdeclarator): Likewise.
Set TREE_ADDRESSABLE for all fields that are not bitfields.
* c-typeck.c (common_type): Call record_component_aliases for array.
* caller-save.c (setup_save_areas): Rework register loop for unsigned.
Set all save areas to the frame alias set.
* calls.c (initialie_argument_information): Call set_mem_attributes.
(compute_argument_addresses, expand_call): Likewise.
* explow.c (set_mem_attributes): New function.
(stabilize): Use MEM_COPY_ATTRIBUTES and force_reg.
* expr.c (struct move_by_pieces): Remove {to,from}_{struct,readonly}.
LEN and OFFSET now HOST_WIDE_INT.
(clear_by_pieces): Similar changes.
(move_by_pieces): LEN now HOST_WIDE_INT; don't set deleted fields.
(move_by_pieces_ninsns): Now returns unsigned HOST_WIDE_INT.
(move_by_pieces_1): Don't use deleted fields, use MEM_COPY_ATTRIBUTES.
(clear_by_pieces_1): Likewise.
(emit_push_insn): Call set_mem_attributes.
(expand_expr, case INDIRECT_REF): Likewise.
(expand_expr, case VAR_DECL): Call change_address.
* expr.h (ADD_PARM_SIZE, SUB_PARM_SIZE): Use host_integerp and
tree_low_cst.
(get_varargs_alias_set, get_frame_alias_set): New decls.
(record_base_value, record_alias_subset, lang_get_alias_set): Likewise.
(new_alias_set, set_mem_attributes): Likewse.
* function.c (struct temp_slot): ALIAS_SET is HOST_WIDE_INT.
(assign_stack_temp_for_type): Likewise.
Can split slot even if alias set since can copy.
Set MEM_ALIAS_SET and MEM_SET_IN_STRUCT_P.
(assign_temp): Use host_integerp and tree_low_cst.
(put_var_into_stack): Properly handle SAVE_EXPR.
(put_addressof_into_stack): Likewise.
(assign_parms): Call set_mem_attributes.
Delete #if 0 code.
(fix_lexical_address): Put reference to chain into frame alias set.
(expand_function_start): Call set_mem_attributes.
* integrate.c (expand_inline_function): Likewise.
* recog.c (adj_offsettable_operand): Use MEM_COPY_ATTRIBUTES.
* regmove.c (try_apply_stack_adjustment): Likewise.
* reload.c (push_reload, make_memloc): Likewise.
* reload1.c (alter_reg): Make alias sets for spilled pseudos.
* rtl.def (MEM): Update comment.
* rtl.h (MEM_ALIAS_SET): Now uses XCWINT.
(move_by_pieces): Change length to HOST_WIDE_INT.
(record_base_value, record_alias_subset): Delete from here.
* stmt.c (expand_decl): Call set_mem_attributes.
* stor-layout.c (finish_record_layout): Call record_component_aliases.i
* toplev.c (compile_file): Call init_alias_once earlier.
* tree.c (lang_get_alias_set, get_alias_set, new_alias_set): Deleted
from here: now in alias.c.
* tree.h (struct tree_type): alias_set is HOST_WIDE_INT.
(struct tree_decl): Likewise.
(get_alias_set, new_alias_set, lang_get_alias_set): Deleted from here.
* varasm.c (make_function_rtl, make_decl_rtl): Call set_mem_attributes.
(output_constant_def, force_const_mem): Likewise.
* cp/Makefile.in (decl.o): Include ../expr.h.
* cp/decl.c (expr.h): Include.
(init_decl_processing): Call record_component_aliases for arrays.
(grokdeclarator): Likewise.
Set TREE_ADDRESSABLE for fields that aren't bitfields.
* cp/tree.c (build_cplus_array_type_1): Call record_component_aliases.
From-SVN: r34308
2000-05-31 22:01:57 +02:00
|
|
|
|
#include "expr.h"
|
1992-02-13 23:21:26 +01:00
|
|
|
|
#include "c-tree.h"
|
toplev.h: New file.
Wed May 6 06:35:38 1998 Robert Lipe <robertl@dgii.com>
* toplev.h: New file. Protypes for functions in toplev.c.
* tree.h, rtl.h: Deleted protos for functions in toplev.c.
* c-common.c, c-convert.c, c-decl.c, c-iterate.c, c-lex.c,
c-parse.in, c-parse.y, c-pragma.c, c-typeck.c, calls.c,
convert.c, dwarf2out.c, except.c, expr.c, final.c, fold-const.c,
function.c, hash.c, profile.c, real.c, reg-stack.c, regclass.c,
reload.c, reload1.c, stmt.c, stor-layout.c, tlink.c, tree.c,
varasm.c: include it.
From-SVN: r19563
1998-05-06 06:45:47 +02:00
|
|
|
|
#include "toplev.h"
|
1999-09-06 23:28:22 +02:00
|
|
|
|
#include "ggc.h"
|
2000-05-07 03:37:07 +02:00
|
|
|
|
#include "tm_p.h"
|
1998-06-10 12:12:36 +02:00
|
|
|
|
#include "cpplib.h"
|
Makefile.in (TARGET_H, [...]): New.
* Makefile.in (TARGET_H, TARGET_DEF_H): New.
(c-decl.o, tree.o, c-typeck.o, $(out_object_file)): Update.
* c-decl.c (duplicate_decls): Use function pointer.
* c-typeck.c (common_type): Similarly.
* tree.c (valid_machine_attribute): Similarly.
(merge_machine_type_attributes): Rename merge_type_attributes.
(merge_machine_decl_attributes): Rename merge_decl_attributes.
(merge_dllimport_decl_attributes): New function.
* tree.h (merge_machine_type_attributes): Rename merge_type_attributes.
(merge_machine_decl_attributes): Rename merge_decl_attributes.
(merge_dllimport_decl_attributes): New prototype.
* target.h: New.
* target-def.h: New.
doc: (Joseph Myers)
* doc/gcc.texi, doc/tm.texi: Update documentation.
cp: Make-lang.in: Update dependencies.
* spew.c: Include target.h.
(duplicate_decls): Call target function.
* decl2.c: include target.h
(import_export_class): Use existence of target function pointer.
* typeck.c: Include target.h.
(qualify_type_recursive): Rename variable. Call target function.
(type_after_usual_arithmetic_conversions): Similarly.
(common_type): Similarly.
config: * 1750a/1750a.c, a29k/29k.c, alpha/alpha.c, arc/arc.c, arm/arm.c,
avr/avr.c, c4x/c4x.c, clipper/clipper.c, convex/convex.c,
d30v/d30v.c, dsp16xx/dsp16xx.c, elxsi/elxsi.c, fr30/fr30.c,
i370/i370.c, i386/i386.c, i860/i860.c, i960/i960.c, ia64/ia64.c,
m32r/m32r.c, m68hc11/m68hc11.c, m68k/m68k.c, m88k/m88k.c,
mips/mips.c, mn10200/mn10200.c, mn10300/mn10300.c, ns32k/ns32k.c,
pa/pa.c, pdp11/pdp11.c, pj/pj.c, romp/romp.c, rs6000/rs6000.c,
sh/sh.c, sparc/sparc.c, v850/v850.c, vax/vax.c, we32k/we32k.c)
: Include target.h and target-def.h. Define target.
* arc/arc-protos.h (arc_valid_machine_decl_attribute): Remove.
* arc/arc.c (arc_valid_machine_decl_attribute): Rename
arc_valid_decl_attribute, make static.
* arc/arc.h (VALID_MACHINE_TYPE_ATTRIBUTE): Remove.
* arm/arm-protos.h (arm_valid_machine_decl_attribute,
arm_valid_type_attribute_p, arm_pe_valid_machine_decl_attribute,
arm_pe_merge_machine_decl_attributes): Remove.
* arm/arm.c (arm_valid_machine_decl_attribute_p): Rename
arm_valid_decl_attribute_p, make static.
(arm_pe_valid_decl_attribute_p): Move from pe.c.
* arm/pe.c (arm_pe_valid_machine_decl_attribute_p): Move to arm.c.
(arm_pe_merge_machine_decl_attributes): Move to tree.c.
* arm/arm.h (VALID_MACHINE_TYPE_ATTRIBUTE): Remove.
* arm/coff.h (VALID_MACHINE_DECL_ATTRIBUTE): Remove.
* arm/elf.h (VALID_MACHINE_DECL_ATTRIBUTE): Remove.
* arm/pe.h (TARGET_DLLIMPORT_DECL_ATTRIBUTES): New.
(VALID_MACHINE_TYPE_ATTRIBUTE, VALID_MACHINE_DECL_ATTRIBUTE): Remove.
* avr/avr-protos.h (valid_machine_type_attribute,
valid_machine_decl_attribute): Remove.
* avr/avr.c (valid_machine_type_attribute,
valid_machine_decl_attribute): Rename and make static.
* avr/avr.h (VALID_MACHINE_TYPE_ATTRIBUTE,
VALID_MACHINE_DECL_ATTRIBUTE): Remove.
* c4x/c4x-protos.h (c4x_valid_type_attribute_p): Remove.
* c4x/c4x.c (c4x_valid_type_attribute_p): Make static.
* c4x/c4x.h (VALID_MACHINE_TYPE_ATTRIBUTE): Remove.
* d30v/d30v.h: Remove obsolete comments.
* h8300/h8300-protos.h (h8300_valid_machine_decl_attribute): Remove.
* h8300/h8300.c (h8300_valid_machine_decl_attribute): Rename, make
static.
* h8300/h8300.h (VALID_MACHINE_DECL_ATTRIBUTE): Remove.
* i386/cygwin.h (TARGET_DLLIMPORT_DECL_ATTRIBUTES): Define.
(i386_pe_merge_decl_attributes, MERGE_MACHINE_DECL_ATTRIBUTES,
i386_pe_valid_type_attributes_p): Remove.
* i386/i386-protos.h (ix86_valid_decl_attribute_p,
ix86_valid_type_attribute_p): Remove.
* i386/i386.c (ix86_valid_decl_attribute_p): Remove.
(ix86_valid_type_attribute_p): Make static.
* i386/i386.h (VALID_MACHINE_DECL_ATTRIBUTE,
VALID_MACHINE_TYPE_ATTRIBUTE): Remove.
* i386/winnt.c (i386_pe_merge_decl_attributes): Move to tree.c.
* ia64/ia64-protos.h (ia64_valid_type_attribute): Remove.
* ia64/ia64.c (ia64_valid_type_attribute): Make static.
* ia64/ia64.h (VALID_MACHINE_TYPE_ATTRIBUTE): Remove.
* m32r/m32r-protos.h (m32r_valid_machine_decl_attribute): Remove.
* m32r/m32r.c (m32r_valid_decl_attribute): Make static.
* m32r/m32r.h (VALID_MACHINE_DECL_ATTRIBUTE): Remove.
* m68hc11/m68hc11-protos.h (m68hc11_valid_decl_attribute_p,
m68hc11_valid_type_attribute_p): Remove.
* m68hc11/m68hc11.c (m68hc11_valid_decl_attribute_p): Remove.
(m68hc11_valid_type_attribute_p): Make static.
* m68hc11/m68hc11.h (VALID_MACHINE_DECL_ATTRIBUTE,
VALID_MACHINE_TYPE_ATTRIBUTE): Remove.
* mcore/mcore-protos.h (mcore_valid_machine_decl_attribute,
mcore_merge_machine_decl_attribute): Remove.
* mcore/mcore.c (mcore_valid_machine_decl_attribute): Rename,
make static.
(mcore_merge_machine_decl_attributes): Move to tree.c.
* mcore/mcore.h (VALID_MACHINE_DECL_ATTRIBUTE,
VALID_MACHINE_TYPE_ATTRIBUTE): Remove.
(TARGET_DLLIMPORT_DECL_ATTRIBUTES): Define.
* ns32k/ns32k-protos.h (ns32k_valid_decl_attribute_p,
ns32k_valid_type_attribute_p): Remove.
* ns32k/ns32k.c (ns32k_valid_decl_attribute_p): Remove.
(ns32k_valid_type_attribute_p): Make static.
* ns32k/ns32k.h (VALID_MACHINE_DECL_ATTRIBUTE,
VALID_MACHINE_TYPE_ATTRIBUTE): Remove.
* rs6000/rs6000-protos.h (rs6000_valid_decl_attribute_p,
rs6000_valid_type_attribute_p): Remove.
* rs6000/rs6000.c (rs6000_valid_decl_attribute_p): Remove.
(rs6000_valid_type_attribute_p): Make static.
* rs6000/rs6000.h (VALID_MACHINE_DECL_ATTRIBUTE,
VALID_MACHINE_TYPE_ATTRIBUTE): Remove.
* sh/sh-protos.h (sh_valid_machine_decl_attribute): Remove.
* sh/sh.c (sh_valid_machine_decl_attribute): Rename, make static.
* sh/sh.h (VALID_MACHINE_DECL_ATTRIBUTE): Remove.
* v850/v850-protos.h (v850_valid_machine_decl_attribute): Remove.
* v850/v850.c (v850_valid_machine_decl_attribute): Rename, make static.
* v850/v850.h (VALID_MACHINE_DECL_ATTRIBUTE): Remove.
From-SVN: r43585
2001-06-26 20:09:27 +02:00
|
|
|
|
#include "target.h"
|
Makefile.in (emit-rtl.o, c-decl.o): Depend on debug.h.
* Makefile.in (emit-rtl.o, c-decl.o): Depend on debug.h.
(final.o): Don't depend on xcoffout.h, dbxout.h or sdbout.h.
(toplev.o): Don't depend on xcoffout.h.
* c-decl.c: Include debug.h
(duplicate_decls): Use debug hook.
* dbxout.c (dbxout_source_file, dbxout_args): Make static.
(dbx_debug_hooks, xcoff_debug_hooks): Update.
(dbxout_types): Remove.
* dbxout.h (dbxout_source_file, dbxout_types, dbxout_args): Remove.
* debug.c (do_nothing_debug_hooks): Update.
(debug_true_tree, debug_nothing_rtx): New.
* debug.h (struct rtx_def): New.
(struct gcc_debug_hooks): New hooks ignore_block,
outlining_inline_function and label.
(debug_true_tree, debug_nothing_rtx, dwarf2out_frame_init,
dwarf2out_frame_finish): New.
* dwarf2out.c (dwarf2out_ignore_block, dwarf2out_abstract_function):
Make static, update prototype.
(dwarf2_debug_hooks): Update.
* dwarf2out.h (dwarf2out_ignore_block, dwarf2out_abstract_function,
dwarf2out_frame_init, dwarf2out_frame_finish): Remove.
* dwarfout.c (dwarf_debug_hooks): Update.
* emit-rtl.c: Include debug.h.
(remove_unnecessary_notes): Use debug hook.
* final.c: Don't include dbxout.h, xcoffout.h or sdbout.h.
(final_scan_insn): Use debug hook.
* integrate.c (output_inline_function): Use debug hook.
* sdbout.c (sdbout_toplevel_data, sdbout_label): Make static.
(sdb_debug_hooks): Update.
* sdbout.h (sdbout_label, sdbout_toplevel_data): Remove.
* toplev.c: Don't include xcoffout.h.
(note_outlining_of_inline_function, debug_ignore_block): Remove.
* toplev.h (note_outlining_of_inline_function, debug_ignore_block):
Remove.
* tree.h (dwarf2out_do_frame): Remove.
From-SVN: r44163
2001-07-19 23:17:09 +02:00
|
|
|
|
#include "debug.h"
|
2003-07-31 21:26:17 +02:00
|
|
|
|
#include "opts.h"
|
2001-10-20 12:04:00 +02:00
|
|
|
|
#include "timevar.h"
|
2001-12-06 00:20:00 +01:00
|
|
|
|
#include "c-common.h"
|
2002-03-15 08:11:14 +01:00
|
|
|
|
#include "c-pragma.h"
|
2003-02-22 11:02:31 +01:00
|
|
|
|
#include "cgraph.h"
|
2003-05-12 05:25:38 +02:00
|
|
|
|
#include "hashtab.h"
|
2003-06-04 19:06:00 +02:00
|
|
|
|
#include "libfuncs.h"
|
|
|
|
|
#include "except.h"
|
2003-07-21 23:25:47 +02:00
|
|
|
|
#include "langhooks-def.h"
|
1998-06-10 12:12:36 +02:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* In grokdeclarator, distinguish syntactic contexts of declarators. */
|
|
|
|
|
enum decl_context
|
|
|
|
|
{ NORMAL, /* Ordinary declaration */
|
|
|
|
|
FUNCDEF, /* Function definition */
|
|
|
|
|
PARM, /* Declaration of parm before function body */
|
|
|
|
|
FIELD, /* Declaration inside struct or union */
|
2002-02-02 01:14:41 +01:00
|
|
|
|
BITFIELD, /* Likewise but with specified width */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
TYPENAME}; /* Typename (inside cast or sizeof) */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Nonzero if we have seen an invalid cross reference
|
|
|
|
|
to a struct, union, or enum, but not yet printed the message. */
|
|
|
|
|
|
|
|
|
|
tree pending_invalid_xref;
|
|
|
|
|
/* File and line to appear in the eventual error message. */
|
2003-05-03 15:28:33 +02:00
|
|
|
|
location_t pending_invalid_xref_location;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* While defining an enum type, this is 1 plus the last enumerator
|
1993-08-31 12:25:38 +02:00
|
|
|
|
constant value. Note that will do not have to save this or `enum_overflow'
|
|
|
|
|
around nested function definition since such a definition could only
|
|
|
|
|
occur in an enum value expression and we don't use these variables in
|
|
|
|
|
that case. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
static tree enum_next_value;
|
|
|
|
|
|
1992-05-18 07:09:24 +02:00
|
|
|
|
/* Nonzero means that there was overflow computing enum_next_value. */
|
|
|
|
|
|
|
|
|
|
static int enum_overflow;
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Parsing a function declarator leaves a list of parameter names
|
2003-07-17 22:12:21 +02:00
|
|
|
|
or a chain of parameter decls here. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
static tree last_function_parms;
|
|
|
|
|
|
2003-07-29 00:19:46 +02:00
|
|
|
|
/* ... and a chain of structure and enum types declared in the
|
|
|
|
|
parmlist here. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
static tree last_function_parm_tags;
|
|
|
|
|
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
/* ... and a chain of all non-parameter declarations (such as
|
|
|
|
|
CONST_DECLs from enumerations) here. */
|
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
static tree last_function_parm_others;
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* After parsing the declarator that starts a function definition,
|
2003-07-17 22:12:21 +02:00
|
|
|
|
`start_function' puts the list of parameter names or chain of decls here
|
|
|
|
|
for `store_parm_decls' to find. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
static tree current_function_parms;
|
|
|
|
|
|
|
|
|
|
/* Similar, for last_function_parm_tags. */
|
2003-07-17 22:12:21 +02:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
static tree current_function_parm_tags;
|
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
/* And for last_function_parm_others. */
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
static tree current_function_parm_others;
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
|
1993-03-18 23:01:56 +01:00
|
|
|
|
/* Similar, for the file and line that the prototype came from if this is
|
|
|
|
|
an old-style definition. */
|
2003-07-17 22:12:21 +02:00
|
|
|
|
|
2003-05-08 17:04:44 +02:00
|
|
|
|
static location_t current_function_prototype_locus;
|
1993-03-18 23:01:56 +01:00
|
|
|
|
|
2000-09-17 09:38:23 +02:00
|
|
|
|
/* The current statement tree. */
|
|
|
|
|
|
2002-06-04 09:11:05 +02:00
|
|
|
|
static GTY(()) struct stmt_tree_s c_stmt_tree;
|
2000-09-17 09:38:23 +02:00
|
|
|
|
|
|
|
|
|
/* The current scope statement stack. */
|
|
|
|
|
|
2002-06-04 09:11:05 +02:00
|
|
|
|
static GTY(()) tree c_scope_stmt_stack;
|
2000-09-17 09:38:23 +02:00
|
|
|
|
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
/* A list of external DECLs that appeared at block scope when there was
|
|
|
|
|
some other global meaning for that identifier. */
|
|
|
|
|
static GTY(()) tree truly_local_externals;
|
|
|
|
|
|
2003-08-07 05:12:09 +02:00
|
|
|
|
/* All the builtins; this is a subset of the entries of global_scope. */
|
2003-07-11 10:33:21 +02:00
|
|
|
|
|
2003-08-07 05:12:09 +02:00
|
|
|
|
static GTY(()) tree first_builtin_decl;
|
|
|
|
|
static GTY(()) tree last_builtin_decl;
|
2003-07-11 10:33:21 +02:00
|
|
|
|
|
|
|
|
|
/* A DECL for the current file-scope context. */
|
|
|
|
|
|
|
|
|
|
static GTY(()) tree current_file_decl;
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Set to 0 at beginning of a function definition, set to 1 if
|
|
|
|
|
a return statement that specifies a return value is seen. */
|
|
|
|
|
|
|
|
|
|
int current_function_returns_value;
|
|
|
|
|
|
|
|
|
|
/* Set to 0 at beginning of a function definition, set to 1 if
|
|
|
|
|
a return statement with no argument is seen. */
|
|
|
|
|
|
|
|
|
|
int current_function_returns_null;
|
|
|
|
|
|
2002-02-06 21:40:18 +01:00
|
|
|
|
/* Set to 0 at beginning of a function definition, set to 1 if
|
|
|
|
|
a call to a noreturn function is seen. */
|
|
|
|
|
|
|
|
|
|
int current_function_returns_abnormally;
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Set to nonzero by `grokdeclarator' for a function
|
|
|
|
|
whose return type is defaulted, if warnings for this are desired. */
|
|
|
|
|
|
|
|
|
|
static int warn_about_return_type;
|
|
|
|
|
|
1992-03-23 03:07:53 +01:00
|
|
|
|
/* Nonzero when starting a function declared `extern inline'. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
static int current_extern_inline;
|
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
/* Each c_scope structure describes the complete contents of one scope.
|
|
|
|
|
Three scopes are distinguished specially: the innermost or current
|
|
|
|
|
scope, the innermost function scope, and the outermost or file scope.
|
|
|
|
|
|
|
|
|
|
Most declarations are recorded in the current scope.
|
|
|
|
|
|
|
|
|
|
All normal label declarations are recorded in the innermost
|
|
|
|
|
function scope, as are bindings of undeclared identifiers to
|
|
|
|
|
error_mark_node. (GCC permits nested functions as an extension,
|
|
|
|
|
hence the 'innermost' qualifier.) Explicitly declared labels
|
|
|
|
|
(using the __label__ extension) appear in the current scope.
|
|
|
|
|
|
|
|
|
|
Being in the global scope (current_scope == global_scope) causes
|
|
|
|
|
special behavior in several places below. Also, under some
|
|
|
|
|
conditions the Objective-C front end records declarations in the
|
|
|
|
|
global scope even though that isn't the current scope.
|
|
|
|
|
|
|
|
|
|
The order of the names, parms, and blocks lists matters, and they
|
|
|
|
|
are frequently appended to. To avoid having to walk all the way to
|
|
|
|
|
the end of the list on each insertion, or reverse the lists later,
|
|
|
|
|
we maintain a pointer to the last list entry for each of the lists.
|
|
|
|
|
|
2003-08-30 23:21:40 +02:00
|
|
|
|
The order of the tags, shadowed, and shadowed_tags
|
2003-08-01 20:41:40 +02:00
|
|
|
|
lists does not matter, so we just prepend to these lists. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
struct c_scope GTY(())
|
2003-07-29 00:19:46 +02:00
|
|
|
|
{
|
|
|
|
|
/* The scope containing this one. */
|
|
|
|
|
struct c_scope *outer;
|
|
|
|
|
|
|
|
|
|
/* The next outermost function scope. */
|
|
|
|
|
struct c_scope *outer_function;
|
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
/* All variables, constants, functions, labels, and typedef names. */
|
2003-07-29 00:19:46 +02:00
|
|
|
|
tree names;
|
2003-08-01 20:41:40 +02:00
|
|
|
|
tree names_last;
|
2003-07-29 00:19:46 +02:00
|
|
|
|
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
/* All parameter declarations. Used only in the outermost scope of
|
2003-08-01 20:41:40 +02:00
|
|
|
|
a function. */
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
tree parms;
|
2003-08-01 20:41:40 +02:00
|
|
|
|
tree parms_last;
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
|
2003-07-29 00:19:46 +02:00
|
|
|
|
/* All structure, union, and enum type tags. */
|
|
|
|
|
tree tags;
|
|
|
|
|
|
|
|
|
|
/* For each scope, a list of shadowed outer-scope definitions
|
|
|
|
|
to be restored when this scope is popped.
|
|
|
|
|
Each link is a TREE_LIST whose TREE_PURPOSE is an identifier and
|
|
|
|
|
whose TREE_VALUE is its old definition (a kind of ..._DECL node). */
|
|
|
|
|
tree shadowed;
|
|
|
|
|
|
|
|
|
|
/* For each scope, a list of shadowed outer-scope tag definitions
|
|
|
|
|
to be restored when this scope is popped.
|
|
|
|
|
Each link is a TREE_LIST whose TREE_PURPOSE is an identifier and
|
|
|
|
|
whose TREE_VALUE is its old definition (a kind of ..._TYPE node). */
|
|
|
|
|
tree shadowed_tags;
|
|
|
|
|
|
|
|
|
|
/* For each scope (except the global one), a chain of BLOCK nodes
|
|
|
|
|
for all the scopes that were entered and exited one level down. */
|
|
|
|
|
tree blocks;
|
2003-08-01 20:41:40 +02:00
|
|
|
|
tree blocks_last;
|
2003-07-29 00:19:46 +02:00
|
|
|
|
|
|
|
|
|
/* True if we are currently filling this scope with parameter
|
|
|
|
|
declarations. */
|
|
|
|
|
bool parm_flag : 1;
|
|
|
|
|
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
/* True if we already complained about forward parameter decls
|
|
|
|
|
in this scope. This prevents double warnings on
|
|
|
|
|
foo (int a; int b; ...) */
|
|
|
|
|
bool warned_forward_parm_decls : 1;
|
|
|
|
|
|
2003-07-29 00:19:46 +02:00
|
|
|
|
/* True if this is the outermost block scope of a function body.
|
|
|
|
|
This scope contains the parameters, the local variables declared
|
|
|
|
|
in the outermost block, and all the labels (except those in
|
|
|
|
|
nested functions, or declared at block scope with __label__). */
|
|
|
|
|
bool function_body : 1;
|
|
|
|
|
|
|
|
|
|
/* True means make a BLOCK for this scope no matter what. */
|
|
|
|
|
bool keep : 1;
|
|
|
|
|
};
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
/* The scope currently in effect. */
|
2000-08-11 00:01:22 +02:00
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
static GTY(()) struct c_scope *current_scope;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
/* A chain of c_scope structures awaiting reuse. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
static GTY((deletable (""))) struct c_scope *scope_freelist;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
/* The innermost function scope. Ordinary (not explicitly declared)
|
|
|
|
|
labels, bindings to error_mark_node, and the lazily-created
|
|
|
|
|
bindings of __func__ and its friends get this scope. */
|
2003-07-29 00:19:46 +02:00
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
static GTY(()) struct c_scope *current_function_scope;
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
/* The outermost scope, corresponding to the C "file scope". This is
|
|
|
|
|
created when the compiler is started and exists through the entire run. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
static GTY(()) struct c_scope *global_scope;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-08-09 23:59:02 +02:00
|
|
|
|
/* Append VAR to LIST in scope SCOPE. */
|
2003-08-01 20:41:40 +02:00
|
|
|
|
#define SCOPE_LIST_APPEND(scope, list, decl) do { \
|
|
|
|
|
struct c_scope *s_ = (scope); \
|
|
|
|
|
tree d_ = (decl); \
|
|
|
|
|
if (s_->list##_last) \
|
|
|
|
|
TREE_CHAIN (s_->list##_last) = d_; \
|
|
|
|
|
else \
|
|
|
|
|
s_->list = d_; \
|
|
|
|
|
s_->list##_last = d_; \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
/* Concatenate FROM in scope FSCOPE onto TO in scope TSCOPE. */
|
|
|
|
|
#define SCOPE_LIST_CONCAT(tscope, to, fscope, from) do { \
|
|
|
|
|
struct c_scope *t_ = (tscope); \
|
|
|
|
|
struct c_scope *f_ = (fscope); \
|
|
|
|
|
if (t_->to##_last) \
|
|
|
|
|
TREE_CHAIN (t_->to##_last) = f_->from; \
|
|
|
|
|
else \
|
|
|
|
|
t_->to = f_->from; \
|
|
|
|
|
t_->to##_last = f_->from##_last; \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
/* True means unconditionally make a BLOCK for the next scope pushed. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
static bool keep_next_level_flag;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-28 02:12:32 +02:00
|
|
|
|
/* True means the next call to pushlevel will be the outermost scope
|
|
|
|
|
of a function body, so do not push a new scope, merely cease
|
|
|
|
|
expecting parameter decls. */
|
2000-08-11 00:01:22 +02:00
|
|
|
|
|
2003-07-28 02:12:32 +02:00
|
|
|
|
static bool next_is_function_body;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
1995-01-14 02:09:01 +01:00
|
|
|
|
/* Functions called automatically at the beginning and end of execution. */
|
|
|
|
|
|
|
|
|
|
tree static_ctors, static_dtors;
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Forward declarations. */
|
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
static struct c_scope *make_scope (void);
|
|
|
|
|
static void pop_scope (void);
|
2003-07-24 22:44:01 +02:00
|
|
|
|
static tree match_builtin_function_types (tree, tree);
|
2003-07-11 10:33:21 +02:00
|
|
|
|
static int duplicate_decls (tree, tree, int, int);
|
2003-06-19 21:43:59 +02:00
|
|
|
|
static int redeclaration_error_message (tree, tree);
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
static tree make_label (tree, location_t);
|
2003-07-24 18:59:32 +02:00
|
|
|
|
static void bind_label (tree, tree, struct c_scope *);
|
2003-06-19 21:43:59 +02:00
|
|
|
|
static void implicit_decl_warning (tree);
|
|
|
|
|
static tree lookup_tag (enum tree_code, tree, int);
|
|
|
|
|
static tree lookup_name_current_level (tree);
|
|
|
|
|
static tree grokdeclarator (tree, tree, enum decl_context, int);
|
|
|
|
|
static tree grokparms (tree, int);
|
|
|
|
|
static void layout_array_type (tree);
|
2003-07-27 22:07:04 +02:00
|
|
|
|
static void store_parm_decls_newstyle (void);
|
|
|
|
|
static void store_parm_decls_oldstyle (void);
|
2003-06-19 21:43:59 +02:00
|
|
|
|
static tree c_make_fname_decl (tree, int);
|
|
|
|
|
static void c_expand_body_1 (tree, int);
|
|
|
|
|
static tree any_external_decl (tree);
|
|
|
|
|
static void record_external_decl (tree);
|
|
|
|
|
static void warn_if_shadowing (tree, tree);
|
|
|
|
|
static void clone_underlying_type (tree);
|
|
|
|
|
static bool flexible_array_type_p (tree);
|
2003-07-11 10:33:21 +02:00
|
|
|
|
static hashval_t link_hash_hash (const void *);
|
|
|
|
|
static int link_hash_eq (const void *, const void *);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2002-01-10 19:51:24 +01:00
|
|
|
|
/* States indicating how grokdeclarator() should handle declspecs marked
|
|
|
|
|
with __attribute__((deprecated)). An object declared as
|
|
|
|
|
__attribute__((deprecated)) suppresses warnings of uses of other
|
|
|
|
|
deprecated items. */
|
2003-06-19 21:43:59 +02:00
|
|
|
|
|
2002-01-10 19:51:24 +01:00
|
|
|
|
enum deprecated_states {
|
|
|
|
|
DEPRECATED_NORMAL,
|
|
|
|
|
DEPRECATED_SUPPRESS
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static enum deprecated_states deprecated_state = DEPRECATED_NORMAL;
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
c_print_identifier (FILE *file, tree node, int indent)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
print_node (file, "symbol", IDENTIFIER_SYMBOL_VALUE (node), indent + 4);
|
|
|
|
|
print_node (file, "tag", IDENTIFIER_TAG_VALUE (node), indent + 4);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
print_node (file, "label", IDENTIFIER_LABEL_VALUE (node), indent + 4);
|
Integrated preprocessor.
top level:
* Makefile.in: Remove all references to c-parse.gperf,
c-gperf.h, and c-parse.h. Remove -d from yacc command line
generating c-parse.c. Update dependencies.
* c-parse.gperf, c-gperf.h: Delete.
* c-common.c: Don't define parse_options, cpp_token, yy_cur,
yy_lim, or yy_get_token. Don't define get_directive_line if
USE_CPPLIB.
* c-common.h: Add multiple include guard. Define RID values
for every keyword in C, C++, and Objective C. Put all the
modifiers first.
(struct c_fileinfo, get_fileinfo, dump_time_statistics): New.
* c-decl.c (c_decode_option): Handle -lang-objc here.
(print_lang_identifier): Handle C_IS_RESERVED_WORD case.
(grokdeclarator): Adjust for new RID scheme.
(extract_interface_info): New stub.
* c-lang.c: Don't declare yy_cur or parse_options.
(lang_init_options): Call cpp_init. Don't call
cpp_options_init.
(lang_init): Don't call check_newline if USE_CPPLIB.
* c-lex.c: Don't include c-parse.h. Do include timevar.h.
Elide lots of unnecessary code if USE_CPPLIB. Delete code
rendered unnecessary by new architecture. Move routines not
shared with C++ to c-parse.in. Maintain a local idea of the
line number. Handle C++ as well as C.
[USE_CPPLIB]: Declare and register callbacks for #ident and
for entering/leaving files.
(init_c_lex, c_lex): Are now the entry points to this file.
(check_newline): Break out directive handling to
process_directive.
(read_ucs, is_extended_char, utf8_extend_token): Moved here
from C++ front end.
(readescape, parse_float): Overhaul.
(lex_number, lex_string, lex_charconst): Break out of c_lex
(n'ee yylex).
(get_fileinfo, update_header_times, dump_one_header,
dump_time_statistics): New and/or moved here from C++.
Support per-file data needed by C++ and per-header timing
statistics (C++ only, at the moment).
* c-lex.h: Update prototypes. Add multiple include guard.
* c-tree.h (struct lang_identifier): Add rid_code field.
(C_IS_RESERVED_WORD, C_RID_CODE): New.
* c-parse.in: Include c-pragma.h. Remove unnecesary calls to
reinit_parse_for_function and/or position_after_white_space.
(save_filename, save_lineno): Look ahead before saving.
(label -> identifier ':'): Save file and line before shifting ':'.
(reservedwords): No need to call get_identifier.
(init_parse, finish_parse, yyerror, yylex, yyprint,
make_pointer_declarator): Are now here for C/ObjC.
(rid_to_yy): Conversion table from RID constants to Yacc codes.
* c-pragma.c: Rewrite parsing logic to fit with cpplib's
#pragma registry. Provide dummy implementation of that
interface if !USE_CPPLIB.
* c-pragma.h: Update to match.
* flags.h: Add multiple include guard.
(flag_detailed_statistics): Moved here from C++.
* toplev.c: Define flag_detailed_statistics.
* gcc.c (C specs): Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* timevar.def (TV_CPP, TV_LEX): New.
* timevar.h: Add multiple include guard.
* objc/lang-specs.h: Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* objc/objc-act.c: Don't mention yy_cur or parse_options.
Initialize cpplib properly. Force lineno to 0 after first
call to check_newline. Don't handle -lang-objc here.
Move forget_protocol_qualifiers and remember_protocol_qualifiers here.
cp:
* Make-lang.in, Makefile.in: Remove all references to input.c,
gxx.gperf, and hash.h. Add ../c-lex.o to C_OBJS.
* gxx.gperf, hash.h, input.c: Delete.
* lang-specs.h: Pass -lang-c++ to cc1plus so cpplib is
initialized properly.
* class.c (fixup_pending_inline): Take a tree, not a
struct pending_inline *. All callers changed.
(init_class_processing): Set RID_PUBLIC, RID_PRIVATE,
RID_PROTECTED entries in ridpointers[] array here.
* decl.c (duplicate_decls): Do not refer to struct
pending_inline.
(record_builtin_type, init_decl_processing): Use RID_MAX not
CP_RID_MAX.
(grokdeclarator): Use C_IS_RESERVED_WORD.
* decl2.c (lang_decode_option): Ignore -lang-c++ for sake of
cpplib.
(grok_x_components): Do not inspect pending_inlines chain.
* cp-tree.h (struct lang_identifier): Add rid_code entry.
(C_IS_RESERVED_WORD, C_RID_CODE, C_RID_YYCODE): New.
(flag_no_gnu_keywords, flag_operator_names, rid_to_yy): Declare.
(DEFARG_LENGTH, struct pending_inline, TIME_IDENTIFIER_TIME,
TIME_IDENTIFIER_FILEINFO): Kill.
Update prototypes.
* lex.h: Expunge cp_rid. Rewrite RIDBIT macros to use just a
single 32-bit word.
* parse.y: Call do_pending_inlines unconditionally.
reinit_parse_for_method is now snarf_method. fn.defpen is no
longer necessary. Remove unnecessary <itype> annotation on
SCOPE. Do not refer to end_of_file or struct pending_inline.
* semantics.c (begin_inline_definitions): Call
do_pending_inlines unconditionally.
* lex.c: Remove all code now shared with C front end.
Initialize cpplib properly if USE_CPPLIB. Put reserved words
into the get_identifier table. Rewrite pragma handling to
work with the registry. Move code to save tokens for later
processing to spew.c.
* spew.c: Rewrite everything in terms of token streams instead
of text. Move routines here from lex.c / input.c as
appropriate. GC-mark trees hanging off the pending inlines
chain.
testsuite:
* g++.old-deja/g++.benjamin/13478.C: Put meaningful tags on
ERROR markers.
* g++.old-deja/g++.brendan/crash8.C: Move ERROR marker up one line.
* gcc.dg/c99-array-nonobj-1.c: Don't expect func[] cases to fail.
* gcc.dg/wtr-label-1.c: Don't use unconstrained .* in error regexps.
* gcc.dg/wtr-suffix-1.c: Correct error regexps.
* gcc.dg/cpp/unc1.c, gcc.dg/cpp/unc2.c, gcc.dg/cpp/unc3.c:
Preprocess only.
* gcc.dg/cpp/unc4.c: Adjust line number in dg-error line.
* gcc.dg/noncompile/const-ll-1.c: Generalize error regexp.
From-SVN: r36216
2000-09-07 02:37:14 +02:00
|
|
|
|
if (C_IS_RESERVED_WORD (node))
|
|
|
|
|
{
|
|
|
|
|
tree rid = ridpointers[C_RID_CODE (node)];
|
|
|
|
|
indent_to (file, indent + 4);
|
2003-07-08 02:35:52 +02:00
|
|
|
|
fprintf (file, "rid " HOST_PTR_PRINTF " \"%s\"",
|
|
|
|
|
(void *) rid, IDENTIFIER_POINTER (rid));
|
Integrated preprocessor.
top level:
* Makefile.in: Remove all references to c-parse.gperf,
c-gperf.h, and c-parse.h. Remove -d from yacc command line
generating c-parse.c. Update dependencies.
* c-parse.gperf, c-gperf.h: Delete.
* c-common.c: Don't define parse_options, cpp_token, yy_cur,
yy_lim, or yy_get_token. Don't define get_directive_line if
USE_CPPLIB.
* c-common.h: Add multiple include guard. Define RID values
for every keyword in C, C++, and Objective C. Put all the
modifiers first.
(struct c_fileinfo, get_fileinfo, dump_time_statistics): New.
* c-decl.c (c_decode_option): Handle -lang-objc here.
(print_lang_identifier): Handle C_IS_RESERVED_WORD case.
(grokdeclarator): Adjust for new RID scheme.
(extract_interface_info): New stub.
* c-lang.c: Don't declare yy_cur or parse_options.
(lang_init_options): Call cpp_init. Don't call
cpp_options_init.
(lang_init): Don't call check_newline if USE_CPPLIB.
* c-lex.c: Don't include c-parse.h. Do include timevar.h.
Elide lots of unnecessary code if USE_CPPLIB. Delete code
rendered unnecessary by new architecture. Move routines not
shared with C++ to c-parse.in. Maintain a local idea of the
line number. Handle C++ as well as C.
[USE_CPPLIB]: Declare and register callbacks for #ident and
for entering/leaving files.
(init_c_lex, c_lex): Are now the entry points to this file.
(check_newline): Break out directive handling to
process_directive.
(read_ucs, is_extended_char, utf8_extend_token): Moved here
from C++ front end.
(readescape, parse_float): Overhaul.
(lex_number, lex_string, lex_charconst): Break out of c_lex
(n'ee yylex).
(get_fileinfo, update_header_times, dump_one_header,
dump_time_statistics): New and/or moved here from C++.
Support per-file data needed by C++ and per-header timing
statistics (C++ only, at the moment).
* c-lex.h: Update prototypes. Add multiple include guard.
* c-tree.h (struct lang_identifier): Add rid_code field.
(C_IS_RESERVED_WORD, C_RID_CODE): New.
* c-parse.in: Include c-pragma.h. Remove unnecesary calls to
reinit_parse_for_function and/or position_after_white_space.
(save_filename, save_lineno): Look ahead before saving.
(label -> identifier ':'): Save file and line before shifting ':'.
(reservedwords): No need to call get_identifier.
(init_parse, finish_parse, yyerror, yylex, yyprint,
make_pointer_declarator): Are now here for C/ObjC.
(rid_to_yy): Conversion table from RID constants to Yacc codes.
* c-pragma.c: Rewrite parsing logic to fit with cpplib's
#pragma registry. Provide dummy implementation of that
interface if !USE_CPPLIB.
* c-pragma.h: Update to match.
* flags.h: Add multiple include guard.
(flag_detailed_statistics): Moved here from C++.
* toplev.c: Define flag_detailed_statistics.
* gcc.c (C specs): Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* timevar.def (TV_CPP, TV_LEX): New.
* timevar.h: Add multiple include guard.
* objc/lang-specs.h: Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* objc/objc-act.c: Don't mention yy_cur or parse_options.
Initialize cpplib properly. Force lineno to 0 after first
call to check_newline. Don't handle -lang-objc here.
Move forget_protocol_qualifiers and remember_protocol_qualifiers here.
cp:
* Make-lang.in, Makefile.in: Remove all references to input.c,
gxx.gperf, and hash.h. Add ../c-lex.o to C_OBJS.
* gxx.gperf, hash.h, input.c: Delete.
* lang-specs.h: Pass -lang-c++ to cc1plus so cpplib is
initialized properly.
* class.c (fixup_pending_inline): Take a tree, not a
struct pending_inline *. All callers changed.
(init_class_processing): Set RID_PUBLIC, RID_PRIVATE,
RID_PROTECTED entries in ridpointers[] array here.
* decl.c (duplicate_decls): Do not refer to struct
pending_inline.
(record_builtin_type, init_decl_processing): Use RID_MAX not
CP_RID_MAX.
(grokdeclarator): Use C_IS_RESERVED_WORD.
* decl2.c (lang_decode_option): Ignore -lang-c++ for sake of
cpplib.
(grok_x_components): Do not inspect pending_inlines chain.
* cp-tree.h (struct lang_identifier): Add rid_code entry.
(C_IS_RESERVED_WORD, C_RID_CODE, C_RID_YYCODE): New.
(flag_no_gnu_keywords, flag_operator_names, rid_to_yy): Declare.
(DEFARG_LENGTH, struct pending_inline, TIME_IDENTIFIER_TIME,
TIME_IDENTIFIER_FILEINFO): Kill.
Update prototypes.
* lex.h: Expunge cp_rid. Rewrite RIDBIT macros to use just a
single 32-bit word.
* parse.y: Call do_pending_inlines unconditionally.
reinit_parse_for_method is now snarf_method. fn.defpen is no
longer necessary. Remove unnecessary <itype> annotation on
SCOPE. Do not refer to end_of_file or struct pending_inline.
* semantics.c (begin_inline_definitions): Call
do_pending_inlines unconditionally.
* lex.c: Remove all code now shared with C front end.
Initialize cpplib properly if USE_CPPLIB. Put reserved words
into the get_identifier table. Rewrite pragma handling to
work with the registry. Move code to save tokens for later
processing to spew.c.
* spew.c: Rewrite everything in terms of token streams instead
of text. Move routines here from lex.c / input.c as
appropriate. GC-mark trees hanging off the pending inlines
chain.
testsuite:
* g++.old-deja/g++.benjamin/13478.C: Put meaningful tags on
ERROR markers.
* g++.old-deja/g++.brendan/crash8.C: Move ERROR marker up one line.
* gcc.dg/c99-array-nonobj-1.c: Don't expect func[] cases to fail.
* gcc.dg/wtr-label-1.c: Don't use unconstrained .* in error regexps.
* gcc.dg/wtr-suffix-1.c: Correct error regexps.
* gcc.dg/cpp/unc1.c, gcc.dg/cpp/unc2.c, gcc.dg/cpp/unc3.c:
Preprocess only.
* gcc.dg/cpp/unc4.c: Adjust line number in dg-error line.
* gcc.dg/noncompile/const-ll-1.c: Generalize error regexp.
From-SVN: r36216
2000-09-07 02:37:14 +02:00
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
1993-03-22 08:04:18 +01:00
|
|
|
|
/* Hook called at end of compilation to assume 1 elt
|
2003-07-24 18:59:32 +02:00
|
|
|
|
for a file-scope tentative array defn that wasn't complete before. */
|
2000-08-11 00:01:22 +02:00
|
|
|
|
|
1993-03-22 08:04:18 +01:00
|
|
|
|
void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
c_finish_incomplete_decl (tree decl)
|
1993-03-22 08:04:18 +01:00
|
|
|
|
{
|
1996-01-16 02:05:06 +01:00
|
|
|
|
if (TREE_CODE (decl) == VAR_DECL)
|
1993-03-22 08:04:18 +01:00
|
|
|
|
{
|
|
|
|
|
tree type = TREE_TYPE (decl);
|
1996-01-16 02:05:06 +01:00
|
|
|
|
if (type != error_mark_node
|
|
|
|
|
&& TREE_CODE (type) == ARRAY_TYPE
|
2000-09-06 08:06:46 +02:00
|
|
|
|
&& ! DECL_EXTERNAL (decl)
|
1996-01-16 02:05:06 +01:00
|
|
|
|
&& TYPE_DOMAIN (type) == 0)
|
1993-03-22 08:04:18 +01:00
|
|
|
|
{
|
2003-07-19 12:19:19 +02:00
|
|
|
|
warning ("%Harray '%D' assumed to have one element",
|
|
|
|
|
&DECL_SOURCE_LOCATION (decl), decl);
|
1996-01-16 02:05:06 +01:00
|
|
|
|
|
1993-03-22 08:04:18 +01:00
|
|
|
|
complete_array_type (type, NULL_TREE, 1);
|
|
|
|
|
|
|
|
|
|
layout_decl (decl, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
/* Reuse or create a struct for this scope. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
static struct c_scope *
|
|
|
|
|
make_scope (void)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-24 18:59:32 +02:00
|
|
|
|
struct c_scope *result;
|
|
|
|
|
if (scope_freelist)
|
2002-06-04 09:11:05 +02:00
|
|
|
|
{
|
2003-07-24 18:59:32 +02:00
|
|
|
|
result = scope_freelist;
|
|
|
|
|
scope_freelist = result->outer;
|
2002-06-04 09:11:05 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
2003-07-24 18:59:32 +02:00
|
|
|
|
result = ggc_alloc_cleared (sizeof (struct c_scope));
|
2002-06-04 09:11:05 +02:00
|
|
|
|
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
return result;
|
2003-03-17 22:16:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
/* Remove the topmost scope from the stack and add it to the
|
|
|
|
|
free list, updating current_function_scope if necessary. */
|
2002-06-04 09:11:05 +02:00
|
|
|
|
|
|
|
|
|
static void
|
2003-07-24 18:59:32 +02:00
|
|
|
|
pop_scope (void)
|
2002-06-04 09:11:05 +02:00
|
|
|
|
{
|
2003-07-24 18:59:32 +02:00
|
|
|
|
struct c_scope *scope = current_scope;
|
2003-06-19 21:43:59 +02:00
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
current_scope = scope->outer;
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
if (scope->function_body)
|
2003-07-24 18:59:32 +02:00
|
|
|
|
current_function_scope = scope->outer_function;
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
memset (scope, 0, sizeof (struct c_scope));
|
|
|
|
|
scope->outer = scope_freelist;
|
|
|
|
|
scope_freelist = scope;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
/* Nonzero if we are currently in the global scope. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
int
|
2003-06-19 21:43:59 +02:00
|
|
|
|
global_bindings_p (void)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-24 18:59:32 +02:00
|
|
|
|
return current_scope == global_scope;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
keep_next_level (void)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
keep_next_level_flag = true;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
/* Identify this scope as currently being filled with parameters. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
void
|
2003-07-17 22:12:21 +02:00
|
|
|
|
declare_parm_level (void)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-24 18:59:32 +02:00
|
|
|
|
current_scope->parm_flag = true;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Nonzero if currently making parm declarations. */
|
|
|
|
|
|
|
|
|
|
int
|
2003-06-19 21:43:59 +02:00
|
|
|
|
in_parm_level_p (void)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-24 18:59:32 +02:00
|
|
|
|
return current_scope->parm_flag;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-29 00:19:46 +02:00
|
|
|
|
/* Enter a new scope. The dummy parameter is for signature
|
|
|
|
|
compatibility with lang_hooks.decls.pushlevel. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
pushlevel (int dummy ATTRIBUTE_UNUSED)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-28 02:12:32 +02:00
|
|
|
|
if (next_is_function_body)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
/* This is the transition from the parameters to the top level
|
|
|
|
|
of the function body. These are the same scope
|
2003-07-24 18:59:32 +02:00
|
|
|
|
(C99 6.2.1p4,6) so we do not push another scope structure.
|
2003-07-28 02:12:32 +02:00
|
|
|
|
next_is_function_body is set only by store_parm_decls, which
|
|
|
|
|
in turn is called when and only when we are about to
|
|
|
|
|
encounter the opening curly brace for the function body.
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
|
2003-07-28 02:12:32 +02:00
|
|
|
|
The outermost block of a function always gets a BLOCK node,
|
|
|
|
|
because the debugging output routines expect that each
|
2003-08-19 23:04:38 +02:00
|
|
|
|
function has at least one BLOCK. */
|
2003-07-24 18:59:32 +02:00
|
|
|
|
current_scope->parm_flag = false;
|
|
|
|
|
current_scope->function_body = true;
|
2003-07-28 02:12:32 +02:00
|
|
|
|
current_scope->keep = true;
|
2003-07-24 18:59:32 +02:00
|
|
|
|
current_scope->outer_function = current_function_scope;
|
|
|
|
|
current_function_scope = current_scope;
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
|
|
|
|
|
keep_next_level_flag = false;
|
2003-07-28 02:12:32 +02:00
|
|
|
|
next_is_function_body = false;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
2003-07-24 18:59:32 +02:00
|
|
|
|
struct c_scope *scope = make_scope ();
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
scope->keep = keep_next_level_flag;
|
|
|
|
|
scope->outer = current_scope;
|
|
|
|
|
current_scope = scope;
|
|
|
|
|
keep_next_level_flag = false;
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
}
|
1996-04-16 23:32:49 +02:00
|
|
|
|
}
|
2000-08-11 00:01:22 +02:00
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
/* Exit a scope. Restore the state of the identifier-decl mappings
|
|
|
|
|
that were in effect when this scope was entered.
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
If KEEP is KEEP_YES (1), this scope had explicit declarations, so
|
|
|
|
|
create a BLOCK node to record its declarations and subblocks for
|
|
|
|
|
debugging output. If KEEP is KEEP_MAYBE, do so only if the names
|
|
|
|
|
or tags lists are nonempty.
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
The second parameter is ignored; it is present only for
|
|
|
|
|
signature compatibility with lang_hooks.decls.poplevel.
|
2003-07-29 00:19:46 +02:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
If FUNCTIONBODY is nonzero, this level is the body of a function,
|
2003-07-29 00:19:46 +02:00
|
|
|
|
even if current_scope->function_body is not set. This is used
|
|
|
|
|
by language-independent code that generates synthetic functions,
|
|
|
|
|
and cannot set current_scope->function_body.
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-29 00:19:46 +02:00
|
|
|
|
FIXME: Eliminate the need for all arguments. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
tree
|
2003-08-01 20:41:40 +02:00
|
|
|
|
poplevel (int keep, int dummy ATTRIBUTE_UNUSED, int functionbody)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-08-01 20:41:40 +02:00
|
|
|
|
struct c_scope *scope = current_scope;
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
tree block;
|
|
|
|
|
tree decl;
|
2003-08-01 20:41:40 +02:00
|
|
|
|
tree p;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
scope->function_body |= functionbody;
|
2003-07-18 05:39:42 +02:00
|
|
|
|
|
|
|
|
|
if (keep == KEEP_MAYBE)
|
2003-08-01 20:41:40 +02:00
|
|
|
|
keep = (scope->names || scope->tags);
|
|
|
|
|
|
|
|
|
|
keep |= scope->keep;
|
|
|
|
|
keep |= scope->function_body;
|
|
|
|
|
|
|
|
|
|
/* If appropriate, create a BLOCK to record the decls for the life
|
|
|
|
|
of this function. */
|
|
|
|
|
block = 0;
|
|
|
|
|
if (keep)
|
|
|
|
|
{
|
|
|
|
|
block = make_node (BLOCK);
|
|
|
|
|
BLOCK_VARS (block) = scope->names;
|
|
|
|
|
BLOCK_SUBBLOCKS (block) = scope->blocks;
|
|
|
|
|
TREE_USED (block) = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* In each subblock, record that this is its superior. */
|
|
|
|
|
for (p = scope->blocks; p; p = TREE_CHAIN (p))
|
|
|
|
|
BLOCK_SUPERCONTEXT (p) = block;
|
|
|
|
|
|
|
|
|
|
/* Clear out the variable bindings in this scope.
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
|
|
|
|
|
Propagate TREE_ADDRESSABLE from nested functions to their
|
2003-08-01 20:41:40 +02:00
|
|
|
|
containing functions.
|
|
|
|
|
|
|
|
|
|
Issue warnings for unused variables and labels, and errors for
|
|
|
|
|
undefined labels, if there are any. */
|
|
|
|
|
|
|
|
|
|
for (p = scope->names; p; p = TREE_CHAIN (p))
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
{
|
2003-08-01 20:41:40 +02:00
|
|
|
|
const location_t *locus = &DECL_SOURCE_LOCATION (p);
|
|
|
|
|
|
|
|
|
|
switch (TREE_CODE (p))
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
{
|
2003-08-01 20:41:40 +02:00
|
|
|
|
case LABEL_DECL:
|
|
|
|
|
if (TREE_USED (p) && !DECL_INITIAL (p))
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
{
|
2003-08-01 20:41:40 +02:00
|
|
|
|
error ("%Hlabel `%D' used but not defined", locus, p);
|
|
|
|
|
DECL_INITIAL (p) = error_mark_node;
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
}
|
2003-08-01 20:41:40 +02:00
|
|
|
|
else if (!TREE_USED (p) && warn_unused_label)
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
{
|
2003-08-01 20:41:40 +02:00
|
|
|
|
if (DECL_INITIAL (p))
|
|
|
|
|
warning ("%Hlabel `%D' defined but not used", locus, p);
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
else
|
2003-08-01 20:41:40 +02:00
|
|
|
|
warning ("%Hlabel `%D' declared but not defined", locus, p);
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
}
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
IDENTIFIER_LABEL_VALUE (DECL_NAME (p)) = 0;
|
|
|
|
|
break;
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
case FUNCTION_DECL:
|
|
|
|
|
if (! TREE_ASM_WRITTEN (p)
|
|
|
|
|
&& DECL_INITIAL (p) != 0
|
|
|
|
|
&& TREE_ADDRESSABLE (p)
|
|
|
|
|
&& DECL_ABSTRACT_ORIGIN (p) != 0
|
|
|
|
|
&& DECL_ABSTRACT_ORIGIN (p) != p)
|
|
|
|
|
TREE_ADDRESSABLE (DECL_ABSTRACT_ORIGIN (p)) = 1;
|
|
|
|
|
goto normal;
|
|
|
|
|
|
|
|
|
|
case VAR_DECL:
|
2003-08-22 08:45:14 +02:00
|
|
|
|
/* Keep this in sync with stmt.c:warn_about_unused_variables.
|
2003-08-01 20:41:40 +02:00
|
|
|
|
No warnings when the global scope is popped because the
|
|
|
|
|
global scope isn't popped for the last translation unit,
|
|
|
|
|
so the warnings are done in c_write_global_declaration. */
|
|
|
|
|
if (warn_unused_variable && scope != global_scope
|
|
|
|
|
&& !TREE_USED (p)
|
|
|
|
|
&& !DECL_IN_SYSTEM_HEADER (p)
|
|
|
|
|
&& DECL_NAME (p)
|
|
|
|
|
&& !DECL_ARTIFICIAL (p))
|
|
|
|
|
warning ("%Hunused variable `%D'", locus, p);
|
|
|
|
|
/* fall through */
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
default:
|
|
|
|
|
normal:
|
|
|
|
|
if (DECL_NAME (p))
|
|
|
|
|
{
|
|
|
|
|
if (DECL_EXTERNAL (p) && scope != global_scope)
|
|
|
|
|
/* External decls stay in the symbol-value slot but are
|
|
|
|
|
inaccessible. */
|
|
|
|
|
C_DECL_INVISIBLE (p) = 1;
|
|
|
|
|
else
|
|
|
|
|
IDENTIFIER_SYMBOL_VALUE (DECL_NAME (p)) = 0;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
/* Clear out the parameter bindings in this scope, if any.
|
|
|
|
|
Unused-parameter warnings are handled by function.c. */
|
|
|
|
|
for (p = scope->parms; p; p = TREE_CHAIN (p))
|
|
|
|
|
if (DECL_NAME (p))
|
|
|
|
|
IDENTIFIER_SYMBOL_VALUE (DECL_NAME (p)) = 0;
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
/* Clear out the tag-meanings declared in this scope.
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
Set the TYPE_CONTEXTs for all of the tagged types belonging to
|
|
|
|
|
this scope so that they point to the appropriate construct, i.e.
|
|
|
|
|
either to the current FUNCTION_DECL node, or else to the BLOCK
|
|
|
|
|
node we just constructed.
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
Note that for tagged types whose scope is just the formal
|
|
|
|
|
parameter list for some function type specification, we can't
|
|
|
|
|
properly set their TYPE_CONTEXTs here, because we don't have a
|
|
|
|
|
pointer to the appropriate FUNCTION_TYPE node readily available
|
|
|
|
|
to us. For those cases, the TYPE_CONTEXTs of the relevant tagged
|
|
|
|
|
type nodes get set in `grokdeclarator' as soon as we have created
|
|
|
|
|
the FUNCTION_TYPE node which will represent the "scope" for these
|
|
|
|
|
"parameter list local" tagged types. */
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
decl = scope->function_body ? current_function_decl : block;
|
|
|
|
|
for (p = scope->tags; p; p = TREE_CHAIN (p))
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
{
|
2003-08-01 20:41:40 +02:00
|
|
|
|
if (TREE_PURPOSE (p))
|
|
|
|
|
IDENTIFIER_TAG_VALUE (TREE_PURPOSE (p)) = 0;
|
|
|
|
|
if (decl)
|
|
|
|
|
TYPE_CONTEXT (TREE_VALUE (p)) = decl;
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
/* Restore all name- and label-meanings from outer scopes that were
|
|
|
|
|
shadowed by this scope. */
|
|
|
|
|
for (p = scope->shadowed; p; p = TREE_CHAIN (p))
|
|
|
|
|
if (TREE_VALUE (p) && TREE_CODE (TREE_VALUE (p)) == LABEL_DECL)
|
|
|
|
|
IDENTIFIER_LABEL_VALUE (TREE_PURPOSE (p)) = TREE_VALUE (p);
|
|
|
|
|
else
|
|
|
|
|
IDENTIFIER_SYMBOL_VALUE (TREE_PURPOSE (p)) = TREE_VALUE (p);
|
2000-09-19 09:59:58 +02:00
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
/* Restore all tag-meanings from outer scopes that were shadowed by
|
|
|
|
|
this scope. */
|
|
|
|
|
for (p = scope->shadowed_tags; p; p = TREE_CHAIN (p))
|
|
|
|
|
IDENTIFIER_TAG_VALUE (TREE_PURPOSE (p)) = TREE_VALUE (p);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
/* Dispose of the block that we just made inside some higher level. */
|
|
|
|
|
if (scope->function_body)
|
|
|
|
|
DECL_INITIAL (current_function_decl) = block;
|
|
|
|
|
else if (scope->outer)
|
1992-08-26 08:03:24 +02:00
|
|
|
|
{
|
2003-08-01 20:41:40 +02:00
|
|
|
|
if (block)
|
|
|
|
|
SCOPE_LIST_APPEND (scope->outer, blocks, block);
|
|
|
|
|
/* If we did not make a block for the scope just exited, any
|
|
|
|
|
blocks made for inner scopes must be carried forward so they
|
|
|
|
|
will later become subblocks of something else. */
|
|
|
|
|
else if (scope->blocks)
|
|
|
|
|
SCOPE_LIST_CONCAT (scope->outer, blocks, scope, blocks);
|
1992-08-26 08:03:24 +02:00
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
/* Pop the current scope, and free the structure for reuse. */
|
|
|
|
|
pop_scope ();
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
return block;
|
|
|
|
|
}
|
1992-08-26 08:03:24 +02:00
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
/* Insert BLOCK at the end of the list of subblocks of the current
|
|
|
|
|
scope. This is used when a BIND_EXPR is expanded, to handle the
|
|
|
|
|
BLOCK node inside the BIND_EXPR. */
|
1992-08-26 08:03:24 +02:00
|
|
|
|
|
|
|
|
|
void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
insert_block (tree block)
|
1992-08-26 08:03:24 +02:00
|
|
|
|
{
|
|
|
|
|
TREE_USED (block) = 1;
|
2003-08-01 20:41:40 +02:00
|
|
|
|
SCOPE_LIST_APPEND (current_scope, blocks, block);
|
1992-08-26 08:03:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
/* Set the BLOCK node for the innermost scope (the one we are
|
|
|
|
|
currently in). The RTL expansion machinery requires us to provide
|
|
|
|
|
this hook, but it is not useful in function-at-a-time mode. */
|
1992-08-26 08:03:24 +02:00
|
|
|
|
|
1992-09-01 22:30:57 +02:00
|
|
|
|
void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
set_block (tree block ATTRIBUTE_UNUSED)
|
1992-08-26 08:03:24 +02:00
|
|
|
|
{
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* Push a definition or a declaration of struct, union or enum tag "name".
|
|
|
|
|
"type" should be the type node.
|
|
|
|
|
We assume that the tag "name" is not already defined.
|
|
|
|
|
|
|
|
|
|
Note that the definition may really be just a forward reference.
|
|
|
|
|
In that case, the TYPE_SIZE will be zero. */
|
|
|
|
|
|
|
|
|
|
void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
pushtag (tree name, tree type)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-24 18:59:32 +02:00
|
|
|
|
struct c_scope *b = current_scope;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-29 00:19:46 +02:00
|
|
|
|
/* Record the identifier as the type's name if it has none. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (name)
|
|
|
|
|
{
|
|
|
|
|
if (TYPE_NAME (type) == 0)
|
|
|
|
|
TYPE_NAME (type) = name;
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
|
|
|
|
|
if (IDENTIFIER_TAG_VALUE (name))
|
|
|
|
|
b->shadowed_tags = tree_cons (name, IDENTIFIER_TAG_VALUE (name),
|
|
|
|
|
b->shadowed_tags);
|
|
|
|
|
IDENTIFIER_TAG_VALUE (name) = type;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
c-common.c, [...]: Remove all references to obstack functions obsoleted by GC...
* c-common.c, c-decl.c, c-lang.c, c-lex.c, c-parse.in, c-pragma.c,
c-typeck.c, objc/objc-act.c: Remove all references to obstack
functions obsoleted by GC, such as push_obstacks_nochange,
end_temporary_allocation, savealloc, saveable_tree_cons, etc.
and code which existed only to decide whether or not to call
them. Remove now-unused NESTED argument from start_function;
all callers changed. Do not change behavior based on ggc_p.
The use of the ixp_obstack in c-iterate.c and the util_obstack
in objc/objc-act.c remain; these are not obsoleted by garbage
collection.
* c-tree.h: Update prototype for start_function.
* c-parse.y, c-parse.c, objc/objc-parse.c, objc/objc-parse.y: Rebuild.
From-SVN: r31611
2000-01-25 18:13:14 +01:00
|
|
|
|
b->tags = tree_cons (name, type, b->tags);
|
1992-03-08 23:08:20 +01:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Create a fake NULL-named TYPE_DECL node whose TREE_TYPE will be the
|
2003-07-24 18:59:32 +02:00
|
|
|
|
tagged type we just added to the current scope. This fake
|
1992-02-13 23:21:26 +01:00
|
|
|
|
NULL-named TYPE_DECL node helps dwarfout.c to know when it needs
|
1992-08-14 13:33:04 +02:00
|
|
|
|
to output a representation of a tagged type, and it also gives
|
1992-02-13 23:21:26 +01:00
|
|
|
|
us a convenient place to record the "scope start" address for the
|
|
|
|
|
tagged type. */
|
|
|
|
|
|
1992-07-07 00:35:53 +02:00
|
|
|
|
TYPE_STUB_DECL (type) = pushdecl (build_decl (TYPE_DECL, NULL_TREE, type));
|
1996-11-20 21:36:53 +01:00
|
|
|
|
|
|
|
|
|
/* An approximation for now, so we can tell this is a function-scope tag.
|
|
|
|
|
This will be updated in poplevel. */
|
|
|
|
|
TYPE_CONTEXT (type) = DECL_CONTEXT (TYPE_STUB_DECL (type));
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-24 22:44:01 +02:00
|
|
|
|
/* Subroutine of duplicate_decls. Allow harmless mismatches in return
|
|
|
|
|
and argument types provided that the type modes match. This function
|
|
|
|
|
return a unified type given a suitable match, and 0 otherwise. */
|
|
|
|
|
|
|
|
|
|
static tree
|
|
|
|
|
match_builtin_function_types (tree oldtype, tree newtype)
|
|
|
|
|
{
|
|
|
|
|
tree newrettype, oldrettype;
|
|
|
|
|
tree newargs, oldargs;
|
|
|
|
|
tree trytype, tryargs;
|
|
|
|
|
|
|
|
|
|
/* Accept the return type of the new declaration if same modes. */
|
|
|
|
|
oldrettype = TREE_TYPE (oldtype);
|
|
|
|
|
newrettype = TREE_TYPE (newtype);
|
|
|
|
|
|
|
|
|
|
if (TYPE_MODE (oldrettype) != TYPE_MODE (newrettype))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
oldargs = TYPE_ARG_TYPES (oldtype);
|
|
|
|
|
newargs = TYPE_ARG_TYPES (newtype);
|
|
|
|
|
tryargs = newargs;
|
|
|
|
|
|
|
|
|
|
while (oldargs || newargs)
|
|
|
|
|
{
|
|
|
|
|
if (! oldargs
|
|
|
|
|
|| ! newargs
|
|
|
|
|
|| ! TREE_VALUE (oldargs)
|
|
|
|
|
|| ! TREE_VALUE (newargs)
|
|
|
|
|
|| TYPE_MODE (TREE_VALUE (oldargs))
|
|
|
|
|
!= TYPE_MODE (TREE_VALUE (newargs)))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
oldargs = TREE_CHAIN (oldargs);
|
|
|
|
|
newargs = TREE_CHAIN (newargs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
trytype = build_function_type (newrettype, tryargs);
|
|
|
|
|
return build_type_attribute_variant (trytype, TYPE_ATTRIBUTES (oldtype));
|
|
|
|
|
}
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Handle when a new declaration NEWDECL
|
|
|
|
|
has the same name as an old one OLDDECL
|
|
|
|
|
in the same binding contour.
|
|
|
|
|
Prints an error message if appropriate.
|
|
|
|
|
|
|
|
|
|
If safely possible, alter OLDDECL to look like NEWDECL, and return 1.
|
1995-11-29 19:55:34 +01:00
|
|
|
|
Otherwise, return 0.
|
|
|
|
|
|
|
|
|
|
When DIFFERENT_BINDING_LEVEL is true, NEWDECL is an external declaration,
|
2003-07-24 18:59:32 +02:00
|
|
|
|
and OLDDECL is in an outer scope and should thus not be changed. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
static int
|
2003-07-11 10:33:21 +02:00
|
|
|
|
duplicate_decls (tree newdecl, tree olddecl, int different_binding_level,
|
|
|
|
|
int different_tu)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-11 10:33:21 +02:00
|
|
|
|
int types_match = comptypes (TREE_TYPE (newdecl), TREE_TYPE (olddecl),
|
2003-08-30 23:24:19 +02:00
|
|
|
|
COMPARE_STRICT);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
int new_is_definition = (TREE_CODE (newdecl) == FUNCTION_DECL
|
|
|
|
|
&& DECL_INITIAL (newdecl) != 0);
|
1992-06-29 06:54:53 +02:00
|
|
|
|
tree oldtype = TREE_TYPE (olddecl);
|
|
|
|
|
tree newtype = TREE_TYPE (newdecl);
|
1999-01-27 02:43:17 +01:00
|
|
|
|
int errmsg = 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
builtin.c (get_pointer_alignment): Use DECL_P and TYPE_P macros.
* builtin.c (get_pointer_alignment): Use DECL_P and TYPE_P macros.
* c-common.c (decl_attributes,check_format_info,truthvalue_conversion,
c_get_alias_set): Likewise.
* c-decl.c (duplicate_decls): Likewise.
* c-typeck.c (default_conversion,build_unary_op): Likewise.
* calls.c (initialize_argument_information): Likewise.
* dwarf2out.c (decl_class_context,add_abstract_origin_attribute):
Likewise.
* dwarfout.c (decl_class_context,output_type): Likewise.
* expr.c (get_inner_reference): Likewise.
* fold-const.c (simple_operand_p,fold): Likewise.
* function.c (aggregate_value_p): Likewise.
* stmt.c (expand_asm_operands): Likewise.
* varasm.c (named_section): Likewise.
* call.c (check_dtor_name,build_new_method_call): Likewise.
* decl.c (push_class_binding,poplevel,pushtag,lookup_namespace_name,
make_typename_type,check_initializer,cp_finish_decl,xref_tag): Likewise.
* decl2.c (grokfield,build_expr_from_tree,build_expr_from_tree,
decl_namespace,arg_assoc_template_arg,arg_assoc,
validate_nonmember_using_decl,do_class_using_decl): Likewise.
* error.c (dump_template_argument,dump_expr,cp_file_of,cp_line_of,
args_to_string): Likewise.
* friend.c (is_friend): Likewise.
* lex.c (note_got_semicolon,note_list_got_semicolon,is_global): Likewise.
* method.c (build_overload_nested_name,build_overload_value,
build_qualified_name,build_qualified_name,hack_identifier): Likewise.
* parse.y (typename_sub,typename_sub1): Likewise.
* pt.c (push_inline_template_parms_recursive,check_template_shadow,
process_partial_specialization,convert_template_argument,
template_args_equal,add_pending_template,lookup_template_class,
for_each_template_parm_r,maybe_fold_nontype_arg,
tsubst,instantiate_template,type_unification_real,unify,
instantiate_pending_templates,set_mangled_name_for_template_decl):
Likewise.
* repo.c (repo_get_id,repo_template_used): Likewise.
* search.c (lookup_field_1): Likewise.
* tree.c (walk_tree,get_type_decl,cp_tree_equal,member_p): Likewise.
* xref.c (classname): Likewise.
From-SVN: r32698
2000-03-23 01:41:05 +01:00
|
|
|
|
if (DECL_P (olddecl))
|
2001-10-18 20:29:02 +02:00
|
|
|
|
{
|
|
|
|
|
if (TREE_CODE (newdecl) == FUNCTION_DECL
|
|
|
|
|
&& TREE_CODE (olddecl) == FUNCTION_DECL
|
|
|
|
|
&& (DECL_UNINLINABLE (newdecl) || DECL_UNINLINABLE (olddecl)))
|
|
|
|
|
{
|
|
|
|
|
if (DECL_DECLARED_INLINE_P (newdecl)
|
|
|
|
|
&& DECL_UNINLINABLE (newdecl)
|
|
|
|
|
&& lookup_attribute ("noinline", DECL_ATTRIBUTES (newdecl)))
|
|
|
|
|
/* Already warned elsewhere. */;
|
|
|
|
|
else if (DECL_DECLARED_INLINE_P (olddecl)
|
|
|
|
|
&& DECL_UNINLINABLE (olddecl)
|
|
|
|
|
&& lookup_attribute ("noinline", DECL_ATTRIBUTES (olddecl)))
|
|
|
|
|
/* Already warned. */;
|
|
|
|
|
else if (DECL_DECLARED_INLINE_P (newdecl)
|
|
|
|
|
&& ! DECL_DECLARED_INLINE_P (olddecl)
|
|
|
|
|
&& DECL_UNINLINABLE (olddecl)
|
|
|
|
|
&& lookup_attribute ("noinline", DECL_ATTRIBUTES (olddecl)))
|
|
|
|
|
{
|
2003-07-19 12:19:19 +02:00
|
|
|
|
warning ("%Hfunction '%D' redeclared as inline",
|
|
|
|
|
&DECL_SOURCE_LOCATION (newdecl), newdecl);
|
|
|
|
|
warning ("%Hprevious declaration of function '%D' "
|
|
|
|
|
"with attribute noinline",
|
|
|
|
|
&DECL_SOURCE_LOCATION (olddecl), olddecl);
|
2001-10-18 20:29:02 +02:00
|
|
|
|
}
|
|
|
|
|
else if (DECL_DECLARED_INLINE_P (olddecl)
|
|
|
|
|
&& DECL_UNINLINABLE (newdecl)
|
|
|
|
|
&& lookup_attribute ("noinline", DECL_ATTRIBUTES (newdecl)))
|
|
|
|
|
{
|
2003-07-19 12:19:19 +02:00
|
|
|
|
warning ("%Hfunction '%D' redeclared with attribute noinline",
|
|
|
|
|
&DECL_SOURCE_LOCATION (newdecl), newdecl);
|
|
|
|
|
warning ("%Hprevious declaration of function '%D' was inline",
|
|
|
|
|
&DECL_SOURCE_LOCATION (olddecl), olddecl);
|
2001-10-18 20:29:02 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DECL_ATTRIBUTES (newdecl)
|
|
|
|
|
= (*targetm.merge_decl_attributes) (olddecl, newdecl);
|
|
|
|
|
}
|
1995-02-21 23:56:58 +01:00
|
|
|
|
|
1992-06-29 06:54:53 +02:00
|
|
|
|
if (TREE_CODE (newtype) == ERROR_MARK
|
|
|
|
|
|| TREE_CODE (oldtype) == ERROR_MARK)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
types_match = 0;
|
|
|
|
|
|
|
|
|
|
/* New decl is completely inconsistent with the old one =>
|
|
|
|
|
tell caller to replace the old one.
|
|
|
|
|
This is always an error except in the case of shadowing a builtin. */
|
|
|
|
|
if (TREE_CODE (olddecl) != TREE_CODE (newdecl))
|
|
|
|
|
{
|
|
|
|
|
if (TREE_CODE (olddecl) == FUNCTION_DECL
|
2003-04-14 05:13:07 +02:00
|
|
|
|
&& DECL_BUILT_IN (olddecl))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
1993-10-08 05:59:33 +01:00
|
|
|
|
/* If you declare a built-in or predefined function name as static,
|
|
|
|
|
the old definition is overridden,
|
1992-02-13 23:21:26 +01:00
|
|
|
|
but optionally warn this was a bad choice of name. */
|
|
|
|
|
if (!TREE_PUBLIC (newdecl))
|
|
|
|
|
{
|
2003-04-14 05:13:07 +02:00
|
|
|
|
if (warn_shadow)
|
2003-07-19 12:19:19 +02:00
|
|
|
|
warning ("%Hshadowing built-in function '%D'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (newdecl), newdecl);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2003-07-19 12:19:19 +02:00
|
|
|
|
warning ("%Hbuilt-in function '%D' declared as non-function",
|
|
|
|
|
&DECL_SOURCE_LOCATION (newdecl), newdecl);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%H'%D' redeclared as different kind of symbol",
|
|
|
|
|
&DECL_SOURCE_LOCATION (newdecl), newdecl);
|
|
|
|
|
error ("%Hprevious declaration of '%D'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (olddecl), olddecl);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
/* For real parm decl following a forward decl, return 1 so old decl
|
|
|
|
|
will be reused. Only allow this to happen once. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (types_match && TREE_CODE (newdecl) == PARM_DECL
|
|
|
|
|
&& TREE_ASM_WRITTEN (olddecl) && ! TREE_ASM_WRITTEN (newdecl))
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
{
|
|
|
|
|
TREE_ASM_WRITTEN (olddecl) = 0;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* The new declaration is the same kind of object as the old one.
|
|
|
|
|
The declarations may partially match. Print warnings if they don't
|
|
|
|
|
match enough. Ultimately, copy most of the information from the new
|
|
|
|
|
decl to the old one, and keep using the old one. */
|
|
|
|
|
|
c-common.c, [...]: Delete code implementing -traditional mode.
* c-common.c, c-common.h, c-decl.c, c-lex.c, c-parse.in,
c-tree.h, c-typeck.c, cppexp.c, cpplex.c, cpplib.c, cpplib.h,
cppmacro.c, objc/lang-specs.h, objc/objc-act.c,
builtin-types.def, builtins.def, dwarf2out.c, dwarfout.c,
gcc.c, toplev.c: Delete code implementing -traditional mode.
* ada/misc.c, ch/ch-tree.h, ch/decl.c, cp/decl2.c, f/com.c,
f/lex.c, f/top.c, java/builtins.c, java/decl.c: Delete
traditional-mode-related code copied from the C front end
but not used, or used only to permit the compiler to link.
* doc/bugreport.texi, doc/cpp.texi, doc/extend.texi,
doc/invoke.texi, doc/standards.texi, doc/trouble.texi:
Document removal of -traditional mode for compilation, and
remove documentation only relevant to that mode.
* config/nextstep.h, config/ptx4.h, config/svr4.h,
config/convex/convex.h, config/d30v/d30v.h,
config/i386/dgux.h, config/i386/osf1elf.h,
config/i386/osfelf.h, config/i386/osfrose.h,
config/i386/sco5.h, config/i386/sol2.h, config/m68k/a-ux.h,
config/m68k/hp310.h, config/m88k/dgux.h,
config/m88k/dguxbcs.h, config/m88k/luna.h, config/m88k/m88k.c,
config/m88k/m88k.h, config/m88k/openbsd.h,
config/mips/abi64.h, config/mips/osfrose.h,
config/mips/svr4-5.h, config/mips/svr4-t.h,
config/sparc/sol2-sld-64.h, config/sparc/sol2.h,
config/stormy16/stormy16.h: Remove all references to
-traditional from target specs. Delete all mention of the
no-longer-necessary TRADITIONAL_RETURN_FLOAT macro. Also
delete a couple of commented-out definitions of
DOLLARS_IN_IDENTIFIERS, with (incorrect) commentary referring
to -traditional.
* system.h: Poison TRADITIONAL_RETURN_FLOAT.
* doc/tm.texi: Remove mention of TRADITIONAL_RETURN_FLOAT macro.
* testsuite/gcc.c-torture/execute/920730-1t.c,
testsuite/gcc.c-torture/execute/920730-1t.x,
testsuite/gcc.dg/ext-glob.c: Delete test cases, only relevant
to -traditional.
From-SVN: r50110
2002-02-27 19:48:07 +01:00
|
|
|
|
if (TREE_CODE (olddecl) == FUNCTION_DECL && DECL_BUILT_IN (olddecl))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
1992-06-21 23:15:34 +02:00
|
|
|
|
/* A function declaration for a built-in function. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (!TREE_PUBLIC (newdecl))
|
|
|
|
|
{
|
|
|
|
|
/* If you declare a built-in function name as static, the
|
|
|
|
|
built-in definition is overridden,
|
|
|
|
|
but optionally warn this was a bad choice of name. */
|
|
|
|
|
if (warn_shadow)
|
2003-07-19 12:19:19 +02:00
|
|
|
|
warning ("%Hshadowing built-in function '%D'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (newdecl), newdecl);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Discard the old built-in function. */
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2003-07-26 15:27:20 +02:00
|
|
|
|
if (!types_match)
|
1992-07-01 04:20:59 +02:00
|
|
|
|
{
|
2003-07-24 22:44:01 +02:00
|
|
|
|
/* Accept harmless mismatch in function types.
|
2001-01-08 00:15:47 +01:00
|
|
|
|
This is for the ffs and fprintf builtins. */
|
2003-07-24 22:44:01 +02:00
|
|
|
|
tree trytype = match_builtin_function_types (oldtype, newtype);
|
2000-08-11 00:01:22 +02:00
|
|
|
|
|
2003-07-24 22:44:01 +02:00
|
|
|
|
if (trytype)
|
|
|
|
|
{
|
2003-08-30 23:24:19 +02:00
|
|
|
|
types_match = comptypes (newtype, trytype, COMPARE_STRICT);
|
1992-11-25 18:33:21 +01:00
|
|
|
|
if (types_match)
|
1995-11-29 19:55:34 +01:00
|
|
|
|
oldtype = trytype;
|
2003-07-24 22:44:01 +02:00
|
|
|
|
if (! different_binding_level)
|
|
|
|
|
TREE_TYPE (olddecl) = oldtype;
|
1992-07-01 04:20:59 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!types_match)
|
1992-06-21 23:18:59 +02:00
|
|
|
|
{
|
|
|
|
|
/* If types don't match for a built-in, throw away the built-in. */
|
2003-07-19 12:19:19 +02:00
|
|
|
|
warning ("%Hconflicting types for built-in function '%D'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (newdecl), newdecl);
|
1992-06-21 23:18:59 +02:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
else if (TREE_CODE (olddecl) == FUNCTION_DECL
|
1992-06-21 23:15:34 +02:00
|
|
|
|
&& DECL_SOURCE_LINE (olddecl) == 0)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
1992-06-21 23:15:34 +02:00
|
|
|
|
/* A function declaration for a predeclared function
|
|
|
|
|
that isn't actually built in. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (!TREE_PUBLIC (newdecl))
|
|
|
|
|
{
|
1992-08-14 13:33:04 +02:00
|
|
|
|
/* If you declare it as static, the
|
1992-06-21 23:15:34 +02:00
|
|
|
|
default definition is overridden. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else if (!types_match)
|
1992-06-21 23:15:34 +02:00
|
|
|
|
{
|
1992-06-22 03:35:52 +02:00
|
|
|
|
/* If the types don't match, preserve volatility indication.
|
|
|
|
|
Later on, we will discard everything else about the
|
|
|
|
|
default declaration. */
|
1992-06-21 23:15:34 +02:00
|
|
|
|
TREE_THIS_VOLATILE (newdecl) |= TREE_THIS_VOLATILE (olddecl);
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
1992-07-07 04:11:08 +02:00
|
|
|
|
/* Permit char *foo () to match void *foo (...) if not pedantic,
|
|
|
|
|
if one of them came from a system header file. */
|
1992-06-29 06:26:19 +02:00
|
|
|
|
else if (!types_match
|
|
|
|
|
&& TREE_CODE (olddecl) == FUNCTION_DECL
|
|
|
|
|
&& TREE_CODE (newdecl) == FUNCTION_DECL
|
1992-06-29 06:54:53 +02:00
|
|
|
|
&& TREE_CODE (TREE_TYPE (oldtype)) == POINTER_TYPE
|
|
|
|
|
&& TREE_CODE (TREE_TYPE (newtype)) == POINTER_TYPE
|
1992-07-07 04:11:08 +02:00
|
|
|
|
&& (DECL_IN_SYSTEM_HEADER (olddecl)
|
|
|
|
|
|| DECL_IN_SYSTEM_HEADER (newdecl))
|
1992-07-25 01:52:30 +02:00
|
|
|
|
&& ((TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (newtype))) == void_type_node
|
1992-06-29 06:54:53 +02:00
|
|
|
|
&& TYPE_ARG_TYPES (oldtype) == 0
|
|
|
|
|
&& self_promoting_args_p (TYPE_ARG_TYPES (newtype))
|
|
|
|
|
&& TREE_TYPE (TREE_TYPE (oldtype)) == char_type_node)
|
1992-06-29 06:26:19 +02:00
|
|
|
|
||
|
1992-06-29 06:54:53 +02:00
|
|
|
|
(TREE_TYPE (TREE_TYPE (newtype)) == char_type_node
|
|
|
|
|
&& TYPE_ARG_TYPES (newtype) == 0
|
|
|
|
|
&& self_promoting_args_p (TYPE_ARG_TYPES (oldtype))
|
1992-07-25 01:52:30 +02:00
|
|
|
|
&& TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (oldtype))) == void_type_node)))
|
1992-06-29 06:26:19 +02:00
|
|
|
|
{
|
|
|
|
|
if (pedantic)
|
2003-07-19 12:19:19 +02:00
|
|
|
|
pedwarn ("%Hconflicting types for '%D'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (newdecl), newdecl);
|
1992-06-29 06:54:53 +02:00
|
|
|
|
/* Make sure we keep void * as ret type, not char *. */
|
1992-07-25 01:52:30 +02:00
|
|
|
|
if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (oldtype))) == void_type_node)
|
1992-06-29 06:54:53 +02:00
|
|
|
|
TREE_TYPE (newdecl) = newtype = oldtype;
|
1994-07-03 01:09:49 +02:00
|
|
|
|
|
|
|
|
|
/* Set DECL_IN_SYSTEM_HEADER, so that if we see another declaration
|
|
|
|
|
we will come back here again. */
|
|
|
|
|
DECL_IN_SYSTEM_HEADER (newdecl) = 1;
|
1992-06-29 06:26:19 +02:00
|
|
|
|
}
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
/* Permit void foo (...) to match int foo (...) if the latter is the
|
|
|
|
|
definition and implicit int was used. See c-torture/compile/920625-2.c. */
|
|
|
|
|
else if (!types_match && new_is_definition
|
|
|
|
|
&& TREE_CODE (olddecl) == FUNCTION_DECL
|
|
|
|
|
&& TREE_CODE (newdecl) == FUNCTION_DECL
|
|
|
|
|
&& TYPE_MAIN_VARIANT (TREE_TYPE (oldtype)) == void_type_node
|
|
|
|
|
&& TYPE_MAIN_VARIANT (TREE_TYPE (newtype)) == integer_type_node
|
|
|
|
|
&& C_FUNCTION_IMPLICIT_INT (newdecl))
|
|
|
|
|
{
|
2003-07-19 12:19:19 +02:00
|
|
|
|
pedwarn ("%Hconflicting types for '%D'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (newdecl), newdecl);
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
/* Make sure we keep void as the return type. */
|
|
|
|
|
TREE_TYPE (newdecl) = newtype = oldtype;
|
|
|
|
|
C_FUNCTION_IMPLICIT_INT (newdecl) = 0;
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
else if (!types_match
|
|
|
|
|
/* Permit char *foo (int, ...); followed by char *foo ();
|
|
|
|
|
if not pedantic. */
|
|
|
|
|
&& ! (TREE_CODE (olddecl) == FUNCTION_DECL
|
|
|
|
|
&& ! pedantic
|
|
|
|
|
/* Return types must still match. */
|
1992-06-29 06:54:53 +02:00
|
|
|
|
&& comptypes (TREE_TYPE (oldtype),
|
2003-08-30 23:24:19 +02:00
|
|
|
|
TREE_TYPE (newtype), COMPARE_STRICT)
|
1992-06-29 06:54:53 +02:00
|
|
|
|
&& TYPE_ARG_TYPES (newtype) == 0))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hconflicting types for '%D'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (newdecl), newdecl);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Check for function type mismatch
|
|
|
|
|
involving an empty arglist vs a nonempty one. */
|
|
|
|
|
if (TREE_CODE (olddecl) == FUNCTION_DECL
|
1992-06-29 06:54:53 +02:00
|
|
|
|
&& comptypes (TREE_TYPE (oldtype),
|
2003-08-30 23:24:19 +02:00
|
|
|
|
TREE_TYPE (newtype), COMPARE_STRICT)
|
1992-06-29 06:54:53 +02:00
|
|
|
|
&& ((TYPE_ARG_TYPES (oldtype) == 0
|
1992-02-13 23:21:26 +01:00
|
|
|
|
&& DECL_INITIAL (olddecl) == 0)
|
|
|
|
|
||
|
1992-06-29 06:54:53 +02:00
|
|
|
|
(TYPE_ARG_TYPES (newtype) == 0
|
1992-02-13 23:21:26 +01:00
|
|
|
|
&& DECL_INITIAL (newdecl) == 0)))
|
|
|
|
|
{
|
|
|
|
|
/* Classify the problem further. */
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree t = TYPE_ARG_TYPES (oldtype);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (t == 0)
|
1992-06-29 06:54:53 +02:00
|
|
|
|
t = TYPE_ARG_TYPES (newtype);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
for (; t; t = TREE_CHAIN (t))
|
|
|
|
|
{
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree type = TREE_VALUE (t);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
1992-07-25 01:52:30 +02:00
|
|
|
|
if (TREE_CHAIN (t) == 0
|
|
|
|
|
&& TYPE_MAIN_VARIANT (type) != void_type_node)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
c-decl.c (duplicate_decls, [...]): Remove leading capital from diagnostics.
* c-decl.c (duplicate_decls, push_parm_decl): Remove leading
capital from diagnostics.
* c-lex.c (cb_file_change): Similarly.
* c-parse.in : Similarly.
* cfgrtl.c (verify_flow_info): Similarly.
* collect2.c: Similarly.
* cppfiles.c (find_include_file): Similarly.
* cppinit.c (cpp_handle_option): Similarly.
* cpplex.c (cpp_spell_token): Similarly.
* cppmain.c (do_preprocessing): Similarly.
* gcc.c (translate_options, process_command, do_spec1,
main, pfatal_execute): Similarly.
* genattr.c (main): Similarly.
* genattrtab.c (check_attr_test, operate_exp, simplify_test_exp,
write_test_expr, main): Similarly.
* gencodes.c (main): Similarly.
* genconfig.c (main): Similarly.
* genconstants.c (main): Similarly.
* genemit.c (main): Similarly.
* genextract.c (main): Similarly.
* genflags.c (main): Similarly.
* genopinit.c (main): Similarly.
* genoutput.c (process_template, main): Similarly.
* genpeep.c (main): Similarly.
* genrecog.c (main): Similarly.
* gensupport.c (is_predicable, identify_predicable_attribute,
alter_predicate_for_insn, init_md_reader_args, main): Similarly.
* ggc-page.c (alloc_anon): Similarly.
* mips-tfile.c (add_string, add_procedure, add_file, read_line,
parse_begin, parse_bend, parse_def, parse_end, parse_file,
parse_stabs_common, parse_stabs, write_varray, write_object,
read_seek, copy_object, main, error): Similarly.
* profile.c (compute_branch_probabilities): Similarly.
* reg-stack.c (check_asm_stack_operands): Similarly.
* reload.c (find_reloads): Similarly.
* reload1.c (spill_failure, failed_reload): Similarly.
* rtl-error.c (_fatal_insn_not_found): Similarly.
* toplev.c (read_integral_parameter, crash_signal,
decode_f_option, set_target_switch, parse_options_and_default_flags)
: Similarly.
* tradcif.y (parse_number, yylex): Similarly.
* tradcpp.c (main, fancy_abort): Similarly.
* tree.c (tree_check_failed): Similarly.
* varray.c (varray_check_failed): Similarly.
* xcoffout.c (xcoff_output_standard_types): Similarly.
cp:
* call.c (build_java_interface_fn_ref): Similarly.
* except.c (is_admissible_throw_operand): Similarly.
* init.c (build_java_class_ref): Similarly.
* xref.c (open_xref_file): Similarly.
objc:
* objc-act.c (get_object_ref, lookup_and_install_protocols,
build_objc_string_object, objc_declare_alias, build_ivar_chain,
finish_message_expr, build_protocol_expr, is_public,
start_class): Similarly.
testsuite:
* objc.dg/alias.m: Update.
* objc.dg/class-1.m: Update.
* objc.dg/const-str-1.m: Update.
* objc.dg/fwd-proto-1.m: Update.
* objc.dg/id-1.m: Update.
* objc.dg/super-class-1.m: Update.
From-SVN: r47518
2001-12-02 01:04:36 +01:00
|
|
|
|
error ("a parameter list with an ellipsis can't match an empty parameter name list declaration");
|
1992-02-13 23:21:26 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2002-04-19 08:22:18 +02:00
|
|
|
|
if (c_type_promotes_to (type) != type)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
c-decl.c (duplicate_decls, [...]): Remove leading capital from diagnostics.
* c-decl.c (duplicate_decls, push_parm_decl): Remove leading
capital from diagnostics.
* c-lex.c (cb_file_change): Similarly.
* c-parse.in : Similarly.
* cfgrtl.c (verify_flow_info): Similarly.
* collect2.c: Similarly.
* cppfiles.c (find_include_file): Similarly.
* cppinit.c (cpp_handle_option): Similarly.
* cpplex.c (cpp_spell_token): Similarly.
* cppmain.c (do_preprocessing): Similarly.
* gcc.c (translate_options, process_command, do_spec1,
main, pfatal_execute): Similarly.
* genattr.c (main): Similarly.
* genattrtab.c (check_attr_test, operate_exp, simplify_test_exp,
write_test_expr, main): Similarly.
* gencodes.c (main): Similarly.
* genconfig.c (main): Similarly.
* genconstants.c (main): Similarly.
* genemit.c (main): Similarly.
* genextract.c (main): Similarly.
* genflags.c (main): Similarly.
* genopinit.c (main): Similarly.
* genoutput.c (process_template, main): Similarly.
* genpeep.c (main): Similarly.
* genrecog.c (main): Similarly.
* gensupport.c (is_predicable, identify_predicable_attribute,
alter_predicate_for_insn, init_md_reader_args, main): Similarly.
* ggc-page.c (alloc_anon): Similarly.
* mips-tfile.c (add_string, add_procedure, add_file, read_line,
parse_begin, parse_bend, parse_def, parse_end, parse_file,
parse_stabs_common, parse_stabs, write_varray, write_object,
read_seek, copy_object, main, error): Similarly.
* profile.c (compute_branch_probabilities): Similarly.
* reg-stack.c (check_asm_stack_operands): Similarly.
* reload.c (find_reloads): Similarly.
* reload1.c (spill_failure, failed_reload): Similarly.
* rtl-error.c (_fatal_insn_not_found): Similarly.
* toplev.c (read_integral_parameter, crash_signal,
decode_f_option, set_target_switch, parse_options_and_default_flags)
: Similarly.
* tradcif.y (parse_number, yylex): Similarly.
* tradcpp.c (main, fancy_abort): Similarly.
* tree.c (tree_check_failed): Similarly.
* varray.c (varray_check_failed): Similarly.
* xcoffout.c (xcoff_output_standard_types): Similarly.
cp:
* call.c (build_java_interface_fn_ref): Similarly.
* except.c (is_admissible_throw_operand): Similarly.
* init.c (build_java_class_ref): Similarly.
* xref.c (open_xref_file): Similarly.
objc:
* objc-act.c (get_object_ref, lookup_and_install_protocols,
build_objc_string_object, objc_declare_alias, build_ivar_chain,
finish_message_expr, build_protocol_expr, is_public,
start_class): Similarly.
testsuite:
* objc.dg/alias.m: Update.
* objc.dg/class-1.m: Update.
* objc.dg/const-str-1.m: Update.
* objc.dg/fwd-proto-1.m: Update.
* objc.dg/id-1.m: Update.
* objc.dg/super-class-1.m: Update.
From-SVN: r47518
2001-12-02 01:04:36 +01:00
|
|
|
|
error ("an argument type that has a default promotion can't match an empty parameter name list declaration");
|
1992-02-13 23:21:26 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
if (C_DECL_IMPLICIT (olddecl))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hprevious implicit declaration of '%D'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (olddecl), olddecl);
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
else
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hprevious declaration of '%D'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (olddecl), olddecl);
|
2003-02-10 13:45:54 +01:00
|
|
|
|
|
|
|
|
|
/* This is safer because the initializer might contain references
|
|
|
|
|
to variables that were declared between olddecl and newdecl. This
|
|
|
|
|
will make the initializer invalid for olddecl in case it gets
|
|
|
|
|
assigned to olddecl below. */
|
2003-03-12 10:54:38 +01:00
|
|
|
|
if (TREE_CODE (newdecl) == VAR_DECL)
|
|
|
|
|
DECL_INITIAL (newdecl) = 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
2002-08-07 03:25:01 +02:00
|
|
|
|
/* TLS cannot follow non-TLS declaration. */
|
|
|
|
|
else if (TREE_CODE (olddecl) == VAR_DECL && TREE_CODE (newdecl) == VAR_DECL
|
|
|
|
|
&& !DECL_THREAD_LOCAL (olddecl) && DECL_THREAD_LOCAL (newdecl))
|
|
|
|
|
{
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hthread-local declaration of '%D' follows non thread-local "
|
|
|
|
|
"declaration", &DECL_SOURCE_LOCATION (newdecl), newdecl);
|
|
|
|
|
error ("%Hprevious declaration of '%D'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (olddecl), olddecl);
|
2002-08-07 03:25:01 +02:00
|
|
|
|
}
|
|
|
|
|
/* non-TLS declaration cannot follow TLS declaration. */
|
|
|
|
|
else if (TREE_CODE (olddecl) == VAR_DECL && TREE_CODE (newdecl) == VAR_DECL
|
|
|
|
|
&& DECL_THREAD_LOCAL (olddecl) && !DECL_THREAD_LOCAL (newdecl))
|
|
|
|
|
{
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hnon thread-local declaration of '%D' follows "
|
|
|
|
|
"thread-local declaration",
|
|
|
|
|
&DECL_SOURCE_LOCATION (newdecl), newdecl);
|
|
|
|
|
error ("%Hprevious declaration of '%D'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (olddecl), olddecl);
|
2002-08-07 03:25:01 +02:00
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
1994-08-12 13:52:04 +02:00
|
|
|
|
errmsg = redeclaration_error_message (newdecl, olddecl);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (errmsg)
|
|
|
|
|
{
|
2003-07-19 12:19:19 +02:00
|
|
|
|
const location_t *locus = &DECL_SOURCE_LOCATION (newdecl);
|
1999-01-27 02:43:17 +01:00
|
|
|
|
switch (errmsg)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hredefinition of '%D'", locus, newdecl);
|
1999-01-27 02:43:17 +01:00
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hredeclaration of '%D'", locus, newdecl);
|
1999-01-27 02:43:17 +01:00
|
|
|
|
break;
|
|
|
|
|
case 3:
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hconflicting declarations of '%D'", locus, newdecl);
|
1999-01-27 02:43:17 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
abort ();
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-19 12:19:19 +02:00
|
|
|
|
locus = &DECL_SOURCE_LOCATION (olddecl);
|
|
|
|
|
if (DECL_INITIAL (olddecl)
|
2003-07-24 18:59:32 +02:00
|
|
|
|
&& current_scope == global_scope)
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%H'%D' previously defined here", locus, olddecl);
|
|
|
|
|
else
|
|
|
|
|
error ("%H'%D' previously declared here", locus, olddecl);
|
2002-02-20 23:59:35 +01:00
|
|
|
|
return 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
1995-02-21 23:56:58 +01:00
|
|
|
|
else if (TREE_CODE (newdecl) == TYPE_DECL
|
2000-08-11 00:01:22 +02:00
|
|
|
|
&& (DECL_IN_SYSTEM_HEADER (olddecl)
|
1995-02-21 23:56:58 +01:00
|
|
|
|
|| DECL_IN_SYSTEM_HEADER (newdecl)))
|
|
|
|
|
{
|
2003-07-19 12:19:19 +02:00
|
|
|
|
const location_t *locus = &DECL_SOURCE_LOCATION (newdecl);
|
|
|
|
|
warning ("%Hredefinition of '%D'", locus, newdecl);
|
|
|
|
|
locus = &DECL_SOURCE_LOCATION (olddecl);
|
|
|
|
|
if (DECL_INITIAL (olddecl)
|
2003-07-24 18:59:32 +02:00
|
|
|
|
&& current_scope == global_scope)
|
2003-07-19 12:19:19 +02:00
|
|
|
|
warning ("%H'%D' previously defined here", locus, olddecl);
|
|
|
|
|
else
|
|
|
|
|
warning ("%H'%D' previously declared here", locus, olddecl);
|
1995-02-21 23:56:58 +01:00
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
else if (TREE_CODE (olddecl) == FUNCTION_DECL
|
|
|
|
|
&& DECL_INITIAL (olddecl) != 0
|
1992-06-29 06:54:53 +02:00
|
|
|
|
&& TYPE_ARG_TYPES (oldtype) == 0
|
1995-04-25 19:30:35 +02:00
|
|
|
|
&& TYPE_ARG_TYPES (newtype) != 0
|
|
|
|
|
&& TYPE_ACTUAL_ARG_TYPES (oldtype) != 0)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree type, parm;
|
|
|
|
|
int nargs;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Prototype decl follows defn w/o prototype. */
|
|
|
|
|
|
1992-06-29 06:54:53 +02:00
|
|
|
|
for (parm = TYPE_ACTUAL_ARG_TYPES (oldtype),
|
|
|
|
|
type = TYPE_ARG_TYPES (newtype),
|
1992-02-13 23:21:26 +01:00
|
|
|
|
nargs = 1;
|
1999-01-27 02:43:17 +01:00
|
|
|
|
;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
parm = TREE_CHAIN (parm), type = TREE_CHAIN (type), nargs++)
|
|
|
|
|
{
|
1999-01-27 02:43:17 +01:00
|
|
|
|
if (TYPE_MAIN_VARIANT (TREE_VALUE (parm)) == void_type_node
|
|
|
|
|
&& TYPE_MAIN_VARIANT (TREE_VALUE (type)) == void_type_node)
|
|
|
|
|
{
|
2003-07-19 12:19:19 +02:00
|
|
|
|
const location_t *locus = &DECL_SOURCE_LOCATION (newdecl);
|
|
|
|
|
warning ("%Hprototype for '%D' follows", locus, newdecl);
|
|
|
|
|
locus = &DECL_SOURCE_LOCATION (olddecl);
|
|
|
|
|
warning ("%Hnon-prototype definition here", locus);
|
1999-01-27 02:43:17 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
1992-07-25 01:52:30 +02:00
|
|
|
|
if (TYPE_MAIN_VARIANT (TREE_VALUE (parm)) == void_type_node
|
|
|
|
|
|| TYPE_MAIN_VARIANT (TREE_VALUE (type)) == void_type_node)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-19 12:19:19 +02:00
|
|
|
|
const location_t *locus = &DECL_SOURCE_LOCATION (newdecl);
|
|
|
|
|
error ("%Hprototype for '%D' follows and number of "
|
|
|
|
|
"arguments doesn't match", locus, newdecl);
|
|
|
|
|
locus = &DECL_SOURCE_LOCATION (olddecl);
|
|
|
|
|
error ("%Hnon-prototype definition here", locus);
|
1999-01-27 02:43:17 +01:00
|
|
|
|
errmsg = 1;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
/* Type for passing arg must be consistent
|
|
|
|
|
with that declared for the arg. */
|
2003-07-11 10:33:21 +02:00
|
|
|
|
if (! comptypes (TREE_VALUE (parm), TREE_VALUE (type),
|
2003-08-30 23:24:19 +02:00
|
|
|
|
COMPARE_STRICT))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-19 12:19:19 +02:00
|
|
|
|
const location_t *locus = &DECL_SOURCE_LOCATION (newdecl);
|
|
|
|
|
error ("%Hprototype for '%D' follows and argument %d "
|
|
|
|
|
"doesn't match", locus, newdecl, nargs);
|
|
|
|
|
locus = &DECL_SOURCE_LOCATION (olddecl);
|
|
|
|
|
error ("%Hnon-prototype definition here", locus);
|
1999-01-27 02:43:17 +01:00
|
|
|
|
errmsg = 1;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
1992-05-15 04:18:01 +02:00
|
|
|
|
/* Warn about mismatches in various flags. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
2003-07-29 00:19:46 +02:00
|
|
|
|
const location_t *locus = &DECL_SOURCE_LOCATION (newdecl);
|
|
|
|
|
|
1992-05-15 04:18:01 +02:00
|
|
|
|
/* Warn if function is now inline
|
|
|
|
|
but was previously declared not inline and has been called. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (TREE_CODE (olddecl) == FUNCTION_DECL
|
2001-10-08 18:37:06 +02:00
|
|
|
|
&& ! DECL_DECLARED_INLINE_P (olddecl)
|
|
|
|
|
&& DECL_DECLARED_INLINE_P (newdecl)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
&& TREE_USED (olddecl))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
warning ("%H'%D' declared inline after being called",
|
2003-07-29 00:19:46 +02:00
|
|
|
|
locus, newdecl);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (TREE_CODE (olddecl) == FUNCTION_DECL
|
2001-10-08 18:37:06 +02:00
|
|
|
|
&& ! DECL_DECLARED_INLINE_P (olddecl)
|
|
|
|
|
&& DECL_DECLARED_INLINE_P (newdecl)
|
1992-07-05 23:12:43 +02:00
|
|
|
|
&& DECL_INITIAL (olddecl) != 0)
|
2003-07-19 12:19:19 +02:00
|
|
|
|
warning ("%H'%D' declared inline after its definition",
|
2003-07-29 00:19:46 +02:00
|
|
|
|
locus, newdecl);
|
1994-03-21 23:07:03 +01:00
|
|
|
|
|
|
|
|
|
/* If pedantic, warn when static declaration follows a non-static
|
2003-07-29 00:19:46 +02:00
|
|
|
|
declaration. Otherwise, do so only for functions. */
|
1994-03-21 23:07:03 +01:00
|
|
|
|
if ((pedantic || TREE_CODE (olddecl) == FUNCTION_DECL)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
&& TREE_PUBLIC (olddecl)
|
|
|
|
|
&& !TREE_PUBLIC (newdecl))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
warning ("%Hstatic declaration for '%D' follows non-static",
|
2003-07-29 00:19:46 +02:00
|
|
|
|
locus, newdecl);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
1999-01-16 17:43:26 +01:00
|
|
|
|
/* If warn_traditional, warn when a non-static function
|
2003-07-29 00:19:46 +02:00
|
|
|
|
declaration follows a static one. */
|
2000-08-21 16:54:28 +02:00
|
|
|
|
if (warn_traditional && !in_system_header
|
1999-01-16 17:43:26 +01:00
|
|
|
|
&& TREE_CODE (olddecl) == FUNCTION_DECL
|
|
|
|
|
&& !TREE_PUBLIC (olddecl)
|
|
|
|
|
&& TREE_PUBLIC (newdecl))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
warning ("%Hnon-static declaration for '%D' follows static",
|
2003-07-29 00:19:46 +02:00
|
|
|
|
locus, newdecl);
|
1999-01-16 17:43:26 +01:00
|
|
|
|
|
1994-04-18 23:56:01 +02:00
|
|
|
|
/* Warn when const declaration follows a non-const
|
|
|
|
|
declaration, but not for functions. */
|
|
|
|
|
if (TREE_CODE (olddecl) != FUNCTION_DECL
|
|
|
|
|
&& !TREE_READONLY (olddecl)
|
|
|
|
|
&& TREE_READONLY (newdecl))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
warning ("%Hconst declaration for '%D' follows non-const",
|
2003-07-29 00:19:46 +02:00
|
|
|
|
locus, newdecl);
|
1992-05-15 04:18:01 +02:00
|
|
|
|
/* These bits are logically part of the type, for variables.
|
|
|
|
|
But not for functions
|
|
|
|
|
(where qualifiers are not valid ANSI anyway). */
|
1994-04-18 23:56:01 +02:00
|
|
|
|
else if (pedantic && TREE_CODE (olddecl) != FUNCTION_DECL
|
1992-02-13 23:21:26 +01:00
|
|
|
|
&& (TREE_READONLY (newdecl) != TREE_READONLY (olddecl)
|
|
|
|
|
|| TREE_THIS_VOLATILE (newdecl) != TREE_THIS_VOLATILE (olddecl)))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
pedwarn ("%Htype qualifiers for '%D' conflict with previous "
|
2003-07-29 00:19:46 +02:00
|
|
|
|
"declaration", locus, newdecl);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1992-07-31 08:14:04 +02:00
|
|
|
|
/* Optionally warn about more than one declaration for the same name. */
|
1994-08-12 15:10:54 +02:00
|
|
|
|
if (errmsg == 0 && warn_redundant_decls && DECL_SOURCE_LINE (olddecl) != 0
|
1997-12-07 01:31:01 +01:00
|
|
|
|
/* Don't warn about a function declaration
|
1992-07-31 08:14:04 +02:00
|
|
|
|
followed by a definition. */
|
|
|
|
|
&& !(TREE_CODE (newdecl) == FUNCTION_DECL && DECL_INITIAL (newdecl) != 0
|
1993-07-06 08:12:49 +02:00
|
|
|
|
&& DECL_INITIAL (olddecl) == 0)
|
|
|
|
|
/* Don't warn about extern decl followed by (tentative) definition. */
|
|
|
|
|
&& !(DECL_EXTERNAL (olddecl) && ! DECL_EXTERNAL (newdecl)))
|
1992-07-31 08:14:04 +02:00
|
|
|
|
{
|
2003-07-19 12:19:19 +02:00
|
|
|
|
warning ("%Hredundant redeclaration of '%D' in same scope",
|
|
|
|
|
&DECL_SOURCE_LOCATION (newdecl), newdecl);
|
|
|
|
|
warning ("%Hprevious declaration of '%D'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (olddecl), olddecl);
|
1992-07-31 08:14:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Copy all the DECL_... slots specified in the new decl
|
1992-06-29 06:54:53 +02:00
|
|
|
|
except for any that we copy here from the old type.
|
|
|
|
|
|
|
|
|
|
Past this point, we don't change OLDTYPE and NEWTYPE
|
|
|
|
|
even if we change the types of NEWDECL and OLDDECL. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
if (types_match)
|
|
|
|
|
{
|
1995-11-29 19:55:34 +01:00
|
|
|
|
/* When copying info to olddecl, we store into write_olddecl
|
|
|
|
|
instead. This allows us to avoid modifying olddecl when
|
|
|
|
|
different_binding_level is true. */
|
|
|
|
|
tree write_olddecl = different_binding_level ? newdecl : olddecl;
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Merge the data types specified in the two decls. */
|
|
|
|
|
if (TREE_CODE (newdecl) != FUNCTION_DECL || !DECL_BUILT_IN (olddecl))
|
1995-11-29 19:55:34 +01:00
|
|
|
|
{
|
|
|
|
|
if (different_binding_level)
|
2001-01-25 03:03:14 +01:00
|
|
|
|
{
|
|
|
|
|
if (TYPE_ARG_TYPES (oldtype) != 0
|
|
|
|
|
&& TYPE_ARG_TYPES (newtype) == 0)
|
|
|
|
|
TREE_TYPE (newdecl) = common_type (newtype, oldtype);
|
|
|
|
|
else
|
|
|
|
|
TREE_TYPE (newdecl)
|
|
|
|
|
= build_type_attribute_variant
|
|
|
|
|
(newtype,
|
|
|
|
|
merge_attributes (TYPE_ATTRIBUTES (newtype),
|
|
|
|
|
TYPE_ATTRIBUTES (oldtype)));
|
|
|
|
|
}
|
1995-11-29 19:55:34 +01:00
|
|
|
|
else
|
|
|
|
|
TREE_TYPE (newdecl)
|
|
|
|
|
= TREE_TYPE (olddecl)
|
|
|
|
|
= common_type (newtype, oldtype);
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* Lay the type out, unless already done. */
|
|
|
|
|
if (oldtype != TREE_TYPE (newdecl))
|
|
|
|
|
{
|
|
|
|
|
if (TREE_TYPE (newdecl) != error_mark_node)
|
|
|
|
|
layout_type (TREE_TYPE (newdecl));
|
|
|
|
|
if (TREE_CODE (newdecl) != FUNCTION_DECL
|
|
|
|
|
&& TREE_CODE (newdecl) != TYPE_DECL
|
|
|
|
|
&& TREE_CODE (newdecl) != CONST_DECL)
|
|
|
|
|
layout_decl (newdecl, 0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Since the type is OLDDECL's, make OLDDECL's size go with. */
|
|
|
|
|
DECL_SIZE (newdecl) = DECL_SIZE (olddecl);
|
c-common.c (decl_attributes): Set DECL_SIZE_UNIT.
* c-common.c (decl_attributes): Set DECL_SIZE_UNIT.
* c-decl.c (duplicate_decls, finish_enum): Likewise.
(finish_decl): Remove -Wlarger-than code from here.
* flags.h (id_clash_len): Now int.
(larger_than_size): Now HOST_WIDE_INT.
* fold-const.c (size_int_wide): No more HIGH parm; NUMBER is signed.
Clean up checking to see if in table.
(make_bit_field_ref): Remove extra parm to bitsize_int.
* ggc-common.c (ggc_mark_tree_children): Mark DECL_SIZE_UNIT.
* print-tree.c (print_node): Print DECL_SIZE_UNIT and TYPE_SIZE_UNIT.
* stmt.c (expand_decl): Use DECL_SIZE_UNIT for stack checking size
and for computing size of decl.
* stor-layout.c (layout_decl): Set DECL_SIZE_UNIT.
Move -Wlarger-than code to here.
(layout_record): Remove extra arg to bitsize_int.
Set TYPE_BINFO_SIZE_UNIT.
(layout_union): Remove extra arg to bitsize_int.
Use proper type for size of QUAL_UNION.
(layout_type): Remove extra arg to bitsize_int.
* toplev.c (id_clash_len): Now int.
(larger_than_size): Now HOST_WIDE_INT.
(decode_W_option): Clean up id-clash and larger-than- cases.
* tree.c (get_identifier, maybe_get_identifier): Remove unneeded casts.
(expr_align, case FUNCTION_DECL): DECL_ALIGN is not defined.
* tree.h (BINFO_SIZE_UNIT, TYPE_BINFO_SIZE_UNIT, DECL_SIZE_UNIT): New.
(struct tree_decl): New field size_unit.
(size_int_wide): No HIGH operand; NUMBER is now signed.
(size_int_2): Deleted.
(size_int, bitsize_int): Don't use it and rework args.
* varasm.c (assemble_variable, output_constructor): Use DECL_SIZE_UNIT.
* ch/decl.c (layout_enum): Set DECL_SIZE_UNIT.
* ch/satisfy.c (safe_satisfy_decl): Likewise.
* cp/class.c (build_primary_vtable, layout_vtable_decl): Likewise.
(avoid_overlap, build_base_field): Likewise.
(build_base_field, build_base_fields, is_empty_class):
Test DECL_SIZE with integer_zero.
(layout_class_type): Set CLASSTYPE_SIZE_UNIT.
* cp/cp-tree.h (struct lang_type): New field size_unit.
(CLASSTYPE_SIZE_UNIT): New macro.
* cp/decl.c (init_decl_processing): Set DECL_SIZE_UNIT.
(cp_finish_decl): Delete -Wlarger-than processing.
* cp/optimize.c (remap_decl): Walk DECL_SIZE_UNIT.
* cp/pt.c (tsubst_decl): Set DECL_SIZE_UNIT.
* cp/tree.c (make_binfo): binfo vector is one entry longer.
(walk_tree): Walk DECL_SIZE_UNIT.
* f/com.c (ffecom_sym_transform): Use DECL_SIZE_UNIT.
(ffecom_transform_common_, ffecom_transform_equiv_): Likewise.
(duplicate_decls): Likewise.
(ffecom_tree_canonize_ptr_): Delete extra arg to bitsize_int.
(finish_decl): Delete -Wlarger-than processing.
* java/class.c (build_class_ref, push_super_field): Set DECL_SIZE_UNIT.
* java/constants.c (build_constants_constructor): Likewise.
From-SVN: r32068
2000-02-20 02:11:00 +01:00
|
|
|
|
DECL_SIZE_UNIT (newdecl) = DECL_SIZE_UNIT (olddecl);
|
1999-11-03 19:11:23 +01:00
|
|
|
|
DECL_MODE (newdecl) = DECL_MODE (olddecl);
|
1992-04-04 10:50:38 +02:00
|
|
|
|
if (TREE_CODE (olddecl) != FUNCTION_DECL)
|
|
|
|
|
if (DECL_ALIGN (olddecl) > DECL_ALIGN (newdecl))
|
2000-06-14 07:30:09 +02:00
|
|
|
|
{
|
|
|
|
|
DECL_ALIGN (newdecl) = DECL_ALIGN (olddecl);
|
|
|
|
|
DECL_USER_ALIGN (newdecl) |= DECL_ALIGN (olddecl);
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
1992-07-28 04:20:22 +02:00
|
|
|
|
/* Keep the old rtl since we can safely use it. */
|
varasm.c (assemble_alias): Use DECL_ASSEMBLER_NAME...
* varasm.c (assemble_alias): Use DECL_ASSEMBLER_NAME, not the
contents of the RTL, to determine the name of the object.
* tree.h (DECL_RTL): Allocate RTL lazily.
(SET_DECL_RTL): New macro.
(DECL_RTL_SET_P): Likewise.
(COPY_DECL_RTL): Likewise.
(DECL_RTL_IF_SET): Likewise.
* varasm.c (make_decl_rtl): Add assertions about the kind of
declaration we are processing.
* c-decl.c (duplicate_decls): Use COPY_DECL_RTL, DECL_RTL_SET_P, etc.
(start_decl): Likewise.
(finish_decl): Likewise.
* c-semantics.c (emit_local_var): Likewise.
* calls.c (expand_call): Likewise.
* dbxout.c (dbxout_symbol): Likewise.
* emit-rtl.c (unshare_all_rtl): Likewise.
(unshare_all_decls): Likewise.
(reset_used_decls): Likewise.
* expr.c (store_constructor): Likewise.
(safe_from_p): Likewise.
(expand_expr): Likewise.
* function.c (put_var_into_stack): Likewise.
(instantiate_decls_1): Likewise.
(assign_parms): Likewise.
(expand_function_start): Likewise.
(expand_function_end): Likewise.
* ggc-common.c (gcc_mark_trees): Likewise.
* integrate.c (function_cannot_inline_p): Likewise.
(copy_decl_for_inlining): Likewise.
(expand_inline_function): Likewise.
(integrate_parm_decls): Likewise.
(integrate_decl_tree): Likewise.
* print-tree.c (print_node): Likewise.
* reg-stack.c (stack_result): Likewise.
* stmt.c (label_rtx): Likewise.
(expand_return): Likewise.
(expand_decl): Likewise.
(expand_decl_cleanup): Likewise.
(expand_anon_union_decl): Likewise.
* toplev.c (check_global_declarations): Likewise.
(rest_of_decl_compilation): Likewise.
* tree.c (simple_cst_equal): Likewise.
* objc/objc-act.c (generate_static_references): Likewise.
* class.c (build_clone): Use COPY_DECL_RTL, DECL_RTL_SET_P, etc.
* cp-tree.h (DECL_IN_MEMORY_P): Likewise.
* decl.c (duplicate_decls): Likewise.
(builtin_function): Likewise.
(build_library_fn): Likewise.
(build_cp_library_fn): Likewise.
(check_initializer): Likewise.
(cp_finish_decl): Likewise.
* decl2.c (grokfield): Likewise.
(grok_function_init): Remove #if 0'd code.
(finish_anon_union): Use COPY_DECL_RTL, DECL_RTL_SET_P, etc.
* friend.c (do_friend): Likewise.
* init.c (get_temp_regvar): Likewise.
* method.c (make_thunk): Likewise.
* pt.c (tsubst_friend_function): Likewise.
(tsubst_decl): Likewise.
(regenerate_decl_from_template): Likewise.
* semantics.c (genrtl_named_return_value): Likewise.
(expand_body): Likewise.
(genrtl_finish_function): Likewise.
* tree.c (cp_tree_equal): Likewise.
* com.c (ffecom_member_phase_2): Use COPY_DECL_RTL,
DECL_RTL_SET_P, etc.
(duplicate_decls): Likewise.
(start_decl): Likewise.
* class.c (build_static_field_ref): Likewise.
(make_method_value): Likewise.
(get_dispatch_table): Likewise.
* decl.c (push_jvm_slot): Use COPY_DECL_RTL, DECL_RTL_SET_P, etc.
From-SVN: r40482
2001-03-15 03:51:03 +01:00
|
|
|
|
COPY_DECL_RTL (olddecl, newdecl);
|
1992-07-28 04:20:22 +02:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Merge the type qualifiers. */
|
|
|
|
|
if (TREE_READONLY (newdecl))
|
1995-11-29 19:55:34 +01:00
|
|
|
|
TREE_READONLY (write_olddecl) = 1;
|
c-convert.c (convert): Return if output or input type is ERROR_MARK.
* c-convert.c (convert): Return if output or input type is ERROR_MARK.
* c-decl.c (duplicate_decls): Only look at DECL_BUILT_IN_NONANSI
and DECL_INLINE if FUNCTION_DECL.
(pushdecl, redeclaration_error_message): Likewise, for DECL_INLINE.
(store_parm_decls): Check for type of PARM_DECL being ERROR_MARK.
Use DECL_WEAK, not DECL_RESULT, to flag for already seen.
(combine_parm_decls): Likewise.
* ggc-common.c (gcc_mark_tree_children, case 'd'): Use DECL_RESULT_FLD.
* print-tree.c (print_node): Likewise.
Only test DECL_PACKED, DECL_INLINE, DECL_BIT_FIELD, and
DECL_TRANSPARENT_UNION on proper decl types.
Properly handly DECL_INCOMING_RTL and DECL_SAVED_INSNS.
* stor-layout.c (layout_decl): Only check DECL_PACKED and
DECL_BIT_FIELD of FIELD_DECL.
* tree.h (DECL_RESULT_FLD): New macro.
* cp/class.c (check_field_decl): Fix typo.
(build_vtbl_or_vbase_field): Don't clear DECL_SAVED_INSNS.
(check_methods): Likewise.
(check_field_decls): Likewise.
Use DECL_CONTEXT, not DECL_FIELD_CONTEXT.
* cp-tree.h (DECL_SHADOWED_FOR_VAR, DECL_TEMPLATE_RESULT):
Use DECL_RESULT_FLD, not DECL_RESULT.
* cp/decl.c (xref_tag): Use DECL_TEMPLATE_RESULT.
* cp/lex.c (identifier_type): Likewise.
* cp/pt.c (determine_specialization, lookup_template_class): Likewise.
(tsubst_friend_function, tsubst_decl, instantiate_template): Likewise.
(resolve_overloaded_unification, more_specialized): Likewise.
* cp/semantics.c (finish_member_declaration): Likewise.
* cp/typeck.c (build_x_function_call): Likewise.
From-SVN: r32759
2000-03-27 03:26:18 +02:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (TREE_THIS_VOLATILE (newdecl))
|
1992-07-07 03:47:54 +02:00
|
|
|
|
{
|
1995-11-29 19:55:34 +01:00
|
|
|
|
TREE_THIS_VOLATILE (write_olddecl) = 1;
|
2000-07-18 19:53:35 +02:00
|
|
|
|
if (TREE_CODE (newdecl) == VAR_DECL
|
|
|
|
|
/* If an automatic variable is re-declared in the same
|
|
|
|
|
function scope, but the old declaration was not
|
|
|
|
|
volatile, make_var_volatile() would crash because the
|
|
|
|
|
variable would have been assigned to a pseudo, not a
|
|
|
|
|
MEM. Since this duplicate declaration is invalid
|
|
|
|
|
anyway, we just skip the call. */
|
|
|
|
|
&& errmsg == 0)
|
1992-07-07 03:47:54 +02:00
|
|
|
|
make_var_volatile (newdecl);
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
1995-11-29 19:55:34 +01:00
|
|
|
|
/* Keep source location of definition rather than declaration. */
|
|
|
|
|
/* When called with different_binding_level set, keep the old
|
|
|
|
|
information so that meaningful diagnostics can be given. */
|
|
|
|
|
if (DECL_INITIAL (newdecl) == 0 && DECL_INITIAL (olddecl) != 0
|
|
|
|
|
&& ! different_binding_level)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
DECL_SOURCE_LINE (newdecl) = DECL_SOURCE_LINE (olddecl);
|
|
|
|
|
DECL_SOURCE_FILE (newdecl) = DECL_SOURCE_FILE (olddecl);
|
|
|
|
|
}
|
|
|
|
|
|
1992-07-07 03:47:54 +02:00
|
|
|
|
/* Merge the unused-warning information. */
|
|
|
|
|
if (DECL_IN_SYSTEM_HEADER (olddecl))
|
|
|
|
|
DECL_IN_SYSTEM_HEADER (newdecl) = 1;
|
|
|
|
|
else if (DECL_IN_SYSTEM_HEADER (newdecl))
|
1995-11-29 19:55:34 +01:00
|
|
|
|
DECL_IN_SYSTEM_HEADER (write_olddecl) = 1;
|
1992-07-07 03:47:54 +02:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Merge the initialization information. */
|
1995-11-29 19:55:34 +01:00
|
|
|
|
/* When called with different_binding_level set, don't copy over
|
|
|
|
|
DECL_INITIAL, so that we don't accidentally change function
|
|
|
|
|
declarations into function definitions. */
|
|
|
|
|
if (DECL_INITIAL (newdecl) == 0 && ! different_binding_level)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
|
1994-02-17 23:49:29 +01:00
|
|
|
|
|
|
|
|
|
/* Merge the section attribute.
|
|
|
|
|
We want to issue an error if the sections conflict but that must be
|
|
|
|
|
done later in decl_attributes since we are called before attributes
|
|
|
|
|
are assigned. */
|
|
|
|
|
if (DECL_SECTION_NAME (newdecl) == NULL_TREE)
|
|
|
|
|
DECL_SECTION_NAME (newdecl) = DECL_SECTION_NAME (olddecl);
|
1994-04-09 14:25:26 +02:00
|
|
|
|
|
1999-09-07 07:49:18 +02:00
|
|
|
|
/* Copy the assembler name.
|
|
|
|
|
Currently, it can only be defined in the prototype. */
|
Compute DECL_ASSEMBLER_NAME lazily.
* tree.h (DECL_ASSEMBLER_NAME): Compute it lazily.
(DECL_ASSEMBLER_NAME_SET_P): New macro.
(SET_DECL_ASSEMBLER_NAME): Likewise.
(COPY_DECL_ASSEMBLER_NAME): Likewise.
(set_decl_assembler_name): Declare.
(lang_set_decl_assembler_name): Likewise.
* tree.c (lang_set_decl_assembler_name): New variab.e
(set_decl_assembler_name): New function.
(init_obstacks): Set lang_set_decl_assembler_name.
(build_decl): Don't set DECL_ASSEMBLER_NAME.
* c-decl.c (duplicate_decls): Use SET_DECL_ASSEMBLER_NAME,
COPY_DECL_ASSEMBLER_NAME, etc. Don't set DECL_ASSEMBLER_NAME
where it's not necessary.
(builtin_function): Likewise.
(finish_decl): Likewise.
* dbxout.c (dbxout_type_methods): Likewise.
* ggc-common.c (ggc_mark_trees): Likewise.
* profile.c (output_func_start_profiler): Likewise.
* varasm.c (make_decl_rtl): Likewise.
* class.c (get_vtable_decl): Use SET_DECL_ASSEMBLER_NAME,
COPY_DECL_ASSEMBLER_NAME, etc. Don't set DECL_ASSEMBLER_NAME
where it's not necessary.
(add_method): Remove optimization involving comparison of
DECL_ASSEMBLER_NAME.
(build_vtbl_or_vbase_field): Use SET_DECL_ASSEMBLER_NAME,
COPY_DECL_ASSEMBLER_NAME, etc. Don't set DECL_ASSEMBLER_NAME
where it's not necessary.
(check_methods): Likewise.
(build_clone): Likewise.
(built_vtt): Likewise.
* cp-tree.h (DECL_NEEDED_P): Likewise.
* decl.c (pushtag): Likewise.
(duplicate_decls): Likewise.
(pushdecl): Likewise.
(builtin_function): Likewise.
(build_library_fn_1): Set DECL_LANGUAGE for library functions.
(build_cp_library_fn): Likewise.
(maybe_commonize_var): Use SET_DECL_ASSEMBLER_NAME,
COPY_DECL_ASSEMBLER_NAME, etc. Don't set DECL_ASSEMBLER_NAME
where it's not necessary.
(make_rtl_for_nonlocal_decl): Likewise.
(cp_finish_decl): Likewise.
(grokfndecl): Likewise.
(grokvardecl): Likewise.
(grokdeclarator): Likewise.
(start_function): Likewise.
(cp_missing_return_ok_p): Likewise.
* decl2.c (grokclassfn): Likewise.
(check_classfn): Likewise.
(finish_static_data_member_decl): Likewise.
(grokfield): Likewise.
* error.c (GLOBAL_IORD_P): Remove.
(dump_global_iord): Improve output.
(dump_decl): Avoid using DECL_ASSEMBLER_NAME.
* except.c (nothrow_libfn_p): Summarily reject any function not in
namespace-scope.
* init.c (build_java_class_ref): Don't explicitly set
DECL_ASSEMBLER_NAME after calling mangle_decl.
* mangle.c (mangle_decl_string): Handle extern "C" functions.
(mangle_decl): Set the DECL_ASSEMBLER_NAME for the decl.
* method.c (set_mangled_name_for_decl): Don't explicitly set
DECL_ASSEMBLER_NAME after calling mangle_decl.
(make_thunk): Explicitly set the DECL_ASSEMBLER_NAME and
IDENTIFIER_GLOBAL_VALUE for the thunk.
* pt.c (set_mangled_name_for_template_decl): Remove.
(check_explicit_specialization): Don't use it.
(looup_template_class): Don't set DECL_ASSEMBLER_NAME.
(tsubst_friend_function): Likewise.
(tsubst_decl): Likewise.
(regenerate_decl_from_template): Use COPY_DECL_ASSEMBLER_NAME.
* rtti.c (get_tinfo_decl): Use SET_DECL_ASSEMBLER_NAME,
COPY_DECL_ASSEMBLER_NAME, etc. Don't set DECL_ASSEMBLER_NAME
where it's not necessary.
(tinfo_base_init): Likewise.
(create_real_tinfo_var): Likewise.
* search.c (looup_field_1): Likewise.
* semantics.c (finish_named_return_value): Likewise.
* tree.c (init_tree): Set lang_set_decl_assembler_name.
* com.c (builtin_function): Use SET_DECL_ASSEMBLER_NAME.
* class.c (build_class_ref): Use SET_DECL_ASSEMBLER_NAME.
(layout_class): Likewise.
(layout_class_method): Likewise.
(emit_register_classes): Likewise.
* decl.c (builtin_function): Likewise.
(give_name_to_locals): Likewise.
From-SVN: r40642
2001-03-20 00:50:04 +01:00
|
|
|
|
COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl);
|
1999-09-07 07:49:18 +02:00
|
|
|
|
|
1995-01-14 02:09:01 +01:00
|
|
|
|
if (TREE_CODE (newdecl) == FUNCTION_DECL)
|
|
|
|
|
{
|
|
|
|
|
DECL_STATIC_CONSTRUCTOR(newdecl) |= DECL_STATIC_CONSTRUCTOR(olddecl);
|
|
|
|
|
DECL_STATIC_DESTRUCTOR (newdecl) |= DECL_STATIC_DESTRUCTOR (olddecl);
|
2001-12-05 23:37:41 +01:00
|
|
|
|
DECL_NO_LIMIT_STACK (newdecl) |= DECL_NO_LIMIT_STACK (olddecl);
|
1998-07-30 12:38:22 +02:00
|
|
|
|
DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (newdecl)
|
|
|
|
|
|= DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (olddecl);
|
2003-04-17 23:27:37 +02:00
|
|
|
|
TREE_THIS_VOLATILE (newdecl) |= TREE_THIS_VOLATILE (olddecl);
|
|
|
|
|
TREE_READONLY (newdecl) |= TREE_READONLY (olddecl);
|
2003-04-14 04:55:31 +02:00
|
|
|
|
DECL_IS_MALLOC (newdecl) |= DECL_IS_MALLOC (olddecl);
|
|
|
|
|
DECL_IS_PURE (newdecl) |= DECL_IS_PURE (olddecl);
|
1995-01-14 02:09:01 +01:00
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
/* If cannot merge, then use the new type and qualifiers,
|
|
|
|
|
and don't preserve the old rtl. */
|
1995-11-29 19:55:34 +01:00
|
|
|
|
else if (! different_binding_level)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
TREE_TYPE (olddecl) = TREE_TYPE (newdecl);
|
|
|
|
|
TREE_READONLY (olddecl) = TREE_READONLY (newdecl);
|
|
|
|
|
TREE_THIS_VOLATILE (olddecl) = TREE_THIS_VOLATILE (newdecl);
|
|
|
|
|
TREE_SIDE_EFFECTS (olddecl) = TREE_SIDE_EFFECTS (newdecl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Merge the storage class information. */
|
2002-04-28 20:31:34 +02:00
|
|
|
|
merge_weak (newdecl, olddecl);
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* For functions, static overrides non-static. */
|
|
|
|
|
if (TREE_CODE (newdecl) == FUNCTION_DECL)
|
|
|
|
|
{
|
|
|
|
|
TREE_PUBLIC (newdecl) &= TREE_PUBLIC (olddecl);
|
|
|
|
|
/* This is since we don't automatically
|
|
|
|
|
copy the attributes of NEWDECL into OLDDECL. */
|
1995-11-29 19:55:34 +01:00
|
|
|
|
/* No need to worry about different_binding_level here because
|
|
|
|
|
then TREE_PUBLIC (newdecl) was true. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
|
|
|
|
|
/* If this clears `static', clear it in the identifier too. */
|
|
|
|
|
if (! TREE_PUBLIC (olddecl))
|
|
|
|
|
TREE_PUBLIC (DECL_NAME (olddecl)) = 0;
|
|
|
|
|
}
|
1992-07-12 04:56:45 +02:00
|
|
|
|
if (DECL_EXTERNAL (newdecl))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-11 10:33:21 +02:00
|
|
|
|
if (! different_binding_level || different_tu)
|
2000-08-28 03:44:28 +02:00
|
|
|
|
{
|
|
|
|
|
/* Don't mess with these flags on local externs; they remain
|
|
|
|
|
external even if there's a declaration at file scope which
|
|
|
|
|
isn't. */
|
|
|
|
|
TREE_STATIC (newdecl) = TREE_STATIC (olddecl);
|
|
|
|
|
DECL_EXTERNAL (newdecl) = DECL_EXTERNAL (olddecl);
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* An extern decl does not override previous storage class. */
|
|
|
|
|
TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl);
|
1996-03-05 13:51:14 +01:00
|
|
|
|
if (! DECL_EXTERNAL (newdecl))
|
2003-07-11 10:33:21 +02:00
|
|
|
|
{
|
|
|
|
|
DECL_CONTEXT (newdecl) = DECL_CONTEXT (olddecl);
|
|
|
|
|
/* If we have two non-EXTERNAL file-scope decls that are
|
|
|
|
|
the same, only one of them should be written out. */
|
|
|
|
|
if (different_tu)
|
|
|
|
|
TREE_ASM_WRITTEN (newdecl) = 1;
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TREE_STATIC (olddecl) = TREE_STATIC (newdecl);
|
|
|
|
|
TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
|
|
|
|
|
}
|
1992-09-07 08:57:50 +02:00
|
|
|
|
|
1995-11-29 19:55:34 +01:00
|
|
|
|
if (TREE_CODE (newdecl) == FUNCTION_DECL)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2001-02-21 15:42:27 +01:00
|
|
|
|
/* If we're redefining a function previously defined as extern
|
|
|
|
|
inline, make sure we emit debug info for the inline before we
|
|
|
|
|
throw it away, in case it was inlined into a function that hasn't
|
|
|
|
|
been written out yet. */
|
2002-11-20 11:37:08 +01:00
|
|
|
|
if (new_is_definition && DECL_INITIAL (olddecl))
|
2001-02-21 15:42:27 +01:00
|
|
|
|
{
|
2002-11-20 11:37:08 +01:00
|
|
|
|
if (TREE_USED (olddecl))
|
|
|
|
|
(*debug_hooks->outlining_inline_function) (olddecl);
|
c-convert.c (convert): Return if output or input type is ERROR_MARK.
* c-convert.c (convert): Return if output or input type is ERROR_MARK.
* c-decl.c (duplicate_decls): Only look at DECL_BUILT_IN_NONANSI
and DECL_INLINE if FUNCTION_DECL.
(pushdecl, redeclaration_error_message): Likewise, for DECL_INLINE.
(store_parm_decls): Check for type of PARM_DECL being ERROR_MARK.
Use DECL_WEAK, not DECL_RESULT, to flag for already seen.
(combine_parm_decls): Likewise.
* ggc-common.c (gcc_mark_tree_children, case 'd'): Use DECL_RESULT_FLD.
* print-tree.c (print_node): Likewise.
Only test DECL_PACKED, DECL_INLINE, DECL_BIT_FIELD, and
DECL_TRANSPARENT_UNION on proper decl types.
Properly handly DECL_INCOMING_RTL and DECL_SAVED_INSNS.
* stor-layout.c (layout_decl): Only check DECL_PACKED and
DECL_BIT_FIELD of FIELD_DECL.
* tree.h (DECL_RESULT_FLD): New macro.
* cp/class.c (check_field_decl): Fix typo.
(build_vtbl_or_vbase_field): Don't clear DECL_SAVED_INSNS.
(check_methods): Likewise.
(check_field_decls): Likewise.
Use DECL_CONTEXT, not DECL_FIELD_CONTEXT.
* cp-tree.h (DECL_SHADOWED_FOR_VAR, DECL_TEMPLATE_RESULT):
Use DECL_RESULT_FLD, not DECL_RESULT.
* cp/decl.c (xref_tag): Use DECL_TEMPLATE_RESULT.
* cp/lex.c (identifier_type): Likewise.
* cp/pt.c (determine_specialization, lookup_template_class): Likewise.
(tsubst_friend_function, tsubst_decl, instantiate_template): Likewise.
(resolve_overloaded_unification, more_specialized): Likewise.
* cp/semantics.c (finish_member_declaration): Likewise.
* cp/typeck.c (build_x_function_call): Likewise.
From-SVN: r32759
2000-03-27 03:26:18 +02:00
|
|
|
|
|
2001-02-21 15:42:27 +01:00
|
|
|
|
/* The new defn must not be inline. */
|
|
|
|
|
DECL_INLINE (newdecl) = 0;
|
|
|
|
|
DECL_UNINLINABLE (newdecl) = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* If either decl says `inline', this fn is inline,
|
|
|
|
|
unless its definition was passed already. */
|
2001-10-08 18:37:06 +02:00
|
|
|
|
if (DECL_DECLARED_INLINE_P (newdecl)
|
2001-12-24 09:45:59 +01:00
|
|
|
|
|| DECL_DECLARED_INLINE_P (olddecl))
|
|
|
|
|
DECL_DECLARED_INLINE_P (newdecl) = 1;
|
2001-10-18 20:29:02 +02:00
|
|
|
|
|
|
|
|
|
DECL_UNINLINABLE (newdecl) = DECL_UNINLINABLE (olddecl)
|
|
|
|
|
= (DECL_UNINLINABLE (newdecl) || DECL_UNINLINABLE (olddecl));
|
2001-02-21 15:42:27 +01:00
|
|
|
|
}
|
c-convert.c (convert): Return if output or input type is ERROR_MARK.
* c-convert.c (convert): Return if output or input type is ERROR_MARK.
* c-decl.c (duplicate_decls): Only look at DECL_BUILT_IN_NONANSI
and DECL_INLINE if FUNCTION_DECL.
(pushdecl, redeclaration_error_message): Likewise, for DECL_INLINE.
(store_parm_decls): Check for type of PARM_DECL being ERROR_MARK.
Use DECL_WEAK, not DECL_RESULT, to flag for already seen.
(combine_parm_decls): Likewise.
* ggc-common.c (gcc_mark_tree_children, case 'd'): Use DECL_RESULT_FLD.
* print-tree.c (print_node): Likewise.
Only test DECL_PACKED, DECL_INLINE, DECL_BIT_FIELD, and
DECL_TRANSPARENT_UNION on proper decl types.
Properly handly DECL_INCOMING_RTL and DECL_SAVED_INSNS.
* stor-layout.c (layout_decl): Only check DECL_PACKED and
DECL_BIT_FIELD of FIELD_DECL.
* tree.h (DECL_RESULT_FLD): New macro.
* cp/class.c (check_field_decl): Fix typo.
(build_vtbl_or_vbase_field): Don't clear DECL_SAVED_INSNS.
(check_methods): Likewise.
(check_field_decls): Likewise.
Use DECL_CONTEXT, not DECL_FIELD_CONTEXT.
* cp-tree.h (DECL_SHADOWED_FOR_VAR, DECL_TEMPLATE_RESULT):
Use DECL_RESULT_FLD, not DECL_RESULT.
* cp/decl.c (xref_tag): Use DECL_TEMPLATE_RESULT.
* cp/lex.c (identifier_type): Likewise.
* cp/pt.c (determine_specialization, lookup_template_class): Likewise.
(tsubst_friend_function, tsubst_decl, instantiate_template): Likewise.
(resolve_overloaded_unification, more_specialized): Likewise.
* cp/semantics.c (finish_member_declaration): Likewise.
* cp/typeck.c (build_x_function_call): Likewise.
From-SVN: r32759
2000-03-27 03:26:18 +02:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (DECL_BUILT_IN (olddecl))
|
|
|
|
|
{
|
1995-11-29 19:55:34 +01:00
|
|
|
|
/* Get rid of any built-in function if new arg types don't match it
|
|
|
|
|
or if we have a function definition. */
|
|
|
|
|
if (! types_match || new_is_definition)
|
|
|
|
|
{
|
|
|
|
|
if (! different_binding_level)
|
|
|
|
|
{
|
|
|
|
|
TREE_TYPE (olddecl) = TREE_TYPE (newdecl);
|
1999-09-24 12:07:04 +02:00
|
|
|
|
DECL_BUILT_IN_CLASS (olddecl) = NOT_BUILT_IN;
|
1995-11-29 19:55:34 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* If redeclaring a builtin function, and not a definition,
|
|
|
|
|
it stays built in. */
|
1999-09-24 12:07:04 +02:00
|
|
|
|
DECL_BUILT_IN_CLASS (newdecl) = DECL_BUILT_IN_CLASS (olddecl);
|
1995-11-29 19:55:34 +01:00
|
|
|
|
DECL_FUNCTION_CODE (newdecl) = DECL_FUNCTION_CODE (olddecl);
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
2001-12-24 09:45:59 +01:00
|
|
|
|
|
1995-11-29 19:55:34 +01:00
|
|
|
|
/* Also preserve various other info from the definition. */
|
|
|
|
|
if (! new_is_definition)
|
|
|
|
|
{
|
|
|
|
|
DECL_RESULT (newdecl) = DECL_RESULT (olddecl);
|
|
|
|
|
/* When called with different_binding_level set, don't copy over
|
|
|
|
|
DECL_INITIAL, so that we don't accidentally change function
|
|
|
|
|
declarations into function definitions. */
|
|
|
|
|
if (! different_binding_level)
|
2001-12-04 11:34:40 +01:00
|
|
|
|
DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
|
1995-11-29 19:55:34 +01:00
|
|
|
|
DECL_SAVED_INSNS (newdecl) = DECL_SAVED_INSNS (olddecl);
|
2001-12-04 11:34:40 +01:00
|
|
|
|
DECL_SAVED_TREE (newdecl) = DECL_SAVED_TREE (olddecl);
|
2003-07-09 02:31:20 +02:00
|
|
|
|
DECL_ESTIMATED_INSNS (newdecl) = DECL_ESTIMATED_INSNS (olddecl);
|
1995-11-29 19:55:34 +01:00
|
|
|
|
DECL_ARGUMENTS (newdecl) = DECL_ARGUMENTS (olddecl);
|
2001-12-24 09:45:59 +01:00
|
|
|
|
|
|
|
|
|
/* Set DECL_INLINE on the declaration if we've got a body
|
|
|
|
|
from which to instantiate. */
|
|
|
|
|
if (DECL_INLINE (olddecl) && ! DECL_UNINLINABLE (newdecl))
|
|
|
|
|
{
|
|
|
|
|
DECL_INLINE (newdecl) = 1;
|
|
|
|
|
DECL_ABSTRACT_ORIGIN (newdecl)
|
|
|
|
|
= (different_binding_level
|
|
|
|
|
? DECL_ORIGIN (olddecl)
|
|
|
|
|
: DECL_ABSTRACT_ORIGIN (olddecl));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* If a previous declaration said inline, mark the
|
|
|
|
|
definition as inlinable. */
|
|
|
|
|
if (DECL_DECLARED_INLINE_P (newdecl)
|
|
|
|
|
&& ! DECL_UNINLINABLE (newdecl))
|
|
|
|
|
DECL_INLINE (newdecl) = 1;
|
1995-11-29 19:55:34 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (different_binding_level)
|
2000-08-28 03:44:28 +02:00
|
|
|
|
return 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
1992-09-07 08:57:50 +02:00
|
|
|
|
/* Copy most of the decl-specific fields of NEWDECL into OLDDECL.
|
1998-04-04 15:32:39 +02:00
|
|
|
|
But preserve OLDDECL's DECL_UID. */
|
1992-09-07 08:57:50 +02:00
|
|
|
|
{
|
2001-10-11 05:16:15 +02:00
|
|
|
|
unsigned olddecl_uid = DECL_UID (olddecl);
|
1992-09-07 08:57:50 +02:00
|
|
|
|
|
Use memset/memcmp instead of bzero/bcmp.
* c-decl.c (duplicate_decls, copy_lang_decl), dwarfout.c
(dwarfout_line), gcc.c (main, save_string), tree.c (init_obstacks,
perm_calloc, get_identifier, maybe_get_identifier,
real_value_from_int_cst, simple_cst_equal), varasm.c
(assemble_name, assemble_real, immed_real_const_1,
compare_constant_1, decode_rtx_const, output_constant_pool): Use
strrchr () instead of rindex (). Use memcmp () instead of bcmp
(). Use memcpy () instead of bcopy (). Use memset () instead of
bzero ().
cp:
* tree.c (cp_tree_equal): Use memcmp () instead of bcmp ().
From-SVN: r37228
2000-11-03 19:55:54 +01:00
|
|
|
|
memcpy ((char *) olddecl + sizeof (struct tree_common),
|
|
|
|
|
(char *) newdecl + sizeof (struct tree_common),
|
|
|
|
|
sizeof (struct tree_decl) - sizeof (struct tree_common));
|
1992-09-07 08:57:50 +02:00
|
|
|
|
DECL_UID (olddecl) = olddecl_uid;
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
1998-02-18 11:38:57 +01:00
|
|
|
|
/* NEWDECL contains the merged attribute lists.
|
|
|
|
|
Update OLDDECL to be the same. */
|
Table-driven attributes.
* c-decl.c, config/alpha/alpha.c, config/arc/arc.c,
config/arm/arm.c, config/arm/pe.c, config/avr/avr.c,
config/avr/avr.h, config/d30v/d30v.h, config/fr30/fr30.h,
config/h8300/h8300.c, config/i386/cygwin.h, config/i386/winnt.c,
config/m32r/m32r.c, config/mcore/mcore.c, config/sh/sh.c,
config/stormy16/stormy16.h, config/v850/v850.c, doc/c-tree.texi,
doc/tm.texi, ggc-common.c, integrate.c, print-tree.c, tree.c,
tree.h: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* tree.h (struct tree_decl): Change machine_attributes to
attributes.
* doc/c-tree.texi: Document that all attributes are now attached
to decls and types.
* c-common.c (add_attribute, attrtab, attrtab_idx,
default_valid_lang_attribute, valid_lang_attribute): Remove.
(attribute_tables, attributes_initialized,
c_common_attribute_table, default_lang_attribute_table): New
variables.
(handle_packed_attribute, handle_nocommon_attribute,
handle_common_attribute, handle_noreturn_attribute,
handle_unused_attribute, handle_const_attribute,
handle_transparent_union_attribute, handle_constructor_attribute,
handle_destructor_attribute, handle_mode_attribute,
handle_section_attribute, handle_aligned_attribute,
handle_weak_attribute, handle_alias_attribute,
handle_no_instrument_function_attribute,
handle_no_check_memory_usage_attribute, handle_malloc_attribute,
handle_no_limit_stack_attribute, handle_pure_attribute): New
functions.
(init_attributes, decl_attributes): Rewrite to implement
table-driven attributes.
* c-common.h (enum attribute_flags): Move to tree.h.
* c-format.c (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Rename to
handle_format_attribute and handle_format_arg_attribute. Update
for table-driven attributes.
* c-common.h (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Remove prototypes.
(handle_format_attribute, handle_format_arg_attribute): Add
prototypes.
* c-decl.c (grokdeclarator): Handle attributes nested inside
declarators.
* c-parse.in (setattrs, maybe_setattrs): Remove.
(maybe_type_quals_setattrs): Rename to maybe_type_quals_attrs.
Update to handle nested attributes properly.
(maybe_resetattrs, after_type_declarator,
parm_declarator_nostarttypename, notype_declarator, absdcl1_noea,
absdcl1_ea, direct_absdcl1): Update to handle nested attributes
properly.
(make_pointer_declarator): Update to handle nested attributes
properly.
* doc/extend.texi: Update documentation of limits of attributes
syntax. Warn about problems with attribute semantics in C++.
* target.h (struct target): Remove valid_decl_attribute and
valid_type_attribute. Add attribute_table and
function_attribute_inlinable_p.
* target-def.h (TARGET_VALID_DECL_ATTRIBUTE,
TARGET_VALID_TYPE_ATTRIBUTE): Remove.
(TARGET_ATTRIBUTE_TABLE, TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P):
Add.
(TARGET_INITIALIZER): Update.
* integrate.c (FUNCTION_ATTRIBUTE_INLINABLE_P): Remove default
definition.
(function_attribute_inlinable_p): New function. Check for the
presence of any machine attributes before using
targetm.function_attribute_inlinable_p.
(function_cannot_inline_p): Update.
* Makefile.in (integrate.o): Update dependencies.
* doc/tm.texi: Update documentation of target attributes and
example definition of TARGET_VALID_TYPE_ATTRIBUTE.
* tree.c (default_valid_attribute_p, valid_machine_attribute):
Remove.
(default_target_attribute_table,
default_function_attribute_inlinable_p): New.
(lookup_attribute): Update comment to clarify handling of multiple
attributes with the same name.
(merge_attributes, attribute_list_contained): Allow multiple
attributes with the same name but different arguments to appear in
the same attribute list.
* tree.h (default_valid_attribute_p): Remove prototype.
(struct attribute_spec): New.
(default_target_attribute_table): Declare.
(enum attribute_flags): Move from c-common.h. Add
ATTR_FLAG_TYPE_IN_PLACE.
(default_function_attribute_inlinable_p): Declare.
* config/alpha/alpha.c (vms_valid_decl_attribute_p): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(vms_attribute_table): New.
* config/arc/arc.c (arc_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arc_attribute_table, arc_handle_interrupt_attribute): New.
* config/arm/arm.c (arm_valid_type_attribute_p,
arm_valid_decl_attribute_p, arm_pe_valid_decl_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arm_attribute_table, arm_handle_fndecl_attribute,
arm_handle_isr_attribute): New.
* config/avr/avr.c (avr_valid_type_attribute,
avr_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE, TARGET_VALID_TYPE_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(avr_attribute_table, avr_handle_progmem_attribute,
avr_handle_fndecl_attribute): New.
* config/c4x/c4x.c (c4x_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(c4x_attribute_table, c4x_handle_fntype_attribute): New.
* config/h8300/h8300.c (h8300_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(h8300_attribute_table, h8300_handle_fndecl_attribute,
h8300_handle_eightbit_data_attribute,
h8300_handle_tiny_data_attribute): New.
* config/i386/i386-protos.h (ix86_valid_type_attribute_p,
i386_pe_valid_decl_attribute_p, i386_pe_valid_type_attribute_p):
Remove prototypes.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New
declarations.
* config/i386/i386.c (ix86_valid_type_attribute_p: Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ix86_attribute_table, ix86_handle_cdecl_attribute,
ix86_handle_regparm_attribute): New.
* config/i386/winnt.c (i386_pe_valid_decl_attribute_p,
i386_pe_valid_type_attribute_p): Remove.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New.
* config/ia64/ia64.c (ia64_valid_type_attribute): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ia64_attribute_table): New.
* config/m32r/m32r.c (m32r_valid_decl_attribute, interrupt_ident1,
interrupt_ident2, model_ident1, model_ident2): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(init_idents): Update.
(m32r_attribute_table, m32r_handle_model_attribute): New.
* config/m68hc11/m68hc11.c (m68hc11_valid_type_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(m68hc11_attribute_table, m68hc11_handle_fntype_attribute): New.
* config/mcore/mcore.c (mcore_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(mcore_attribute_table, mcore_handle_naked_attribute): New.
* config/ns32k/ns32k.c (ns32k_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ns32k_attribute_table, ns32k_handle_fntype_attribute): New.
* config/rs6000/rs6000.c (rs6000_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(rs6000_attribute_table, rs6000_handle_longcall_attribute): New.
* config/sh/sh.c (sh_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(sh_attribute_table, sh_handle_interrupt_handler_attribute,
sh_handle_sp_switch_attribute, sh_handle_trap_exit_attribute):
New.
* config/stormy16/stormy16.c (stormy16_valid_type_attribute):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define
(TARGET_ATTRIBUTE_TABLE): Define.
(stormy16_attribute_table, stormy16_handle_interrupt_attribute):
New.
* config/v850/v850.c (v850_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(v850_attribute_table, v850_handle_interrupt_attribute,
v850_handle_data_area_attribute): New.
* config/v850/v850-c.c (mark_current_function_as_interrupt):
Return void. Call decl_attributes instead of
valid_machine_attribute.
cp:
Table-driven attributes.
* decl.c: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* decl2.c (cplus_decl_attributes): Only take one attributes
parameter.
* cp-tree.c (cplus_decl_attributes): Update prototype.
* class.c (finish_struct), decl.c (start_decl, start_function),
decl2.c (grokfield), friend.c (do_friend), parse.y
(parse_bitfield): Update calls to cplus_decl_attributes.
* decl.c (grokdeclarator): Take a pointer to a single ordinary
attribute list.
* decl.h (grokdeclarator): Update prototype.
* decl2.c (grokfield): Take a single ordinary attribute list.
* friend.c (do_friend): Likewise.
* decl.c (shadow_tag, groktypename, start_decl,
start_handler_parms, grokdeclarator, grokparms, start_function,
start_method), decl2.c (grokfield, grokbitfield, grokoptypename),
parse.y (parse_field, parse_bitfield, component_decl_1), pt.c
(process_template_parm, do_decl_instantiation): Pass single
ordinary attribute lists around.
* decl.c (grokdeclarator): Correct handling of nested attributes.
Revert the patch
1998-10-18 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (grokdeclarator): Embedded attrs bind to the right,
not the left.
.
* cp-tree.h (cp_valid_lang_attribute): Remove declaration
(cp_attribute_table): Declare.
* decl.c (valid_lang_attribute): Don't define.
(lang_attribute_table): Define.
(init_decl_processing): Initialize lang_attribute_table instead of
valid_lang_attribute.
* tree.c (cp_valid_lang_attribute): Remove.
(handle_java_interface_attribute, handle_com_interface_attribute,
handle_init_priority_attribute): New functions.
(cp_attribute_table): New array.
* decl2.c (import_export_class): Don't use
targetm.valid_type_attribute.
testsuite:
Table-driven attributes.
* g++.dg/ext/attrib1.C: New test.
From-SVN: r45718
2001-09-21 03:27:06 +02:00
|
|
|
|
DECL_ATTRIBUTES (olddecl) = DECL_ATTRIBUTES (newdecl);
|
1998-02-18 11:38:57 +01:00
|
|
|
|
|
2003-05-14 07:40:12 +02:00
|
|
|
|
/* If OLDDECL had its DECL_RTL instantiated, re-invoke make_decl_rtl
|
|
|
|
|
so that encode_section_info has a chance to look at the new decl
|
|
|
|
|
flags and attributes. */
|
|
|
|
|
if (DECL_RTL_SET_P (olddecl)
|
|
|
|
|
&& (TREE_CODE (olddecl) == FUNCTION_DECL
|
|
|
|
|
|| (TREE_CODE (olddecl) == VAR_DECL
|
|
|
|
|
&& TREE_STATIC (olddecl))))
|
|
|
|
|
make_decl_rtl (olddecl, NULL);
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
/* Return any external DECL associated with ID, whether or not it is
|
|
|
|
|
currently in scope. */
|
2003-05-22 21:39:13 +02:00
|
|
|
|
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
static tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
any_external_decl (tree id)
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
{
|
|
|
|
|
tree decl = IDENTIFIER_SYMBOL_VALUE (id);
|
|
|
|
|
tree t;
|
|
|
|
|
|
2003-05-22 21:39:13 +02:00
|
|
|
|
if (decl == 0 || TREE_CODE (decl) == ERROR_MARK)
|
|
|
|
|
return 0;
|
|
|
|
|
else if (TREE_CODE (decl) != TYPE_DECL && DECL_EXTERNAL (decl))
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
return decl;
|
|
|
|
|
|
|
|
|
|
t = purpose_member (id, truly_local_externals);
|
|
|
|
|
if (t)
|
|
|
|
|
return TREE_VALUE (t);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Record an external decl DECL. This only does something if a
|
|
|
|
|
shadowing decl already exists. */
|
|
|
|
|
static void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
record_external_decl (tree decl)
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
{
|
|
|
|
|
tree name = DECL_NAME (decl);
|
|
|
|
|
if (!IDENTIFIER_SYMBOL_VALUE (name))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
truly_local_externals = tree_cons (name, decl, truly_local_externals);
|
|
|
|
|
}
|
|
|
|
|
|
2001-12-06 00:20:00 +01:00
|
|
|
|
/* Check whether decl-node X shadows an existing declaration.
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
OLD is the old IDENTIFIER_SYMBOL_VALUE of the DECL_NAME of X,
|
2001-12-06 00:20:00 +01:00
|
|
|
|
which might be a NULL_TREE. */
|
|
|
|
|
static void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
warn_if_shadowing (tree x, tree old)
|
2001-12-06 00:20:00 +01:00
|
|
|
|
{
|
2003-03-22 04:28:39 +01:00
|
|
|
|
const char *name;
|
2001-12-06 00:20:00 +01:00
|
|
|
|
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
/* Nothing to shadow? */
|
|
|
|
|
if (old == 0
|
|
|
|
|
/* Shadow warnings not wanted? */
|
|
|
|
|
|| !warn_shadow
|
|
|
|
|
/* No shadow warnings for internally generated vars. */
|
|
|
|
|
|| DECL_SOURCE_LINE (x) == 0
|
|
|
|
|
/* No shadow warnings for vars made for inlining. */
|
|
|
|
|
|| DECL_FROM_INLINE (x)
|
|
|
|
|
/* Don't warn about the parm names in function declarator
|
|
|
|
|
within a function declarator.
|
|
|
|
|
It would be nice to avoid warning in any function
|
|
|
|
|
declarator in a declaration, as opposed to a definition,
|
|
|
|
|
but there is no way to tell it's not a definition. */
|
2003-07-29 00:19:46 +02:00
|
|
|
|
|| (TREE_CODE (x) == PARM_DECL && current_scope->outer->parm_flag))
|
2001-12-06 00:20:00 +01:00
|
|
|
|
return;
|
|
|
|
|
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
name = IDENTIFIER_POINTER (DECL_NAME (x));
|
|
|
|
|
if (TREE_CODE (old) == PARM_DECL)
|
|
|
|
|
shadow_warning (SW_PARAM, name, old);
|
2003-08-29 23:57:05 +02:00
|
|
|
|
else if (DECL_FILE_SCOPE_P (old))
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
shadow_warning (SW_GLOBAL, name, old);
|
|
|
|
|
else
|
|
|
|
|
shadow_warning (SW_LOCAL, name, old);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Subroutine of pushdecl.
|
|
|
|
|
|
|
|
|
|
X is a TYPE_DECL for a typedef statement. Create a brand new
|
|
|
|
|
..._TYPE node (which will be just a variant of the existing
|
|
|
|
|
..._TYPE node with identical properties) and then install X
|
|
|
|
|
as the TYPE_NAME of this brand new (duplicate) ..._TYPE node.
|
|
|
|
|
|
|
|
|
|
The whole point here is to end up with a situation where each
|
|
|
|
|
and every ..._TYPE node the compiler creates will be uniquely
|
|
|
|
|
associated with AT MOST one node representing a typedef name.
|
|
|
|
|
This way, even though the compiler substitutes corresponding
|
|
|
|
|
..._TYPE nodes for TYPE_DECL (i.e. "typedef name") nodes very
|
|
|
|
|
early on, later parts of the compiler can always do the reverse
|
|
|
|
|
translation and get back the corresponding typedef name. For
|
|
|
|
|
example, given:
|
|
|
|
|
|
|
|
|
|
typedef struct S MY_TYPE;
|
|
|
|
|
MY_TYPE object;
|
|
|
|
|
|
|
|
|
|
Later parts of the compiler might only know that `object' was of
|
|
|
|
|
type `struct S' if it were not for code just below. With this
|
|
|
|
|
code however, later parts of the compiler see something like:
|
|
|
|
|
|
|
|
|
|
struct S' == struct S
|
|
|
|
|
typedef struct S' MY_TYPE;
|
|
|
|
|
struct S' object;
|
|
|
|
|
|
|
|
|
|
And they can then deduce (from the node for type struct S') that
|
|
|
|
|
the original object declaration was:
|
|
|
|
|
|
|
|
|
|
MY_TYPE object;
|
|
|
|
|
|
|
|
|
|
Being able to do this is important for proper support of protoize,
|
|
|
|
|
and also for generating precise symbolic debugging information
|
|
|
|
|
which takes full account of the programmer's (typedef) vocabulary.
|
|
|
|
|
|
|
|
|
|
Obviously, we don't want to generate a duplicate ..._TYPE node if
|
|
|
|
|
the TYPE_DECL node that we are now processing really represents a
|
|
|
|
|
standard built-in type.
|
|
|
|
|
|
|
|
|
|
Since all standard types are effectively declared at line zero
|
|
|
|
|
in the source file, we can easily check to see if we are working
|
|
|
|
|
on a standard type by checking the current value of lineno. */
|
|
|
|
|
|
|
|
|
|
static void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
clone_underlying_type (tree x)
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
{
|
|
|
|
|
if (DECL_SOURCE_LINE (x) == 0)
|
2001-12-06 00:20:00 +01:00
|
|
|
|
{
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
if (TYPE_NAME (TREE_TYPE (x)) == 0)
|
|
|
|
|
TYPE_NAME (TREE_TYPE (x)) = x;
|
|
|
|
|
}
|
|
|
|
|
else if (TREE_TYPE (x) != error_mark_node
|
|
|
|
|
&& DECL_ORIGINAL_TYPE (x) == NULL_TREE)
|
|
|
|
|
{
|
|
|
|
|
tree tt = TREE_TYPE (x);
|
|
|
|
|
DECL_ORIGINAL_TYPE (x) = tt;
|
|
|
|
|
tt = build_type_copy (tt);
|
|
|
|
|
TYPE_NAME (tt) = x;
|
|
|
|
|
TREE_USED (tt) = TREE_USED (x);
|
|
|
|
|
TREE_TYPE (x) = tt;
|
2001-12-06 00:20:00 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Record a decl-node X as belonging to the current lexical scope.
|
|
|
|
|
Check for errors (such as an incompatible declaration for the same
|
|
|
|
|
name already seen in the same scope).
|
|
|
|
|
|
|
|
|
|
Returns either X or an old decl for the same name.
|
|
|
|
|
If an old decl is returned, it may have been smashed
|
|
|
|
|
to agree with what X says. */
|
|
|
|
|
|
|
|
|
|
tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
pushdecl (tree x)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree name = DECL_NAME (x);
|
2003-07-24 18:59:32 +02:00
|
|
|
|
struct c_scope *scope = current_scope;
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
|
|
|
|
|
#ifdef ENABLE_CHECKING
|
|
|
|
|
if (error_mark_node == 0)
|
|
|
|
|
/* Called too early. */
|
|
|
|
|
abort ();
|
|
|
|
|
#endif
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2001-10-08 18:37:06 +02:00
|
|
|
|
/* Functions need the lang_decl data. */
|
|
|
|
|
if (TREE_CODE (x) == FUNCTION_DECL && ! DECL_LANG_SPECIFIC (x))
|
2003-07-19 16:47:15 +02:00
|
|
|
|
DECL_LANG_SPECIFIC (x) = ggc_alloc_cleared (sizeof (struct lang_decl));
|
2001-10-08 18:37:06 +02:00
|
|
|
|
|
1993-02-27 20:08:53 +01:00
|
|
|
|
/* A local extern declaration for a function doesn't constitute nesting.
|
|
|
|
|
A local auto declaration does, since it's a forward decl
|
|
|
|
|
for a nested function coming later. */
|
2003-07-11 10:33:21 +02:00
|
|
|
|
if (current_function_decl == NULL
|
|
|
|
|
|| ((TREE_CODE (x) == FUNCTION_DECL || TREE_CODE (x) == VAR_DECL)
|
|
|
|
|
&& DECL_INITIAL (x) == 0 && DECL_EXTERNAL (x)))
|
|
|
|
|
DECL_CONTEXT (x) = current_file_decl;
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
else
|
|
|
|
|
DECL_CONTEXT (x) = current_function_decl;
|
2003-07-11 10:33:21 +02:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (name)
|
|
|
|
|
{
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
tree old;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2001-11-03 01:00:01 +01:00
|
|
|
|
if (warn_nested_externs
|
2003-07-24 18:59:32 +02:00
|
|
|
|
&& scope != global_scope
|
2001-11-03 01:00:01 +01:00
|
|
|
|
&& DECL_EXTERNAL (x)
|
|
|
|
|
&& !DECL_IN_SYSTEM_HEADER (x))
|
|
|
|
|
warning ("nested extern declaration of `%s'",
|
|
|
|
|
IDENTIFIER_POINTER (name));
|
|
|
|
|
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
old = lookup_name_current_level (name);
|
2003-07-11 10:33:21 +02:00
|
|
|
|
if (old && duplicate_decls (x, old, 0, false))
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
{
|
|
|
|
|
/* For PARM_DECLs, old may be a forward declaration.
|
|
|
|
|
If so, we want to remove it from its old location
|
|
|
|
|
(in the variables chain) and rechain it in the
|
|
|
|
|
location given by the new declaration. */
|
|
|
|
|
if (TREE_CODE (x) == PARM_DECL)
|
|
|
|
|
{
|
|
|
|
|
tree *p;
|
|
|
|
|
for (p = &scope->names; *p; p = &TREE_CHAIN (*p))
|
|
|
|
|
if (*p == old)
|
|
|
|
|
{
|
|
|
|
|
*p = TREE_CHAIN (old);
|
2003-08-01 20:41:40 +02:00
|
|
|
|
SCOPE_LIST_APPEND (scope, parms, old);
|
|
|
|
|
break;
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return old;
|
|
|
|
|
}
|
2003-07-24 18:59:32 +02:00
|
|
|
|
if (DECL_EXTERNAL (x) || scope == global_scope)
|
2000-08-11 00:01:22 +02:00
|
|
|
|
{
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
/* Find and check against a previous, not-in-scope, external
|
|
|
|
|
decl for this identifier. (C99 s???: If two declarations
|
|
|
|
|
with external linkage, referring to the same object, have
|
|
|
|
|
incompatible types, the behavior is undefined). */
|
|
|
|
|
tree ext = any_external_decl (name);
|
|
|
|
|
if (ext)
|
2000-08-11 00:01:22 +02:00
|
|
|
|
{
|
2003-07-24 18:59:32 +02:00
|
|
|
|
if (duplicate_decls (x, ext, scope != global_scope,
|
2003-07-11 10:33:21 +02:00
|
|
|
|
false))
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
x = copy_node (ext);
|
2000-08-11 00:01:22 +02:00
|
|
|
|
}
|
1994-07-13 03:37:25 +02:00
|
|
|
|
else
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
record_external_decl (x);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
2003-06-19 21:43:59 +02:00
|
|
|
|
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
if (TREE_CODE (x) == TYPE_DECL)
|
|
|
|
|
clone_underlying_type (x);
|
|
|
|
|
|
|
|
|
|
/* If storing a local value, there may already be one
|
|
|
|
|
(inherited). If so, record it for restoration when this
|
2003-07-24 18:59:32 +02:00
|
|
|
|
scope ends. Take care not to do this if we are replacing an
|
|
|
|
|
older decl in the same scope (i.e. duplicate_decls returned
|
|
|
|
|
false, above). */
|
|
|
|
|
if (scope != global_scope
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
&& IDENTIFIER_SYMBOL_VALUE (name)
|
|
|
|
|
&& IDENTIFIER_SYMBOL_VALUE (name) != old)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
warn_if_shadowing (x, IDENTIFIER_SYMBOL_VALUE (name));
|
|
|
|
|
scope->shadowed = tree_cons (name, IDENTIFIER_SYMBOL_VALUE (name),
|
|
|
|
|
scope->shadowed);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
/* Install the new declaration in the requested scope. */
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
IDENTIFIER_SYMBOL_VALUE (name) = x;
|
|
|
|
|
C_DECL_INVISIBLE (x) = 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-08-30 23:21:40 +02:00
|
|
|
|
/* If x's type is incomplete because it's based on a
|
|
|
|
|
structure or union which has not yet been fully declared,
|
|
|
|
|
attach it to that structure or union type, so we can go
|
|
|
|
|
back and complete the variable declaration later, if the
|
|
|
|
|
structure or union gets fully declared.
|
|
|
|
|
|
2000-06-08 00:43:44 +02:00
|
|
|
|
If the input is erroneous, we can have error_mark in the type
|
|
|
|
|
slot (e.g. "f(void a, ...)") - that doesn't count as an
|
2003-08-30 23:21:40 +02:00
|
|
|
|
incomplete type. */
|
2000-06-08 00:43:44 +02:00
|
|
|
|
if (TREE_TYPE (x) != error_mark_node
|
|
|
|
|
&& !COMPLETE_TYPE_P (TREE_TYPE (x)))
|
2001-12-05 15:09:56 +01:00
|
|
|
|
{
|
|
|
|
|
tree element = TREE_TYPE (x);
|
|
|
|
|
|
|
|
|
|
while (TREE_CODE (element) == ARRAY_TYPE)
|
|
|
|
|
element = TREE_TYPE (element);
|
2003-08-30 23:21:40 +02:00
|
|
|
|
element = TYPE_MAIN_VARIANT (element);
|
|
|
|
|
|
2003-08-24 00:18:54 +02:00
|
|
|
|
if ((TREE_CODE (element) == RECORD_TYPE
|
|
|
|
|
|| TREE_CODE (element) == UNION_TYPE)
|
|
|
|
|
&& (TREE_CODE (x) != TYPE_DECL
|
2003-09-01 19:32:18 +02:00
|
|
|
|
|| TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE)
|
|
|
|
|
&& !COMPLETE_TYPE_P (element))
|
2003-08-30 23:21:40 +02:00
|
|
|
|
C_TYPE_INCOMPLETE_VARS (element)
|
|
|
|
|
= tree_cons (NULL_TREE, x, C_TYPE_INCOMPLETE_VARS (element));
|
2001-12-05 15:09:56 +01:00
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
if (TREE_CODE (x) == PARM_DECL)
|
2003-08-01 20:41:40 +02:00
|
|
|
|
SCOPE_LIST_APPEND (scope, parms, x);
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
else
|
2003-08-01 20:41:40 +02:00
|
|
|
|
SCOPE_LIST_APPEND (scope, names, x);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
return x;
|
|
|
|
|
}
|
|
|
|
|
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
/* Record X as belonging to the global scope (C99 "file scope").
|
2003-06-12 21:01:08 +02:00
|
|
|
|
This is used only internally by the Objective-C front end,
|
2003-08-01 20:41:40 +02:00
|
|
|
|
and is limited to its needs. duplicate_decls is not called;
|
|
|
|
|
if there is any preexisting decl for this identifier, it is an ICE. */
|
|
|
|
|
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
pushdecl_top_level (tree x)
|
2003-03-17 22:16:07 +01:00
|
|
|
|
{
|
2003-08-01 20:41:40 +02:00
|
|
|
|
tree name;
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
|
|
|
|
|
if (TREE_CODE (x) != VAR_DECL)
|
|
|
|
|
abort ();
|
|
|
|
|
|
|
|
|
|
name = DECL_NAME (x);
|
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
if (IDENTIFIER_SYMBOL_VALUE (name))
|
|
|
|
|
abort ();
|
2003-03-17 22:16:07 +01:00
|
|
|
|
|
2003-07-11 10:33:21 +02:00
|
|
|
|
DECL_CONTEXT (x) = current_file_decl;
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
IDENTIFIER_SYMBOL_VALUE (name) = x;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
SCOPE_LIST_APPEND (global_scope, names, x);
|
|
|
|
|
return x;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
/* Generate an implicit declaration for identifier FUNCTIONID as a
|
|
|
|
|
function of type int (). */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
implicitly_declare (tree functionid)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
tree decl = any_external_decl (functionid);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
if (decl)
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
{
|
|
|
|
|
/* Implicit declaration of a function already declared
|
|
|
|
|
(somehow) in a different scope, or as a built-in.
|
|
|
|
|
If this is the first time this has happened, warn;
|
|
|
|
|
then recycle the old declaration. */
|
|
|
|
|
if (!C_DECL_IMPLICIT (decl))
|
|
|
|
|
{
|
|
|
|
|
implicit_decl_warning (DECL_NAME (decl));
|
2003-08-29 23:57:05 +02:00
|
|
|
|
if (! DECL_FILE_SCOPE_P (decl))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
warning ("%Hprevious declaration of '%D'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (decl), decl);
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
C_DECL_IMPLICIT (decl) = 1;
|
|
|
|
|
}
|
2003-04-15 18:35:52 +02:00
|
|
|
|
/* If this function is global, then it must already be in the
|
2003-07-24 18:59:32 +02:00
|
|
|
|
global scope, so there's no need to push it again. */
|
|
|
|
|
if (current_scope == global_scope)
|
2003-04-15 18:35:52 +02:00
|
|
|
|
return decl;
|
|
|
|
|
/* If this is a local declaration, make a copy; we can't have
|
2003-07-24 18:59:32 +02:00
|
|
|
|
the same DECL listed in two different scopes. */
|
2003-04-15 18:35:52 +02:00
|
|
|
|
return pushdecl (copy_node (decl));
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
/* Not seen before. */
|
|
|
|
|
decl = build_decl (FUNCTION_DECL, functionid, default_function_type);
|
1992-07-12 04:56:45 +02:00
|
|
|
|
DECL_EXTERNAL (decl) = 1;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
TREE_PUBLIC (decl) = 1;
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
C_DECL_IMPLICIT (decl) = 1;
|
|
|
|
|
implicit_decl_warning (functionid);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-29 00:19:46 +02:00
|
|
|
|
/* C89 says implicit declarations are in the innermost block.
|
c-common.c, [...]: Delete code implementing -traditional mode.
* c-common.c, c-common.h, c-decl.c, c-lex.c, c-parse.in,
c-tree.h, c-typeck.c, cppexp.c, cpplex.c, cpplib.c, cpplib.h,
cppmacro.c, objc/lang-specs.h, objc/objc-act.c,
builtin-types.def, builtins.def, dwarf2out.c, dwarfout.c,
gcc.c, toplev.c: Delete code implementing -traditional mode.
* ada/misc.c, ch/ch-tree.h, ch/decl.c, cp/decl2.c, f/com.c,
f/lex.c, f/top.c, java/builtins.c, java/decl.c: Delete
traditional-mode-related code copied from the C front end
but not used, or used only to permit the compiler to link.
* doc/bugreport.texi, doc/cpp.texi, doc/extend.texi,
doc/invoke.texi, doc/standards.texi, doc/trouble.texi:
Document removal of -traditional mode for compilation, and
remove documentation only relevant to that mode.
* config/nextstep.h, config/ptx4.h, config/svr4.h,
config/convex/convex.h, config/d30v/d30v.h,
config/i386/dgux.h, config/i386/osf1elf.h,
config/i386/osfelf.h, config/i386/osfrose.h,
config/i386/sco5.h, config/i386/sol2.h, config/m68k/a-ux.h,
config/m68k/hp310.h, config/m88k/dgux.h,
config/m88k/dguxbcs.h, config/m88k/luna.h, config/m88k/m88k.c,
config/m88k/m88k.h, config/m88k/openbsd.h,
config/mips/abi64.h, config/mips/osfrose.h,
config/mips/svr4-5.h, config/mips/svr4-t.h,
config/sparc/sol2-sld-64.h, config/sparc/sol2.h,
config/stormy16/stormy16.h: Remove all references to
-traditional from target specs. Delete all mention of the
no-longer-necessary TRADITIONAL_RETURN_FLOAT macro. Also
delete a couple of commented-out definitions of
DOLLARS_IN_IDENTIFIERS, with (incorrect) commentary referring
to -traditional.
* system.h: Poison TRADITIONAL_RETURN_FLOAT.
* doc/tm.texi: Remove mention of TRADITIONAL_RETURN_FLOAT macro.
* testsuite/gcc.c-torture/execute/920730-1t.c,
testsuite/gcc.c-torture/execute/920730-1t.x,
testsuite/gcc.dg/ext-glob.c: Delete test cases, only relevant
to -traditional.
From-SVN: r50110
2002-02-27 19:48:07 +01:00
|
|
|
|
So we record the decl in the standard fashion. */
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
decl = pushdecl (decl);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
/* No need to call objc_check_decl here - it's a function type. */
|
2001-05-01 14:11:35 +02:00
|
|
|
|
rest_of_decl_compilation (decl, NULL, 0, 0);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-29 00:19:46 +02:00
|
|
|
|
/* Write a record describing this implicit function declaration
|
|
|
|
|
to the prototypes file (if requested). */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
gen_aux_info_record (decl, 0, 1, 0);
|
|
|
|
|
|
2001-10-02 09:12:25 +02:00
|
|
|
|
/* Possibly apply some default attributes to this implicit declaration. */
|
|
|
|
|
decl_attributes (&decl, NULL_TREE, 0);
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
return decl;
|
|
|
|
|
}
|
|
|
|
|
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
static void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
implicit_decl_warning (tree id)
|
2000-07-31 20:10:31 +02:00
|
|
|
|
{
|
top level:
* c-common.c (declare_function_name): Use func_id_node,
function_id_node, and pretty_function_id_node. Do not make
__func__ visible at file scope.
* c-common.h (c_tree_index): Add CTI_FUNCTION_ID,
CTI_PRETTY_FUNCTION_ID, and CTI_FUNC_ID.
(function_id_node, pretty_function_id_node, func_id_node): New
macros.
* c-decl.c (init_decl_processing): Initialize function_id_node,
pretty_function_id_node, and func_id_node.
(c_make_fname_decl): Correct comment.
* tree.h (struct tree_identifier): Constify pointer member.
* c-decl.c (pushdecl, implicit_decl_warning): Constify a char *.
* c-pragma.h (struct weak_syms): Constify name and value members.
(add_weak): Constify arguments.
* calls.c (special_function_p): Constify a char *.
(expand_call): Remove variable which is initialized and then
never used.
* dependence.c (struct def_use, struct induction, struct subscript):
Constify 'variable' member.
(get_low_bound, have_induction_variable): Constify char * argument.
(find_induction_variable): Add braces to avoid dangling else.
(classify_dependence): Constify char * arrays.
* profile.c (output_func_start_profiler): Constify a char *.
* stor-layout.c (finalize_record_size): Constify a char *.
* tree.c (is_attribute_p): Constify a char *.
* varasm.c (add_weak, remove_from_pending_weak_list): Constify argument.
* varasm.c (make_function_rtl, make_decl_rtl): Rearrange code
for comprehensibility. Do not call get_identifier if we did
not change the DECL_ASSEMBLER_NAME of the decl. Use alloca to
create temporary string constants, not ggc_alloc_string. No
need to copy result of ASM_FORMAT_PRIVATE_NAME. Use const
char * to hold IDENTIFIER_POINTERs.
ch:
* inout.c (add_enum_to_list): Use DECL_NAME directly, don't get
its IDENTIFIER_POINTER and immediately call get_identifier on it.
* lex.c (yywrap): Constify a char *.
cp:
* class.c (build_secondary_vtable): Constify a char *.
* decl.c (init_decl_processing): Initialize function_id_node,
pretty_function_id_node, and func_id_node.
* input.c (struct input_source): Constify 'str'.
(feed_input): Constify first argument.
* mangle.c (write_identifier): Constify argument.
* pt.c (mangle_class_name_for_template): Constify argument.
f:
* ansify.c: Use #line, not # <number>.
java:
* jcf-parse.c (set_source_filename): Constify a char *.
* jcf-write.c (append_innerclasses_attribute,
make_class_file_name): Constify a char *. Don't recycle a
variable for an unrelated purpose.
* parse.y: (build_alias_initializer_parameter_list): Constify a char *.
(breakdown_qualified): Do not modify IDENTIFIER_POINTER strings.
From-SVN: r36055
2000-08-29 23:39:49 +02:00
|
|
|
|
const char *name = IDENTIFIER_POINTER (id);
|
2000-07-31 20:10:31 +02:00
|
|
|
|
if (mesg_implicit_function_declaration == 2)
|
|
|
|
|
error ("implicit declaration of function `%s'", name);
|
|
|
|
|
else if (mesg_implicit_function_declaration == 1)
|
|
|
|
|
warning ("implicit declaration of function `%s'", name);
|
|
|
|
|
}
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Return zero if the declaration NEWDECL is valid
|
|
|
|
|
when the declaration OLDDECL (assumed to be for the same name)
|
|
|
|
|
has already been seen.
|
1999-01-27 02:43:17 +01:00
|
|
|
|
Otherwise return 1 if NEWDECL is a redefinition, 2 if it is a redeclaration,
|
|
|
|
|
and 3 if it is a conflicting declaration. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
1999-01-27 02:43:17 +01:00
|
|
|
|
static int
|
2003-06-19 21:43:59 +02:00
|
|
|
|
redeclaration_error_message (tree newdecl, tree olddecl)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
if (TREE_CODE (newdecl) == TYPE_DECL)
|
|
|
|
|
{
|
c-common.c, [...]: Delete code implementing -traditional mode.
* c-common.c, c-common.h, c-decl.c, c-lex.c, c-parse.in,
c-tree.h, c-typeck.c, cppexp.c, cpplex.c, cpplib.c, cpplib.h,
cppmacro.c, objc/lang-specs.h, objc/objc-act.c,
builtin-types.def, builtins.def, dwarf2out.c, dwarfout.c,
gcc.c, toplev.c: Delete code implementing -traditional mode.
* ada/misc.c, ch/ch-tree.h, ch/decl.c, cp/decl2.c, f/com.c,
f/lex.c, f/top.c, java/builtins.c, java/decl.c: Delete
traditional-mode-related code copied from the C front end
but not used, or used only to permit the compiler to link.
* doc/bugreport.texi, doc/cpp.texi, doc/extend.texi,
doc/invoke.texi, doc/standards.texi, doc/trouble.texi:
Document removal of -traditional mode for compilation, and
remove documentation only relevant to that mode.
* config/nextstep.h, config/ptx4.h, config/svr4.h,
config/convex/convex.h, config/d30v/d30v.h,
config/i386/dgux.h, config/i386/osf1elf.h,
config/i386/osfelf.h, config/i386/osfrose.h,
config/i386/sco5.h, config/i386/sol2.h, config/m68k/a-ux.h,
config/m68k/hp310.h, config/m88k/dgux.h,
config/m88k/dguxbcs.h, config/m88k/luna.h, config/m88k/m88k.c,
config/m88k/m88k.h, config/m88k/openbsd.h,
config/mips/abi64.h, config/mips/osfrose.h,
config/mips/svr4-5.h, config/mips/svr4-t.h,
config/sparc/sol2-sld-64.h, config/sparc/sol2.h,
config/stormy16/stormy16.h: Remove all references to
-traditional from target specs. Delete all mention of the
no-longer-necessary TRADITIONAL_RETURN_FLOAT macro. Also
delete a couple of commented-out definitions of
DOLLARS_IN_IDENTIFIERS, with (incorrect) commentary referring
to -traditional.
* system.h: Poison TRADITIONAL_RETURN_FLOAT.
* doc/tm.texi: Remove mention of TRADITIONAL_RETURN_FLOAT macro.
* testsuite/gcc.c-torture/execute/920730-1t.c,
testsuite/gcc.c-torture/execute/920730-1t.x,
testsuite/gcc.dg/ext-glob.c: Delete test cases, only relevant
to -traditional.
From-SVN: r50110
2002-02-27 19:48:07 +01:00
|
|
|
|
/* Do not complain about type redeclarations where at least one
|
|
|
|
|
declaration was in a system header. */
|
1995-02-21 23:56:58 +01:00
|
|
|
|
if (DECL_IN_SYSTEM_HEADER (olddecl) || DECL_IN_SYSTEM_HEADER (newdecl))
|
|
|
|
|
return 0;
|
1999-01-27 02:43:17 +01:00
|
|
|
|
return 1;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
else if (TREE_CODE (newdecl) == FUNCTION_DECL)
|
|
|
|
|
{
|
|
|
|
|
/* Declarations of functions can insist on internal linkage
|
|
|
|
|
but they can't be inconsistent with internal linkage,
|
|
|
|
|
so there can be no error on that account.
|
|
|
|
|
However defining the same name twice is no good. */
|
|
|
|
|
if (DECL_INITIAL (olddecl) != 0 && DECL_INITIAL (newdecl) != 0
|
|
|
|
|
/* However, defining once as extern inline and a second
|
|
|
|
|
time in another way is ok. */
|
2001-10-08 18:37:06 +02:00
|
|
|
|
&& ! (DECL_DECLARED_INLINE_P (olddecl) && DECL_EXTERNAL (olddecl)
|
|
|
|
|
&& ! (DECL_DECLARED_INLINE_P (newdecl)
|
|
|
|
|
&& DECL_EXTERNAL (newdecl))))
|
1999-01-27 02:43:17 +01:00
|
|
|
|
return 1;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
2003-08-29 23:57:05 +02:00
|
|
|
|
else if (DECL_FILE_SCOPE_P (newdecl))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-24 18:59:32 +02:00
|
|
|
|
/* Objects declared at file scope: */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* If at least one is a reference, it's ok. */
|
1992-07-12 04:56:45 +02:00
|
|
|
|
if (DECL_EXTERNAL (newdecl) || DECL_EXTERNAL (olddecl))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
return 0;
|
|
|
|
|
/* Reject two definitions. */
|
|
|
|
|
if (DECL_INITIAL (olddecl) != 0 && DECL_INITIAL (newdecl) != 0)
|
1999-01-27 02:43:17 +01:00
|
|
|
|
return 1;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Now we have two tentative defs, or one tentative and one real def. */
|
|
|
|
|
/* Insist that the linkage match. */
|
|
|
|
|
if (TREE_PUBLIC (olddecl) != TREE_PUBLIC (newdecl))
|
1999-01-27 02:43:17 +01:00
|
|
|
|
return 3;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
2003-07-24 18:59:32 +02:00
|
|
|
|
else if (current_scope->parm_flag
|
1992-02-13 23:21:26 +01:00
|
|
|
|
&& TREE_ASM_WRITTEN (olddecl) && !TREE_ASM_WRITTEN (newdecl))
|
|
|
|
|
return 0;
|
|
|
|
|
else
|
|
|
|
|
{
|
1994-03-18 00:45:04 +01:00
|
|
|
|
/* Newdecl has block scope. If olddecl has block scope also, then
|
|
|
|
|
reject two definitions, and reject a definition together with an
|
|
|
|
|
external reference. Otherwise, it is OK, because newdecl must
|
|
|
|
|
be an extern reference to olddecl. */
|
|
|
|
|
if (!(DECL_EXTERNAL (newdecl) && DECL_EXTERNAL (olddecl))
|
1995-03-06 00:27:16 +01:00
|
|
|
|
&& DECL_CONTEXT (newdecl) == DECL_CONTEXT (olddecl))
|
1999-01-27 02:43:17 +01:00
|
|
|
|
return 2;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-07-18 05:39:42 +02:00
|
|
|
|
|
|
|
|
|
/* Issue an error message for a reference to an undeclared variable
|
|
|
|
|
ID, including a reference to a builtin outside of function-call
|
|
|
|
|
context. Establish a binding of the identifier to error_mark_node
|
|
|
|
|
in an appropriate scope, which will suppress further errors for the
|
|
|
|
|
same identifier. */
|
|
|
|
|
void
|
|
|
|
|
undeclared_variable (tree id)
|
|
|
|
|
{
|
|
|
|
|
static bool already = false;
|
2003-08-01 20:41:40 +02:00
|
|
|
|
struct c_scope *scope;
|
2003-07-18 05:39:42 +02:00
|
|
|
|
|
|
|
|
|
if (current_function_decl == 0)
|
|
|
|
|
{
|
|
|
|
|
error ("`%s' undeclared here (not in a function)",
|
|
|
|
|
IDENTIFIER_POINTER (id));
|
2003-08-01 20:41:40 +02:00
|
|
|
|
scope = current_scope;
|
2003-07-18 05:39:42 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
error ("`%s' undeclared (first use in this function)",
|
|
|
|
|
IDENTIFIER_POINTER (id));
|
|
|
|
|
|
|
|
|
|
if (! already)
|
|
|
|
|
{
|
|
|
|
|
error ("(Each undeclared identifier is reported only once");
|
|
|
|
|
error ("for each function it appears in.)");
|
|
|
|
|
already = true;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
scope = current_function_scope;
|
2003-07-18 05:39:42 +02:00
|
|
|
|
}
|
2003-08-01 20:41:40 +02:00
|
|
|
|
|
|
|
|
|
scope->shadowed = tree_cons (id, IDENTIFIER_SYMBOL_VALUE (id),
|
|
|
|
|
scope->shadowed);
|
|
|
|
|
IDENTIFIER_SYMBOL_VALUE (id) = error_mark_node;
|
2003-07-18 05:39:42 +02:00
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
/* Subroutine of lookup_label, declare_label, define_label: construct a
|
|
|
|
|
LABEL_DECL with all the proper frills. */
|
|
|
|
|
|
|
|
|
|
static tree
|
|
|
|
|
make_label (tree name, location_t location)
|
|
|
|
|
{
|
|
|
|
|
tree label = build_decl (LABEL_DECL, name, void_type_node);
|
|
|
|
|
|
|
|
|
|
DECL_CONTEXT (label) = current_function_decl;
|
|
|
|
|
DECL_MODE (label) = VOIDmode;
|
|
|
|
|
DECL_SOURCE_LOCATION (label) = location;
|
|
|
|
|
|
|
|
|
|
return label;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Another subroutine of lookup_label, declare_label, define_label:
|
|
|
|
|
set up the binding of name to LABEL_DECL in the given SCOPE. */
|
|
|
|
|
|
|
|
|
|
static void
|
2003-07-24 18:59:32 +02:00
|
|
|
|
bind_label (tree name, tree label, struct c_scope *scope)
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
{
|
|
|
|
|
if (IDENTIFIER_LABEL_VALUE (name))
|
|
|
|
|
scope->shadowed = tree_cons (name, IDENTIFIER_LABEL_VALUE (name),
|
|
|
|
|
scope->shadowed);
|
|
|
|
|
IDENTIFIER_LABEL_VALUE (name) = label;
|
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
SCOPE_LIST_APPEND (scope, names, label);
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Get the LABEL_DECL corresponding to identifier NAME as a label.
|
1992-02-13 23:21:26 +01:00
|
|
|
|
Create one if none exists so far for the current function.
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
This is called when a label is used in a goto expression or
|
|
|
|
|
has its address taken. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
tree
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
lookup_label (tree name)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
tree label;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
1993-01-25 07:36:24 +01:00
|
|
|
|
if (current_function_decl == 0)
|
|
|
|
|
{
|
|
|
|
|
error ("label %s referenced outside of any function",
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
IDENTIFIER_POINTER (name));
|
1993-01-25 07:36:24 +01:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
/* Use a label already defined or ref'd with this name, but not if
|
|
|
|
|
it is inherited from a containing function and wasn't declared
|
|
|
|
|
using __label__. */
|
|
|
|
|
label = IDENTIFIER_LABEL_VALUE (name);
|
|
|
|
|
if (label && (DECL_CONTEXT (label) == current_function_decl
|
|
|
|
|
|| C_DECLARED_LABEL_FLAG (label)))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
/* If the label has only been declared, update its apparent
|
|
|
|
|
location to point here, for better diagnostics if it
|
|
|
|
|
turns out not to have been defined. */
|
|
|
|
|
if (!TREE_USED (label))
|
|
|
|
|
DECL_SOURCE_LOCATION (label) = input_location;
|
|
|
|
|
return label;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
/* No label binding for that identifier; make one. */
|
|
|
|
|
label = make_label (name, input_location);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-29 00:19:46 +02:00
|
|
|
|
/* Ordinary labels go in the current function scope. */
|
2003-07-24 18:59:32 +02:00
|
|
|
|
bind_label (name, label, current_function_scope);
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
return label;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
/* Make a label named NAME in the current function, shadowing silently
|
|
|
|
|
any that may be inherited from containing functions or containing
|
|
|
|
|
scopes. This is called for __label__ declarations. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
/* Note that valid use, if the label being shadowed comes from another
|
|
|
|
|
scope in the same function, requires calling declare_nonlocal_label
|
|
|
|
|
right away. (Is this still true? -zw 2003-07-17) */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
tree
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
declare_label (tree name)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
tree label = IDENTIFIER_LABEL_VALUE (name);
|
|
|
|
|
tree dup;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
/* Check to make sure that the label hasn't already been declared
|
|
|
|
|
at this scope */
|
2003-07-24 18:59:32 +02:00
|
|
|
|
for (dup = current_scope->names; dup; dup = TREE_CHAIN (dup))
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
if (dup == label)
|
|
|
|
|
{
|
|
|
|
|
error ("duplicate label declaration `%s'", IDENTIFIER_POINTER (name));
|
|
|
|
|
error ("%Hthis is a previous declaration",
|
|
|
|
|
&DECL_SOURCE_LOCATION (dup));
|
1994-10-01 11:58:44 +01:00
|
|
|
|
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
/* Just use the previous declaration. */
|
|
|
|
|
return dup;
|
|
|
|
|
}
|
1994-10-01 11:58:44 +01:00
|
|
|
|
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
label = make_label (name, input_location);
|
|
|
|
|
C_DECLARED_LABEL_FLAG (label) = 1;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
/* Declared labels go in the current scope. */
|
2003-07-24 18:59:32 +02:00
|
|
|
|
bind_label (name, label, current_scope);
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
return label;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Define a label, specifying the location in the source file.
|
|
|
|
|
Return the LABEL_DECL node for the label, if the definition is valid.
|
|
|
|
|
Otherwise return 0. */
|
|
|
|
|
|
|
|
|
|
tree
|
2003-07-01 11:00:45 +02:00
|
|
|
|
define_label (location_t location, tree name)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
tree label;
|
|
|
|
|
|
|
|
|
|
/* Find any preexisting label with this name. It is an error
|
|
|
|
|
if that label has already been defined in this function, or
|
|
|
|
|
if there is a containing function with a declared label with
|
|
|
|
|
the same name. */
|
|
|
|
|
label = IDENTIFIER_LABEL_VALUE (name);
|
|
|
|
|
|
|
|
|
|
if (label
|
|
|
|
|
&& ((DECL_CONTEXT (label) == current_function_decl
|
|
|
|
|
&& DECL_INITIAL (label) != 0)
|
|
|
|
|
|| (DECL_CONTEXT (label) != current_function_decl
|
|
|
|
|
&& C_DECLARED_LABEL_FLAG (label))))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-29 00:19:46 +02:00
|
|
|
|
location_t *prev_loc = &DECL_SOURCE_LOCATION (label);
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
error ("%Hduplicate label `%D'", &location, label);
|
|
|
|
|
if (DECL_INITIAL (label))
|
2003-07-29 00:19:46 +02:00
|
|
|
|
error ("%H`%D' previously defined here", prev_loc, label);
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
else
|
2003-07-29 00:19:46 +02:00
|
|
|
|
error ("%H`%D' previously declared here", prev_loc, label);
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
return 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
else if (label && DECL_CONTEXT (label) == current_function_decl)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
/* The label has been used or declared already in this function,
|
|
|
|
|
but not defined. Update its location to point to this
|
|
|
|
|
definition. */
|
|
|
|
|
DECL_SOURCE_LOCATION (label) = location;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
/* No label binding for that identifier; make one. */
|
|
|
|
|
label = make_label (name, location);
|
|
|
|
|
|
2003-07-29 00:19:46 +02:00
|
|
|
|
/* Ordinary labels go in the current function scope. */
|
2003-07-24 18:59:32 +02:00
|
|
|
|
bind_label (name, label, current_function_scope);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
* c-decl.c (named_labels, shadowed_labels, label_level_chain)
(push_label_level, pop_label_level): Kill.
(struct binding_level): Rename level_chain to outer.
Add outer_function field. Change parm_flag, function_body,
keep, keep_if_subblocks to 1-bit bitfields of type bool.
(current_function_level): New variable.
(keep_next_level_flag, keep_next_if_subblocks): Change type to bool.
(keep_next_level, declare_parm_level, warn_if_shadowing):
Update to match.
(struct language_function): Kill named_labels, shadowed_labels fields.
(c_init_decl_processing, start_function, c_push__function_context)
(c_pop_function_context): No need to muck with named_labels nor
shadowed_labels.
(make_binding_level): No need to clear the structure here.
(pop_binding_level): Always operate on current_binding_level.
Update current_function_level if necessary.
(pushlevel): Don't clear named_labels. Update current_function_level
if necessary. Use "true" and "false" where appropriate.
(poplevel): Diagnose labels defined but not used, or vice
versa, and clear out label-meanings leaving scope, while
walking down the decls list, for all binding levels.
Handle LABEL_DECLs appearing in the shadowed list.
pop_binding_level takes no arguments.
(pushdecl_function_level): Use current_function_level.
(make_label, bind_label): New static functions.
(declare_label): New exported function.
(lookup_label, define_label): Rewritten for new data structure.
(shadow_label): Kill.
* c-tree.h: Prototype declare_label; don't prototype
push_label_level, pop_label_level, nor shadow_label.
* c-parse.in: Remove all calls to push_label_level and
pop_label_level. Use declare_label for __label__ decls.
* doc/extend.texi: Clarify that __label__ can be used to
declare labels with local scope in any nested block, not
just statement expressions. Cross-reference nested functions
section from local labels section.
testsuite:
* gcc.dg/noncompile/label-1.c: New comprehensive test case for
diagnostics of ill-formed constructs involving labels.
* gcc.dg/noncompile/label-lineno-1.c: Add error regexp for
the new 'previously defined here' message.
From-SVN: r69597
2003-07-20 01:32:55 +02:00
|
|
|
|
|
|
|
|
|
if (warn_traditional && !in_system_header && lookup_name (name))
|
|
|
|
|
warning ("%Htraditional C lacks a separate namespace for labels, "
|
|
|
|
|
"identifier `%s' conflicts", &location,
|
|
|
|
|
IDENTIFIER_POINTER (name));
|
|
|
|
|
|
|
|
|
|
/* Mark label as having been defined. */
|
|
|
|
|
DECL_INITIAL (label) = error_mark_node;
|
|
|
|
|
return label;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
/* Return the list of declarations of the current scope. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
getdecls (void)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-24 18:59:32 +02:00
|
|
|
|
return current_scope->names;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Given NAME, an IDENTIFIER_NODE,
|
|
|
|
|
return the structure (or union or enum) definition for that name.
|
2003-07-24 18:59:32 +02:00
|
|
|
|
If THISLEVEL_ONLY is nonzero, searches only the current_scope.
|
1992-02-13 23:21:26 +01:00
|
|
|
|
CODE says which kind of type the caller wants;
|
|
|
|
|
it is RECORD_TYPE or UNION_TYPE or ENUMERAL_TYPE.
|
|
|
|
|
If the wrong kind of type is found, an error is reported. */
|
|
|
|
|
|
|
|
|
|
static tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
lookup_tag (enum tree_code code, tree name, int thislevel_only)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
tree tag = IDENTIFIER_TAG_VALUE (name);
|
|
|
|
|
int thislevel = 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
if (!tag)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
/* We only care about whether it's in this level if
|
|
|
|
|
thislevel_only was set or it might be a type clash. */
|
|
|
|
|
if (thislevel_only || TREE_CODE (tag) != code)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-24 18:59:32 +02:00
|
|
|
|
if (current_scope == global_scope
|
|
|
|
|
|| purpose_member (name, current_scope->tags))
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
thislevel = 1;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
|
|
|
|
|
if (thislevel_only && !thislevel)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (tag) != code)
|
|
|
|
|
{
|
|
|
|
|
/* Definition isn't the kind we were looking for. */
|
|
|
|
|
pending_invalid_xref = name;
|
2003-05-03 15:28:33 +02:00
|
|
|
|
pending_invalid_xref_location = input_location;
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
|
|
|
|
|
/* If in the same binding level as a declaration as a tag
|
|
|
|
|
of a different type, this must not be allowed to
|
|
|
|
|
shadow that tag, so give the error immediately.
|
|
|
|
|
(For example, "struct foo; union foo;" is invalid.) */
|
|
|
|
|
if (thislevel)
|
|
|
|
|
pending_xref_error ();
|
|
|
|
|
}
|
|
|
|
|
return tag;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Print an error message now
|
|
|
|
|
for a recent invalid struct, union or enum cross reference.
|
|
|
|
|
We don't print them immediately because they are not invalid
|
|
|
|
|
when used in the `struct foo;' construct for shadowing. */
|
|
|
|
|
|
|
|
|
|
void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
pending_xref_error (void)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
if (pending_invalid_xref != 0)
|
2003-05-08 17:04:44 +02:00
|
|
|
|
error ("%H`%s' defined as wrong kind of tag",
|
|
|
|
|
&pending_invalid_xref_location,
|
|
|
|
|
IDENTIFIER_POINTER (pending_invalid_xref));
|
1992-02-13 23:21:26 +01:00
|
|
|
|
pending_invalid_xref = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
/* Look up NAME in the current scope and its superiors
|
1992-02-13 23:21:26 +01:00
|
|
|
|
in the namespace of variables, functions and typedefs.
|
|
|
|
|
Return a ..._DECL node of some kind representing its definition,
|
|
|
|
|
or return 0 if it is undefined. */
|
|
|
|
|
|
|
|
|
|
tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
lookup_name (tree name)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
tree decl = IDENTIFIER_SYMBOL_VALUE (name);
|
|
|
|
|
if (decl == 0 || decl == error_mark_node)
|
|
|
|
|
return decl;
|
|
|
|
|
if (C_DECL_INVISIBLE (decl))
|
|
|
|
|
return 0;
|
|
|
|
|
return decl;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
/* Similar to `lookup_name' but look only at the current scope. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
static tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
lookup_name_current_level (tree name)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
tree decl = IDENTIFIER_SYMBOL_VALUE (name);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
if (decl == 0 || decl == error_mark_node || C_DECL_INVISIBLE (decl))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
return 0;
|
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
if (current_scope == global_scope)
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
return decl;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
/* Scan the current scope for a decl with name NAME.
|
|
|
|
|
For PARM_DECLs, we have to look at both ->parms and ->names, since
|
|
|
|
|
forward parameter declarations wind up on the ->names list. */
|
|
|
|
|
if (TREE_CODE (decl) == PARM_DECL
|
|
|
|
|
&& chain_member (decl, current_scope->parms))
|
|
|
|
|
return decl;
|
2003-07-24 18:59:32 +02:00
|
|
|
|
if (chain_member (decl, current_scope->names))
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
return decl;
|
|
|
|
|
|
|
|
|
|
return 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create the predefined scalar types of C,
|
1996-07-04 00:07:53 +02:00
|
|
|
|
and some nodes representing standard constants (0, 1, (void *) 0).
|
2003-07-24 18:59:32 +02:00
|
|
|
|
Initialize the global scope.
|
1992-02-13 23:21:26 +01:00
|
|
|
|
Make definitions for built-in primitive functions. */
|
|
|
|
|
|
|
|
|
|
void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
c_init_decl_processing (void)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree endlink;
|
1999-07-20 12:41:10 +02:00
|
|
|
|
tree ptr_ftype_void, ptr_ftype_ptr;
|
2003-06-29 13:28:00 +02:00
|
|
|
|
location_t save_loc = input_location;
|
|
|
|
|
|
c-common.c: Include c-lex.h.
* c-common.c: Include c-lex.h.
(c_common_lang_init): Change prototype. Call init_c_lex and
init_pragma from here.
* c-common.h (c_common_lang_init): Change prototype.
* c-decl.c (init_decl_processing): Rename. Call c_parse_init.
* c-lang.c (c_init): Change prototype. Update.
(c_init_options): Update.
* c-lex.c (cpp_filename): Remove.
(init_c_lex): Update. Read the main file, and get the original
file name.
(yyparse): Finish the command line options.
* c-parse.in (c_parse_init): Call init_reswords here.
(init_parse): Remove.
* c-tree.h (c_init_decl_processing): New.
* cpphash.c (_cpp_init_hashtable): After initializing the hash
table, populate it.
* cppinit.c (read_original_filename, cpp_finish_options): New.
(cpp_create_reader): New prototype. Defer hash table initialization.
(cpp_start_read): Rename cpp_read_main_file. Initialize the
hash table. Get the original filename.
* cpplib.h (cpp_create_reader): Update.
(cpp_start_read): Remove.
(cpp_read_main_file, cpp_finish_options): New.
* cppmain.c (main, do_preprocessing): Update.
* langhooks.h (struct langhooks): Update init prototype.
* toplev.c (general_init, parse_options_and_default_flags,
process_options, lang_indpendent_init, lang_dependent_init,
init_asm_output): New; perform the bulk of initialization.
(compile_file): Move most of initialization to above functions.
(debug_hooks): Initialize statically.
(set_Wunused): Relocate.
(toplev_main): Move most of initialization to other init functions.
Have a clear logic flow.
* tree.h (init_parse, init_decl_processing): Remove.
ada:
* misc.c (gnat_init): Change prototype. Include the
functionality of the old init_parse and init_decl_processing.
(gnat_init_decl_processing): New prototype.
(init_parse): Remove.
* utils.c (init_decl_processing): Rename gnat_init_decl_processing.
cp: * cp-tree.h (init_reswords, cxx_init_decl_processing): New.
(cxx_init): Update prototype.
* decl.c (init_decl_processing): Rename. Move null node init
to its creation time.
* lex.c (cxx_init_options): Update.
(cxx_init): Combine with old init_parse; also call
cxx_init_decl_processing.
f: * com.c (ffecom_init_decl_processing): Renamed from
init_decl_processing.
(init_parse): Move contents to ffe_init.
(ffe_init): Update prototype.
java: * decl.c (init_decl_processing): Rename java_init_decl_processing.
* java-tree.h: New prototype.
* lang.c (java_init): Update prototype. Combine with old init_parse.
objc: * objc-act.c (objc_init): Update prototype, combine with old
init_parse.
(objc_init_options): Update.
From-SVN: r47046
2001-11-15 11:01:10 +01:00
|
|
|
|
/* Adds some ggc roots, and reserved words for c-parse.in. */
|
|
|
|
|
c_parse_init ();
|
|
|
|
|
|
2003-07-29 00:19:46 +02:00
|
|
|
|
current_function_decl = 0;
|
2000-08-11 00:01:22 +02:00
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
/* Make the c_scope structure for global names. */
|
2000-08-11 00:01:22 +02:00
|
|
|
|
pushlevel (0);
|
2003-07-24 18:59:32 +02:00
|
|
|
|
global_scope = current_scope;
|
2003-07-29 00:19:46 +02:00
|
|
|
|
|
2003-06-04 19:19:36 +02:00
|
|
|
|
/* Declarations from c_common_nodes_and_builtins must not be associated
|
|
|
|
|
with this input file, lest we get differences between using and not
|
|
|
|
|
using preprocessed headers. */
|
2003-06-29 13:28:00 +02:00
|
|
|
|
input_location.file = "<internal>";
|
|
|
|
|
input_location.line = 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-11 10:33:21 +02:00
|
|
|
|
/* Make the DECL for the toplevel file scope. */
|
|
|
|
|
current_file_decl = build_decl (TRANSLATION_UNIT_DECL, NULL, NULL);
|
|
|
|
|
|
1999-09-10 12:36:02 +02:00
|
|
|
|
build_common_tree_nodes (flag_signed_char);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
c-common.c (SIZE_TYPE, WCHAR_TYPE): Define.
* c-common.c (SIZE_TYPE, WCHAR_TYPE): Define.
(flag_short_double, flag_short_wchar): Define.
(c_common_nodes_and_builtins): Create many tree nodes shared
between C and C++ here instead of in cp/decl.c and ...
* c-decl.c (init_decl_processing): ... here.
(SIZE_TYPE, WCHAR_TYPE): Don't define.
(flag_short_double, flag_short_wchar): Don't define.
(record_builtin_type): New function.
(build_void_list_node): New function.
* c-common.h (flag_short_double, flag_short_wchar,
record_builtin_type, build_void_list_node): Declare.
cp:
* decl.c (SIZE_TYPE, PTRDIFF_TYPE, WCHAR_TYPE): Don't define.
(record_builtin_type): Make non-static.
(flag_short_double): Don't declare.
(init_decl_processing): Remove the creation of many tree nodes now
in c_common_nodes_and_builtins.
(build_void_list_node): New function.
* decl2.c (flag_short_double, flag_short_wchar): Don't define.
* cp-tree.h (flag_short_wchar): Don't declare.
From-SVN: r38695
2001-01-05 00:53:54 +01:00
|
|
|
|
c_common_nodes_and_builtins ();
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-24 22:48:13 +02:00
|
|
|
|
/* In C, comparisons and TRUTH_* expressions have type int. */
|
|
|
|
|
truthvalue_type_node = integer_type_node;
|
|
|
|
|
truthvalue_true_node = integer_one_node;
|
|
|
|
|
truthvalue_false_node = integer_zero_node;
|
|
|
|
|
|
|
|
|
|
/* Even in C99, which has a real boolean type. */
|
2000-11-13 15:14:44 +01:00
|
|
|
|
pushdecl (build_decl (TYPE_DECL, get_identifier ("_Bool"),
|
2003-07-24 22:48:13 +02:00
|
|
|
|
boolean_type_node));
|
2000-11-13 15:14:44 +01:00
|
|
|
|
|
1999-07-20 12:41:10 +02:00
|
|
|
|
endlink = void_list_node;
|
1997-09-10 20:00:28 +02:00
|
|
|
|
ptr_ftype_void = build_function_type (ptr_type_node, endlink);
|
|
|
|
|
ptr_ftype_ptr
|
|
|
|
|
= build_function_type (ptr_type_node,
|
|
|
|
|
tree_cons (NULL_TREE, ptr_type_node, endlink));
|
|
|
|
|
|
2003-06-29 13:28:00 +02:00
|
|
|
|
input_location = save_loc;
|
2003-06-04 19:19:36 +02:00
|
|
|
|
|
1995-01-17 22:43:40 +01:00
|
|
|
|
pedantic_lvalues = pedantic;
|
|
|
|
|
|
2000-03-08 12:21:28 +01:00
|
|
|
|
make_fname_decl = c_make_fname_decl;
|
Lazy __FUNCTION__ generation.
gcc:
Lazy __FUNCTION__ generation.
* c-common.h (RID_FUNCTION_NAME, RID_PRETTY_FUNCTION_NAME,
RID_C99_FUNCTION_NAME): New _RIDs.
(CTI_FUNCTION_ID, CTI_PRETTY_FUNCTION_ID, CTI_FUNC_ID): Remove.
(CTI_FUNCTION_NAME_DECL, CTI_PRETTY_FUNCTION_NAME_DECL,
CTI_C99_FUNCTION_NAME_DECL, CTI_SAVED_FUNCTION_NAME_DECLS): New
global tree slots.
(function_id_node, pretty_function_id_node, func_id_node): Remove.
(c99_function_name_decl_node, function_name_decl_node,
pretty_function_name_decl_node, saved_function_name_decls):
Declare.
(struct language_function): Remove x_function_name_declared_p.
(make_fname_decl): Remove a parameter.
(declare_function_names): Remove prototype.
(start_fname_decls, finish_fname_decls): Prototype.
(fname_as_string): Likewise.
(fname_string, fname_decl): Likewise.
* c-common.c (make_fname_decl): Adjust.
(struct fname_var_t): New struct.
(fname_vars): New static array.
(declare_function_name): Remove.
(start_fname_decls, finish_fname_decls): New functions.
(fname_as_string): New function from remnants of
declare_function_name.
(fname_string, fname_decl): New functions.
* c-decl.c (c_function_name_declared_p): Remove.
(init_decl_processing): Don't generate __FUNCTION__ et al ids,
don't call declare_function_name. Call start_fname_decls.
(c_make_fname_decl): Adjust parameters. Generate the name. Don't
clobber the line number. Call finish_decl.
(start_function): Call start_fname_decls.
(finish_function): Call finish_fname_decls.
Remove c_function_name_declared_p.
(push_c_function_context): Don't push c_function_name_declared_p.
(pop_c_function_context): Don't pop c_function_name_declared_p.
(c_begin_compound_stmt): Don't check c_function_name_declared_p.
* c-parse.in (STRING_FUNC_NAME, VAR_FUNC_NAME): New tokens.
(program): Call finish_fname_decls for C.
(primary): Add VAR_FUNC_NAME.
(reswords): Add slots for __FUNCTION__ et al.
(rid_to_yy): Add mappings for __FUNCTION__ et al.
(yylexname): If it's a STRING_FUNC_NAME generate the function name
now. Don't look for VAR_DECLs containing __FUNCTION__ et al.
* c-semantics.c (prune_unused_decls): Remove.
(finish_stmt_tree): Don't call prune_unused_decls.
(genrtl_decl_stmt): Don't prune unused decls here.
cp:
Lazy __FUNCTION__ generation.
* cp-tree.def (FUNCTION_NAME): Remove.
* cp-tree.h (function_name_declared_p): Remove.
(cp_fname_init): Prototype.
* decl.c (init_decl_processing): Don't generate __FUNCTION__ et al ids,
don't call declare_function_name. Call start_fname_decls.
(cp_make_fname_decl): Adjust parameters. Generate the name. Don't
clobber the line number.
(cp_fname_init): New function.
(start_function): Call start_fname_decls.
(finish_function): Call finish_fname_decls.
* lex.c (reswords): Add slots for __FUNCTION__ et al.
(rid_to_yy): Add mappings for __FUNCTION__ et al.
* optimize.c (maybe_clone_body): Remove function_name_declared_p.
* parse.y (VAR_FUNC_NAME): New token.
(primary): Add VAR_FUNC_NAME.
* pt.c (tsubst_decl): Adjust a DECL_PRETTY_FUNCTION_P's
generation.
(tsubst, FUNCTION_NAME case): Remove.
(tsubst_copy, FUNCTION_NAME case): Remove.
(tsubst_expr, DECL_STMT case): Be careful with a
DECL_PRETTY_FUNCTION_P.
(instantiate_decl): Remove function_name_declared_p.
* semantics.c (begin_compound_statement): Don't call
declare_function_name here.
(setup_vtbl_ptr). Don't save & restore function_name_declared_p.
(finish_translation_unit): Call finish_fname_decls.
(expand_body): Remove function_name_declared_p.
* typeck2.c (digest_init): Allow any ERROR_MARK.
testsuite:
* gcc.dg/c99-func-2.c: Remove xfail.
* gcc.dg/c99-func-3.c: Remove xfail.
* gcc.dg/c99-func-4.c: Remove xfail.
From-SVN: r41520
2001-04-24 10:22:06 +02:00
|
|
|
|
start_fname_decls ();
|
2003-07-11 10:33:21 +02:00
|
|
|
|
|
2003-08-07 05:12:09 +02:00
|
|
|
|
first_builtin_decl = global_scope->names;
|
|
|
|
|
last_builtin_decl = global_scope->names_last;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-08 12:21:28 +01:00
|
|
|
|
/* Create the VAR_DECL for __FUNCTION__ etc. ID is the name to give the
|
|
|
|
|
decl, NAME is the initialization string and TYPE_DEP indicates whether
|
|
|
|
|
NAME depended on the type of the function. As we don't yet implement
|
|
|
|
|
delayed emission of static data, we mark the decl as emitted
|
|
|
|
|
so it is not placed in the output. Anything using it must therefore pull
|
2003-08-01 20:41:40 +02:00
|
|
|
|
out the STRING_CST initializer directly. FIXME. */
|
2000-03-08 12:21:28 +01:00
|
|
|
|
|
|
|
|
|
static tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
c_make_fname_decl (tree id, int type_dep)
|
2000-03-08 12:21:28 +01:00
|
|
|
|
{
|
Lazy __FUNCTION__ generation.
gcc:
Lazy __FUNCTION__ generation.
* c-common.h (RID_FUNCTION_NAME, RID_PRETTY_FUNCTION_NAME,
RID_C99_FUNCTION_NAME): New _RIDs.
(CTI_FUNCTION_ID, CTI_PRETTY_FUNCTION_ID, CTI_FUNC_ID): Remove.
(CTI_FUNCTION_NAME_DECL, CTI_PRETTY_FUNCTION_NAME_DECL,
CTI_C99_FUNCTION_NAME_DECL, CTI_SAVED_FUNCTION_NAME_DECLS): New
global tree slots.
(function_id_node, pretty_function_id_node, func_id_node): Remove.
(c99_function_name_decl_node, function_name_decl_node,
pretty_function_name_decl_node, saved_function_name_decls):
Declare.
(struct language_function): Remove x_function_name_declared_p.
(make_fname_decl): Remove a parameter.
(declare_function_names): Remove prototype.
(start_fname_decls, finish_fname_decls): Prototype.
(fname_as_string): Likewise.
(fname_string, fname_decl): Likewise.
* c-common.c (make_fname_decl): Adjust.
(struct fname_var_t): New struct.
(fname_vars): New static array.
(declare_function_name): Remove.
(start_fname_decls, finish_fname_decls): New functions.
(fname_as_string): New function from remnants of
declare_function_name.
(fname_string, fname_decl): New functions.
* c-decl.c (c_function_name_declared_p): Remove.
(init_decl_processing): Don't generate __FUNCTION__ et al ids,
don't call declare_function_name. Call start_fname_decls.
(c_make_fname_decl): Adjust parameters. Generate the name. Don't
clobber the line number. Call finish_decl.
(start_function): Call start_fname_decls.
(finish_function): Call finish_fname_decls.
Remove c_function_name_declared_p.
(push_c_function_context): Don't push c_function_name_declared_p.
(pop_c_function_context): Don't pop c_function_name_declared_p.
(c_begin_compound_stmt): Don't check c_function_name_declared_p.
* c-parse.in (STRING_FUNC_NAME, VAR_FUNC_NAME): New tokens.
(program): Call finish_fname_decls for C.
(primary): Add VAR_FUNC_NAME.
(reswords): Add slots for __FUNCTION__ et al.
(rid_to_yy): Add mappings for __FUNCTION__ et al.
(yylexname): If it's a STRING_FUNC_NAME generate the function name
now. Don't look for VAR_DECLs containing __FUNCTION__ et al.
* c-semantics.c (prune_unused_decls): Remove.
(finish_stmt_tree): Don't call prune_unused_decls.
(genrtl_decl_stmt): Don't prune unused decls here.
cp:
Lazy __FUNCTION__ generation.
* cp-tree.def (FUNCTION_NAME): Remove.
* cp-tree.h (function_name_declared_p): Remove.
(cp_fname_init): Prototype.
* decl.c (init_decl_processing): Don't generate __FUNCTION__ et al ids,
don't call declare_function_name. Call start_fname_decls.
(cp_make_fname_decl): Adjust parameters. Generate the name. Don't
clobber the line number.
(cp_fname_init): New function.
(start_function): Call start_fname_decls.
(finish_function): Call finish_fname_decls.
* lex.c (reswords): Add slots for __FUNCTION__ et al.
(rid_to_yy): Add mappings for __FUNCTION__ et al.
* optimize.c (maybe_clone_body): Remove function_name_declared_p.
* parse.y (VAR_FUNC_NAME): New token.
(primary): Add VAR_FUNC_NAME.
* pt.c (tsubst_decl): Adjust a DECL_PRETTY_FUNCTION_P's
generation.
(tsubst, FUNCTION_NAME case): Remove.
(tsubst_copy, FUNCTION_NAME case): Remove.
(tsubst_expr, DECL_STMT case): Be careful with a
DECL_PRETTY_FUNCTION_P.
(instantiate_decl): Remove function_name_declared_p.
* semantics.c (begin_compound_statement): Don't call
declare_function_name here.
(setup_vtbl_ptr). Don't save & restore function_name_declared_p.
(finish_translation_unit): Call finish_fname_decls.
(expand_body): Remove function_name_declared_p.
* typeck2.c (digest_init): Allow any ERROR_MARK.
testsuite:
* gcc.dg/c99-func-2.c: Remove xfail.
* gcc.dg/c99-func-3.c: Remove xfail.
* gcc.dg/c99-func-4.c: Remove xfail.
From-SVN: r41520
2001-04-24 10:22:06 +02:00
|
|
|
|
const char *name = fname_as_string (type_dep);
|
2000-03-08 12:21:28 +01:00
|
|
|
|
tree decl, type, init;
|
|
|
|
|
size_t length = strlen (name);
|
|
|
|
|
|
|
|
|
|
type = build_array_type
|
|
|
|
|
(build_qualified_type (char_type_node, TYPE_QUAL_CONST),
|
Lazy __FUNCTION__ generation.
gcc:
Lazy __FUNCTION__ generation.
* c-common.h (RID_FUNCTION_NAME, RID_PRETTY_FUNCTION_NAME,
RID_C99_FUNCTION_NAME): New _RIDs.
(CTI_FUNCTION_ID, CTI_PRETTY_FUNCTION_ID, CTI_FUNC_ID): Remove.
(CTI_FUNCTION_NAME_DECL, CTI_PRETTY_FUNCTION_NAME_DECL,
CTI_C99_FUNCTION_NAME_DECL, CTI_SAVED_FUNCTION_NAME_DECLS): New
global tree slots.
(function_id_node, pretty_function_id_node, func_id_node): Remove.
(c99_function_name_decl_node, function_name_decl_node,
pretty_function_name_decl_node, saved_function_name_decls):
Declare.
(struct language_function): Remove x_function_name_declared_p.
(make_fname_decl): Remove a parameter.
(declare_function_names): Remove prototype.
(start_fname_decls, finish_fname_decls): Prototype.
(fname_as_string): Likewise.
(fname_string, fname_decl): Likewise.
* c-common.c (make_fname_decl): Adjust.
(struct fname_var_t): New struct.
(fname_vars): New static array.
(declare_function_name): Remove.
(start_fname_decls, finish_fname_decls): New functions.
(fname_as_string): New function from remnants of
declare_function_name.
(fname_string, fname_decl): New functions.
* c-decl.c (c_function_name_declared_p): Remove.
(init_decl_processing): Don't generate __FUNCTION__ et al ids,
don't call declare_function_name. Call start_fname_decls.
(c_make_fname_decl): Adjust parameters. Generate the name. Don't
clobber the line number. Call finish_decl.
(start_function): Call start_fname_decls.
(finish_function): Call finish_fname_decls.
Remove c_function_name_declared_p.
(push_c_function_context): Don't push c_function_name_declared_p.
(pop_c_function_context): Don't pop c_function_name_declared_p.
(c_begin_compound_stmt): Don't check c_function_name_declared_p.
* c-parse.in (STRING_FUNC_NAME, VAR_FUNC_NAME): New tokens.
(program): Call finish_fname_decls for C.
(primary): Add VAR_FUNC_NAME.
(reswords): Add slots for __FUNCTION__ et al.
(rid_to_yy): Add mappings for __FUNCTION__ et al.
(yylexname): If it's a STRING_FUNC_NAME generate the function name
now. Don't look for VAR_DECLs containing __FUNCTION__ et al.
* c-semantics.c (prune_unused_decls): Remove.
(finish_stmt_tree): Don't call prune_unused_decls.
(genrtl_decl_stmt): Don't prune unused decls here.
cp:
Lazy __FUNCTION__ generation.
* cp-tree.def (FUNCTION_NAME): Remove.
* cp-tree.h (function_name_declared_p): Remove.
(cp_fname_init): Prototype.
* decl.c (init_decl_processing): Don't generate __FUNCTION__ et al ids,
don't call declare_function_name. Call start_fname_decls.
(cp_make_fname_decl): Adjust parameters. Generate the name. Don't
clobber the line number.
(cp_fname_init): New function.
(start_function): Call start_fname_decls.
(finish_function): Call finish_fname_decls.
* lex.c (reswords): Add slots for __FUNCTION__ et al.
(rid_to_yy): Add mappings for __FUNCTION__ et al.
* optimize.c (maybe_clone_body): Remove function_name_declared_p.
* parse.y (VAR_FUNC_NAME): New token.
(primary): Add VAR_FUNC_NAME.
* pt.c (tsubst_decl): Adjust a DECL_PRETTY_FUNCTION_P's
generation.
(tsubst, FUNCTION_NAME case): Remove.
(tsubst_copy, FUNCTION_NAME case): Remove.
(tsubst_expr, DECL_STMT case): Be careful with a
DECL_PRETTY_FUNCTION_P.
(instantiate_decl): Remove function_name_declared_p.
* semantics.c (begin_compound_statement): Don't call
declare_function_name here.
(setup_vtbl_ptr). Don't save & restore function_name_declared_p.
(finish_translation_unit): Call finish_fname_decls.
(expand_body): Remove function_name_declared_p.
* typeck2.c (digest_init): Allow any ERROR_MARK.
testsuite:
* gcc.dg/c99-func-2.c: Remove xfail.
* gcc.dg/c99-func-3.c: Remove xfail.
* gcc.dg/c99-func-4.c: Remove xfail.
From-SVN: r41520
2001-04-24 10:22:06 +02:00
|
|
|
|
build_index_type (size_int (length)));
|
2000-03-08 12:21:28 +01:00
|
|
|
|
|
|
|
|
|
decl = build_decl (VAR_DECL, id, type);
|
2003-06-19 21:43:59 +02:00
|
|
|
|
|
2000-03-08 12:21:28 +01:00
|
|
|
|
TREE_STATIC (decl) = 1;
|
|
|
|
|
TREE_READONLY (decl) = 1;
|
|
|
|
|
DECL_ARTIFICIAL (decl) = 1;
|
2003-06-19 21:43:59 +02:00
|
|
|
|
|
2000-03-08 12:21:28 +01:00
|
|
|
|
init = build_string (length + 1, name);
|
|
|
|
|
TREE_TYPE (init) = type;
|
|
|
|
|
DECL_INITIAL (decl) = init;
|
Lazy __FUNCTION__ generation.
gcc:
Lazy __FUNCTION__ generation.
* c-common.h (RID_FUNCTION_NAME, RID_PRETTY_FUNCTION_NAME,
RID_C99_FUNCTION_NAME): New _RIDs.
(CTI_FUNCTION_ID, CTI_PRETTY_FUNCTION_ID, CTI_FUNC_ID): Remove.
(CTI_FUNCTION_NAME_DECL, CTI_PRETTY_FUNCTION_NAME_DECL,
CTI_C99_FUNCTION_NAME_DECL, CTI_SAVED_FUNCTION_NAME_DECLS): New
global tree slots.
(function_id_node, pretty_function_id_node, func_id_node): Remove.
(c99_function_name_decl_node, function_name_decl_node,
pretty_function_name_decl_node, saved_function_name_decls):
Declare.
(struct language_function): Remove x_function_name_declared_p.
(make_fname_decl): Remove a parameter.
(declare_function_names): Remove prototype.
(start_fname_decls, finish_fname_decls): Prototype.
(fname_as_string): Likewise.
(fname_string, fname_decl): Likewise.
* c-common.c (make_fname_decl): Adjust.
(struct fname_var_t): New struct.
(fname_vars): New static array.
(declare_function_name): Remove.
(start_fname_decls, finish_fname_decls): New functions.
(fname_as_string): New function from remnants of
declare_function_name.
(fname_string, fname_decl): New functions.
* c-decl.c (c_function_name_declared_p): Remove.
(init_decl_processing): Don't generate __FUNCTION__ et al ids,
don't call declare_function_name. Call start_fname_decls.
(c_make_fname_decl): Adjust parameters. Generate the name. Don't
clobber the line number. Call finish_decl.
(start_function): Call start_fname_decls.
(finish_function): Call finish_fname_decls.
Remove c_function_name_declared_p.
(push_c_function_context): Don't push c_function_name_declared_p.
(pop_c_function_context): Don't pop c_function_name_declared_p.
(c_begin_compound_stmt): Don't check c_function_name_declared_p.
* c-parse.in (STRING_FUNC_NAME, VAR_FUNC_NAME): New tokens.
(program): Call finish_fname_decls for C.
(primary): Add VAR_FUNC_NAME.
(reswords): Add slots for __FUNCTION__ et al.
(rid_to_yy): Add mappings for __FUNCTION__ et al.
(yylexname): If it's a STRING_FUNC_NAME generate the function name
now. Don't look for VAR_DECLs containing __FUNCTION__ et al.
* c-semantics.c (prune_unused_decls): Remove.
(finish_stmt_tree): Don't call prune_unused_decls.
(genrtl_decl_stmt): Don't prune unused decls here.
cp:
Lazy __FUNCTION__ generation.
* cp-tree.def (FUNCTION_NAME): Remove.
* cp-tree.h (function_name_declared_p): Remove.
(cp_fname_init): Prototype.
* decl.c (init_decl_processing): Don't generate __FUNCTION__ et al ids,
don't call declare_function_name. Call start_fname_decls.
(cp_make_fname_decl): Adjust parameters. Generate the name. Don't
clobber the line number.
(cp_fname_init): New function.
(start_function): Call start_fname_decls.
(finish_function): Call finish_fname_decls.
* lex.c (reswords): Add slots for __FUNCTION__ et al.
(rid_to_yy): Add mappings for __FUNCTION__ et al.
* optimize.c (maybe_clone_body): Remove function_name_declared_p.
* parse.y (VAR_FUNC_NAME): New token.
(primary): Add VAR_FUNC_NAME.
* pt.c (tsubst_decl): Adjust a DECL_PRETTY_FUNCTION_P's
generation.
(tsubst, FUNCTION_NAME case): Remove.
(tsubst_copy, FUNCTION_NAME case): Remove.
(tsubst_expr, DECL_STMT case): Be careful with a
DECL_PRETTY_FUNCTION_P.
(instantiate_decl): Remove function_name_declared_p.
* semantics.c (begin_compound_statement): Don't call
declare_function_name here.
(setup_vtbl_ptr). Don't save & restore function_name_declared_p.
(finish_translation_unit): Call finish_fname_decls.
(expand_body): Remove function_name_declared_p.
* typeck2.c (digest_init): Allow any ERROR_MARK.
testsuite:
* gcc.dg/c99-func-2.c: Remove xfail.
* gcc.dg/c99-func-3.c: Remove xfail.
* gcc.dg/c99-func-4.c: Remove xfail.
From-SVN: r41520
2001-04-24 10:22:06 +02:00
|
|
|
|
|
|
|
|
|
TREE_USED (decl) = 1;
|
2003-01-03 20:29:51 +01:00
|
|
|
|
|
|
|
|
|
if (current_function_decl)
|
2003-08-01 20:41:40 +02:00
|
|
|
|
{
|
|
|
|
|
DECL_CONTEXT (decl) = current_function_decl;
|
|
|
|
|
IDENTIFIER_SYMBOL_VALUE (id) = decl;
|
|
|
|
|
SCOPE_LIST_APPEND (current_function_scope, names, decl);
|
|
|
|
|
}
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
|
Lazy __FUNCTION__ generation.
gcc:
Lazy __FUNCTION__ generation.
* c-common.h (RID_FUNCTION_NAME, RID_PRETTY_FUNCTION_NAME,
RID_C99_FUNCTION_NAME): New _RIDs.
(CTI_FUNCTION_ID, CTI_PRETTY_FUNCTION_ID, CTI_FUNC_ID): Remove.
(CTI_FUNCTION_NAME_DECL, CTI_PRETTY_FUNCTION_NAME_DECL,
CTI_C99_FUNCTION_NAME_DECL, CTI_SAVED_FUNCTION_NAME_DECLS): New
global tree slots.
(function_id_node, pretty_function_id_node, func_id_node): Remove.
(c99_function_name_decl_node, function_name_decl_node,
pretty_function_name_decl_node, saved_function_name_decls):
Declare.
(struct language_function): Remove x_function_name_declared_p.
(make_fname_decl): Remove a parameter.
(declare_function_names): Remove prototype.
(start_fname_decls, finish_fname_decls): Prototype.
(fname_as_string): Likewise.
(fname_string, fname_decl): Likewise.
* c-common.c (make_fname_decl): Adjust.
(struct fname_var_t): New struct.
(fname_vars): New static array.
(declare_function_name): Remove.
(start_fname_decls, finish_fname_decls): New functions.
(fname_as_string): New function from remnants of
declare_function_name.
(fname_string, fname_decl): New functions.
* c-decl.c (c_function_name_declared_p): Remove.
(init_decl_processing): Don't generate __FUNCTION__ et al ids,
don't call declare_function_name. Call start_fname_decls.
(c_make_fname_decl): Adjust parameters. Generate the name. Don't
clobber the line number. Call finish_decl.
(start_function): Call start_fname_decls.
(finish_function): Call finish_fname_decls.
Remove c_function_name_declared_p.
(push_c_function_context): Don't push c_function_name_declared_p.
(pop_c_function_context): Don't pop c_function_name_declared_p.
(c_begin_compound_stmt): Don't check c_function_name_declared_p.
* c-parse.in (STRING_FUNC_NAME, VAR_FUNC_NAME): New tokens.
(program): Call finish_fname_decls for C.
(primary): Add VAR_FUNC_NAME.
(reswords): Add slots for __FUNCTION__ et al.
(rid_to_yy): Add mappings for __FUNCTION__ et al.
(yylexname): If it's a STRING_FUNC_NAME generate the function name
now. Don't look for VAR_DECLs containing __FUNCTION__ et al.
* c-semantics.c (prune_unused_decls): Remove.
(finish_stmt_tree): Don't call prune_unused_decls.
(genrtl_decl_stmt): Don't prune unused decls here.
cp:
Lazy __FUNCTION__ generation.
* cp-tree.def (FUNCTION_NAME): Remove.
* cp-tree.h (function_name_declared_p): Remove.
(cp_fname_init): Prototype.
* decl.c (init_decl_processing): Don't generate __FUNCTION__ et al ids,
don't call declare_function_name. Call start_fname_decls.
(cp_make_fname_decl): Adjust parameters. Generate the name. Don't
clobber the line number.
(cp_fname_init): New function.
(start_function): Call start_fname_decls.
(finish_function): Call finish_fname_decls.
* lex.c (reswords): Add slots for __FUNCTION__ et al.
(rid_to_yy): Add mappings for __FUNCTION__ et al.
* optimize.c (maybe_clone_body): Remove function_name_declared_p.
* parse.y (VAR_FUNC_NAME): New token.
(primary): Add VAR_FUNC_NAME.
* pt.c (tsubst_decl): Adjust a DECL_PRETTY_FUNCTION_P's
generation.
(tsubst, FUNCTION_NAME case): Remove.
(tsubst_copy, FUNCTION_NAME case): Remove.
(tsubst_expr, DECL_STMT case): Be careful with a
DECL_PRETTY_FUNCTION_P.
(instantiate_decl): Remove function_name_declared_p.
* semantics.c (begin_compound_statement): Don't call
declare_function_name here.
(setup_vtbl_ptr). Don't save & restore function_name_declared_p.
(finish_translation_unit): Call finish_fname_decls.
(expand_body): Remove function_name_declared_p.
* typeck2.c (digest_init): Allow any ERROR_MARK.
testsuite:
* gcc.dg/c99-func-2.c: Remove xfail.
* gcc.dg/c99-func-3.c: Remove xfail.
* gcc.dg/c99-func-4.c: Remove xfail.
From-SVN: r41520
2001-04-24 10:22:06 +02:00
|
|
|
|
finish_decl (decl, init, NULL_TREE);
|
2000-08-11 00:01:22 +02:00
|
|
|
|
|
2000-03-08 12:21:28 +01:00
|
|
|
|
return decl;
|
|
|
|
|
}
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Return a definition for a builtin function named NAME and whose data type
|
|
|
|
|
is TYPE. TYPE should be a function type with argument types.
|
|
|
|
|
FUNCTION_CODE tells later passes how to compile calls to this function.
|
|
|
|
|
See tree.h for its possible values.
|
|
|
|
|
|
|
|
|
|
If LIBRARY_NAME is nonzero, use that for DECL_ASSEMBLER_NAME,
|
2002-07-02 01:07:19 +02:00
|
|
|
|
the name to be called if we can't opencode the function. If
|
|
|
|
|
ATTRS is nonzero, use that for the function's attribute list. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
1992-03-23 03:07:53 +01:00
|
|
|
|
tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
builtin_function (const char *name, tree type, int function_code,
|
|
|
|
|
enum built_in_class class, const char *library_name,
|
|
|
|
|
tree attrs)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
tree decl = build_decl (FUNCTION_DECL, get_identifier (name), type);
|
1992-07-12 04:56:45 +02:00
|
|
|
|
DECL_EXTERNAL (decl) = 1;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
TREE_PUBLIC (decl) = 1;
|
|
|
|
|
if (library_name)
|
Compute DECL_ASSEMBLER_NAME lazily.
* tree.h (DECL_ASSEMBLER_NAME): Compute it lazily.
(DECL_ASSEMBLER_NAME_SET_P): New macro.
(SET_DECL_ASSEMBLER_NAME): Likewise.
(COPY_DECL_ASSEMBLER_NAME): Likewise.
(set_decl_assembler_name): Declare.
(lang_set_decl_assembler_name): Likewise.
* tree.c (lang_set_decl_assembler_name): New variab.e
(set_decl_assembler_name): New function.
(init_obstacks): Set lang_set_decl_assembler_name.
(build_decl): Don't set DECL_ASSEMBLER_NAME.
* c-decl.c (duplicate_decls): Use SET_DECL_ASSEMBLER_NAME,
COPY_DECL_ASSEMBLER_NAME, etc. Don't set DECL_ASSEMBLER_NAME
where it's not necessary.
(builtin_function): Likewise.
(finish_decl): Likewise.
* dbxout.c (dbxout_type_methods): Likewise.
* ggc-common.c (ggc_mark_trees): Likewise.
* profile.c (output_func_start_profiler): Likewise.
* varasm.c (make_decl_rtl): Likewise.
* class.c (get_vtable_decl): Use SET_DECL_ASSEMBLER_NAME,
COPY_DECL_ASSEMBLER_NAME, etc. Don't set DECL_ASSEMBLER_NAME
where it's not necessary.
(add_method): Remove optimization involving comparison of
DECL_ASSEMBLER_NAME.
(build_vtbl_or_vbase_field): Use SET_DECL_ASSEMBLER_NAME,
COPY_DECL_ASSEMBLER_NAME, etc. Don't set DECL_ASSEMBLER_NAME
where it's not necessary.
(check_methods): Likewise.
(build_clone): Likewise.
(built_vtt): Likewise.
* cp-tree.h (DECL_NEEDED_P): Likewise.
* decl.c (pushtag): Likewise.
(duplicate_decls): Likewise.
(pushdecl): Likewise.
(builtin_function): Likewise.
(build_library_fn_1): Set DECL_LANGUAGE for library functions.
(build_cp_library_fn): Likewise.
(maybe_commonize_var): Use SET_DECL_ASSEMBLER_NAME,
COPY_DECL_ASSEMBLER_NAME, etc. Don't set DECL_ASSEMBLER_NAME
where it's not necessary.
(make_rtl_for_nonlocal_decl): Likewise.
(cp_finish_decl): Likewise.
(grokfndecl): Likewise.
(grokvardecl): Likewise.
(grokdeclarator): Likewise.
(start_function): Likewise.
(cp_missing_return_ok_p): Likewise.
* decl2.c (grokclassfn): Likewise.
(check_classfn): Likewise.
(finish_static_data_member_decl): Likewise.
(grokfield): Likewise.
* error.c (GLOBAL_IORD_P): Remove.
(dump_global_iord): Improve output.
(dump_decl): Avoid using DECL_ASSEMBLER_NAME.
* except.c (nothrow_libfn_p): Summarily reject any function not in
namespace-scope.
* init.c (build_java_class_ref): Don't explicitly set
DECL_ASSEMBLER_NAME after calling mangle_decl.
* mangle.c (mangle_decl_string): Handle extern "C" functions.
(mangle_decl): Set the DECL_ASSEMBLER_NAME for the decl.
* method.c (set_mangled_name_for_decl): Don't explicitly set
DECL_ASSEMBLER_NAME after calling mangle_decl.
(make_thunk): Explicitly set the DECL_ASSEMBLER_NAME and
IDENTIFIER_GLOBAL_VALUE for the thunk.
* pt.c (set_mangled_name_for_template_decl): Remove.
(check_explicit_specialization): Don't use it.
(looup_template_class): Don't set DECL_ASSEMBLER_NAME.
(tsubst_friend_function): Likewise.
(tsubst_decl): Likewise.
(regenerate_decl_from_template): Use COPY_DECL_ASSEMBLER_NAME.
* rtti.c (get_tinfo_decl): Use SET_DECL_ASSEMBLER_NAME,
COPY_DECL_ASSEMBLER_NAME, etc. Don't set DECL_ASSEMBLER_NAME
where it's not necessary.
(tinfo_base_init): Likewise.
(create_real_tinfo_var): Likewise.
* search.c (looup_field_1): Likewise.
* semantics.c (finish_named_return_value): Likewise.
* tree.c (init_tree): Set lang_set_decl_assembler_name.
* com.c (builtin_function): Use SET_DECL_ASSEMBLER_NAME.
* class.c (build_class_ref): Use SET_DECL_ASSEMBLER_NAME.
(layout_class): Likewise.
(layout_class_method): Likewise.
(emit_register_classes): Likewise.
* decl.c (builtin_function): Likewise.
(give_name_to_locals): Likewise.
From-SVN: r40642
2001-03-20 00:50:04 +01:00
|
|
|
|
SET_DECL_ASSEMBLER_NAME (decl, get_identifier (library_name));
|
2001-05-01 14:11:35 +02:00
|
|
|
|
make_decl_rtl (decl, NULL);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
pushdecl (decl);
|
1999-09-24 12:07:04 +02:00
|
|
|
|
DECL_BUILT_IN_CLASS (decl) = class;
|
|
|
|
|
DECL_FUNCTION_CODE (decl) = function_code;
|
|
|
|
|
|
1992-06-25 12:53:19 +02:00
|
|
|
|
/* Warn if a function in the namespace for users
|
|
|
|
|
is used without an occasion to consider it declared. */
|
|
|
|
|
if (name[0] != '_' || name[1] != '_')
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
C_DECL_INVISIBLE (decl) = 1;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2001-10-02 09:12:25 +02:00
|
|
|
|
/* Possibly apply some default attributes to this built-in function. */
|
2002-07-02 01:07:19 +02:00
|
|
|
|
if (attrs)
|
|
|
|
|
decl_attributes (&decl, attrs, ATTR_FLAG_BUILT_IN);
|
|
|
|
|
else
|
|
|
|
|
decl_attributes (&decl, NULL_TREE, 0);
|
2001-10-02 09:12:25 +02:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
return decl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Called when a declaration is seen that contains no names to declare.
|
|
|
|
|
If its type is a reference to a structure, union or enum inherited
|
|
|
|
|
from a containing scope, shadow that tag name for the current scope
|
|
|
|
|
with a forward reference.
|
|
|
|
|
If its type defines a new named structure or union
|
|
|
|
|
or defines an enum, it is valid but we need not do anything here.
|
|
|
|
|
Otherwise, it is an error. */
|
|
|
|
|
|
|
|
|
|
void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
shadow_tag (tree declspecs)
|
1992-07-25 10:06:54 +02:00
|
|
|
|
{
|
|
|
|
|
shadow_tag_warned (declspecs, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
shadow_tag_warned (tree declspecs, int warned)
|
|
|
|
|
|
|
|
|
|
|
1993-04-24 01:27:20 +02:00
|
|
|
|
/* 1 => we have done a pedwarn. 2 => we have done a warning, but
|
|
|
|
|
no pedwarn. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
int found_tag = 0;
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree link;
|
1998-02-18 11:38:57 +01:00
|
|
|
|
tree specs, attrs;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
pending_invalid_xref = 0;
|
|
|
|
|
|
1998-02-18 11:38:57 +01:00
|
|
|
|
/* Remove the attributes from declspecs, since they will confuse the
|
|
|
|
|
following code. */
|
|
|
|
|
split_specs_attrs (declspecs, &specs, &attrs);
|
|
|
|
|
|
1998-06-15 15:22:59 +02:00
|
|
|
|
for (link = specs; link; link = TREE_CHAIN (link))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree value = TREE_VALUE (link);
|
|
|
|
|
enum tree_code code = TREE_CODE (value);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
if (code == RECORD_TYPE || code == UNION_TYPE || code == ENUMERAL_TYPE)
|
|
|
|
|
/* Used to test also that TYPE_SIZE (value) != 0.
|
|
|
|
|
That caused warning for `struct foo;' at top level in the file. */
|
|
|
|
|
{
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
tree name = TYPE_NAME (value);
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree t;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
found_tag++;
|
|
|
|
|
|
|
|
|
|
if (name == 0)
|
|
|
|
|
{
|
1993-04-24 01:27:20 +02:00
|
|
|
|
if (warned != 1 && code != ENUMERAL_TYPE)
|
|
|
|
|
/* Empty unnamed enum OK */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
pedwarn ("unnamed struct/union that defines no instances");
|
|
|
|
|
warned = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
t = lookup_tag (code, name, 1);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
if (t == 0)
|
|
|
|
|
{
|
|
|
|
|
t = make_node (code);
|
|
|
|
|
pushtag (name, t);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
1995-05-20 13:04:26 +02:00
|
|
|
|
if (!warned && ! in_system_header)
|
1993-04-24 01:27:20 +02:00
|
|
|
|
{
|
|
|
|
|
warning ("useless keyword or type name in empty declaration");
|
|
|
|
|
warned = 2;
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1993-04-24 01:27:20 +02:00
|
|
|
|
if (found_tag > 1)
|
|
|
|
|
error ("two types specified in one empty declaration");
|
|
|
|
|
|
|
|
|
|
if (warned != 1)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
if (found_tag == 0)
|
|
|
|
|
pedwarn ("empty declaration");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-05-25 13:12:47 +02:00
|
|
|
|
/* Construct an array declarator. EXPR is the expression inside [], or
|
|
|
|
|
NULL_TREE. QUALS are the type qualifiers inside the [] (to be applied
|
|
|
|
|
to the pointer to which a parameter array is converted). STATIC_P is
|
2002-09-22 04:03:17 +02:00
|
|
|
|
nonzero if "static" is inside the [], zero otherwise. VLA_UNSPEC_P
|
|
|
|
|
is nonzero is the array is [*], a VLA of unspecified length which is
|
2001-05-25 13:12:47 +02:00
|
|
|
|
nevertheless a complete type (not currently implemented by GCC),
|
|
|
|
|
zero otherwise. The declarator is constructed as an ARRAY_REF
|
|
|
|
|
(to be decoded by grokdeclarator), whose operand 0 is what's on the
|
|
|
|
|
left of the [] (filled by in set_array_declarator_type) and operand 1
|
|
|
|
|
is the expression inside; whose TREE_TYPE is the type qualifiers and
|
|
|
|
|
which has TREE_STATIC set if "static" is used. */
|
|
|
|
|
|
|
|
|
|
tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
build_array_declarator (tree expr, tree quals, int static_p, int vla_unspec_p)
|
2001-05-25 13:12:47 +02:00
|
|
|
|
{
|
|
|
|
|
tree decl;
|
|
|
|
|
decl = build_nt (ARRAY_REF, NULL_TREE, expr);
|
|
|
|
|
TREE_TYPE (decl) = quals;
|
|
|
|
|
TREE_STATIC (decl) = (static_p ? 1 : 0);
|
|
|
|
|
if (pedantic && !flag_isoc99)
|
|
|
|
|
{
|
|
|
|
|
if (static_p || quals != NULL_TREE)
|
2002-07-21 23:35:17 +02:00
|
|
|
|
pedwarn ("ISO C90 does not support `static' or type qualifiers in parameter array declarators");
|
2001-05-25 13:12:47 +02:00
|
|
|
|
if (vla_unspec_p)
|
2002-07-21 23:35:17 +02:00
|
|
|
|
pedwarn ("ISO C90 does not support `[*]' array declarators");
|
2001-05-25 13:12:47 +02:00
|
|
|
|
}
|
|
|
|
|
if (vla_unspec_p)
|
|
|
|
|
warning ("GCC does not yet properly implement `[*]' array declarators");
|
|
|
|
|
return decl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set the type of an array declarator. DECL is the declarator, as
|
|
|
|
|
constructed by build_array_declarator; TYPE is what appears on the left
|
2002-09-22 04:03:17 +02:00
|
|
|
|
of the [] and goes in operand 0. ABSTRACT_P is nonzero if it is an
|
2001-05-25 13:12:47 +02:00
|
|
|
|
abstract declarator, zero otherwise; this is used to reject static and
|
|
|
|
|
type qualifiers in abstract declarators, where they are not in the
|
|
|
|
|
C99 grammar. */
|
|
|
|
|
|
|
|
|
|
tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
set_array_declarator_type (tree decl, tree type, int abstract_p)
|
2001-05-25 13:12:47 +02:00
|
|
|
|
{
|
|
|
|
|
TREE_OPERAND (decl, 0) = type;
|
|
|
|
|
if (abstract_p && (TREE_TYPE (decl) != NULL_TREE || TREE_STATIC (decl)))
|
|
|
|
|
error ("static or type qualifiers in abstract declarator");
|
|
|
|
|
return decl;
|
|
|
|
|
}
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Decode a "typename", such as "int **", returning a ..._TYPE node. */
|
|
|
|
|
|
|
|
|
|
tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
groktypename (tree typename)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2001-12-15 05:06:05 +01:00
|
|
|
|
tree specs, attrs;
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (TREE_CODE (typename) != TREE_LIST)
|
|
|
|
|
return typename;
|
2001-12-15 05:06:05 +01:00
|
|
|
|
|
|
|
|
|
split_specs_attrs (TREE_PURPOSE (typename), &specs, &attrs);
|
|
|
|
|
|
2002-02-02 01:14:41 +01:00
|
|
|
|
typename = grokdeclarator (TREE_VALUE (typename), specs, TYPENAME, 0);
|
2001-12-15 05:06:05 +01:00
|
|
|
|
|
|
|
|
|
/* Apply attributes. */
|
|
|
|
|
decl_attributes (&typename, attrs, 0);
|
|
|
|
|
|
|
|
|
|
return typename;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return a PARM_DECL node for a given pair of specs and declarator. */
|
|
|
|
|
|
|
|
|
|
tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
groktypename_in_parm_context (tree typename)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
if (TREE_CODE (typename) != TREE_LIST)
|
|
|
|
|
return typename;
|
|
|
|
|
return grokdeclarator (TREE_VALUE (typename),
|
|
|
|
|
TREE_PURPOSE (typename),
|
2002-02-02 01:14:41 +01:00
|
|
|
|
PARM, 0);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Decode a declarator in an ordinary declaration or data definition.
|
|
|
|
|
This is called as soon as the type information and variable name
|
|
|
|
|
have been parsed, before parsing the initializer if any.
|
|
|
|
|
Here we create the ..._DECL node, fill in its type,
|
|
|
|
|
and put it on the list of decls for the current context.
|
|
|
|
|
The ..._DECL node is returned as the value.
|
|
|
|
|
|
|
|
|
|
Exception: for arrays where the length is not specified,
|
|
|
|
|
the type is left null, to be filled in by `finish_decl'.
|
|
|
|
|
|
|
|
|
|
Function definitions do not come here; they go to start_function
|
|
|
|
|
instead. However, external and forward declarations of functions
|
|
|
|
|
do go through here. Structure field declarations are done by
|
|
|
|
|
grokfield and not through here. */
|
|
|
|
|
|
|
|
|
|
tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
start_decl (tree declarator, tree declspecs, int initialized, tree attributes)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2002-01-10 19:51:24 +01:00
|
|
|
|
tree decl;
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree tem;
|
2003-06-19 21:43:59 +02:00
|
|
|
|
|
2002-01-10 19:51:24 +01:00
|
|
|
|
/* An object declared as __attribute__((deprecated)) suppresses
|
|
|
|
|
warnings of uses of other deprecated items. */
|
|
|
|
|
if (lookup_attribute ("deprecated", attributes))
|
|
|
|
|
deprecated_state = DEPRECATED_SUPPRESS;
|
|
|
|
|
|
|
|
|
|
decl = grokdeclarator (declarator, declspecs,
|
2002-02-02 01:14:41 +01:00
|
|
|
|
NORMAL, initialized);
|
2003-06-19 21:43:59 +02:00
|
|
|
|
|
2002-01-10 19:51:24 +01:00
|
|
|
|
deprecated_state = DEPRECATED_NORMAL;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2000-08-11 00:01:22 +02:00
|
|
|
|
if (warn_main > 0 && TREE_CODE (decl) != FUNCTION_DECL
|
2000-08-24 22:09:27 +02:00
|
|
|
|
&& MAIN_NAME_P (DECL_NAME (decl)))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
warning ("%H'%D' is usually a function",
|
|
|
|
|
&DECL_SOURCE_LOCATION (decl), decl);
|
1997-01-19 21:04:35 +01:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (initialized)
|
|
|
|
|
/* Is it valid for this decl to have an initializer at all?
|
|
|
|
|
If not, set INITIALIZED to zero, which will indirectly
|
|
|
|
|
tell `finish_decl' to ignore the initializer once it is parsed. */
|
|
|
|
|
switch (TREE_CODE (decl))
|
|
|
|
|
{
|
|
|
|
|
case TYPE_DECL:
|
2002-10-19 05:14:11 +02:00
|
|
|
|
error ("typedef `%s' is initialized (use __typeof__ instead)",
|
2002-10-09 23:27:38 +02:00
|
|
|
|
IDENTIFIER_POINTER (DECL_NAME (decl)));
|
|
|
|
|
initialized = 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case FUNCTION_DECL:
|
|
|
|
|
error ("function `%s' is initialized like a variable",
|
|
|
|
|
IDENTIFIER_POINTER (DECL_NAME (decl)));
|
|
|
|
|
initialized = 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PARM_DECL:
|
|
|
|
|
/* DECL_INITIAL in a PARM_DECL is really DECL_ARG_TYPE. */
|
|
|
|
|
error ("parameter `%s' is initialized",
|
|
|
|
|
IDENTIFIER_POINTER (DECL_NAME (decl)));
|
|
|
|
|
initialized = 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
/* Don't allow initializations for incomplete types
|
|
|
|
|
except for arrays which might be completed by the initialization. */
|
2000-10-20 02:58:35 +02:00
|
|
|
|
|
|
|
|
|
/* This can happen if the array size is an undefined macro. We already
|
|
|
|
|
gave a warning, so we don't need another one. */
|
|
|
|
|
if (TREE_TYPE (decl) == error_mark_node)
|
|
|
|
|
initialized = 0;
|
|
|
|
|
else if (COMPLETE_TYPE_P (TREE_TYPE (decl)))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
/* A complete type is ok if size is fixed. */
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (TYPE_SIZE (TREE_TYPE (decl))) != INTEGER_CST
|
|
|
|
|
|| C_DECL_VARIABLE_SIZE (decl))
|
|
|
|
|
{
|
|
|
|
|
error ("variable-sized object may not be initialized");
|
|
|
|
|
initialized = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE)
|
|
|
|
|
{
|
|
|
|
|
error ("variable `%s' has initializer but incomplete type",
|
|
|
|
|
IDENTIFIER_POINTER (DECL_NAME (decl)));
|
|
|
|
|
initialized = 0;
|
|
|
|
|
}
|
tree.h (COMPLETE_TYPE_P): New macro.
gcc
* tree.h (COMPLETE_TYPE_P): New macro.
(COMPLETE_OR_VOID_TYPE_P): New macro.
(COMPLETE_OR_UNBOUND_ARRAY_TYPE_P): New macro.
* stor-layout.c (layout_type, case VOID_TYPE): Don't set TYPE_SIZE.
* c-aux-info.c (gen_type): Use them.
* c-common.c (c_expand_expr_stmt): Likewise.
* c-decl.c (poplevel, pushdecl, start_decl, finish_decl,
grokdeclarator, grokparms, finish_struct, start_function,
store_parm_decls, combine_parm_decls): Likewise.
* c-parse.y (cast_expr): Likewise.
* c-typeck.c (require_complete_type, c_sizeof, c_sizeof_nowarn,
c_size_in_bytes, c_alignof, build_component_ref,
build_indirect_ref, build_array_ref, convert_arguments,
build_binary_op, pointer_diff, build_unary_op, digest_init: Likewise.
* calls.c (initialize_argument_information): Likewise.
* convert.c (convert_to_integer): Likewise.
* dbxout.c (dbxout_typedefs, dbxout_type, dbxout_symbol): Likewise.
* dwarfout.c (location_or_const_value_attribute,
output_enumeration_type_die, output_structure_type_die,
output_union_type_die, output_type): Likewise.
* expr.c (safe_from_p, expand_expr): Likewise.
* function.c (assign_parms): Likewise.
* sdbout.c (sdbout_symbol, sdbout_one_type): Likewise.
* tree.c (build_array_type, build_function_type,
build_method_type, build_offset_type, build_complex_type): Likewise.
* c-parse.c, c-parse.h: Regenerated.
gcc/cp
* typeck.c (require_complete_type, complete_type,
complete_type_or_else, c_sizeof, c_sizeof_nowarn,
build_array_ref, convert_arguments, pointer_diff,
build_x_unary_op, build_unary_op, build_c_cast,
build_modify_expr): Use COMPLETE_TYPE_P etc.
* call.c (is_complete, convert_like_real,
build_new_method_call): Likewise.
* class.c (build_vbase_pointer_fields, check_bases,
build_base_field, finish_struct_1, pushclass): Likewise.
* cvt.c (cp_convert_to_pointer, convert_to_void): Likewise.
* decl.c (maybe_process_template_type_declaration, pushtag,
pushdecl, redeclaration_error_message, start_decl, start_decl_1,
layout_var_decl, check_initializer, cp_finish_decl,
grokdeclarator, require_complete_types_for_parms,
grok_op_properties, xref_tag, xref_basetypes,
check_function_type): Likewise.
* decl2.c (check_classfn, reparse_absdcl_as_casts): Likewise.
* friend.c (do_friend): Likewise.
* init.c (build_offset_ref): Likewise.
* parse.y (structsp): Likewise.
* pt.c (maybe_process_partial_specialization,
tsubst_friend_function, instantiate_class_template, tsubst,
do_type_instantiation, instantiate_pending_templates): Likewise.
* repo.c (repo_get_id): Likewise.
* rtti.c (build_typeid, get_typeid, build_dynamic_cast_1,
synthesize_tinfo_var, emit_support_tinfos): Likewise.
* search.c (lookup_fnfields_1, lookup_conversions): Likewise.
* semantics.c (begin_class_definition): Likewise.
* tree.c (build_cplus_method_type): Likewise.
* typeck2.c (digest_init, build_functional_cast,
add_exception_specifier): Likewise.
* parse.h, parse.c: Regenerated.
From-SVN: r32671
2000-03-21 19:10:48 +01:00
|
|
|
|
else if (!COMPLETE_TYPE_P (TREE_TYPE (TREE_TYPE (decl))))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
error ("elements of array `%s' have incomplete type",
|
|
|
|
|
IDENTIFIER_POINTER (DECL_NAME (decl)));
|
|
|
|
|
initialized = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (initialized)
|
|
|
|
|
{
|
1992-07-12 04:56:45 +02:00
|
|
|
|
DECL_EXTERNAL (decl) = 0;
|
2003-07-24 18:59:32 +02:00
|
|
|
|
if (current_scope == global_scope)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
TREE_STATIC (decl) = 1;
|
|
|
|
|
|
|
|
|
|
/* Tell `pushdecl' this is an initialized decl
|
|
|
|
|
even though we don't yet have the initializer expression.
|
|
|
|
|
Also tell `finish_decl' it may store the real initializer. */
|
|
|
|
|
DECL_INITIAL (decl) = error_mark_node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If this is a function declaration, write a record describing it to the
|
|
|
|
|
prototypes file (if requested). */
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (decl) == FUNCTION_DECL)
|
|
|
|
|
gen_aux_info_record (decl, 0, 0, TYPE_ARG_TYPES (TREE_TYPE (decl)) != 0);
|
|
|
|
|
|
1996-05-06 20:36:48 +02:00
|
|
|
|
/* ANSI specifies that a tentative definition which is not merged with
|
|
|
|
|
a non-tentative definition behaves exactly like a definition with an
|
|
|
|
|
initializer equal to zero. (Section 3.7.2)
|
2002-05-22 03:11:29 +02:00
|
|
|
|
|
|
|
|
|
-fno-common gives strict ANSI behavior, though this tends to break
|
|
|
|
|
a large body of code that grew up without this rule.
|
|
|
|
|
|
|
|
|
|
Thread-local variables are never common, since there's no entrenched
|
|
|
|
|
body of code to break, and it allows more efficient variable references
|
2003-01-18 03:26:43 +01:00
|
|
|
|
in the presence of dynamic linking. */
|
2002-05-22 03:11:29 +02:00
|
|
|
|
|
|
|
|
|
if (TREE_CODE (decl) == VAR_DECL
|
|
|
|
|
&& !initialized
|
|
|
|
|
&& TREE_PUBLIC (decl)
|
|
|
|
|
&& !DECL_THREAD_LOCAL (decl)
|
|
|
|
|
&& !flag_no_common)
|
1996-05-06 20:36:48 +02:00
|
|
|
|
DECL_COMMON (decl) = 1;
|
1995-06-07 00:39:24 +02:00
|
|
|
|
|
1995-04-25 22:06:42 +02:00
|
|
|
|
/* Set attributes here so if duplicate decl, will have proper attributes. */
|
c-common.c (decl_attributes): Take a pointer to the node to which attributes are to be attached...
* c-common.c (decl_attributes): Take a pointer to the node to
which attributes are to be attached, and a flags argument.
* c-common.h (enum attribute_flags): New.
(decl_attributes): Update prototype.
* c-decl.c (start_decl, push_parm_decl, finish_struct,
finish_enum, start_function): Update calls to decl_attributes.
* c-parse.in (component_declarator, component_notype_declarator,
label): Update calls to decl_attributes.
cp:
* decl2.c (cplus_decl_attributes): Take a pointer to the node to
which attributes are to be attached, and a flags argument. Update
call to decl_attributes.
(grokfield): Update call to decl_attributes.
* class.c (finish_struct): Update call to cplus_decl_attributes.
* cp-tree.h (cplus_decl_attributes): Update prototype.
* decl.c (start_decl, grokdeclarator, start_function): Update
calls to decl_attributes and cplus_decl_attributes.
* friend.c (do_friend): Update call to cplus_decl_attributes.
* parse.y (parse_bitfield): Update call to cplus_decl_attributes.
From-SVN: r43995
2001-07-13 22:40:43 +02:00
|
|
|
|
decl_attributes (&decl, attributes, 0);
|
1995-04-25 22:06:42 +02:00
|
|
|
|
|
targhooks.c: New file.
* targhooks.c: New file.
* targhooks.h: New file.
* Makefile.in: Add targhooks.o support.
(function.o): Depend on$(TARGET_H).
(stmt.o): Likewise.
(combine.o): Depend on $(TREE_H) and $(TARGET_H).
* builtins.c (apply_args_size, expand_builtin_apply_args_1,
expand_builtin_apply): Convert to calls.struct_value_rtx hook.
(expand_builtin_saveregs): Convert to
calls.expand_builtin_saveregs hook.
* c-decl.c (start_decl): Handle new calls.promote_prototypes hook
here, instead of ...
(get_parm_info) ... here.
(store_parm_decls_oldstyle): Convert to calls.promote_prototypes
hook.
(finish_function): Handle calls.promote_prototypes hook here too.
* c-typeck.c (convert_arguments): Convert to
calls.promote_prototypes hook.
(c_convert_parm_for_inlining): Likewise.
* calls.c (initialize_argument_information): Convert to
calls.promote_function_args hook.
(expand_call): Convert to calls.struct_value_rtx,
calls.strict_argument_naming,
calls.pretend_outgoing_varargs_named, and
calls.promote_function_return hooks. Pass fndecl to
aggregate_value_p. Initialize CUMULATIVE_ARGS before calling
hooks, so they can use that.
(emit_library_call_value_1): Likewise.
* combine.c (setup_incoming_promotions): Convert to
calls.promote_function_args hook.
* emit-rtl.c: Convert to calls.struct_value_rtx hook.
* expr.c (expand_assignment): Pass call to aggregate_value_p.
(expand_expr): Likewise.
* expr.h: Remove support for SETUP_INCOMING_VARARGS,
STRICT_ARGUMENT_NAMING, PRETEND_OUTGOING_VARARGS_NAMED,
RETURN_IN_MEMORY macro defaults.
* final.c (profile_function): Convert to calls.struct_value_rtx
hook.
* function.c (aggregate_value_p): Accept function type tree as
second parameter; try to deduce fntype from it. Convert to
calls.return_in_memory hook.
(assign_parms): Convert to calls.setup_incoming_varargs,
calls.strict_argument_naming, calls.promote_function_args,
calls.pretend_outgoing_varargs_named hooks. Pass fndecl to
aggregate_value_p.
(expand_function_start): Likewise. Convert to
calls.struct_value_rtx hook.
(expand_function_end): Convert to calls.promote_function_return hook.
(allocate_struct_function): Pass fndecl to aggregate_value_p.
* hard-reg-set.h: Update comments to new hook names.
* integrate.c (expand_inline_function): Pass fndecl to aggregate_value_p.
* reg-stack.c (stack_result): Likewise.
* rtl.h (struct_value_rtx, struct_value_incoming_rtx): Delete.
* stmt.c (expand_value_return): Convert to
calls.promote_function_return hook.
* target-def.h: Add TARGET_PROMOTE_FUNCTION_ARGS,
TARGET_PROMOTE_FUNCTION_RETURN, TARGET_PROMOTE_PROTOTYPES,
TARGET_STRUCT_VALUE_RTX, TARGET_RETURN_IN_MEMORY,
TARGET_EXPAND_BUILTIN_SAVEREGS, TARGET_SETUP_INCOMING_VARARGS,
TARGET_STRICT_ARGUMENT_NAMING,
TARGET_PRETEND_OUTGOING_VARARGS_NAMED, and TARGET_CALLS.
* target.h: Likewise.
* tree.h (aggregate_value_p): Also takes a tree to deduce function
attributes from (for target hooks).
* doc/tm.texi (PROMOTE_FUNCTION_ARGS, PROMOTE_FUNCTION_RETURN,
PROMOTE_PROTOTYPES, RETURN_IN_MEMORY, STRUCT_VALUE_REGNUM,
STRUCT_VALUE, STRUCT_VALUE_INCOMING_REGNUM, STRUCT_VALUE_INCOMING,
EXPAND_BUILTIN_SAVEREGS, SETUP_INCOMING_VARARGS,
STRICT_ARGUMENT_NAMING, PRETEND_OUTGOING_VARARGS_NAMED): Convert
to hooks.
* config/alpha/alpha.c (alpha_output_mi_thunk_osf): Pass function
to aggregate_value_p.
* config/arm/arm.c (arm_init_cumulative_args,
arm_output_mi_thunk): Likewise.
* config/i386/i386.c (ix86_return_pops_args, x86_this_parameter):
Likewise.
* config/mips/mips.c (mips_save_reg_p, mips_expand_prologue,
mips_can_use_return_insn): Likewise.
* config/rs6000/rs6000.c (rs6000_output_mi_thunk): Likewise.
* config/s390/s390.c (s390_output_mi_thunk): Likewise.
* config/sparc/sparc.c (sparc_output_mi_thunk): Pass function to
aggregate_value_p.
* config/story16/stormy16.c (xstormy16_asm_output_mi_thunk): Pass
function to aggregate_value_p.
* objc/objc-act.c (generate_struct_by_value_array): Pass NULL to
aggregate_value_p.
* config/sh/sh-protos.h (sh_builtin_saveregs): Remove.
(sh_attr_renesas_p, sh_cfun_attr_renesas_p, sh_function_arg,
sh_function_arg_advance, sh_pass_in_reg_p): New. * config/sh/sh.c
(sh_handle_renesas_attribute, sh_promote_prototypes,
sh_struct_value_rtx, sh_return_in_memory, sh_builtin_saveregs,
sh_setup_incoming_varargs, sh_strict_argument_naming,
sh_pretend_outgoing_varargs_named): New decls.
(targetm): Add new hooks.
(calc_live_regs): Save MACL and MACH if the function has the
renesas attribute.
(sh_expand_prologue): Support renesas attribute.
(sh_builtin_saveregs): Make static.
(sh_build_va_list): Support renesas attribute.
(sh_va_start): Likewise.
(sh_va_arg): Likewise.
(sh_promote_prototypes): New.
(sh_function_arg): New, moved from sh.h. Support renesas
attribute.
(sh_function_arg_advance): Likewise.
(sh_return_in_memory): Likewise.
(sh_strict_argument_naming): Likewise.
(sh_pretend_outgoing_varargs_named): Likewise.
(sh_struct_value_rtx): New.
(sh_attribute): Add renesas attribute.
(sh_handle_renesas_attribute): New.
(sh_attr_renesas_p, sh_cfun_attr_renesas_p): New.
(sh_ms_bitfield_layout_p): Support renesas attribute also.
(sh_output_mi_thunk): Pass function to aggregate_value_p. *
config/sh/sh.h (TARGET_SWITCHES): Add -mrenesas as an alias for
-mhitachi.
(STRUCT_VALUE_REGNUM, STRUCT_VALUE, RETURN_IN_MEMORY): Moved to
target hooks.
(sh_args): Add renesas_abi flag.
(INIT_CUMULATIVE_ARGS): Set it. Pass fndecl to aggregate_value_p.
(FUNCTION_ARG_ADVANCE, FUNCTION_ARG): Move to sh.c.
(PASS_IN_REG_P): Support renesas attribute. Pass DF and TF on the
stack for the renesas abi.
(STRICT_ARGUMENT_NAMING, PRETEND_OUTGOING_VARARGS_NAMED,
SETUP_INCOMING_VARARGS, EXPAND_BUILTIN_SAVEREGS,
PROMOTE_PROTOTYPES): Moved to sh.c. * config/sh/sh.md (call): Set
call cookie to indicate renesas calls.
* decl.c (finish_function): Pass fndecl to aggregate_value_p.
* misc.c (default_pass_by_ref): Convert to calls.return_in_memory
hook.
From-SVN: r71048
2003-09-04 05:18:05 +02:00
|
|
|
|
if (TREE_CODE (decl) == FUNCTION_DECL
|
|
|
|
|
&& targetm.calls.promote_prototypes (TREE_TYPE (decl)))
|
|
|
|
|
{
|
|
|
|
|
tree ce = declarator;
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (ce) == INDIRECT_REF)
|
|
|
|
|
ce = TREE_OPERAND (declarator, 0);
|
|
|
|
|
if (TREE_CODE (ce) == CALL_EXPR)
|
|
|
|
|
{
|
|
|
|
|
tree args = TREE_PURPOSE (TREE_OPERAND (ce, 1));
|
|
|
|
|
for (; args; args = TREE_CHAIN (args))
|
|
|
|
|
{
|
|
|
|
|
tree type = TREE_TYPE (args);
|
|
|
|
|
if (INTEGRAL_TYPE_P (type)
|
|
|
|
|
&& TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
|
|
|
|
|
DECL_ARG_TYPE (args) = integer_type_node;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-10-18 20:29:02 +02:00
|
|
|
|
if (TREE_CODE (decl) == FUNCTION_DECL
|
|
|
|
|
&& DECL_DECLARED_INLINE_P (decl)
|
|
|
|
|
&& DECL_UNINLINABLE (decl)
|
|
|
|
|
&& lookup_attribute ("noinline", DECL_ATTRIBUTES (decl)))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
warning ("%Hinline function '%D' given attribute noinline",
|
|
|
|
|
&DECL_SOURCE_LOCATION (decl), decl);
|
2001-10-18 20:29:02 +02:00
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
/* Add this decl to the current scope.
|
1992-02-13 23:21:26 +01:00
|
|
|
|
TEM may equal DECL or it may be a previous decl of the same name. */
|
|
|
|
|
tem = pushdecl (decl);
|
|
|
|
|
|
|
|
|
|
/* For a local variable, define the RTL now. */
|
2003-07-24 18:59:32 +02:00
|
|
|
|
if (current_scope != global_scope
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* But not if this is a duplicate decl
|
|
|
|
|
and we preserved the rtl from the previous one
|
|
|
|
|
(which may or may not happen). */
|
varasm.c (assemble_alias): Use DECL_ASSEMBLER_NAME...
* varasm.c (assemble_alias): Use DECL_ASSEMBLER_NAME, not the
contents of the RTL, to determine the name of the object.
* tree.h (DECL_RTL): Allocate RTL lazily.
(SET_DECL_RTL): New macro.
(DECL_RTL_SET_P): Likewise.
(COPY_DECL_RTL): Likewise.
(DECL_RTL_IF_SET): Likewise.
* varasm.c (make_decl_rtl): Add assertions about the kind of
declaration we are processing.
* c-decl.c (duplicate_decls): Use COPY_DECL_RTL, DECL_RTL_SET_P, etc.
(start_decl): Likewise.
(finish_decl): Likewise.
* c-semantics.c (emit_local_var): Likewise.
* calls.c (expand_call): Likewise.
* dbxout.c (dbxout_symbol): Likewise.
* emit-rtl.c (unshare_all_rtl): Likewise.
(unshare_all_decls): Likewise.
(reset_used_decls): Likewise.
* expr.c (store_constructor): Likewise.
(safe_from_p): Likewise.
(expand_expr): Likewise.
* function.c (put_var_into_stack): Likewise.
(instantiate_decls_1): Likewise.
(assign_parms): Likewise.
(expand_function_start): Likewise.
(expand_function_end): Likewise.
* ggc-common.c (gcc_mark_trees): Likewise.
* integrate.c (function_cannot_inline_p): Likewise.
(copy_decl_for_inlining): Likewise.
(expand_inline_function): Likewise.
(integrate_parm_decls): Likewise.
(integrate_decl_tree): Likewise.
* print-tree.c (print_node): Likewise.
* reg-stack.c (stack_result): Likewise.
* stmt.c (label_rtx): Likewise.
(expand_return): Likewise.
(expand_decl): Likewise.
(expand_decl_cleanup): Likewise.
(expand_anon_union_decl): Likewise.
* toplev.c (check_global_declarations): Likewise.
(rest_of_decl_compilation): Likewise.
* tree.c (simple_cst_equal): Likewise.
* objc/objc-act.c (generate_static_references): Likewise.
* class.c (build_clone): Use COPY_DECL_RTL, DECL_RTL_SET_P, etc.
* cp-tree.h (DECL_IN_MEMORY_P): Likewise.
* decl.c (duplicate_decls): Likewise.
(builtin_function): Likewise.
(build_library_fn): Likewise.
(build_cp_library_fn): Likewise.
(check_initializer): Likewise.
(cp_finish_decl): Likewise.
* decl2.c (grokfield): Likewise.
(grok_function_init): Remove #if 0'd code.
(finish_anon_union): Use COPY_DECL_RTL, DECL_RTL_SET_P, etc.
* friend.c (do_friend): Likewise.
* init.c (get_temp_regvar): Likewise.
* method.c (make_thunk): Likewise.
* pt.c (tsubst_friend_function): Likewise.
(tsubst_decl): Likewise.
(regenerate_decl_from_template): Likewise.
* semantics.c (genrtl_named_return_value): Likewise.
(expand_body): Likewise.
(genrtl_finish_function): Likewise.
* tree.c (cp_tree_equal): Likewise.
* com.c (ffecom_member_phase_2): Use COPY_DECL_RTL,
DECL_RTL_SET_P, etc.
(duplicate_decls): Likewise.
(start_decl): Likewise.
* class.c (build_static_field_ref): Likewise.
(make_method_value): Likewise.
(get_dispatch_table): Likewise.
* decl.c (push_jvm_slot): Use COPY_DECL_RTL, DECL_RTL_SET_P, etc.
From-SVN: r40482
2001-03-15 03:51:03 +01:00
|
|
|
|
&& !DECL_RTL_SET_P (tem)
|
2003-08-29 23:57:05 +02:00
|
|
|
|
&& DECL_FILE_SCOPE_P (tem))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2000-10-20 02:58:35 +02:00
|
|
|
|
if (TREE_TYPE (tem) != error_mark_node
|
2003-07-29 00:19:46 +02:00
|
|
|
|
&& (COMPLETE_TYPE_P (TREE_TYPE (tem))
|
|
|
|
|
|| (TREE_CODE (TREE_TYPE (tem)) == ARRAY_TYPE
|
|
|
|
|
&& DECL_INITIAL (tem) != 0)))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
expand_decl (tem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return tem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Finish processing of a declaration;
|
|
|
|
|
install its initial value.
|
|
|
|
|
If the length of an array type is not known before,
|
|
|
|
|
it must be determined now, from the initial value, or it is an error. */
|
|
|
|
|
|
|
|
|
|
void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
finish_decl (tree decl, tree init, tree asmspec_tree)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree type = TREE_TYPE (decl);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
int was_incomplete = (DECL_SIZE (decl) == 0);
|
stringpool.c: New file.
* stringpool.c: New file.
* ggc-common.c (ggc_mark_string_ptr, ggc_add_string_root): Delete.
(ggc_alloc_string): Now in stringpool.o.
* ggc-page.c, ggc-simple.c: Do not define or allocate empty_string.
* ggc.h: Delete prototype of ggc_add_string_root. #define
ggc_add_string_root and ggc_mark_string to nothing. Prototype
init_stringpool and stringpool_statistics.
(ggc_alloc_string): Returns a const char *.
* tree.c (hash_table, do_identifier_warnings): Delete.
(init_obstacks): Don't initialize the identifier hash table.
(get_identifier, maybe_get_identifier, start_identifier_warnings,
set_identifier_size): Now in stringpool.c.
* tree.h (struct tree_string): Constify pointer field.
(approx_sqrt): Prototype.
* Makefile.in (stringpool.o): Add rule, mention in OBJS.
* toplev.c (approx_sqrt): New function.
(compile_file): Call stringpool_statistics if mem_report is on.
(main): Call init_stringpool.
* builtins.c (c_strlen), c-decl.c (finish_decl), c-lex.c
(process_directive), c-typeck.c (constructor_asmspec, struct
initializer_stack, start_init), except.c (create_rethrow_ref),
stmt.c (digit_strings), toplev.c (decode_f_option), tree.c
(built_in_filename), varasm,c (in_named_name,
assemble_static_space, struct constant_descriptor, struct
deferred_string, struct pool_constant, force_const_mem),
i386.c (pic_label_name, global_offset_table_name), rs6000.c
(rs6000_emit_prologue, rs6000_emit_epilogue) : Constify a char *.
* c-common.c (combine_strings): Combine strings in scratch
buffer, then pass to build_string.
* optabs.c (init_libfuncs), profile.c (init_edge_profiler,
output_func_start_profiler), stmt.c (init_stmt), alpha.c
(alpha_need_linkage), arm.c (arm_encode_call_attribute),
i386.c (load_pic_register), ia64.c (ia64_encode_section_info),
rs6000.c (rs6000_encode_section_info): Create string in
scratch buffer, then pass to ggc_alloc_string.
* stmt.c (expand_asm_operands): If we must adjust the
constraint strings, do so by creating a new one, not by
modifying the old one in place. Constify some char *s.
* config/pa/pa.c (hppa_encode_label): Drop unnecessary second
argument. Create string in scratch buffer, then pass to
ggc_alloc_string.
* config/pa/pa-protos.h: Update prototype.
* config/pa/elf.h, config/pa/pa.h, config/pa/som.h:
hppa_encode_label takes only one argument.
* c-parse.in (if_prefix): Find the filename and line number at
$-2 and $-1 respectively.
* diagnostic.c (error_recursion): Add missing newline, use
fputs, translate string.
cp:
* lex.c (struct impl_files, internal_filename): Constify a char *.
java:
* jcf-parse.c (get_constant), parse.y (do_merge_string_cste):
Create string in scratch buffer, then pass to build_string.
From-SVN: r37514
2000-11-17 07:05:31 +01:00
|
|
|
|
const char *asmspec = 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2001-10-10 13:33:39 +02:00
|
|
|
|
/* If a name was specified, get the string. */
|
2003-07-24 18:59:32 +02:00
|
|
|
|
if (current_scope == global_scope)
|
2002-03-22 23:51:48 +01:00
|
|
|
|
asmspec_tree = maybe_apply_renaming_pragma (decl, asmspec_tree);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (asmspec_tree)
|
1994-04-25 22:47:30 +02:00
|
|
|
|
asmspec = TREE_STRING_POINTER (asmspec_tree);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* If `start_decl' didn't like having an initialization, ignore it now. */
|
|
|
|
|
if (init != 0 && DECL_INITIAL (decl) == 0)
|
|
|
|
|
init = 0;
|
2003-06-19 21:43:59 +02:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Don't crash if parm is initialized. */
|
|
|
|
|
if (TREE_CODE (decl) == PARM_DECL)
|
|
|
|
|
init = 0;
|
|
|
|
|
|
|
|
|
|
if (init)
|
2002-10-09 23:27:38 +02:00
|
|
|
|
store_init_value (decl, init);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* Deduce size of array from initialization, if not already known */
|
|
|
|
|
if (TREE_CODE (type) == ARRAY_TYPE
|
|
|
|
|
&& TYPE_DOMAIN (type) == 0
|
|
|
|
|
&& TREE_CODE (decl) != TYPE_DECL)
|
|
|
|
|
{
|
|
|
|
|
int do_default
|
|
|
|
|
= (TREE_STATIC (decl)
|
|
|
|
|
/* Even if pedantic, an external linkage array
|
|
|
|
|
may have incomplete type at first. */
|
|
|
|
|
? pedantic && !TREE_PUBLIC (decl)
|
1992-07-12 04:56:45 +02:00
|
|
|
|
: !DECL_EXTERNAL (decl));
|
1992-02-13 23:21:26 +01:00
|
|
|
|
int failure
|
|
|
|
|
= complete_array_type (type, DECL_INITIAL (decl), do_default);
|
|
|
|
|
|
|
|
|
|
/* Get the completed type made by complete_array_type. */
|
|
|
|
|
type = TREE_TYPE (decl);
|
|
|
|
|
|
|
|
|
|
if (failure == 1)
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hinitializer fails to determine size of '%D'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (decl), decl);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2000-09-20 21:35:10 +02:00
|
|
|
|
else if (failure == 2)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
if (do_default)
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Harray size missing in '%D'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (decl), decl);
|
1993-03-22 08:04:18 +01:00
|
|
|
|
/* If a `static' var's size isn't known,
|
|
|
|
|
make it extern as well as static, so it does not get
|
|
|
|
|
allocated.
|
|
|
|
|
If it is not `static', then do not mark extern;
|
|
|
|
|
finish_incomplete_decl will give it a default size
|
|
|
|
|
and it will get allocated. */
|
|
|
|
|
else if (!pedantic && TREE_STATIC (decl) && ! TREE_PUBLIC (decl))
|
1992-07-12 04:56:45 +02:00
|
|
|
|
DECL_EXTERNAL (decl) = 1;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
1994-04-06 21:35:10 +02:00
|
|
|
|
/* TYPE_MAX_VALUE is always one less than the number of elements
|
|
|
|
|
in the array, because we start counting at zero. Therefore,
|
|
|
|
|
warn only if the value is less than zero. */
|
2000-09-20 21:35:10 +02:00
|
|
|
|
else if (pedantic && TYPE_DOMAIN (type) != 0
|
|
|
|
|
&& tree_int_cst_sgn (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) < 0)
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hzero or negative size array '%D'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (decl), decl);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
layout_decl (decl, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (decl) == VAR_DECL)
|
|
|
|
|
{
|
2000-10-20 02:58:35 +02:00
|
|
|
|
if (DECL_SIZE (decl) == 0 && TREE_TYPE (decl) != error_mark_node
|
|
|
|
|
&& COMPLETE_TYPE_P (TREE_TYPE (decl)))
|
1993-05-26 06:22:32 +02:00
|
|
|
|
layout_decl (decl, 0);
|
|
|
|
|
|
1992-08-14 10:09:22 +02:00
|
|
|
|
if (DECL_SIZE (decl) == 0
|
2000-10-20 02:58:35 +02:00
|
|
|
|
/* Don't give an error if we already gave one earlier. */
|
|
|
|
|
&& TREE_TYPE (decl) != error_mark_node
|
1992-08-14 10:09:22 +02:00
|
|
|
|
&& (TREE_STATIC (decl)
|
|
|
|
|
?
|
|
|
|
|
/* A static variable with an incomplete type
|
1993-08-07 10:48:29 +02:00
|
|
|
|
is an error if it is initialized.
|
1993-10-08 05:59:33 +01:00
|
|
|
|
Also if it is not file scope.
|
1992-08-14 10:09:22 +02:00
|
|
|
|
Otherwise, let it through, but if it is not `extern'
|
|
|
|
|
then it may cause an error message later. */
|
1996-02-13 23:47:16 +01:00
|
|
|
|
(DECL_INITIAL (decl) != 0
|
2003-08-29 23:57:05 +02:00
|
|
|
|
|| !DECL_FILE_SCOPE_P (decl))
|
1992-08-14 10:09:22 +02:00
|
|
|
|
:
|
|
|
|
|
/* An automatic variable with an incomplete type
|
|
|
|
|
is an error. */
|
1992-08-14 10:34:32 +02:00
|
|
|
|
!DECL_EXTERNAL (decl)))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hstorage size of '%D' isn't known",
|
|
|
|
|
&DECL_SOURCE_LOCATION (decl), decl);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
TREE_TYPE (decl) = error_mark_node;
|
|
|
|
|
}
|
|
|
|
|
|
1992-07-12 04:56:45 +02:00
|
|
|
|
if ((DECL_EXTERNAL (decl) || TREE_STATIC (decl))
|
1993-02-02 05:38:30 +01:00
|
|
|
|
&& DECL_SIZE (decl) != 0)
|
1993-02-03 00:35:04 +01:00
|
|
|
|
{
|
|
|
|
|
if (TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST)
|
|
|
|
|
constant_expression_warning (DECL_SIZE (decl));
|
|
|
|
|
else
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hstorage size of '%D' isn't constant",
|
|
|
|
|
&DECL_SOURCE_LOCATION (decl), decl);
|
1993-02-03 00:35:04 +01:00
|
|
|
|
}
|
1997-11-02 22:19:36 +01:00
|
|
|
|
|
2000-08-11 00:01:22 +02:00
|
|
|
|
if (TREE_USED (type))
|
1997-11-02 22:19:36 +01:00
|
|
|
|
TREE_USED (decl) = 1;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
2003-04-28 21:58:52 +02:00
|
|
|
|
/* If this is a function and an assembler name is specified, reset DECL_RTL
|
|
|
|
|
so we can give it its new name. Also, update built_in_decls if it
|
|
|
|
|
was a normal built-in. */
|
1994-04-16 22:38:20 +02:00
|
|
|
|
if (TREE_CODE (decl) == FUNCTION_DECL && asmspec)
|
2000-08-11 00:01:22 +02:00
|
|
|
|
{
|
2003-05-19 18:41:47 +02:00
|
|
|
|
/* ASMSPEC is given, and not the name of a register. Mark the
|
|
|
|
|
name with a star so assemble_name won't munge it. */
|
|
|
|
|
char *starred = alloca (strlen (asmspec) + 2);
|
|
|
|
|
starred[0] = '*';
|
|
|
|
|
strcpy (starred + 1, asmspec);
|
|
|
|
|
|
2003-04-28 21:58:52 +02:00
|
|
|
|
if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
|
|
|
|
|
{
|
|
|
|
|
tree builtin = built_in_decls [DECL_FUNCTION_CODE (decl)];
|
|
|
|
|
SET_DECL_RTL (builtin, NULL_RTX);
|
2003-05-19 18:41:47 +02:00
|
|
|
|
SET_DECL_ASSEMBLER_NAME (builtin, get_identifier (starred));
|
2003-04-28 21:58:52 +02:00
|
|
|
|
#ifdef TARGET_MEM_FUNCTIONS
|
|
|
|
|
if (DECL_FUNCTION_CODE (decl) == BUILT_IN_MEMCPY)
|
2003-05-19 18:41:47 +02:00
|
|
|
|
init_block_move_fn (starred);
|
2003-04-28 21:58:52 +02:00
|
|
|
|
else if (DECL_FUNCTION_CODE (decl) == BUILT_IN_MEMSET)
|
2003-05-19 18:41:47 +02:00
|
|
|
|
init_block_clear_fn (starred);
|
2003-04-28 21:58:52 +02:00
|
|
|
|
#else
|
|
|
|
|
if (DECL_FUNCTION_CODE (decl) == BUILT_IN_BCOPY)
|
2003-05-19 18:41:47 +02:00
|
|
|
|
init_block_move_fn (starred);
|
2003-04-28 21:58:52 +02:00
|
|
|
|
else if (DECL_FUNCTION_CODE (decl) == BUILT_IN_BZERO)
|
2003-05-19 18:41:47 +02:00
|
|
|
|
init_block_clear_fn (starred);
|
2003-04-28 21:58:52 +02:00
|
|
|
|
#endif
|
|
|
|
|
}
|
varasm.c (assemble_alias): Use DECL_ASSEMBLER_NAME...
* varasm.c (assemble_alias): Use DECL_ASSEMBLER_NAME, not the
contents of the RTL, to determine the name of the object.
* tree.h (DECL_RTL): Allocate RTL lazily.
(SET_DECL_RTL): New macro.
(DECL_RTL_SET_P): Likewise.
(COPY_DECL_RTL): Likewise.
(DECL_RTL_IF_SET): Likewise.
* varasm.c (make_decl_rtl): Add assertions about the kind of
declaration we are processing.
* c-decl.c (duplicate_decls): Use COPY_DECL_RTL, DECL_RTL_SET_P, etc.
(start_decl): Likewise.
(finish_decl): Likewise.
* c-semantics.c (emit_local_var): Likewise.
* calls.c (expand_call): Likewise.
* dbxout.c (dbxout_symbol): Likewise.
* emit-rtl.c (unshare_all_rtl): Likewise.
(unshare_all_decls): Likewise.
(reset_used_decls): Likewise.
* expr.c (store_constructor): Likewise.
(safe_from_p): Likewise.
(expand_expr): Likewise.
* function.c (put_var_into_stack): Likewise.
(instantiate_decls_1): Likewise.
(assign_parms): Likewise.
(expand_function_start): Likewise.
(expand_function_end): Likewise.
* ggc-common.c (gcc_mark_trees): Likewise.
* integrate.c (function_cannot_inline_p): Likewise.
(copy_decl_for_inlining): Likewise.
(expand_inline_function): Likewise.
(integrate_parm_decls): Likewise.
(integrate_decl_tree): Likewise.
* print-tree.c (print_node): Likewise.
* reg-stack.c (stack_result): Likewise.
* stmt.c (label_rtx): Likewise.
(expand_return): Likewise.
(expand_decl): Likewise.
(expand_decl_cleanup): Likewise.
(expand_anon_union_decl): Likewise.
* toplev.c (check_global_declarations): Likewise.
(rest_of_decl_compilation): Likewise.
* tree.c (simple_cst_equal): Likewise.
* objc/objc-act.c (generate_static_references): Likewise.
* class.c (build_clone): Use COPY_DECL_RTL, DECL_RTL_SET_P, etc.
* cp-tree.h (DECL_IN_MEMORY_P): Likewise.
* decl.c (duplicate_decls): Likewise.
(builtin_function): Likewise.
(build_library_fn): Likewise.
(build_cp_library_fn): Likewise.
(check_initializer): Likewise.
(cp_finish_decl): Likewise.
* decl2.c (grokfield): Likewise.
(grok_function_init): Remove #if 0'd code.
(finish_anon_union): Use COPY_DECL_RTL, DECL_RTL_SET_P, etc.
* friend.c (do_friend): Likewise.
* init.c (get_temp_regvar): Likewise.
* method.c (make_thunk): Likewise.
* pt.c (tsubst_friend_function): Likewise.
(tsubst_decl): Likewise.
(regenerate_decl_from_template): Likewise.
* semantics.c (genrtl_named_return_value): Likewise.
(expand_body): Likewise.
(genrtl_finish_function): Likewise.
* tree.c (cp_tree_equal): Likewise.
* com.c (ffecom_member_phase_2): Use COPY_DECL_RTL,
DECL_RTL_SET_P, etc.
(duplicate_decls): Likewise.
(start_decl): Likewise.
* class.c (build_static_field_ref): Likewise.
(make_method_value): Likewise.
(get_dispatch_table): Likewise.
* decl.c (push_jvm_slot): Use COPY_DECL_RTL, DECL_RTL_SET_P, etc.
From-SVN: r40482
2001-03-15 03:51:03 +01:00
|
|
|
|
SET_DECL_RTL (decl, NULL_RTX);
|
2003-05-19 18:41:47 +02:00
|
|
|
|
SET_DECL_ASSEMBLER_NAME (decl, get_identifier (starred));
|
2000-08-11 00:01:22 +02:00
|
|
|
|
}
|
1994-04-16 22:38:20 +02:00
|
|
|
|
|
2003-07-22 04:23:27 +02:00
|
|
|
|
/* If #pragma weak was used, mark the decl weak now. */
|
2003-07-24 18:59:32 +02:00
|
|
|
|
if (current_scope == global_scope)
|
2003-07-22 04:23:27 +02:00
|
|
|
|
maybe_apply_pragma_weak (decl);
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Output the assembler code and/or RTL code for variables and functions,
|
|
|
|
|
unless the type is an undefined structure or union.
|
|
|
|
|
If not, it will get done when the type is completed. */
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL)
|
|
|
|
|
{
|
2002-08-10 04:18:28 +02:00
|
|
|
|
/* This is a no-op in c-lang.c or something real in objc-act.c. */
|
c-common.c (enum c_language_kind, flag_objc): Remove.
* c-common.c (enum c_language_kind, flag_objc): Remove.
(fix_string_type, check_case_value, c_common_nodes_and_builtins,
c_add_case_label, finish_label_addr_expr, boolean_increment):
Use c_dialect_ macros.
* c-common.h (enum c_language_kind): Extend.
(c_dialect_cxx, c_dialect_objc): New.
(flag_objc): Remove.
(c_common_init_options): Update prototype.
* c-cppbuiltin.c (define__GNUC__, c_cpp_builtins): Use c_dialect_
macros.
* c-decl.c (finsih_decl, grokfield, finish_struct): Use c_dialect_
macros.
* c-format.c (C_STD_VER, C_STD_NAME): Similarly.
* c-lang.c (c_init_options): Remove.
(c_language): Define.
(LANG_HOOKS_INIT_OPTIONS): Use common hook.
* c-lex.c (lex_charconst): Use c_dialect_cxx().
* c-opts.c (lang_flags): Make function-local.
(c_common_init_options): Use c_dialect_ macros. Handle
C++ diagnostic requirements.
(c_common_handle_option, c_common_post_options): Use flag_cxx.
* c-parse.in (init_reswords): Use c_dialect_objc ().
* c-pch.c (get_ident): Use c_language.
* c-pretty-print.c (pp_c_bool_literal): Use c_dialect_ macros.
* c-typeck.c (comptypes, build_c_cast): Similarly.
* objc/objc-lang.c (c_language): Define.
(LANG_HOOKS_INIT_OPTIONS): Use common hook.
(objc_init_options): Remove.
cp:
* Make-lang.in: Update.
* cp-lang.c (c_language): Define.
(LANG_HOOKS_INIT_OPTIONS): Use common hook.
* cp-tree.h (cxx_init_options): Remove.
* lex.c: Don't include diagnostic.h.
(cxx_init_options): Remove.
From-SVN: r68734
2003-06-30 21:36:25 +02:00
|
|
|
|
if (c_dialect_objc ())
|
2002-08-10 04:18:28 +02:00
|
|
|
|
objc_check_decl (decl);
|
2000-09-17 09:38:23 +02:00
|
|
|
|
|
2003-08-29 23:57:05 +02:00
|
|
|
|
if (DECL_FILE_SCOPE_P (decl))
|
2001-02-26 12:11:38 +01:00
|
|
|
|
{
|
|
|
|
|
if (DECL_INITIAL (decl) == NULL_TREE
|
|
|
|
|
|| DECL_INITIAL (decl) == error_mark_node)
|
|
|
|
|
/* Don't output anything
|
|
|
|
|
when a tentative file-scope definition is seen.
|
|
|
|
|
But at end of compilation, do output code for them. */
|
|
|
|
|
DECL_DEFER_OUTPUT (decl) = 1;
|
2003-07-11 10:33:21 +02:00
|
|
|
|
rest_of_decl_compilation (decl, asmspec, true, 0);
|
2001-02-26 12:11:38 +01:00
|
|
|
|
}
|
2000-09-17 09:38:23 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
2001-05-21 20:36:57 +02:00
|
|
|
|
/* This is a local variable. If there is an ASMSPEC, the
|
|
|
|
|
user has requested that we handle it specially. */
|
2000-09-17 09:38:23 +02:00
|
|
|
|
if (asmspec)
|
2000-11-26 01:40:46 +01:00
|
|
|
|
{
|
2001-05-21 20:36:57 +02:00
|
|
|
|
/* In conjunction with an ASMSPEC, the `register'
|
|
|
|
|
keyword indicates that we should place the variable
|
|
|
|
|
in a particular register. */
|
|
|
|
|
if (DECL_REGISTER (decl))
|
|
|
|
|
DECL_C_HARD_REGISTER (decl) = 1;
|
|
|
|
|
|
|
|
|
|
/* If this is not a static variable, issue a warning.
|
|
|
|
|
It doesn't make any sense to give an ASMSPEC for an
|
|
|
|
|
ordinary, non-register local variable. Historically,
|
|
|
|
|
GCC has accepted -- but ignored -- the ASMSPEC in
|
|
|
|
|
this case. */
|
2003-06-19 21:43:59 +02:00
|
|
|
|
if (TREE_CODE (decl) == VAR_DECL
|
2001-05-21 20:36:57 +02:00
|
|
|
|
&& !DECL_REGISTER (decl)
|
|
|
|
|
&& !TREE_STATIC (decl))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
warning ("%Hignoring asm-specifier for non-static local "
|
|
|
|
|
"variable '%D'", &DECL_SOURCE_LOCATION (decl), decl);
|
2001-05-21 20:36:57 +02:00
|
|
|
|
else
|
|
|
|
|
SET_DECL_ASSEMBLER_NAME (decl, get_identifier (asmspec));
|
2000-11-26 01:40:46 +01:00
|
|
|
|
}
|
2001-05-21 20:36:57 +02:00
|
|
|
|
|
2001-10-24 16:46:44 +02:00
|
|
|
|
if (TREE_CODE (decl) != FUNCTION_DECL)
|
|
|
|
|
add_decl_stmt (decl);
|
2000-09-17 09:38:23 +02:00
|
|
|
|
}
|
c-common.c, [...]: Remove all references to obstack functions obsoleted by GC...
* c-common.c, c-decl.c, c-lang.c, c-lex.c, c-parse.in, c-pragma.c,
c-typeck.c, objc/objc-act.c: Remove all references to obstack
functions obsoleted by GC, such as push_obstacks_nochange,
end_temporary_allocation, savealloc, saveable_tree_cons, etc.
and code which existed only to decide whether or not to call
them. Remove now-unused NESTED argument from start_function;
all callers changed. Do not change behavior based on ggc_p.
The use of the ixp_obstack in c-iterate.c and the util_obstack
in objc/objc-act.c remain; these are not obsoleted by garbage
collection.
* c-tree.h: Update prototype for start_function.
* c-parse.y, c-parse.c, objc/objc-parse.c, objc/objc-parse.y: Rebuild.
From-SVN: r31611
2000-01-25 18:13:14 +01:00
|
|
|
|
|
2003-08-29 23:57:05 +02:00
|
|
|
|
if (!DECL_FILE_SCOPE_P (decl))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
/* Recompute the RTL of a local array now
|
|
|
|
|
if it used to be an incomplete type. */
|
|
|
|
|
if (was_incomplete
|
1992-07-12 04:56:45 +02:00
|
|
|
|
&& ! TREE_STATIC (decl) && ! DECL_EXTERNAL (decl))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
/* If we used it already as memory, it must stay in memory. */
|
|
|
|
|
TREE_ADDRESSABLE (decl) = TREE_USED (decl);
|
|
|
|
|
/* If it's still incomplete now, no init will save it. */
|
|
|
|
|
if (DECL_SIZE (decl) == 0)
|
|
|
|
|
DECL_INITIAL (decl) = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-11 10:33:21 +02:00
|
|
|
|
/* If this was marked 'used', be sure it will be output. */
|
|
|
|
|
if (lookup_attribute ("used", DECL_ATTRIBUTES (decl)))
|
|
|
|
|
mark_referenced (DECL_ASSEMBLER_NAME (decl));
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (TREE_CODE (decl) == TYPE_DECL)
|
|
|
|
|
{
|
2002-08-10 04:18:28 +02:00
|
|
|
|
/* This is a no-op in c-lang.c or something real in objc-act.c. */
|
c-common.c (enum c_language_kind, flag_objc): Remove.
* c-common.c (enum c_language_kind, flag_objc): Remove.
(fix_string_type, check_case_value, c_common_nodes_and_builtins,
c_add_case_label, finish_label_addr_expr, boolean_increment):
Use c_dialect_ macros.
* c-common.h (enum c_language_kind): Extend.
(c_dialect_cxx, c_dialect_objc): New.
(flag_objc): Remove.
(c_common_init_options): Update prototype.
* c-cppbuiltin.c (define__GNUC__, c_cpp_builtins): Use c_dialect_
macros.
* c-decl.c (finsih_decl, grokfield, finish_struct): Use c_dialect_
macros.
* c-format.c (C_STD_VER, C_STD_NAME): Similarly.
* c-lang.c (c_init_options): Remove.
(c_language): Define.
(LANG_HOOKS_INIT_OPTIONS): Use common hook.
* c-lex.c (lex_charconst): Use c_dialect_cxx().
* c-opts.c (lang_flags): Make function-local.
(c_common_init_options): Use c_dialect_ macros. Handle
C++ diagnostic requirements.
(c_common_handle_option, c_common_post_options): Use flag_cxx.
* c-parse.in (init_reswords): Use c_dialect_objc ().
* c-pch.c (get_ident): Use c_language.
* c-pretty-print.c (pp_c_bool_literal): Use c_dialect_ macros.
* c-typeck.c (comptypes, build_c_cast): Similarly.
* objc/objc-lang.c (c_language): Define.
(LANG_HOOKS_INIT_OPTIONS): Use common hook.
(objc_init_options): Remove.
cp:
* Make-lang.in: Update.
* cp-lang.c (c_language): Define.
(LANG_HOOKS_INIT_OPTIONS): Use common hook.
* cp-tree.h (cxx_init_options): Remove.
* lex.c: Don't include diagnostic.h.
(cxx_init_options): Remove.
From-SVN: r68734
2003-06-30 21:36:25 +02:00
|
|
|
|
if (c_dialect_objc ())
|
2002-08-10 04:18:28 +02:00
|
|
|
|
objc_check_decl (decl);
|
2003-08-29 23:57:05 +02:00
|
|
|
|
rest_of_decl_compilation (decl, NULL, DECL_FILE_SCOPE_P (decl), 0);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* At the end of a declaration, throw away any variable type sizes
|
|
|
|
|
of types defined inside that declaration. There is no use
|
|
|
|
|
computing them in the following function definition. */
|
2003-07-24 18:59:32 +02:00
|
|
|
|
if (current_scope == global_scope)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
get_pending_sizes ();
|
2003-06-04 19:06:00 +02:00
|
|
|
|
|
|
|
|
|
/* Install a cleanup (aka destructor) if one was given. */
|
|
|
|
|
if (TREE_CODE (decl) == VAR_DECL && !TREE_STATIC (decl))
|
|
|
|
|
{
|
|
|
|
|
tree attr = lookup_attribute ("cleanup", DECL_ATTRIBUTES (decl));
|
|
|
|
|
if (attr)
|
|
|
|
|
{
|
|
|
|
|
static bool eh_initialized_p;
|
|
|
|
|
|
|
|
|
|
tree cleanup_id = TREE_VALUE (TREE_VALUE (attr));
|
|
|
|
|
tree cleanup_decl = lookup_name (cleanup_id);
|
|
|
|
|
tree cleanup;
|
|
|
|
|
|
|
|
|
|
/* Build "cleanup(&decl)" for the destructor. */
|
|
|
|
|
cleanup = build_unary_op (ADDR_EXPR, decl, 0);
|
|
|
|
|
cleanup = build_tree_list (NULL_TREE, cleanup);
|
|
|
|
|
cleanup = build_function_call (cleanup_decl, cleanup);
|
|
|
|
|
|
|
|
|
|
/* Don't warn about decl unused; the cleanup uses it. */
|
|
|
|
|
TREE_USED (decl) = 1;
|
|
|
|
|
|
|
|
|
|
/* Initialize EH, if we've been told to do so. */
|
|
|
|
|
if (flag_exceptions && !eh_initialized_p)
|
|
|
|
|
{
|
|
|
|
|
eh_initialized_p = true;
|
|
|
|
|
eh_personality_libfunc
|
|
|
|
|
= init_one_libfunc (USING_SJLJ_EXCEPTIONS
|
|
|
|
|
? "__gcc_personality_sj0"
|
|
|
|
|
: "__gcc_personality_v0");
|
|
|
|
|
using_eh_for_cleanups ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
add_stmt (build_stmt (CLEANUP_STMT, decl, cleanup));
|
|
|
|
|
}
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
/* Given a parsed parameter declaration, decode it into a PARM_DECL
|
|
|
|
|
and push that on the current scope. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
push_parm_decl (tree parm)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
1994-03-25 19:55:59 +01:00
|
|
|
|
tree decl;
|
2003-07-29 00:19:46 +02:00
|
|
|
|
|
|
|
|
|
/* Don't attempt to expand sizes while parsing this decl.
|
|
|
|
|
(We can get here with i_s_e 1 somehow from Objective-C.) */
|
|
|
|
|
int save_immediate_size_expand = immediate_size_expand;
|
1992-03-23 03:07:53 +01:00
|
|
|
|
immediate_size_expand = 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
1995-05-12 13:09:47 +02:00
|
|
|
|
decl = grokdeclarator (TREE_VALUE (TREE_PURPOSE (parm)),
|
2002-02-02 01:14:41 +01:00
|
|
|
|
TREE_PURPOSE (TREE_PURPOSE (parm)), PARM, 0);
|
c-common.c (decl_attributes): Take a pointer to the node to which attributes are to be attached...
* c-common.c (decl_attributes): Take a pointer to the node to
which attributes are to be attached, and a flags argument.
* c-common.h (enum attribute_flags): New.
(decl_attributes): Update prototype.
* c-decl.c (start_decl, push_parm_decl, finish_struct,
finish_enum, start_function): Update calls to decl_attributes.
* c-parse.in (component_declarator, component_notype_declarator,
label): Update calls to decl_attributes.
cp:
* decl2.c (cplus_decl_attributes): Take a pointer to the node to
which attributes are to be attached, and a flags argument. Update
call to decl_attributes.
(grokfield): Update call to decl_attributes.
* class.c (finish_struct): Update call to cplus_decl_attributes.
* cp-tree.h (cplus_decl_attributes): Update prototype.
* decl.c (start_decl, grokdeclarator, start_function): Update
calls to decl_attributes and cplus_decl_attributes.
* friend.c (do_friend): Update call to cplus_decl_attributes.
* parse.y (parse_bitfield): Update call to cplus_decl_attributes.
From-SVN: r43995
2001-07-13 22:40:43 +02:00
|
|
|
|
decl_attributes (&decl, TREE_VALUE (parm), 0);
|
1993-04-24 01:18:52 +02:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
decl = pushdecl (decl);
|
|
|
|
|
|
|
|
|
|
finish_decl (decl, NULL_TREE, NULL_TREE);
|
2003-07-29 00:19:46 +02:00
|
|
|
|
|
|
|
|
|
immediate_size_expand = save_immediate_size_expand;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
/* Mark all the parameter declarations to date as forward decls,
|
|
|
|
|
shift them to the variables list, and reset the parameters list.
|
|
|
|
|
Also diagnose use of this extension. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
void
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
mark_forward_parm_decls (void)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-08-01 20:41:40 +02:00
|
|
|
|
tree parm;
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
|
|
|
|
|
if (pedantic && !current_scope->warned_forward_parm_decls)
|
|
|
|
|
{
|
|
|
|
|
pedwarn ("ISO C forbids forward parameter declarations");
|
|
|
|
|
current_scope->warned_forward_parm_decls = true;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
for (parm = current_scope->parms; parm; parm = TREE_CHAIN (parm))
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
TREE_ASM_WRITTEN (parm) = 1;
|
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
SCOPE_LIST_CONCAT (current_scope, names, current_scope, parms);
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
current_scope->parms = 0;
|
2003-08-01 20:41:40 +02:00
|
|
|
|
current_scope->parms_last = 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
2003-01-10 03:22:34 +01:00
|
|
|
|
static GTY(()) int compound_literal_number;
|
|
|
|
|
|
2001-12-04 23:55:40 +01:00
|
|
|
|
/* Build a COMPOUND_LITERAL_EXPR. TYPE is the type given in the compound
|
|
|
|
|
literal, which may be an incomplete array type completed by the
|
|
|
|
|
initializer; INIT is a CONSTRUCTOR that initializes the compound
|
|
|
|
|
literal. */
|
|
|
|
|
|
|
|
|
|
tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
build_compound_literal (tree type, tree init)
|
2001-12-04 23:55:40 +01:00
|
|
|
|
{
|
|
|
|
|
/* We do not use start_decl here because we have a type, not a declarator;
|
|
|
|
|
and do not use finish_decl because the decl should be stored inside
|
|
|
|
|
the COMPOUND_LITERAL_EXPR rather than added elsewhere as a DECL_STMT. */
|
|
|
|
|
tree decl = build_decl (VAR_DECL, NULL_TREE, type);
|
|
|
|
|
tree complit;
|
2001-12-17 02:18:41 +01:00
|
|
|
|
tree stmt;
|
2001-12-04 23:55:40 +01:00
|
|
|
|
DECL_EXTERNAL (decl) = 0;
|
|
|
|
|
TREE_PUBLIC (decl) = 0;
|
2003-07-24 18:59:32 +02:00
|
|
|
|
TREE_STATIC (decl) = (current_scope == global_scope);
|
2001-12-04 23:55:40 +01:00
|
|
|
|
DECL_CONTEXT (decl) = current_function_decl;
|
|
|
|
|
TREE_USED (decl) = 1;
|
|
|
|
|
TREE_TYPE (decl) = type;
|
2002-07-22 12:15:49 +02:00
|
|
|
|
TREE_READONLY (decl) = TREE_READONLY (type);
|
2001-12-04 23:55:40 +01:00
|
|
|
|
store_init_value (decl, init);
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type))
|
|
|
|
|
{
|
|
|
|
|
int failure = complete_array_type (type, DECL_INITIAL (decl), 1);
|
|
|
|
|
if (failure)
|
|
|
|
|
abort ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type = TREE_TYPE (decl);
|
|
|
|
|
if (type == error_mark_node || !COMPLETE_TYPE_P (type))
|
|
|
|
|
return error_mark_node;
|
|
|
|
|
|
2001-12-17 02:18:41 +01:00
|
|
|
|
stmt = build_stmt (DECL_STMT, decl);
|
|
|
|
|
complit = build1 (COMPOUND_LITERAL_EXPR, TREE_TYPE (decl), stmt);
|
2001-12-04 23:55:40 +01:00
|
|
|
|
TREE_SIDE_EFFECTS (complit) = 1;
|
|
|
|
|
|
|
|
|
|
layout_decl (decl, 0);
|
|
|
|
|
|
|
|
|
|
if (TREE_STATIC (decl))
|
|
|
|
|
{
|
|
|
|
|
/* This decl needs a name for the assembler output. We also need
|
2002-07-22 12:11:16 +02:00
|
|
|
|
a unique suffix to be added to the name. */
|
|
|
|
|
char *name;
|
|
|
|
|
|
2003-06-19 21:43:59 +02:00
|
|
|
|
ASM_FORMAT_PRIVATE_NAME (name, "__compound_literal",
|
2003-01-10 03:22:34 +01:00
|
|
|
|
compound_literal_number);
|
|
|
|
|
compound_literal_number++;
|
2002-07-22 12:11:16 +02:00
|
|
|
|
DECL_NAME (decl) = get_identifier (name);
|
|
|
|
|
DECL_DEFER_OUTPUT (decl) = 1;
|
|
|
|
|
DECL_COMDAT (decl) = 1;
|
|
|
|
|
DECL_ARTIFICIAL (decl) = 1;
|
|
|
|
|
pushdecl (decl);
|
2001-12-04 23:55:40 +01:00
|
|
|
|
rest_of_decl_compilation (decl, NULL, 1, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return complit;
|
|
|
|
|
}
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Make TYPE a complete type based on INITIAL_VALUE.
|
1992-03-23 03:07:53 +01:00
|
|
|
|
Return 0 if successful, 1 if INITIAL_VALUE can't be deciphered,
|
1992-02-13 23:21:26 +01:00
|
|
|
|
2 if there was no information (in which case assume 1 if DO_DEFAULT). */
|
|
|
|
|
|
|
|
|
|
int
|
2003-06-19 21:43:59 +02:00
|
|
|
|
complete_array_type (tree type, tree initial_value, int do_default)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree maxindex = NULL_TREE;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
int value = 0;
|
|
|
|
|
|
|
|
|
|
if (initial_value)
|
|
|
|
|
{
|
|
|
|
|
/* Note MAXINDEX is really the maximum index,
|
|
|
|
|
one less than the size. */
|
|
|
|
|
if (TREE_CODE (initial_value) == STRING_CST)
|
|
|
|
|
{
|
|
|
|
|
int eltsize
|
|
|
|
|
= int_size_in_bytes (TREE_TYPE (TREE_TYPE (initial_value)));
|
1993-10-08 02:49:18 +01:00
|
|
|
|
maxindex = build_int_2 ((TREE_STRING_LENGTH (initial_value)
|
|
|
|
|
/ eltsize) - 1, 0);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
else if (TREE_CODE (initial_value) == CONSTRUCTOR)
|
|
|
|
|
{
|
1993-09-13 22:17:48 +02:00
|
|
|
|
tree elts = CONSTRUCTOR_ELTS (initial_value);
|
builtins.c (c_strlen): Use size_diffop and return ssizetype value.
* builtins.c (c_strlen): Use size_diffop and return ssizetype value.
(expand_builtin_strcpy): Pass correct type to size_binop.
(expand_builtin_strcmp): Likewise.
Clean up conditional structure.
* c-decl.c (init_decl_processing): Don't call set_sizetype twice.
(complete_array_type): Don't use size_binop for MAXINDEX.
* c-typeck.c (c_sizeof): Use size_one_node and TYPE_SIZE_UNIT.
(c_sizeof_nowarn, c_size_in_bytes): Likewise.
(c_alignof): Use size_one_node.
(build_unary_op): Pass arg of proper type to size_binop.
(really_start_incremental_init, push_init_level): Use sizetype for
constructor{,_bit,_unfilled}_index.
(pop_init_label, output_init_element): Likewise.
(output_pending_init_elements, process_init_element): Likewise.
* calls.c (compute_argument_block_size): Field VAR is ssizetype.
* expr.c (store_expr): Use size_int.
(store_constructor): Use proper types for size_binop args.
(get_inner_reference, expand_expr, case ARRAY_REF): Likewise.
(expand_expr_unaligned): Likewise.
(string_contant): Return object of sizetype.
* expr.h (SUB_PARM_SIZE): Call size_diffop and pass proper types.
(ARGS_SIZE_RTX): Call ARGS_SIZE_TREE.
(ARGS_SIZE_TREE): Pass proper types to size_binop.
* fold-const.c (int_const_binop): Refine when size_int is called.
(fold_convert): Likewise.
(size_int_wide): Rework to take KIND as arg, only take low order
bits, handle new sizetype_tab datatype, and chain entries in
size_table.
(size_int_type_wide): New function.
(size_binop): Validate types of arguments.
(ssize_binop): Deleted.
(size_diffop): New function.
(extract_muldiv): Only fold division into multiplication for sizetypes.
* function.c (assign_parms): Use size_diffop and make sure
VAR field is of ssizetype; also pass proper type to size_binop.
(locate_and_pad_parm, pad_to_arg_alignment): Likewise.
(round_down): Deleted from here.
* store-layout.c (sizetype_tab): Now an array.
(sizetype_set, early_root_list): New variables.
(variable_size): Use size_one_node.
(round_up): Pass proper type to size_binop.
(round_down): Moved to here and corrected as above.
(layout_record): Pass proper arg types to size_binop.
(layout_type): Likewise.
If sizetype_set is zero, record the type just laid out.
(make_unsigned_type): Don't call set_sizetype;
(make_signed_type): Likewise; also, call fixup_signed_type.
(initialize_sizetypes): New function.
(set_sizetype): Make copy of types, set TYPE_IS_SIZETYPE, and
set name of bitsizetype to "bit_size_type".
Fix up type of sizes of all types made before call.
* tm.texi (ROUND_TYPE_SIZE_UNIT): New macro.
* tree.c (fix_sizetype): Deleted.
(build_common_tree_nodes): Call initialize_sizetypes.
(build_common_tree_nodes_2): Don't call fix_sizetype.
* tree.h (TYPE_IS_SIZETYPE): New macro.
(initialize_sizetype): New declaration.
(enum size_type_kind): New type.
(struct sizetype_tab): Deleted.
(sizetype_tab): Now array; adjust sizetype macros.
(size_diffop, size_int_type_wide): New functions.
(size_int_wide): Change number of args and type; access macros changed.
(ssize_int, sbitsize_int): New macros.
* config/i960/i960.h (ROUND_TYPE_SIZE): Use size_int.
(ROUND_TYPE_SIZE_UNIT): New macro.
* ch/actions.c (chill_convert_for_assignment): Don't use size_binop
for things that aren't sizes.
(expand_varying_length_assignment): Likewise.
* ch/convert.c (digest_array_tuple, convert): Likewise.
* ch/typeck.c (build_chill_slice, smash_dummy_type): Likewise.
(build_chill_slice_with_range): Likewise.
(build_chill_slice_with_length): Likewise.
(build_array_from_set): Adjust types for size_binop.
* ch/expr.c (build_concat_expr, build_chill_repetition_op): Likewise.
(build_chill_sizeof): Use TYPE_SIZE_UNIT.
* ch/tree.c (build_string_type): Pass proper type to size_binop.
* cp/class.c (dfs_build_vtable_offset_vtbl_entries): Don't use
size_binop on things that are not sizes; ssize_binop deleted.
Call size_diffop when appropriate.
(dfs_build_vcall_offset_vtbl_entries): Likewise.
(build_primary_vtable, build_secondary_vtable): Likewise.
(dfs_set_offset_for_unshared_vbases, dfs_modify_vtables): Likewise.
Variable I is HOST_WIDE_INT.
(get_vfield_offset): Pass proper types to size_binop.
(size_extra_vtbl_entries, layout_virtual_bases): Likewise.
(finish_struct_1): Likewise.
(skip_rtti_stuff): Arg N is now pointer to signed.
(layout_class_type): Use size_zero_node.
* cp/cp-tree.h (skip_rtti_stuff): Arg N is pointer to signed.
* cp/cvt.c (cp_convert_to_pointer): Pass proper types to size_binop.
* cp/decl.c (complete_arry_type): Pass proper types to size_binop.
(xref_basetypes): BINFO_OFFSET is sizetype.
* cp/error.c (dump_expr): Don't use size_binop non-sizes.
* cp/expr.c (cplus_expand_constant): Pass proper types to size_binop.
* cp/init.c (construct_virtual_bases): Fix type error.
(build_vec_delete_1): Pass proper type to size_binop and don't
fold result.
* cp/lex.c (cp_make_lang_type): BINFO_OFFSET is sizetype.
* cp/rtti.c (get_base_offset): Pass proper type to size_binop.
* cp/search.c (dfs_find_vbases): Fix type error.
(expand_upcast_fixups): Arg to skip_rtti_stuff is pointer to signed.
(dfs_get_vbase_types): BINFO_OFFSET is sizetype.
* cp/tree.c (debug_binfo): Variable N is signed.
Use HOST_WIDE_INT_PRINT_DEC.
* cp/typeck.c (comptypes): sizetype is same as equivalent integer type.
(c_sizeof, c_sizeof_nowarn, expr_sizeof): Use TYPE_SIZE_UNIT,
size_one_node and size_zero_node.
(c_alignof): Use size_one_node.
(build_component_addr): Pass proper types to size_binop.
(expand_ptrmemfunc_cst): Don't use size_binop on non-sizes.
* f/com.c (ffecom_arrayref_): Convert args to size_binop to proper
type.
(ffecom_tree_canonize_ptr_): Don't use size_binop for non-sizes.
(ffecom_tree_canonize_ref_): Likewise.
(type_for_mode): Handle TImode.
* f/ste.c (ffeste_io_dofio_, ffeste_io_douio_): Use TYPE_SIZE_UNIT.
(ffeste_io_ciclist_): Likewise.
* java/expr.c (build_java_ret): Pass proper type to size_binop.
From-SVN: r32225
2000-02-27 22:39:40 +01:00
|
|
|
|
maxindex = build_int_2 (-1, -1);
|
1993-09-13 22:17:48 +02:00
|
|
|
|
for (; elts; elts = TREE_CHAIN (elts))
|
|
|
|
|
{
|
|
|
|
|
if (TREE_PURPOSE (elts))
|
|
|
|
|
maxindex = TREE_PURPOSE (elts);
|
|
|
|
|
else
|
builtins.c (c_strlen): Use size_diffop and return ssizetype value.
* builtins.c (c_strlen): Use size_diffop and return ssizetype value.
(expand_builtin_strcpy): Pass correct type to size_binop.
(expand_builtin_strcmp): Likewise.
Clean up conditional structure.
* c-decl.c (init_decl_processing): Don't call set_sizetype twice.
(complete_array_type): Don't use size_binop for MAXINDEX.
* c-typeck.c (c_sizeof): Use size_one_node and TYPE_SIZE_UNIT.
(c_sizeof_nowarn, c_size_in_bytes): Likewise.
(c_alignof): Use size_one_node.
(build_unary_op): Pass arg of proper type to size_binop.
(really_start_incremental_init, push_init_level): Use sizetype for
constructor{,_bit,_unfilled}_index.
(pop_init_label, output_init_element): Likewise.
(output_pending_init_elements, process_init_element): Likewise.
* calls.c (compute_argument_block_size): Field VAR is ssizetype.
* expr.c (store_expr): Use size_int.
(store_constructor): Use proper types for size_binop args.
(get_inner_reference, expand_expr, case ARRAY_REF): Likewise.
(expand_expr_unaligned): Likewise.
(string_contant): Return object of sizetype.
* expr.h (SUB_PARM_SIZE): Call size_diffop and pass proper types.
(ARGS_SIZE_RTX): Call ARGS_SIZE_TREE.
(ARGS_SIZE_TREE): Pass proper types to size_binop.
* fold-const.c (int_const_binop): Refine when size_int is called.
(fold_convert): Likewise.
(size_int_wide): Rework to take KIND as arg, only take low order
bits, handle new sizetype_tab datatype, and chain entries in
size_table.
(size_int_type_wide): New function.
(size_binop): Validate types of arguments.
(ssize_binop): Deleted.
(size_diffop): New function.
(extract_muldiv): Only fold division into multiplication for sizetypes.
* function.c (assign_parms): Use size_diffop and make sure
VAR field is of ssizetype; also pass proper type to size_binop.
(locate_and_pad_parm, pad_to_arg_alignment): Likewise.
(round_down): Deleted from here.
* store-layout.c (sizetype_tab): Now an array.
(sizetype_set, early_root_list): New variables.
(variable_size): Use size_one_node.
(round_up): Pass proper type to size_binop.
(round_down): Moved to here and corrected as above.
(layout_record): Pass proper arg types to size_binop.
(layout_type): Likewise.
If sizetype_set is zero, record the type just laid out.
(make_unsigned_type): Don't call set_sizetype;
(make_signed_type): Likewise; also, call fixup_signed_type.
(initialize_sizetypes): New function.
(set_sizetype): Make copy of types, set TYPE_IS_SIZETYPE, and
set name of bitsizetype to "bit_size_type".
Fix up type of sizes of all types made before call.
* tm.texi (ROUND_TYPE_SIZE_UNIT): New macro.
* tree.c (fix_sizetype): Deleted.
(build_common_tree_nodes): Call initialize_sizetypes.
(build_common_tree_nodes_2): Don't call fix_sizetype.
* tree.h (TYPE_IS_SIZETYPE): New macro.
(initialize_sizetype): New declaration.
(enum size_type_kind): New type.
(struct sizetype_tab): Deleted.
(sizetype_tab): Now array; adjust sizetype macros.
(size_diffop, size_int_type_wide): New functions.
(size_int_wide): Change number of args and type; access macros changed.
(ssize_int, sbitsize_int): New macros.
* config/i960/i960.h (ROUND_TYPE_SIZE): Use size_int.
(ROUND_TYPE_SIZE_UNIT): New macro.
* ch/actions.c (chill_convert_for_assignment): Don't use size_binop
for things that aren't sizes.
(expand_varying_length_assignment): Likewise.
* ch/convert.c (digest_array_tuple, convert): Likewise.
* ch/typeck.c (build_chill_slice, smash_dummy_type): Likewise.
(build_chill_slice_with_range): Likewise.
(build_chill_slice_with_length): Likewise.
(build_array_from_set): Adjust types for size_binop.
* ch/expr.c (build_concat_expr, build_chill_repetition_op): Likewise.
(build_chill_sizeof): Use TYPE_SIZE_UNIT.
* ch/tree.c (build_string_type): Pass proper type to size_binop.
* cp/class.c (dfs_build_vtable_offset_vtbl_entries): Don't use
size_binop on things that are not sizes; ssize_binop deleted.
Call size_diffop when appropriate.
(dfs_build_vcall_offset_vtbl_entries): Likewise.
(build_primary_vtable, build_secondary_vtable): Likewise.
(dfs_set_offset_for_unshared_vbases, dfs_modify_vtables): Likewise.
Variable I is HOST_WIDE_INT.
(get_vfield_offset): Pass proper types to size_binop.
(size_extra_vtbl_entries, layout_virtual_bases): Likewise.
(finish_struct_1): Likewise.
(skip_rtti_stuff): Arg N is now pointer to signed.
(layout_class_type): Use size_zero_node.
* cp/cp-tree.h (skip_rtti_stuff): Arg N is pointer to signed.
* cp/cvt.c (cp_convert_to_pointer): Pass proper types to size_binop.
* cp/decl.c (complete_arry_type): Pass proper types to size_binop.
(xref_basetypes): BINFO_OFFSET is sizetype.
* cp/error.c (dump_expr): Don't use size_binop non-sizes.
* cp/expr.c (cplus_expand_constant): Pass proper types to size_binop.
* cp/init.c (construct_virtual_bases): Fix type error.
(build_vec_delete_1): Pass proper type to size_binop and don't
fold result.
* cp/lex.c (cp_make_lang_type): BINFO_OFFSET is sizetype.
* cp/rtti.c (get_base_offset): Pass proper type to size_binop.
* cp/search.c (dfs_find_vbases): Fix type error.
(expand_upcast_fixups): Arg to skip_rtti_stuff is pointer to signed.
(dfs_get_vbase_types): BINFO_OFFSET is sizetype.
* cp/tree.c (debug_binfo): Variable N is signed.
Use HOST_WIDE_INT_PRINT_DEC.
* cp/typeck.c (comptypes): sizetype is same as equivalent integer type.
(c_sizeof, c_sizeof_nowarn, expr_sizeof): Use TYPE_SIZE_UNIT,
size_one_node and size_zero_node.
(c_alignof): Use size_one_node.
(build_component_addr): Pass proper types to size_binop.
(expand_ptrmemfunc_cst): Don't use size_binop on non-sizes.
* f/com.c (ffecom_arrayref_): Convert args to size_binop to proper
type.
(ffecom_tree_canonize_ptr_): Don't use size_binop for non-sizes.
(ffecom_tree_canonize_ref_): Likewise.
(type_for_mode): Handle TImode.
* f/ste.c (ffeste_io_dofio_, ffeste_io_douio_): Use TYPE_SIZE_UNIT.
(ffeste_io_ciclist_): Likewise.
* java/expr.c (build_java_ret): Pass proper type to size_binop.
From-SVN: r32225
2000-02-27 22:39:40 +01:00
|
|
|
|
maxindex = fold (build (PLUS_EXPR, integer_type_node,
|
|
|
|
|
maxindex, integer_one_node));
|
1993-09-13 22:17:48 +02:00
|
|
|
|
}
|
|
|
|
|
maxindex = copy_node (maxindex);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Make an error message unless that happened already. */
|
|
|
|
|
if (initial_value != error_mark_node)
|
|
|
|
|
value = 1;
|
|
|
|
|
|
|
|
|
|
/* Prevent further error messages. */
|
1993-03-22 08:04:18 +01:00
|
|
|
|
maxindex = build_int_2 (0, 0);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!maxindex)
|
|
|
|
|
{
|
|
|
|
|
if (do_default)
|
1993-03-22 08:04:18 +01:00
|
|
|
|
maxindex = build_int_2 (0, 0);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
value = 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (maxindex)
|
|
|
|
|
{
|
|
|
|
|
TYPE_DOMAIN (type) = build_index_type (maxindex);
|
|
|
|
|
if (!TREE_TYPE (maxindex))
|
|
|
|
|
TREE_TYPE (maxindex) = TYPE_DOMAIN (type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Lay out the type now that we can get the real answer. */
|
|
|
|
|
|
|
|
|
|
layout_type (type);
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-17 16:48:28 +02:00
|
|
|
|
/* Determine whether TYPE is a structure with a flexible array member,
|
|
|
|
|
or a union containing such a structure (possibly recursively). */
|
|
|
|
|
|
|
|
|
|
static bool
|
2003-06-19 21:43:59 +02:00
|
|
|
|
flexible_array_type_p (tree type)
|
2002-08-17 16:48:28 +02:00
|
|
|
|
{
|
|
|
|
|
tree x;
|
|
|
|
|
switch (TREE_CODE (type))
|
|
|
|
|
{
|
|
|
|
|
case RECORD_TYPE:
|
|
|
|
|
x = TYPE_FIELDS (type);
|
|
|
|
|
if (x == NULL_TREE)
|
|
|
|
|
return false;
|
|
|
|
|
while (TREE_CHAIN (x) != NULL_TREE)
|
|
|
|
|
x = TREE_CHAIN (x);
|
|
|
|
|
if (TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE
|
|
|
|
|
&& TYPE_SIZE (TREE_TYPE (x)) == NULL_TREE
|
|
|
|
|
&& TYPE_DOMAIN (TREE_TYPE (x)) != NULL_TREE
|
|
|
|
|
&& TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (x))) == NULL_TREE)
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
case UNION_TYPE:
|
|
|
|
|
for (x = TYPE_FIELDS (type); x != NULL_TREE; x = TREE_CHAIN (x))
|
|
|
|
|
{
|
|
|
|
|
if (flexible_array_type_p (TREE_TYPE (x)))
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Given declspecs and a declarator,
|
|
|
|
|
determine the name and type of the object declared
|
|
|
|
|
and construct a ..._DECL node for it.
|
|
|
|
|
(In one case we can return a ..._TYPE node instead.
|
|
|
|
|
For invalid input we sometimes return 0.)
|
|
|
|
|
|
|
|
|
|
DECLSPECS is a chain of tree_list nodes whose value fields
|
|
|
|
|
are the storage classes and type specifiers.
|
|
|
|
|
|
|
|
|
|
DECL_CONTEXT says which syntactic context this declaration is in:
|
|
|
|
|
NORMAL for most contexts. Make a VAR_DECL or FUNCTION_DECL or TYPE_DECL.
|
|
|
|
|
FUNCDEF for a function definition. Like NORMAL but a few different
|
|
|
|
|
error messages in each case. Return value may be zero meaning
|
|
|
|
|
this definition is too screwy to try to parse.
|
|
|
|
|
PARM for a parameter declaration (either within a function prototype
|
|
|
|
|
or before a function body). Make a PARM_DECL, or return void_type_node.
|
|
|
|
|
TYPENAME if for a typename (in a cast or sizeof).
|
|
|
|
|
Don't make a DECL node; just return the ..._TYPE node.
|
|
|
|
|
FIELD for a struct or union field; make a FIELD_DECL.
|
2002-02-02 01:14:41 +01:00
|
|
|
|
BITFIELD for a field with specified width.
|
1992-02-13 23:21:26 +01:00
|
|
|
|
INITIALIZED is 1 if the decl has an initializer.
|
|
|
|
|
|
|
|
|
|
In the TYPENAME case, DECLARATOR is really an absolute declarator.
|
|
|
|
|
It may also be so in the PARM case, for a prototype where the
|
|
|
|
|
argument type is specified but not the name.
|
|
|
|
|
|
|
|
|
|
This function is where the complicated C meanings of `static'
|
1992-03-23 03:07:53 +01:00
|
|
|
|
and `extern' are interpreted. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
static tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
grokdeclarator (tree declarator, tree declspecs,
|
|
|
|
|
enum decl_context decl_context, int initialized)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
int specbits = 0;
|
|
|
|
|
tree spec;
|
|
|
|
|
tree type = NULL_TREE;
|
|
|
|
|
int longlong = 0;
|
|
|
|
|
int constp;
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
int restrictp;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
int volatilep;
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
int type_quals = TYPE_UNQUALIFIED;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
int inlinep;
|
|
|
|
|
int explicit_int = 0;
|
|
|
|
|
int explicit_char = 0;
|
1993-03-04 20:42:57 +01:00
|
|
|
|
int defaulted_int = 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
tree typedef_decl = 0;
|
2002-02-02 01:14:41 +01:00
|
|
|
|
const char *name;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
tree typedef_type = 0;
|
|
|
|
|
int funcdef_flag = 0;
|
|
|
|
|
enum tree_code innermost_code = ERROR_MARK;
|
2002-02-02 01:14:41 +01:00
|
|
|
|
int bitfield = 0;
|
1992-03-23 03:07:53 +01:00
|
|
|
|
int size_varies = 0;
|
Table-driven attributes.
* c-decl.c, config/alpha/alpha.c, config/arc/arc.c,
config/arm/arm.c, config/arm/pe.c, config/avr/avr.c,
config/avr/avr.h, config/d30v/d30v.h, config/fr30/fr30.h,
config/h8300/h8300.c, config/i386/cygwin.h, config/i386/winnt.c,
config/m32r/m32r.c, config/mcore/mcore.c, config/sh/sh.c,
config/stormy16/stormy16.h, config/v850/v850.c, doc/c-tree.texi,
doc/tm.texi, ggc-common.c, integrate.c, print-tree.c, tree.c,
tree.h: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* tree.h (struct tree_decl): Change machine_attributes to
attributes.
* doc/c-tree.texi: Document that all attributes are now attached
to decls and types.
* c-common.c (add_attribute, attrtab, attrtab_idx,
default_valid_lang_attribute, valid_lang_attribute): Remove.
(attribute_tables, attributes_initialized,
c_common_attribute_table, default_lang_attribute_table): New
variables.
(handle_packed_attribute, handle_nocommon_attribute,
handle_common_attribute, handle_noreturn_attribute,
handle_unused_attribute, handle_const_attribute,
handle_transparent_union_attribute, handle_constructor_attribute,
handle_destructor_attribute, handle_mode_attribute,
handle_section_attribute, handle_aligned_attribute,
handle_weak_attribute, handle_alias_attribute,
handle_no_instrument_function_attribute,
handle_no_check_memory_usage_attribute, handle_malloc_attribute,
handle_no_limit_stack_attribute, handle_pure_attribute): New
functions.
(init_attributes, decl_attributes): Rewrite to implement
table-driven attributes.
* c-common.h (enum attribute_flags): Move to tree.h.
* c-format.c (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Rename to
handle_format_attribute and handle_format_arg_attribute. Update
for table-driven attributes.
* c-common.h (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Remove prototypes.
(handle_format_attribute, handle_format_arg_attribute): Add
prototypes.
* c-decl.c (grokdeclarator): Handle attributes nested inside
declarators.
* c-parse.in (setattrs, maybe_setattrs): Remove.
(maybe_type_quals_setattrs): Rename to maybe_type_quals_attrs.
Update to handle nested attributes properly.
(maybe_resetattrs, after_type_declarator,
parm_declarator_nostarttypename, notype_declarator, absdcl1_noea,
absdcl1_ea, direct_absdcl1): Update to handle nested attributes
properly.
(make_pointer_declarator): Update to handle nested attributes
properly.
* doc/extend.texi: Update documentation of limits of attributes
syntax. Warn about problems with attribute semantics in C++.
* target.h (struct target): Remove valid_decl_attribute and
valid_type_attribute. Add attribute_table and
function_attribute_inlinable_p.
* target-def.h (TARGET_VALID_DECL_ATTRIBUTE,
TARGET_VALID_TYPE_ATTRIBUTE): Remove.
(TARGET_ATTRIBUTE_TABLE, TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P):
Add.
(TARGET_INITIALIZER): Update.
* integrate.c (FUNCTION_ATTRIBUTE_INLINABLE_P): Remove default
definition.
(function_attribute_inlinable_p): New function. Check for the
presence of any machine attributes before using
targetm.function_attribute_inlinable_p.
(function_cannot_inline_p): Update.
* Makefile.in (integrate.o): Update dependencies.
* doc/tm.texi: Update documentation of target attributes and
example definition of TARGET_VALID_TYPE_ATTRIBUTE.
* tree.c (default_valid_attribute_p, valid_machine_attribute):
Remove.
(default_target_attribute_table,
default_function_attribute_inlinable_p): New.
(lookup_attribute): Update comment to clarify handling of multiple
attributes with the same name.
(merge_attributes, attribute_list_contained): Allow multiple
attributes with the same name but different arguments to appear in
the same attribute list.
* tree.h (default_valid_attribute_p): Remove prototype.
(struct attribute_spec): New.
(default_target_attribute_table): Declare.
(enum attribute_flags): Move from c-common.h. Add
ATTR_FLAG_TYPE_IN_PLACE.
(default_function_attribute_inlinable_p): Declare.
* config/alpha/alpha.c (vms_valid_decl_attribute_p): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(vms_attribute_table): New.
* config/arc/arc.c (arc_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arc_attribute_table, arc_handle_interrupt_attribute): New.
* config/arm/arm.c (arm_valid_type_attribute_p,
arm_valid_decl_attribute_p, arm_pe_valid_decl_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arm_attribute_table, arm_handle_fndecl_attribute,
arm_handle_isr_attribute): New.
* config/avr/avr.c (avr_valid_type_attribute,
avr_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE, TARGET_VALID_TYPE_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(avr_attribute_table, avr_handle_progmem_attribute,
avr_handle_fndecl_attribute): New.
* config/c4x/c4x.c (c4x_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(c4x_attribute_table, c4x_handle_fntype_attribute): New.
* config/h8300/h8300.c (h8300_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(h8300_attribute_table, h8300_handle_fndecl_attribute,
h8300_handle_eightbit_data_attribute,
h8300_handle_tiny_data_attribute): New.
* config/i386/i386-protos.h (ix86_valid_type_attribute_p,
i386_pe_valid_decl_attribute_p, i386_pe_valid_type_attribute_p):
Remove prototypes.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New
declarations.
* config/i386/i386.c (ix86_valid_type_attribute_p: Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ix86_attribute_table, ix86_handle_cdecl_attribute,
ix86_handle_regparm_attribute): New.
* config/i386/winnt.c (i386_pe_valid_decl_attribute_p,
i386_pe_valid_type_attribute_p): Remove.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New.
* config/ia64/ia64.c (ia64_valid_type_attribute): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ia64_attribute_table): New.
* config/m32r/m32r.c (m32r_valid_decl_attribute, interrupt_ident1,
interrupt_ident2, model_ident1, model_ident2): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(init_idents): Update.
(m32r_attribute_table, m32r_handle_model_attribute): New.
* config/m68hc11/m68hc11.c (m68hc11_valid_type_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(m68hc11_attribute_table, m68hc11_handle_fntype_attribute): New.
* config/mcore/mcore.c (mcore_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(mcore_attribute_table, mcore_handle_naked_attribute): New.
* config/ns32k/ns32k.c (ns32k_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ns32k_attribute_table, ns32k_handle_fntype_attribute): New.
* config/rs6000/rs6000.c (rs6000_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(rs6000_attribute_table, rs6000_handle_longcall_attribute): New.
* config/sh/sh.c (sh_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(sh_attribute_table, sh_handle_interrupt_handler_attribute,
sh_handle_sp_switch_attribute, sh_handle_trap_exit_attribute):
New.
* config/stormy16/stormy16.c (stormy16_valid_type_attribute):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define
(TARGET_ATTRIBUTE_TABLE): Define.
(stormy16_attribute_table, stormy16_handle_interrupt_attribute):
New.
* config/v850/v850.c (v850_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(v850_attribute_table, v850_handle_interrupt_attribute,
v850_handle_data_area_attribute): New.
* config/v850/v850-c.c (mark_current_function_as_interrupt):
Return void. Call decl_attributes instead of
valid_machine_attribute.
cp:
Table-driven attributes.
* decl.c: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* decl2.c (cplus_decl_attributes): Only take one attributes
parameter.
* cp-tree.c (cplus_decl_attributes): Update prototype.
* class.c (finish_struct), decl.c (start_decl, start_function),
decl2.c (grokfield), friend.c (do_friend), parse.y
(parse_bitfield): Update calls to cplus_decl_attributes.
* decl.c (grokdeclarator): Take a pointer to a single ordinary
attribute list.
* decl.h (grokdeclarator): Update prototype.
* decl2.c (grokfield): Take a single ordinary attribute list.
* friend.c (do_friend): Likewise.
* decl.c (shadow_tag, groktypename, start_decl,
start_handler_parms, grokdeclarator, grokparms, start_function,
start_method), decl2.c (grokfield, grokbitfield, grokoptypename),
parse.y (parse_field, parse_bitfield, component_decl_1), pt.c
(process_template_parm, do_decl_instantiation): Pass single
ordinary attribute lists around.
* decl.c (grokdeclarator): Correct handling of nested attributes.
Revert the patch
1998-10-18 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (grokdeclarator): Embedded attrs bind to the right,
not the left.
.
* cp-tree.h (cp_valid_lang_attribute): Remove declaration
(cp_attribute_table): Declare.
* decl.c (valid_lang_attribute): Don't define.
(lang_attribute_table): Define.
(init_decl_processing): Initialize lang_attribute_table instead of
valid_lang_attribute.
* tree.c (cp_valid_lang_attribute): Remove.
(handle_java_interface_attribute, handle_com_interface_attribute,
handle_init_priority_attribute): New functions.
(cp_attribute_table): New array.
* decl2.c (import_export_class): Don't use
targetm.valid_type_attribute.
testsuite:
Table-driven attributes.
* g++.dg/ext/attrib1.C: New test.
From-SVN: r45718
2001-09-21 03:27:06 +02:00
|
|
|
|
tree decl_attr = NULL_TREE;
|
2001-05-25 13:12:47 +02:00
|
|
|
|
tree array_ptr_quals = NULL_TREE;
|
|
|
|
|
int array_parm_static = 0;
|
Table-driven attributes.
* c-decl.c, config/alpha/alpha.c, config/arc/arc.c,
config/arm/arm.c, config/arm/pe.c, config/avr/avr.c,
config/avr/avr.h, config/d30v/d30v.h, config/fr30/fr30.h,
config/h8300/h8300.c, config/i386/cygwin.h, config/i386/winnt.c,
config/m32r/m32r.c, config/mcore/mcore.c, config/sh/sh.c,
config/stormy16/stormy16.h, config/v850/v850.c, doc/c-tree.texi,
doc/tm.texi, ggc-common.c, integrate.c, print-tree.c, tree.c,
tree.h: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* tree.h (struct tree_decl): Change machine_attributes to
attributes.
* doc/c-tree.texi: Document that all attributes are now attached
to decls and types.
* c-common.c (add_attribute, attrtab, attrtab_idx,
default_valid_lang_attribute, valid_lang_attribute): Remove.
(attribute_tables, attributes_initialized,
c_common_attribute_table, default_lang_attribute_table): New
variables.
(handle_packed_attribute, handle_nocommon_attribute,
handle_common_attribute, handle_noreturn_attribute,
handle_unused_attribute, handle_const_attribute,
handle_transparent_union_attribute, handle_constructor_attribute,
handle_destructor_attribute, handle_mode_attribute,
handle_section_attribute, handle_aligned_attribute,
handle_weak_attribute, handle_alias_attribute,
handle_no_instrument_function_attribute,
handle_no_check_memory_usage_attribute, handle_malloc_attribute,
handle_no_limit_stack_attribute, handle_pure_attribute): New
functions.
(init_attributes, decl_attributes): Rewrite to implement
table-driven attributes.
* c-common.h (enum attribute_flags): Move to tree.h.
* c-format.c (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Rename to
handle_format_attribute and handle_format_arg_attribute. Update
for table-driven attributes.
* c-common.h (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Remove prototypes.
(handle_format_attribute, handle_format_arg_attribute): Add
prototypes.
* c-decl.c (grokdeclarator): Handle attributes nested inside
declarators.
* c-parse.in (setattrs, maybe_setattrs): Remove.
(maybe_type_quals_setattrs): Rename to maybe_type_quals_attrs.
Update to handle nested attributes properly.
(maybe_resetattrs, after_type_declarator,
parm_declarator_nostarttypename, notype_declarator, absdcl1_noea,
absdcl1_ea, direct_absdcl1): Update to handle nested attributes
properly.
(make_pointer_declarator): Update to handle nested attributes
properly.
* doc/extend.texi: Update documentation of limits of attributes
syntax. Warn about problems with attribute semantics in C++.
* target.h (struct target): Remove valid_decl_attribute and
valid_type_attribute. Add attribute_table and
function_attribute_inlinable_p.
* target-def.h (TARGET_VALID_DECL_ATTRIBUTE,
TARGET_VALID_TYPE_ATTRIBUTE): Remove.
(TARGET_ATTRIBUTE_TABLE, TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P):
Add.
(TARGET_INITIALIZER): Update.
* integrate.c (FUNCTION_ATTRIBUTE_INLINABLE_P): Remove default
definition.
(function_attribute_inlinable_p): New function. Check for the
presence of any machine attributes before using
targetm.function_attribute_inlinable_p.
(function_cannot_inline_p): Update.
* Makefile.in (integrate.o): Update dependencies.
* doc/tm.texi: Update documentation of target attributes and
example definition of TARGET_VALID_TYPE_ATTRIBUTE.
* tree.c (default_valid_attribute_p, valid_machine_attribute):
Remove.
(default_target_attribute_table,
default_function_attribute_inlinable_p): New.
(lookup_attribute): Update comment to clarify handling of multiple
attributes with the same name.
(merge_attributes, attribute_list_contained): Allow multiple
attributes with the same name but different arguments to appear in
the same attribute list.
* tree.h (default_valid_attribute_p): Remove prototype.
(struct attribute_spec): New.
(default_target_attribute_table): Declare.
(enum attribute_flags): Move from c-common.h. Add
ATTR_FLAG_TYPE_IN_PLACE.
(default_function_attribute_inlinable_p): Declare.
* config/alpha/alpha.c (vms_valid_decl_attribute_p): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(vms_attribute_table): New.
* config/arc/arc.c (arc_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arc_attribute_table, arc_handle_interrupt_attribute): New.
* config/arm/arm.c (arm_valid_type_attribute_p,
arm_valid_decl_attribute_p, arm_pe_valid_decl_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arm_attribute_table, arm_handle_fndecl_attribute,
arm_handle_isr_attribute): New.
* config/avr/avr.c (avr_valid_type_attribute,
avr_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE, TARGET_VALID_TYPE_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(avr_attribute_table, avr_handle_progmem_attribute,
avr_handle_fndecl_attribute): New.
* config/c4x/c4x.c (c4x_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(c4x_attribute_table, c4x_handle_fntype_attribute): New.
* config/h8300/h8300.c (h8300_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(h8300_attribute_table, h8300_handle_fndecl_attribute,
h8300_handle_eightbit_data_attribute,
h8300_handle_tiny_data_attribute): New.
* config/i386/i386-protos.h (ix86_valid_type_attribute_p,
i386_pe_valid_decl_attribute_p, i386_pe_valid_type_attribute_p):
Remove prototypes.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New
declarations.
* config/i386/i386.c (ix86_valid_type_attribute_p: Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ix86_attribute_table, ix86_handle_cdecl_attribute,
ix86_handle_regparm_attribute): New.
* config/i386/winnt.c (i386_pe_valid_decl_attribute_p,
i386_pe_valid_type_attribute_p): Remove.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New.
* config/ia64/ia64.c (ia64_valid_type_attribute): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ia64_attribute_table): New.
* config/m32r/m32r.c (m32r_valid_decl_attribute, interrupt_ident1,
interrupt_ident2, model_ident1, model_ident2): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(init_idents): Update.
(m32r_attribute_table, m32r_handle_model_attribute): New.
* config/m68hc11/m68hc11.c (m68hc11_valid_type_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(m68hc11_attribute_table, m68hc11_handle_fntype_attribute): New.
* config/mcore/mcore.c (mcore_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(mcore_attribute_table, mcore_handle_naked_attribute): New.
* config/ns32k/ns32k.c (ns32k_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ns32k_attribute_table, ns32k_handle_fntype_attribute): New.
* config/rs6000/rs6000.c (rs6000_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(rs6000_attribute_table, rs6000_handle_longcall_attribute): New.
* config/sh/sh.c (sh_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(sh_attribute_table, sh_handle_interrupt_handler_attribute,
sh_handle_sp_switch_attribute, sh_handle_trap_exit_attribute):
New.
* config/stormy16/stormy16.c (stormy16_valid_type_attribute):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define
(TARGET_ATTRIBUTE_TABLE): Define.
(stormy16_attribute_table, stormy16_handle_interrupt_attribute):
New.
* config/v850/v850.c (v850_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(v850_attribute_table, v850_handle_interrupt_attribute,
v850_handle_data_area_attribute): New.
* config/v850/v850-c.c (mark_current_function_as_interrupt):
Return void. Call decl_attributes instead of
valid_machine_attribute.
cp:
Table-driven attributes.
* decl.c: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* decl2.c (cplus_decl_attributes): Only take one attributes
parameter.
* cp-tree.c (cplus_decl_attributes): Update prototype.
* class.c (finish_struct), decl.c (start_decl, start_function),
decl2.c (grokfield), friend.c (do_friend), parse.y
(parse_bitfield): Update calls to cplus_decl_attributes.
* decl.c (grokdeclarator): Take a pointer to a single ordinary
attribute list.
* decl.h (grokdeclarator): Update prototype.
* decl2.c (grokfield): Take a single ordinary attribute list.
* friend.c (do_friend): Likewise.
* decl.c (shadow_tag, groktypename, start_decl,
start_handler_parms, grokdeclarator, grokparms, start_function,
start_method), decl2.c (grokfield, grokbitfield, grokoptypename),
parse.y (parse_field, parse_bitfield, component_decl_1), pt.c
(process_template_parm, do_decl_instantiation): Pass single
ordinary attribute lists around.
* decl.c (grokdeclarator): Correct handling of nested attributes.
Revert the patch
1998-10-18 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (grokdeclarator): Embedded attrs bind to the right,
not the left.
.
* cp-tree.h (cp_valid_lang_attribute): Remove declaration
(cp_attribute_table): Declare.
* decl.c (valid_lang_attribute): Don't define.
(lang_attribute_table): Define.
(init_decl_processing): Initialize lang_attribute_table instead of
valid_lang_attribute.
* tree.c (cp_valid_lang_attribute): Remove.
(handle_java_interface_attribute, handle_com_interface_attribute,
handle_init_priority_attribute): New functions.
(cp_attribute_table): New array.
* decl2.c (import_export_class): Don't use
targetm.valid_type_attribute.
testsuite:
Table-driven attributes.
* g++.dg/ext/attrib1.C: New test.
From-SVN: r45718
2001-09-21 03:27:06 +02:00
|
|
|
|
tree returned_attrs = NULL_TREE;
|
2002-02-02 01:14:41 +01:00
|
|
|
|
|
|
|
|
|
if (decl_context == BITFIELD)
|
|
|
|
|
bitfield = 1, decl_context = FIELD;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
if (decl_context == FUNCDEF)
|
|
|
|
|
funcdef_flag = 1, decl_context = NORMAL;
|
|
|
|
|
|
|
|
|
|
/* Look inside a declarator for the name being declared
|
|
|
|
|
and get it as a string, for an error message. */
|
|
|
|
|
{
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree decl = declarator;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
name = 0;
|
|
|
|
|
|
|
|
|
|
while (decl)
|
|
|
|
|
switch (TREE_CODE (decl))
|
|
|
|
|
{
|
|
|
|
|
case ARRAY_REF:
|
|
|
|
|
case INDIRECT_REF:
|
|
|
|
|
case CALL_EXPR:
|
|
|
|
|
innermost_code = TREE_CODE (decl);
|
|
|
|
|
decl = TREE_OPERAND (decl, 0);
|
|
|
|
|
break;
|
|
|
|
|
|
Table-driven attributes.
* c-decl.c, config/alpha/alpha.c, config/arc/arc.c,
config/arm/arm.c, config/arm/pe.c, config/avr/avr.c,
config/avr/avr.h, config/d30v/d30v.h, config/fr30/fr30.h,
config/h8300/h8300.c, config/i386/cygwin.h, config/i386/winnt.c,
config/m32r/m32r.c, config/mcore/mcore.c, config/sh/sh.c,
config/stormy16/stormy16.h, config/v850/v850.c, doc/c-tree.texi,
doc/tm.texi, ggc-common.c, integrate.c, print-tree.c, tree.c,
tree.h: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* tree.h (struct tree_decl): Change machine_attributes to
attributes.
* doc/c-tree.texi: Document that all attributes are now attached
to decls and types.
* c-common.c (add_attribute, attrtab, attrtab_idx,
default_valid_lang_attribute, valid_lang_attribute): Remove.
(attribute_tables, attributes_initialized,
c_common_attribute_table, default_lang_attribute_table): New
variables.
(handle_packed_attribute, handle_nocommon_attribute,
handle_common_attribute, handle_noreturn_attribute,
handle_unused_attribute, handle_const_attribute,
handle_transparent_union_attribute, handle_constructor_attribute,
handle_destructor_attribute, handle_mode_attribute,
handle_section_attribute, handle_aligned_attribute,
handle_weak_attribute, handle_alias_attribute,
handle_no_instrument_function_attribute,
handle_no_check_memory_usage_attribute, handle_malloc_attribute,
handle_no_limit_stack_attribute, handle_pure_attribute): New
functions.
(init_attributes, decl_attributes): Rewrite to implement
table-driven attributes.
* c-common.h (enum attribute_flags): Move to tree.h.
* c-format.c (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Rename to
handle_format_attribute and handle_format_arg_attribute. Update
for table-driven attributes.
* c-common.h (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Remove prototypes.
(handle_format_attribute, handle_format_arg_attribute): Add
prototypes.
* c-decl.c (grokdeclarator): Handle attributes nested inside
declarators.
* c-parse.in (setattrs, maybe_setattrs): Remove.
(maybe_type_quals_setattrs): Rename to maybe_type_quals_attrs.
Update to handle nested attributes properly.
(maybe_resetattrs, after_type_declarator,
parm_declarator_nostarttypename, notype_declarator, absdcl1_noea,
absdcl1_ea, direct_absdcl1): Update to handle nested attributes
properly.
(make_pointer_declarator): Update to handle nested attributes
properly.
* doc/extend.texi: Update documentation of limits of attributes
syntax. Warn about problems with attribute semantics in C++.
* target.h (struct target): Remove valid_decl_attribute and
valid_type_attribute. Add attribute_table and
function_attribute_inlinable_p.
* target-def.h (TARGET_VALID_DECL_ATTRIBUTE,
TARGET_VALID_TYPE_ATTRIBUTE): Remove.
(TARGET_ATTRIBUTE_TABLE, TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P):
Add.
(TARGET_INITIALIZER): Update.
* integrate.c (FUNCTION_ATTRIBUTE_INLINABLE_P): Remove default
definition.
(function_attribute_inlinable_p): New function. Check for the
presence of any machine attributes before using
targetm.function_attribute_inlinable_p.
(function_cannot_inline_p): Update.
* Makefile.in (integrate.o): Update dependencies.
* doc/tm.texi: Update documentation of target attributes and
example definition of TARGET_VALID_TYPE_ATTRIBUTE.
* tree.c (default_valid_attribute_p, valid_machine_attribute):
Remove.
(default_target_attribute_table,
default_function_attribute_inlinable_p): New.
(lookup_attribute): Update comment to clarify handling of multiple
attributes with the same name.
(merge_attributes, attribute_list_contained): Allow multiple
attributes with the same name but different arguments to appear in
the same attribute list.
* tree.h (default_valid_attribute_p): Remove prototype.
(struct attribute_spec): New.
(default_target_attribute_table): Declare.
(enum attribute_flags): Move from c-common.h. Add
ATTR_FLAG_TYPE_IN_PLACE.
(default_function_attribute_inlinable_p): Declare.
* config/alpha/alpha.c (vms_valid_decl_attribute_p): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(vms_attribute_table): New.
* config/arc/arc.c (arc_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arc_attribute_table, arc_handle_interrupt_attribute): New.
* config/arm/arm.c (arm_valid_type_attribute_p,
arm_valid_decl_attribute_p, arm_pe_valid_decl_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arm_attribute_table, arm_handle_fndecl_attribute,
arm_handle_isr_attribute): New.
* config/avr/avr.c (avr_valid_type_attribute,
avr_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE, TARGET_VALID_TYPE_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(avr_attribute_table, avr_handle_progmem_attribute,
avr_handle_fndecl_attribute): New.
* config/c4x/c4x.c (c4x_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(c4x_attribute_table, c4x_handle_fntype_attribute): New.
* config/h8300/h8300.c (h8300_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(h8300_attribute_table, h8300_handle_fndecl_attribute,
h8300_handle_eightbit_data_attribute,
h8300_handle_tiny_data_attribute): New.
* config/i386/i386-protos.h (ix86_valid_type_attribute_p,
i386_pe_valid_decl_attribute_p, i386_pe_valid_type_attribute_p):
Remove prototypes.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New
declarations.
* config/i386/i386.c (ix86_valid_type_attribute_p: Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ix86_attribute_table, ix86_handle_cdecl_attribute,
ix86_handle_regparm_attribute): New.
* config/i386/winnt.c (i386_pe_valid_decl_attribute_p,
i386_pe_valid_type_attribute_p): Remove.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New.
* config/ia64/ia64.c (ia64_valid_type_attribute): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ia64_attribute_table): New.
* config/m32r/m32r.c (m32r_valid_decl_attribute, interrupt_ident1,
interrupt_ident2, model_ident1, model_ident2): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(init_idents): Update.
(m32r_attribute_table, m32r_handle_model_attribute): New.
* config/m68hc11/m68hc11.c (m68hc11_valid_type_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(m68hc11_attribute_table, m68hc11_handle_fntype_attribute): New.
* config/mcore/mcore.c (mcore_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(mcore_attribute_table, mcore_handle_naked_attribute): New.
* config/ns32k/ns32k.c (ns32k_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ns32k_attribute_table, ns32k_handle_fntype_attribute): New.
* config/rs6000/rs6000.c (rs6000_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(rs6000_attribute_table, rs6000_handle_longcall_attribute): New.
* config/sh/sh.c (sh_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(sh_attribute_table, sh_handle_interrupt_handler_attribute,
sh_handle_sp_switch_attribute, sh_handle_trap_exit_attribute):
New.
* config/stormy16/stormy16.c (stormy16_valid_type_attribute):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define
(TARGET_ATTRIBUTE_TABLE): Define.
(stormy16_attribute_table, stormy16_handle_interrupt_attribute):
New.
* config/v850/v850.c (v850_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(v850_attribute_table, v850_handle_interrupt_attribute,
v850_handle_data_area_attribute): New.
* config/v850/v850-c.c (mark_current_function_as_interrupt):
Return void. Call decl_attributes instead of
valid_machine_attribute.
cp:
Table-driven attributes.
* decl.c: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* decl2.c (cplus_decl_attributes): Only take one attributes
parameter.
* cp-tree.c (cplus_decl_attributes): Update prototype.
* class.c (finish_struct), decl.c (start_decl, start_function),
decl2.c (grokfield), friend.c (do_friend), parse.y
(parse_bitfield): Update calls to cplus_decl_attributes.
* decl.c (grokdeclarator): Take a pointer to a single ordinary
attribute list.
* decl.h (grokdeclarator): Update prototype.
* decl2.c (grokfield): Take a single ordinary attribute list.
* friend.c (do_friend): Likewise.
* decl.c (shadow_tag, groktypename, start_decl,
start_handler_parms, grokdeclarator, grokparms, start_function,
start_method), decl2.c (grokfield, grokbitfield, grokoptypename),
parse.y (parse_field, parse_bitfield, component_decl_1), pt.c
(process_template_parm, do_decl_instantiation): Pass single
ordinary attribute lists around.
* decl.c (grokdeclarator): Correct handling of nested attributes.
Revert the patch
1998-10-18 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (grokdeclarator): Embedded attrs bind to the right,
not the left.
.
* cp-tree.h (cp_valid_lang_attribute): Remove declaration
(cp_attribute_table): Declare.
* decl.c (valid_lang_attribute): Don't define.
(lang_attribute_table): Define.
(init_decl_processing): Initialize lang_attribute_table instead of
valid_lang_attribute.
* tree.c (cp_valid_lang_attribute): Remove.
(handle_java_interface_attribute, handle_com_interface_attribute,
handle_init_priority_attribute): New functions.
(cp_attribute_table): New array.
* decl2.c (import_export_class): Don't use
targetm.valid_type_attribute.
testsuite:
Table-driven attributes.
* g++.dg/ext/attrib1.C: New test.
From-SVN: r45718
2001-09-21 03:27:06 +02:00
|
|
|
|
case TREE_LIST:
|
|
|
|
|
decl = TREE_VALUE (decl);
|
|
|
|
|
break;
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
case IDENTIFIER_NODE:
|
|
|
|
|
name = IDENTIFIER_POINTER (decl);
|
|
|
|
|
decl = 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
abort ();
|
|
|
|
|
}
|
|
|
|
|
if (name == 0)
|
|
|
|
|
name = "type name";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* A function definition's declarator must have the form of
|
|
|
|
|
a function declarator. */
|
|
|
|
|
|
|
|
|
|
if (funcdef_flag && innermost_code != CALL_EXPR)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
/* If this looks like a function definition, make it one,
|
|
|
|
|
even if it occurs where parms are expected.
|
|
|
|
|
Then store_parm_decls will reject it and not use it as a parm. */
|
|
|
|
|
if (decl_context == NORMAL && !funcdef_flag
|
2003-07-24 18:59:32 +02:00
|
|
|
|
&& current_scope->parm_flag)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
decl_context = PARM;
|
|
|
|
|
|
|
|
|
|
/* Look through the decl specs and record which ones appear.
|
|
|
|
|
Some typespecs are defined as built-in typenames.
|
|
|
|
|
Others, the ones that are modifiers of other types,
|
|
|
|
|
are represented by bits in SPECBITS: set the bits for
|
|
|
|
|
the modifiers that appear. Storage class keywords are also in SPECBITS.
|
|
|
|
|
|
|
|
|
|
If there is a typedef name or a type, store the type in TYPE.
|
|
|
|
|
This includes builtin typedefs such as `int'.
|
|
|
|
|
|
|
|
|
|
Set EXPLICIT_INT or EXPLICIT_CHAR if the type is `int' or `char'
|
|
|
|
|
and did not come from a user typedef.
|
|
|
|
|
|
|
|
|
|
Set LONGLONG if `long' is mentioned twice. */
|
|
|
|
|
|
|
|
|
|
for (spec = declspecs; spec; spec = TREE_CHAIN (spec))
|
|
|
|
|
{
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree id = TREE_VALUE (spec);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2002-01-10 19:51:24 +01:00
|
|
|
|
/* If the entire declaration is itself tagged as deprecated then
|
|
|
|
|
suppress reports of deprecated items. */
|
|
|
|
|
if (id && TREE_DEPRECATED (id))
|
|
|
|
|
{
|
|
|
|
|
if (deprecated_state != DEPRECATED_SUPPRESS)
|
|
|
|
|
warn_deprecated_use (id);
|
|
|
|
|
}
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (id == ridpointers[(int) RID_INT])
|
|
|
|
|
explicit_int = 1;
|
|
|
|
|
if (id == ridpointers[(int) RID_CHAR])
|
|
|
|
|
explicit_char = 1;
|
|
|
|
|
|
Integrated preprocessor.
top level:
* Makefile.in: Remove all references to c-parse.gperf,
c-gperf.h, and c-parse.h. Remove -d from yacc command line
generating c-parse.c. Update dependencies.
* c-parse.gperf, c-gperf.h: Delete.
* c-common.c: Don't define parse_options, cpp_token, yy_cur,
yy_lim, or yy_get_token. Don't define get_directive_line if
USE_CPPLIB.
* c-common.h: Add multiple include guard. Define RID values
for every keyword in C, C++, and Objective C. Put all the
modifiers first.
(struct c_fileinfo, get_fileinfo, dump_time_statistics): New.
* c-decl.c (c_decode_option): Handle -lang-objc here.
(print_lang_identifier): Handle C_IS_RESERVED_WORD case.
(grokdeclarator): Adjust for new RID scheme.
(extract_interface_info): New stub.
* c-lang.c: Don't declare yy_cur or parse_options.
(lang_init_options): Call cpp_init. Don't call
cpp_options_init.
(lang_init): Don't call check_newline if USE_CPPLIB.
* c-lex.c: Don't include c-parse.h. Do include timevar.h.
Elide lots of unnecessary code if USE_CPPLIB. Delete code
rendered unnecessary by new architecture. Move routines not
shared with C++ to c-parse.in. Maintain a local idea of the
line number. Handle C++ as well as C.
[USE_CPPLIB]: Declare and register callbacks for #ident and
for entering/leaving files.
(init_c_lex, c_lex): Are now the entry points to this file.
(check_newline): Break out directive handling to
process_directive.
(read_ucs, is_extended_char, utf8_extend_token): Moved here
from C++ front end.
(readescape, parse_float): Overhaul.
(lex_number, lex_string, lex_charconst): Break out of c_lex
(n'ee yylex).
(get_fileinfo, update_header_times, dump_one_header,
dump_time_statistics): New and/or moved here from C++.
Support per-file data needed by C++ and per-header timing
statistics (C++ only, at the moment).
* c-lex.h: Update prototypes. Add multiple include guard.
* c-tree.h (struct lang_identifier): Add rid_code field.
(C_IS_RESERVED_WORD, C_RID_CODE): New.
* c-parse.in: Include c-pragma.h. Remove unnecesary calls to
reinit_parse_for_function and/or position_after_white_space.
(save_filename, save_lineno): Look ahead before saving.
(label -> identifier ':'): Save file and line before shifting ':'.
(reservedwords): No need to call get_identifier.
(init_parse, finish_parse, yyerror, yylex, yyprint,
make_pointer_declarator): Are now here for C/ObjC.
(rid_to_yy): Conversion table from RID constants to Yacc codes.
* c-pragma.c: Rewrite parsing logic to fit with cpplib's
#pragma registry. Provide dummy implementation of that
interface if !USE_CPPLIB.
* c-pragma.h: Update to match.
* flags.h: Add multiple include guard.
(flag_detailed_statistics): Moved here from C++.
* toplev.c: Define flag_detailed_statistics.
* gcc.c (C specs): Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* timevar.def (TV_CPP, TV_LEX): New.
* timevar.h: Add multiple include guard.
* objc/lang-specs.h: Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* objc/objc-act.c: Don't mention yy_cur or parse_options.
Initialize cpplib properly. Force lineno to 0 after first
call to check_newline. Don't handle -lang-objc here.
Move forget_protocol_qualifiers and remember_protocol_qualifiers here.
cp:
* Make-lang.in, Makefile.in: Remove all references to input.c,
gxx.gperf, and hash.h. Add ../c-lex.o to C_OBJS.
* gxx.gperf, hash.h, input.c: Delete.
* lang-specs.h: Pass -lang-c++ to cc1plus so cpplib is
initialized properly.
* class.c (fixup_pending_inline): Take a tree, not a
struct pending_inline *. All callers changed.
(init_class_processing): Set RID_PUBLIC, RID_PRIVATE,
RID_PROTECTED entries in ridpointers[] array here.
* decl.c (duplicate_decls): Do not refer to struct
pending_inline.
(record_builtin_type, init_decl_processing): Use RID_MAX not
CP_RID_MAX.
(grokdeclarator): Use C_IS_RESERVED_WORD.
* decl2.c (lang_decode_option): Ignore -lang-c++ for sake of
cpplib.
(grok_x_components): Do not inspect pending_inlines chain.
* cp-tree.h (struct lang_identifier): Add rid_code entry.
(C_IS_RESERVED_WORD, C_RID_CODE, C_RID_YYCODE): New.
(flag_no_gnu_keywords, flag_operator_names, rid_to_yy): Declare.
(DEFARG_LENGTH, struct pending_inline, TIME_IDENTIFIER_TIME,
TIME_IDENTIFIER_FILEINFO): Kill.
Update prototypes.
* lex.h: Expunge cp_rid. Rewrite RIDBIT macros to use just a
single 32-bit word.
* parse.y: Call do_pending_inlines unconditionally.
reinit_parse_for_method is now snarf_method. fn.defpen is no
longer necessary. Remove unnecessary <itype> annotation on
SCOPE. Do not refer to end_of_file or struct pending_inline.
* semantics.c (begin_inline_definitions): Call
do_pending_inlines unconditionally.
* lex.c: Remove all code now shared with C front end.
Initialize cpplib properly if USE_CPPLIB. Put reserved words
into the get_identifier table. Rewrite pragma handling to
work with the registry. Move code to save tokens for later
processing to spew.c.
* spew.c: Rewrite everything in terms of token streams instead
of text. Move routines here from lex.c / input.c as
appropriate. GC-mark trees hanging off the pending inlines
chain.
testsuite:
* g++.old-deja/g++.benjamin/13478.C: Put meaningful tags on
ERROR markers.
* g++.old-deja/g++.brendan/crash8.C: Move ERROR marker up one line.
* gcc.dg/c99-array-nonobj-1.c: Don't expect func[] cases to fail.
* gcc.dg/wtr-label-1.c: Don't use unconstrained .* in error regexps.
* gcc.dg/wtr-suffix-1.c: Correct error regexps.
* gcc.dg/cpp/unc1.c, gcc.dg/cpp/unc2.c, gcc.dg/cpp/unc3.c:
Preprocess only.
* gcc.dg/cpp/unc4.c: Adjust line number in dg-error line.
* gcc.dg/noncompile/const-ll-1.c: Generalize error regexp.
From-SVN: r36216
2000-09-07 02:37:14 +02:00
|
|
|
|
if (TREE_CODE (id) == IDENTIFIER_NODE && C_IS_RESERVED_WORD (id))
|
|
|
|
|
{
|
|
|
|
|
enum rid i = C_RID_CODE (id);
|
2001-03-02 22:41:37 +01:00
|
|
|
|
if ((int) i <= (int) RID_LAST_MODIFIER)
|
Integrated preprocessor.
top level:
* Makefile.in: Remove all references to c-parse.gperf,
c-gperf.h, and c-parse.h. Remove -d from yacc command line
generating c-parse.c. Update dependencies.
* c-parse.gperf, c-gperf.h: Delete.
* c-common.c: Don't define parse_options, cpp_token, yy_cur,
yy_lim, or yy_get_token. Don't define get_directive_line if
USE_CPPLIB.
* c-common.h: Add multiple include guard. Define RID values
for every keyword in C, C++, and Objective C. Put all the
modifiers first.
(struct c_fileinfo, get_fileinfo, dump_time_statistics): New.
* c-decl.c (c_decode_option): Handle -lang-objc here.
(print_lang_identifier): Handle C_IS_RESERVED_WORD case.
(grokdeclarator): Adjust for new RID scheme.
(extract_interface_info): New stub.
* c-lang.c: Don't declare yy_cur or parse_options.
(lang_init_options): Call cpp_init. Don't call
cpp_options_init.
(lang_init): Don't call check_newline if USE_CPPLIB.
* c-lex.c: Don't include c-parse.h. Do include timevar.h.
Elide lots of unnecessary code if USE_CPPLIB. Delete code
rendered unnecessary by new architecture. Move routines not
shared with C++ to c-parse.in. Maintain a local idea of the
line number. Handle C++ as well as C.
[USE_CPPLIB]: Declare and register callbacks for #ident and
for entering/leaving files.
(init_c_lex, c_lex): Are now the entry points to this file.
(check_newline): Break out directive handling to
process_directive.
(read_ucs, is_extended_char, utf8_extend_token): Moved here
from C++ front end.
(readescape, parse_float): Overhaul.
(lex_number, lex_string, lex_charconst): Break out of c_lex
(n'ee yylex).
(get_fileinfo, update_header_times, dump_one_header,
dump_time_statistics): New and/or moved here from C++.
Support per-file data needed by C++ and per-header timing
statistics (C++ only, at the moment).
* c-lex.h: Update prototypes. Add multiple include guard.
* c-tree.h (struct lang_identifier): Add rid_code field.
(C_IS_RESERVED_WORD, C_RID_CODE): New.
* c-parse.in: Include c-pragma.h. Remove unnecesary calls to
reinit_parse_for_function and/or position_after_white_space.
(save_filename, save_lineno): Look ahead before saving.
(label -> identifier ':'): Save file and line before shifting ':'.
(reservedwords): No need to call get_identifier.
(init_parse, finish_parse, yyerror, yylex, yyprint,
make_pointer_declarator): Are now here for C/ObjC.
(rid_to_yy): Conversion table from RID constants to Yacc codes.
* c-pragma.c: Rewrite parsing logic to fit with cpplib's
#pragma registry. Provide dummy implementation of that
interface if !USE_CPPLIB.
* c-pragma.h: Update to match.
* flags.h: Add multiple include guard.
(flag_detailed_statistics): Moved here from C++.
* toplev.c: Define flag_detailed_statistics.
* gcc.c (C specs): Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* timevar.def (TV_CPP, TV_LEX): New.
* timevar.h: Add multiple include guard.
* objc/lang-specs.h: Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* objc/objc-act.c: Don't mention yy_cur or parse_options.
Initialize cpplib properly. Force lineno to 0 after first
call to check_newline. Don't handle -lang-objc here.
Move forget_protocol_qualifiers and remember_protocol_qualifiers here.
cp:
* Make-lang.in, Makefile.in: Remove all references to input.c,
gxx.gperf, and hash.h. Add ../c-lex.o to C_OBJS.
* gxx.gperf, hash.h, input.c: Delete.
* lang-specs.h: Pass -lang-c++ to cc1plus so cpplib is
initialized properly.
* class.c (fixup_pending_inline): Take a tree, not a
struct pending_inline *. All callers changed.
(init_class_processing): Set RID_PUBLIC, RID_PRIVATE,
RID_PROTECTED entries in ridpointers[] array here.
* decl.c (duplicate_decls): Do not refer to struct
pending_inline.
(record_builtin_type, init_decl_processing): Use RID_MAX not
CP_RID_MAX.
(grokdeclarator): Use C_IS_RESERVED_WORD.
* decl2.c (lang_decode_option): Ignore -lang-c++ for sake of
cpplib.
(grok_x_components): Do not inspect pending_inlines chain.
* cp-tree.h (struct lang_identifier): Add rid_code entry.
(C_IS_RESERVED_WORD, C_RID_CODE, C_RID_YYCODE): New.
(flag_no_gnu_keywords, flag_operator_names, rid_to_yy): Declare.
(DEFARG_LENGTH, struct pending_inline, TIME_IDENTIFIER_TIME,
TIME_IDENTIFIER_FILEINFO): Kill.
Update prototypes.
* lex.h: Expunge cp_rid. Rewrite RIDBIT macros to use just a
single 32-bit word.
* parse.y: Call do_pending_inlines unconditionally.
reinit_parse_for_method is now snarf_method. fn.defpen is no
longer necessary. Remove unnecessary <itype> annotation on
SCOPE. Do not refer to end_of_file or struct pending_inline.
* semantics.c (begin_inline_definitions): Call
do_pending_inlines unconditionally.
* lex.c: Remove all code now shared with C front end.
Initialize cpplib properly if USE_CPPLIB. Put reserved words
into the get_identifier table. Rewrite pragma handling to
work with the registry. Move code to save tokens for later
processing to spew.c.
* spew.c: Rewrite everything in terms of token streams instead
of text. Move routines here from lex.c / input.c as
appropriate. GC-mark trees hanging off the pending inlines
chain.
testsuite:
* g++.old-deja/g++.benjamin/13478.C: Put meaningful tags on
ERROR markers.
* g++.old-deja/g++.brendan/crash8.C: Move ERROR marker up one line.
* gcc.dg/c99-array-nonobj-1.c: Don't expect func[] cases to fail.
* gcc.dg/wtr-label-1.c: Don't use unconstrained .* in error regexps.
* gcc.dg/wtr-suffix-1.c: Correct error regexps.
* gcc.dg/cpp/unc1.c, gcc.dg/cpp/unc2.c, gcc.dg/cpp/unc3.c:
Preprocess only.
* gcc.dg/cpp/unc4.c: Adjust line number in dg-error line.
* gcc.dg/noncompile/const-ll-1.c: Generalize error regexp.
From-SVN: r36216
2000-09-07 02:37:14 +02:00
|
|
|
|
{
|
2002-05-22 03:11:29 +02:00
|
|
|
|
if (i == RID_LONG && (specbits & (1 << (int) RID_LONG)))
|
Integrated preprocessor.
top level:
* Makefile.in: Remove all references to c-parse.gperf,
c-gperf.h, and c-parse.h. Remove -d from yacc command line
generating c-parse.c. Update dependencies.
* c-parse.gperf, c-gperf.h: Delete.
* c-common.c: Don't define parse_options, cpp_token, yy_cur,
yy_lim, or yy_get_token. Don't define get_directive_line if
USE_CPPLIB.
* c-common.h: Add multiple include guard. Define RID values
for every keyword in C, C++, and Objective C. Put all the
modifiers first.
(struct c_fileinfo, get_fileinfo, dump_time_statistics): New.
* c-decl.c (c_decode_option): Handle -lang-objc here.
(print_lang_identifier): Handle C_IS_RESERVED_WORD case.
(grokdeclarator): Adjust for new RID scheme.
(extract_interface_info): New stub.
* c-lang.c: Don't declare yy_cur or parse_options.
(lang_init_options): Call cpp_init. Don't call
cpp_options_init.
(lang_init): Don't call check_newline if USE_CPPLIB.
* c-lex.c: Don't include c-parse.h. Do include timevar.h.
Elide lots of unnecessary code if USE_CPPLIB. Delete code
rendered unnecessary by new architecture. Move routines not
shared with C++ to c-parse.in. Maintain a local idea of the
line number. Handle C++ as well as C.
[USE_CPPLIB]: Declare and register callbacks for #ident and
for entering/leaving files.
(init_c_lex, c_lex): Are now the entry points to this file.
(check_newline): Break out directive handling to
process_directive.
(read_ucs, is_extended_char, utf8_extend_token): Moved here
from C++ front end.
(readescape, parse_float): Overhaul.
(lex_number, lex_string, lex_charconst): Break out of c_lex
(n'ee yylex).
(get_fileinfo, update_header_times, dump_one_header,
dump_time_statistics): New and/or moved here from C++.
Support per-file data needed by C++ and per-header timing
statistics (C++ only, at the moment).
* c-lex.h: Update prototypes. Add multiple include guard.
* c-tree.h (struct lang_identifier): Add rid_code field.
(C_IS_RESERVED_WORD, C_RID_CODE): New.
* c-parse.in: Include c-pragma.h. Remove unnecesary calls to
reinit_parse_for_function and/or position_after_white_space.
(save_filename, save_lineno): Look ahead before saving.
(label -> identifier ':'): Save file and line before shifting ':'.
(reservedwords): No need to call get_identifier.
(init_parse, finish_parse, yyerror, yylex, yyprint,
make_pointer_declarator): Are now here for C/ObjC.
(rid_to_yy): Conversion table from RID constants to Yacc codes.
* c-pragma.c: Rewrite parsing logic to fit with cpplib's
#pragma registry. Provide dummy implementation of that
interface if !USE_CPPLIB.
* c-pragma.h: Update to match.
* flags.h: Add multiple include guard.
(flag_detailed_statistics): Moved here from C++.
* toplev.c: Define flag_detailed_statistics.
* gcc.c (C specs): Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* timevar.def (TV_CPP, TV_LEX): New.
* timevar.h: Add multiple include guard.
* objc/lang-specs.h: Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* objc/objc-act.c: Don't mention yy_cur or parse_options.
Initialize cpplib properly. Force lineno to 0 after first
call to check_newline. Don't handle -lang-objc here.
Move forget_protocol_qualifiers and remember_protocol_qualifiers here.
cp:
* Make-lang.in, Makefile.in: Remove all references to input.c,
gxx.gperf, and hash.h. Add ../c-lex.o to C_OBJS.
* gxx.gperf, hash.h, input.c: Delete.
* lang-specs.h: Pass -lang-c++ to cc1plus so cpplib is
initialized properly.
* class.c (fixup_pending_inline): Take a tree, not a
struct pending_inline *. All callers changed.
(init_class_processing): Set RID_PUBLIC, RID_PRIVATE,
RID_PROTECTED entries in ridpointers[] array here.
* decl.c (duplicate_decls): Do not refer to struct
pending_inline.
(record_builtin_type, init_decl_processing): Use RID_MAX not
CP_RID_MAX.
(grokdeclarator): Use C_IS_RESERVED_WORD.
* decl2.c (lang_decode_option): Ignore -lang-c++ for sake of
cpplib.
(grok_x_components): Do not inspect pending_inlines chain.
* cp-tree.h (struct lang_identifier): Add rid_code entry.
(C_IS_RESERVED_WORD, C_RID_CODE, C_RID_YYCODE): New.
(flag_no_gnu_keywords, flag_operator_names, rid_to_yy): Declare.
(DEFARG_LENGTH, struct pending_inline, TIME_IDENTIFIER_TIME,
TIME_IDENTIFIER_FILEINFO): Kill.
Update prototypes.
* lex.h: Expunge cp_rid. Rewrite RIDBIT macros to use just a
single 32-bit word.
* parse.y: Call do_pending_inlines unconditionally.
reinit_parse_for_method is now snarf_method. fn.defpen is no
longer necessary. Remove unnecessary <itype> annotation on
SCOPE. Do not refer to end_of_file or struct pending_inline.
* semantics.c (begin_inline_definitions): Call
do_pending_inlines unconditionally.
* lex.c: Remove all code now shared with C front end.
Initialize cpplib properly if USE_CPPLIB. Put reserved words
into the get_identifier table. Rewrite pragma handling to
work with the registry. Move code to save tokens for later
processing to spew.c.
* spew.c: Rewrite everything in terms of token streams instead
of text. Move routines here from lex.c / input.c as
appropriate. GC-mark trees hanging off the pending inlines
chain.
testsuite:
* g++.old-deja/g++.benjamin/13478.C: Put meaningful tags on
ERROR markers.
* g++.old-deja/g++.brendan/crash8.C: Move ERROR marker up one line.
* gcc.dg/c99-array-nonobj-1.c: Don't expect func[] cases to fail.
* gcc.dg/wtr-label-1.c: Don't use unconstrained .* in error regexps.
* gcc.dg/wtr-suffix-1.c: Correct error regexps.
* gcc.dg/cpp/unc1.c, gcc.dg/cpp/unc2.c, gcc.dg/cpp/unc3.c:
Preprocess only.
* gcc.dg/cpp/unc4.c: Adjust line number in dg-error line.
* gcc.dg/noncompile/const-ll-1.c: Generalize error regexp.
From-SVN: r36216
2000-09-07 02:37:14 +02:00
|
|
|
|
{
|
|
|
|
|
if (longlong)
|
|
|
|
|
error ("`long long long' is too long for GCC");
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (pedantic && !flag_isoc99 && ! in_system_header
|
|
|
|
|
&& warn_long_long)
|
2002-07-21 23:35:17 +02:00
|
|
|
|
pedwarn ("ISO C90 does not support `long long'");
|
Integrated preprocessor.
top level:
* Makefile.in: Remove all references to c-parse.gperf,
c-gperf.h, and c-parse.h. Remove -d from yacc command line
generating c-parse.c. Update dependencies.
* c-parse.gperf, c-gperf.h: Delete.
* c-common.c: Don't define parse_options, cpp_token, yy_cur,
yy_lim, or yy_get_token. Don't define get_directive_line if
USE_CPPLIB.
* c-common.h: Add multiple include guard. Define RID values
for every keyword in C, C++, and Objective C. Put all the
modifiers first.
(struct c_fileinfo, get_fileinfo, dump_time_statistics): New.
* c-decl.c (c_decode_option): Handle -lang-objc here.
(print_lang_identifier): Handle C_IS_RESERVED_WORD case.
(grokdeclarator): Adjust for new RID scheme.
(extract_interface_info): New stub.
* c-lang.c: Don't declare yy_cur or parse_options.
(lang_init_options): Call cpp_init. Don't call
cpp_options_init.
(lang_init): Don't call check_newline if USE_CPPLIB.
* c-lex.c: Don't include c-parse.h. Do include timevar.h.
Elide lots of unnecessary code if USE_CPPLIB. Delete code
rendered unnecessary by new architecture. Move routines not
shared with C++ to c-parse.in. Maintain a local idea of the
line number. Handle C++ as well as C.
[USE_CPPLIB]: Declare and register callbacks for #ident and
for entering/leaving files.
(init_c_lex, c_lex): Are now the entry points to this file.
(check_newline): Break out directive handling to
process_directive.
(read_ucs, is_extended_char, utf8_extend_token): Moved here
from C++ front end.
(readescape, parse_float): Overhaul.
(lex_number, lex_string, lex_charconst): Break out of c_lex
(n'ee yylex).
(get_fileinfo, update_header_times, dump_one_header,
dump_time_statistics): New and/or moved here from C++.
Support per-file data needed by C++ and per-header timing
statistics (C++ only, at the moment).
* c-lex.h: Update prototypes. Add multiple include guard.
* c-tree.h (struct lang_identifier): Add rid_code field.
(C_IS_RESERVED_WORD, C_RID_CODE): New.
* c-parse.in: Include c-pragma.h. Remove unnecesary calls to
reinit_parse_for_function and/or position_after_white_space.
(save_filename, save_lineno): Look ahead before saving.
(label -> identifier ':'): Save file and line before shifting ':'.
(reservedwords): No need to call get_identifier.
(init_parse, finish_parse, yyerror, yylex, yyprint,
make_pointer_declarator): Are now here for C/ObjC.
(rid_to_yy): Conversion table from RID constants to Yacc codes.
* c-pragma.c: Rewrite parsing logic to fit with cpplib's
#pragma registry. Provide dummy implementation of that
interface if !USE_CPPLIB.
* c-pragma.h: Update to match.
* flags.h: Add multiple include guard.
(flag_detailed_statistics): Moved here from C++.
* toplev.c: Define flag_detailed_statistics.
* gcc.c (C specs): Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* timevar.def (TV_CPP, TV_LEX): New.
* timevar.h: Add multiple include guard.
* objc/lang-specs.h: Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* objc/objc-act.c: Don't mention yy_cur or parse_options.
Initialize cpplib properly. Force lineno to 0 after first
call to check_newline. Don't handle -lang-objc here.
Move forget_protocol_qualifiers and remember_protocol_qualifiers here.
cp:
* Make-lang.in, Makefile.in: Remove all references to input.c,
gxx.gperf, and hash.h. Add ../c-lex.o to C_OBJS.
* gxx.gperf, hash.h, input.c: Delete.
* lang-specs.h: Pass -lang-c++ to cc1plus so cpplib is
initialized properly.
* class.c (fixup_pending_inline): Take a tree, not a
struct pending_inline *. All callers changed.
(init_class_processing): Set RID_PUBLIC, RID_PRIVATE,
RID_PROTECTED entries in ridpointers[] array here.
* decl.c (duplicate_decls): Do not refer to struct
pending_inline.
(record_builtin_type, init_decl_processing): Use RID_MAX not
CP_RID_MAX.
(grokdeclarator): Use C_IS_RESERVED_WORD.
* decl2.c (lang_decode_option): Ignore -lang-c++ for sake of
cpplib.
(grok_x_components): Do not inspect pending_inlines chain.
* cp-tree.h (struct lang_identifier): Add rid_code entry.
(C_IS_RESERVED_WORD, C_RID_CODE, C_RID_YYCODE): New.
(flag_no_gnu_keywords, flag_operator_names, rid_to_yy): Declare.
(DEFARG_LENGTH, struct pending_inline, TIME_IDENTIFIER_TIME,
TIME_IDENTIFIER_FILEINFO): Kill.
Update prototypes.
* lex.h: Expunge cp_rid. Rewrite RIDBIT macros to use just a
single 32-bit word.
* parse.y: Call do_pending_inlines unconditionally.
reinit_parse_for_method is now snarf_method. fn.defpen is no
longer necessary. Remove unnecessary <itype> annotation on
SCOPE. Do not refer to end_of_file or struct pending_inline.
* semantics.c (begin_inline_definitions): Call
do_pending_inlines unconditionally.
* lex.c: Remove all code now shared with C front end.
Initialize cpplib properly if USE_CPPLIB. Put reserved words
into the get_identifier table. Rewrite pragma handling to
work with the registry. Move code to save tokens for later
processing to spew.c.
* spew.c: Rewrite everything in terms of token streams instead
of text. Move routines here from lex.c / input.c as
appropriate. GC-mark trees hanging off the pending inlines
chain.
testsuite:
* g++.old-deja/g++.benjamin/13478.C: Put meaningful tags on
ERROR markers.
* g++.old-deja/g++.brendan/crash8.C: Move ERROR marker up one line.
* gcc.dg/c99-array-nonobj-1.c: Don't expect func[] cases to fail.
* gcc.dg/wtr-label-1.c: Don't use unconstrained .* in error regexps.
* gcc.dg/wtr-suffix-1.c: Correct error regexps.
* gcc.dg/cpp/unc1.c, gcc.dg/cpp/unc2.c, gcc.dg/cpp/unc3.c:
Preprocess only.
* gcc.dg/cpp/unc4.c: Adjust line number in dg-error line.
* gcc.dg/noncompile/const-ll-1.c: Generalize error regexp.
From-SVN: r36216
2000-09-07 02:37:14 +02:00
|
|
|
|
longlong = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-03-02 22:41:37 +01:00
|
|
|
|
else if (specbits & (1 << (int) i))
|
2002-11-10 17:24:26 +01:00
|
|
|
|
{
|
|
|
|
|
if (i == RID_CONST || i == RID_VOLATILE || i == RID_RESTRICT)
|
|
|
|
|
{
|
|
|
|
|
if (!flag_isoc99)
|
|
|
|
|
pedwarn ("duplicate `%s'", IDENTIFIER_POINTER (id));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
error ("duplicate `%s'", IDENTIFIER_POINTER (id));
|
|
|
|
|
}
|
2002-05-22 03:11:29 +02:00
|
|
|
|
|
|
|
|
|
/* Diagnose "__thread extern". Recall that this list
|
|
|
|
|
is in the reverse order seen in the text. */
|
|
|
|
|
if (i == RID_THREAD
|
|
|
|
|
&& (specbits & (1 << (int) RID_EXTERN
|
|
|
|
|
| 1 << (int) RID_STATIC)))
|
|
|
|
|
{
|
|
|
|
|
if (specbits & 1 << (int) RID_EXTERN)
|
|
|
|
|
error ("`__thread' before `extern'");
|
|
|
|
|
else
|
|
|
|
|
error ("`__thread' before `static'");
|
|
|
|
|
}
|
|
|
|
|
|
2001-03-02 22:41:37 +01:00
|
|
|
|
specbits |= 1 << (int) i;
|
Integrated preprocessor.
top level:
* Makefile.in: Remove all references to c-parse.gperf,
c-gperf.h, and c-parse.h. Remove -d from yacc command line
generating c-parse.c. Update dependencies.
* c-parse.gperf, c-gperf.h: Delete.
* c-common.c: Don't define parse_options, cpp_token, yy_cur,
yy_lim, or yy_get_token. Don't define get_directive_line if
USE_CPPLIB.
* c-common.h: Add multiple include guard. Define RID values
for every keyword in C, C++, and Objective C. Put all the
modifiers first.
(struct c_fileinfo, get_fileinfo, dump_time_statistics): New.
* c-decl.c (c_decode_option): Handle -lang-objc here.
(print_lang_identifier): Handle C_IS_RESERVED_WORD case.
(grokdeclarator): Adjust for new RID scheme.
(extract_interface_info): New stub.
* c-lang.c: Don't declare yy_cur or parse_options.
(lang_init_options): Call cpp_init. Don't call
cpp_options_init.
(lang_init): Don't call check_newline if USE_CPPLIB.
* c-lex.c: Don't include c-parse.h. Do include timevar.h.
Elide lots of unnecessary code if USE_CPPLIB. Delete code
rendered unnecessary by new architecture. Move routines not
shared with C++ to c-parse.in. Maintain a local idea of the
line number. Handle C++ as well as C.
[USE_CPPLIB]: Declare and register callbacks for #ident and
for entering/leaving files.
(init_c_lex, c_lex): Are now the entry points to this file.
(check_newline): Break out directive handling to
process_directive.
(read_ucs, is_extended_char, utf8_extend_token): Moved here
from C++ front end.
(readescape, parse_float): Overhaul.
(lex_number, lex_string, lex_charconst): Break out of c_lex
(n'ee yylex).
(get_fileinfo, update_header_times, dump_one_header,
dump_time_statistics): New and/or moved here from C++.
Support per-file data needed by C++ and per-header timing
statistics (C++ only, at the moment).
* c-lex.h: Update prototypes. Add multiple include guard.
* c-tree.h (struct lang_identifier): Add rid_code field.
(C_IS_RESERVED_WORD, C_RID_CODE): New.
* c-parse.in: Include c-pragma.h. Remove unnecesary calls to
reinit_parse_for_function and/or position_after_white_space.
(save_filename, save_lineno): Look ahead before saving.
(label -> identifier ':'): Save file and line before shifting ':'.
(reservedwords): No need to call get_identifier.
(init_parse, finish_parse, yyerror, yylex, yyprint,
make_pointer_declarator): Are now here for C/ObjC.
(rid_to_yy): Conversion table from RID constants to Yacc codes.
* c-pragma.c: Rewrite parsing logic to fit with cpplib's
#pragma registry. Provide dummy implementation of that
interface if !USE_CPPLIB.
* c-pragma.h: Update to match.
* flags.h: Add multiple include guard.
(flag_detailed_statistics): Moved here from C++.
* toplev.c: Define flag_detailed_statistics.
* gcc.c (C specs): Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* timevar.def (TV_CPP, TV_LEX): New.
* timevar.h: Add multiple include guard.
* objc/lang-specs.h: Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* objc/objc-act.c: Don't mention yy_cur or parse_options.
Initialize cpplib properly. Force lineno to 0 after first
call to check_newline. Don't handle -lang-objc here.
Move forget_protocol_qualifiers and remember_protocol_qualifiers here.
cp:
* Make-lang.in, Makefile.in: Remove all references to input.c,
gxx.gperf, and hash.h. Add ../c-lex.o to C_OBJS.
* gxx.gperf, hash.h, input.c: Delete.
* lang-specs.h: Pass -lang-c++ to cc1plus so cpplib is
initialized properly.
* class.c (fixup_pending_inline): Take a tree, not a
struct pending_inline *. All callers changed.
(init_class_processing): Set RID_PUBLIC, RID_PRIVATE,
RID_PROTECTED entries in ridpointers[] array here.
* decl.c (duplicate_decls): Do not refer to struct
pending_inline.
(record_builtin_type, init_decl_processing): Use RID_MAX not
CP_RID_MAX.
(grokdeclarator): Use C_IS_RESERVED_WORD.
* decl2.c (lang_decode_option): Ignore -lang-c++ for sake of
cpplib.
(grok_x_components): Do not inspect pending_inlines chain.
* cp-tree.h (struct lang_identifier): Add rid_code entry.
(C_IS_RESERVED_WORD, C_RID_CODE, C_RID_YYCODE): New.
(flag_no_gnu_keywords, flag_operator_names, rid_to_yy): Declare.
(DEFARG_LENGTH, struct pending_inline, TIME_IDENTIFIER_TIME,
TIME_IDENTIFIER_FILEINFO): Kill.
Update prototypes.
* lex.h: Expunge cp_rid. Rewrite RIDBIT macros to use just a
single 32-bit word.
* parse.y: Call do_pending_inlines unconditionally.
reinit_parse_for_method is now snarf_method. fn.defpen is no
longer necessary. Remove unnecessary <itype> annotation on
SCOPE. Do not refer to end_of_file or struct pending_inline.
* semantics.c (begin_inline_definitions): Call
do_pending_inlines unconditionally.
* lex.c: Remove all code now shared with C front end.
Initialize cpplib properly if USE_CPPLIB. Put reserved words
into the get_identifier table. Rewrite pragma handling to
work with the registry. Move code to save tokens for later
processing to spew.c.
* spew.c: Rewrite everything in terms of token streams instead
of text. Move routines here from lex.c / input.c as
appropriate. GC-mark trees hanging off the pending inlines
chain.
testsuite:
* g++.old-deja/g++.benjamin/13478.C: Put meaningful tags on
ERROR markers.
* g++.old-deja/g++.brendan/crash8.C: Move ERROR marker up one line.
* gcc.dg/c99-array-nonobj-1.c: Don't expect func[] cases to fail.
* gcc.dg/wtr-label-1.c: Don't use unconstrained .* in error regexps.
* gcc.dg/wtr-suffix-1.c: Correct error regexps.
* gcc.dg/cpp/unc1.c, gcc.dg/cpp/unc2.c, gcc.dg/cpp/unc3.c:
Preprocess only.
* gcc.dg/cpp/unc4.c: Adjust line number in dg-error line.
* gcc.dg/noncompile/const-ll-1.c: Generalize error regexp.
From-SVN: r36216
2000-09-07 02:37:14 +02:00
|
|
|
|
goto found;
|
|
|
|
|
}
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (type)
|
|
|
|
|
error ("two or more data types in declaration of `%s'", name);
|
|
|
|
|
/* Actual typedefs come to us as TYPE_DECL nodes. */
|
|
|
|
|
else if (TREE_CODE (id) == TYPE_DECL)
|
|
|
|
|
{
|
2002-01-31 02:01:02 +01:00
|
|
|
|
if (TREE_TYPE (id) == error_mark_node)
|
|
|
|
|
; /* Allow the type to default to int to avoid cascading errors. */
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
type = TREE_TYPE (id);
|
|
|
|
|
decl_attr = DECL_ATTRIBUTES (id);
|
|
|
|
|
typedef_decl = id;
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
/* Built-in types come as identifiers. */
|
|
|
|
|
else if (TREE_CODE (id) == IDENTIFIER_NODE)
|
|
|
|
|
{
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree t = lookup_name (id);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (TREE_TYPE (t) == error_mark_node)
|
|
|
|
|
;
|
|
|
|
|
else if (!t || TREE_CODE (t) != TYPE_DECL)
|
|
|
|
|
error ("`%s' fails to be a typedef or built in type",
|
|
|
|
|
IDENTIFIER_POINTER (id));
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
type = TREE_TYPE (t);
|
|
|
|
|
typedef_decl = t;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (TREE_CODE (id) != ERROR_MARK)
|
|
|
|
|
type = id;
|
|
|
|
|
|
2000-08-11 00:01:22 +02:00
|
|
|
|
found:
|
|
|
|
|
;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typedef_type = type;
|
|
|
|
|
if (type)
|
1992-03-23 03:07:53 +01:00
|
|
|
|
size_varies = C_TYPE_VARIABLE_SIZE (type);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
1993-03-04 20:42:57 +01:00
|
|
|
|
/* No type at all: default to `int', and set DEFAULTED_INT
|
1992-02-13 23:21:26 +01:00
|
|
|
|
because it was not a user-defined typedef. */
|
|
|
|
|
|
|
|
|
|
if (type == 0)
|
|
|
|
|
{
|
1998-05-06 01:18:02 +02:00
|
|
|
|
if ((! (specbits & ((1 << (int) RID_LONG) | (1 << (int) RID_SHORT)
|
|
|
|
|
| (1 << (int) RID_SIGNED)
|
2000-09-17 21:39:56 +02:00
|
|
|
|
| (1 << (int) RID_UNSIGNED)
|
|
|
|
|
| (1 << (int) RID_COMPLEX))))
|
1998-07-01 04:00:35 +02:00
|
|
|
|
/* Don't warn about typedef foo = bar. */
|
|
|
|
|
&& ! (specbits & (1 << (int) RID_TYPEDEF) && initialized)
|
c-common.c, [...]: Remove all references to obstack functions obsoleted by GC...
* c-common.c, c-decl.c, c-lang.c, c-lex.c, c-parse.in, c-pragma.c,
c-typeck.c, objc/objc-act.c: Remove all references to obstack
functions obsoleted by GC, such as push_obstacks_nochange,
end_temporary_allocation, savealloc, saveable_tree_cons, etc.
and code which existed only to decide whether or not to call
them. Remove now-unused NESTED argument from start_function;
all callers changed. Do not change behavior based on ggc_p.
The use of the ixp_obstack in c-iterate.c and the util_obstack
in objc/objc-act.c remain; these are not obsoleted by garbage
collection.
* c-tree.h: Update prototype for start_function.
* c-parse.y, c-parse.c, objc/objc-parse.c, objc/objc-parse.y: Rebuild.
From-SVN: r31611
2000-01-25 18:13:14 +01:00
|
|
|
|
&& ! in_system_header)
|
1996-11-12 20:17:33 +01:00
|
|
|
|
{
|
2000-01-29 20:00:43 +01:00
|
|
|
|
/* Issue a warning if this is an ISO C 99 program or if -Wreturn-type
|
1998-12-01 22:05:17 +01:00
|
|
|
|
and this is a function, or if -Wimplicit; prefer the former
|
|
|
|
|
warning since it is more explicit. */
|
2001-02-12 18:31:42 +01:00
|
|
|
|
if ((warn_implicit_int || warn_return_type || flag_isoc99)
|
|
|
|
|
&& funcdef_flag)
|
1996-11-12 20:17:33 +01:00
|
|
|
|
warn_about_return_type = 1;
|
2000-01-29 20:00:43 +01:00
|
|
|
|
else if (warn_implicit_int || flag_isoc99)
|
2000-08-11 00:01:22 +02:00
|
|
|
|
pedwarn_c99 ("type defaults to `int' in declaration of `%s'",
|
|
|
|
|
name);
|
1996-11-12 20:17:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
1993-03-04 20:42:57 +01:00
|
|
|
|
defaulted_int = 1;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
type = integer_type_node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Now process the modifiers that were specified
|
|
|
|
|
and check for invalid combinations. */
|
|
|
|
|
|
|
|
|
|
/* Long double is a special combination. */
|
|
|
|
|
|
1997-08-11 17:56:58 +02:00
|
|
|
|
if ((specbits & 1 << (int) RID_LONG) && ! longlong
|
1992-07-15 20:34:18 +02:00
|
|
|
|
&& TYPE_MAIN_VARIANT (type) == double_type_node)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2000-08-11 00:01:22 +02:00
|
|
|
|
specbits &= ~(1 << (int) RID_LONG);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
type = long_double_type_node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check all other uses of type modifiers. */
|
|
|
|
|
|
|
|
|
|
if (specbits & ((1 << (int) RID_LONG) | (1 << (int) RID_SHORT)
|
|
|
|
|
| (1 << (int) RID_UNSIGNED) | (1 << (int) RID_SIGNED)))
|
|
|
|
|
{
|
|
|
|
|
int ok = 0;
|
|
|
|
|
|
1997-08-11 17:56:58 +02:00
|
|
|
|
if ((specbits & 1 << (int) RID_LONG)
|
|
|
|
|
&& (specbits & 1 << (int) RID_SHORT))
|
|
|
|
|
error ("both long and short specified for `%s'", name);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
else if (((specbits & 1 << (int) RID_LONG)
|
|
|
|
|
|| (specbits & 1 << (int) RID_SHORT))
|
|
|
|
|
&& explicit_char)
|
|
|
|
|
error ("long or short specified with char for `%s'", name);
|
|
|
|
|
else if (((specbits & 1 << (int) RID_LONG)
|
|
|
|
|
|| (specbits & 1 << (int) RID_SHORT))
|
|
|
|
|
&& TREE_CODE (type) == REAL_TYPE)
|
1997-08-11 17:56:58 +02:00
|
|
|
|
{
|
|
|
|
|
static int already = 0;
|
|
|
|
|
|
|
|
|
|
error ("long or short specified with floating type for `%s'", name);
|
|
|
|
|
if (! already && ! pedantic)
|
|
|
|
|
{
|
|
|
|
|
error ("the only valid combination is `long double'");
|
|
|
|
|
already = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
else if ((specbits & 1 << (int) RID_SIGNED)
|
|
|
|
|
&& (specbits & 1 << (int) RID_UNSIGNED))
|
1997-08-11 17:56:58 +02:00
|
|
|
|
error ("both signed and unsigned specified for `%s'", name);
|
|
|
|
|
else if (TREE_CODE (type) != INTEGER_TYPE)
|
|
|
|
|
error ("long, short, signed or unsigned invalid for `%s'", name);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ok = 1;
|
2002-08-21 18:31:36 +02:00
|
|
|
|
if (!explicit_int && !defaulted_int && !explicit_char)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2002-08-21 18:31:36 +02:00
|
|
|
|
error ("long, short, signed or unsigned used invalidly for `%s'",
|
|
|
|
|
name);
|
|
|
|
|
ok = 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Discard the type modifiers if they are invalid. */
|
|
|
|
|
if (! ok)
|
|
|
|
|
{
|
|
|
|
|
specbits &= ~((1 << (int) RID_LONG) | (1 << (int) RID_SHORT)
|
|
|
|
|
| (1 << (int) RID_UNSIGNED) | (1 << (int) RID_SIGNED));
|
|
|
|
|
longlong = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1993-12-25 13:52:49 +01:00
|
|
|
|
if ((specbits & (1 << (int) RID_COMPLEX))
|
|
|
|
|
&& TREE_CODE (type) != INTEGER_TYPE && TREE_CODE (type) != REAL_TYPE)
|
|
|
|
|
{
|
|
|
|
|
error ("complex invalid for `%s'", name);
|
2000-08-11 00:01:22 +02:00
|
|
|
|
specbits &= ~(1 << (int) RID_COMPLEX);
|
1993-12-25 13:52:49 +01:00
|
|
|
|
}
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Decide whether an integer type is signed or not.
|
2002-02-02 01:14:41 +01:00
|
|
|
|
Optionally treat bitfields as signed by default. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (specbits & 1 << (int) RID_UNSIGNED
|
|
|
|
|
|| (bitfield && ! flag_signed_bitfields
|
1993-03-04 20:42:57 +01:00
|
|
|
|
&& (explicit_int || defaulted_int || explicit_char
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* A typedef for plain `int' without `signed'
|
|
|
|
|
can be controlled just like plain `int'. */
|
|
|
|
|
|| ! (typedef_decl != 0
|
|
|
|
|
&& C_TYPEDEF_EXPLICITLY_SIGNED (typedef_decl)))
|
|
|
|
|
&& TREE_CODE (type) != ENUMERAL_TYPE
|
|
|
|
|
&& !(specbits & 1 << (int) RID_SIGNED)))
|
|
|
|
|
{
|
|
|
|
|
if (longlong)
|
|
|
|
|
type = long_long_unsigned_type_node;
|
|
|
|
|
else if (specbits & 1 << (int) RID_LONG)
|
|
|
|
|
type = long_unsigned_type_node;
|
|
|
|
|
else if (specbits & 1 << (int) RID_SHORT)
|
|
|
|
|
type = short_unsigned_type_node;
|
|
|
|
|
else if (type == char_type_node)
|
|
|
|
|
type = unsigned_char_type_node;
|
|
|
|
|
else if (typedef_decl)
|
c-common.c (unsigned_conversion_warning, [...]): Use new hooks.
* c-common.c (unsigned_conversion_warning, convert_and_check,
unsigned_type, signed_type, shorten_compare,
c_common_get_alias_set, c_common_nodes_and_builtins): Use new hooks.
(unsigned_type, signed_type, signed_or_unsigned_type): Rename.
* c-common.h (unsigned_type, signed_type, signed_or_unsigned_type):
New.
* c-decl.c (grokdeclarator): Update.
* c-format.c (check_format_types): Update.
* c-lang.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
* c-typeck.c (build_binary_op, convert_for_assignment): Update.
* convert.c (convert_to_integer): Use new hooks.
* expmed.c (make_tree): Use new hooks.
* expr.c (store_expr): Use new hooks.
* fold-const.c (operand_equal_for_comparison_p, build_range_check,
all_ones_mask_p, unextend, fold): Use new hooks.
* langhooks.h (struct lang_hooks_for_types): New hooks.
* tree.h (signed_or_unsigned_type, signed_type,
unsigned_type): Remove.
ada:
* gigi.h (unsigned_type, signed_type, signed_or_unsigned_type):
Rename.
* misc.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
* trans.c (tree_transform, convert_with_check): Update.
* utils.c (unsigned_type, signed_type, signed_or_unsigned_type):
Rename.
cp:
* cp-lang.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
* decl.c (grokdeclarator): Update.
* mangle.c (write_integer_cst): Update.
* typeck.c (build_binary_op): Update.
f:
* com.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
(unsigned_type, signed_type, signed_or_unsigned_type): Rename.
java:
* expr.c (build_java_binop): Update.
* java-tree.h (java_signed_type, java_unsigned_type,
java_signed_or_unsigned_type): Update.
* lang.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
* parse.y (patch_binop): Update.
* typeck.c (signed_or_unsigned_type, unsigned_type,
signed_type): Update.
objc:
* objc-lang.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
From-SVN: r51684
2002-04-01 10:46:10 +02:00
|
|
|
|
type = c_common_unsigned_type (type);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
else
|
|
|
|
|
type = unsigned_type_node;
|
|
|
|
|
}
|
|
|
|
|
else if ((specbits & 1 << (int) RID_SIGNED)
|
|
|
|
|
&& type == char_type_node)
|
|
|
|
|
type = signed_char_type_node;
|
|
|
|
|
else if (longlong)
|
|
|
|
|
type = long_long_integer_type_node;
|
|
|
|
|
else if (specbits & 1 << (int) RID_LONG)
|
|
|
|
|
type = long_integer_type_node;
|
|
|
|
|
else if (specbits & 1 << (int) RID_SHORT)
|
|
|
|
|
type = short_integer_type_node;
|
1993-12-25 13:52:49 +01:00
|
|
|
|
|
|
|
|
|
if (specbits & 1 << (int) RID_COMPLEX)
|
1993-03-04 20:42:57 +01:00
|
|
|
|
{
|
2000-09-17 21:39:56 +02:00
|
|
|
|
if (pedantic && !flag_isoc99)
|
2002-07-21 23:35:17 +02:00
|
|
|
|
pedwarn ("ISO C90 does not support complex types");
|
1993-12-25 13:52:49 +01:00
|
|
|
|
/* If we just have "complex", it is equivalent to
|
|
|
|
|
"complex double", but if any modifiers at all are specified it is
|
|
|
|
|
the complex form of TYPE. E.g, "complex short" is
|
|
|
|
|
"complex short int". */
|
|
|
|
|
|
|
|
|
|
if (defaulted_int && ! longlong
|
|
|
|
|
&& ! (specbits & ((1 << (int) RID_LONG) | (1 << (int) RID_SHORT)
|
|
|
|
|
| (1 << (int) RID_SIGNED)
|
|
|
|
|
| (1 << (int) RID_UNSIGNED))))
|
2000-09-17 21:39:56 +02:00
|
|
|
|
{
|
|
|
|
|
if (pedantic)
|
|
|
|
|
pedwarn ("ISO C does not support plain `complex' meaning `double complex'");
|
|
|
|
|
type = complex_double_type_node;
|
|
|
|
|
}
|
1993-03-04 20:42:57 +01:00
|
|
|
|
else if (type == integer_type_node)
|
2000-09-17 21:39:56 +02:00
|
|
|
|
{
|
|
|
|
|
if (pedantic)
|
|
|
|
|
pedwarn ("ISO C does not support complex integer types");
|
|
|
|
|
type = complex_integer_type_node;
|
|
|
|
|
}
|
1993-03-04 20:42:57 +01:00
|
|
|
|
else if (type == float_type_node)
|
|
|
|
|
type = complex_float_type_node;
|
|
|
|
|
else if (type == double_type_node)
|
|
|
|
|
type = complex_double_type_node;
|
|
|
|
|
else if (type == long_double_type_node)
|
|
|
|
|
type = complex_long_double_type_node;
|
|
|
|
|
else
|
2000-09-17 21:39:56 +02:00
|
|
|
|
{
|
|
|
|
|
if (pedantic)
|
|
|
|
|
pedwarn ("ISO C does not support complex integer types");
|
|
|
|
|
type = build_complex_type (type);
|
|
|
|
|
}
|
1993-03-04 20:42:57 +01:00
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
/* Figure out the type qualifiers for the declaration. There are
|
|
|
|
|
two ways a declaration can become qualified. One is something
|
|
|
|
|
like `const int i' where the `const' is explicit. Another is
|
|
|
|
|
something like `typedef const int CI; CI i' where the type of the
|
|
|
|
|
declaration contains the `const'. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
constp = !! (specbits & 1 << (int) RID_CONST) + TYPE_READONLY (type);
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
restrictp = !! (specbits & 1 << (int) RID_RESTRICT) + TYPE_RESTRICT (type);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
volatilep = !! (specbits & 1 << (int) RID_VOLATILE) + TYPE_VOLATILE (type);
|
|
|
|
|
inlinep = !! (specbits & (1 << (int) RID_INLINE));
|
2000-06-26 18:42:23 +02:00
|
|
|
|
if (constp > 1 && ! flag_isoc99)
|
1992-05-18 07:09:24 +02:00
|
|
|
|
pedwarn ("duplicate `const'");
|
2000-06-26 18:42:23 +02:00
|
|
|
|
if (restrictp > 1 && ! flag_isoc99)
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
pedwarn ("duplicate `restrict'");
|
2000-06-26 18:42:23 +02:00
|
|
|
|
if (volatilep > 1 && ! flag_isoc99)
|
1992-05-18 07:09:24 +02:00
|
|
|
|
pedwarn ("duplicate `volatile'");
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
if (! flag_gen_aux_info && (TYPE_QUALS (type)))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
type = TYPE_MAIN_VARIANT (type);
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
type_quals = ((constp ? TYPE_QUAL_CONST : 0)
|
|
|
|
|
| (restrictp ? TYPE_QUAL_RESTRICT : 0)
|
|
|
|
|
| (volatilep ? TYPE_QUAL_VOLATILE : 0));
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* Warn if two storage classes are given. Default to `auto'. */
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
int nclasses = 0;
|
|
|
|
|
|
|
|
|
|
if (specbits & 1 << (int) RID_AUTO) nclasses++;
|
|
|
|
|
if (specbits & 1 << (int) RID_STATIC) nclasses++;
|
|
|
|
|
if (specbits & 1 << (int) RID_EXTERN) nclasses++;
|
|
|
|
|
if (specbits & 1 << (int) RID_REGISTER) nclasses++;
|
|
|
|
|
if (specbits & 1 << (int) RID_TYPEDEF) nclasses++;
|
|
|
|
|
|
2002-05-22 03:11:29 +02:00
|
|
|
|
/* "static __thread" and "extern __thread" are allowed. */
|
|
|
|
|
if ((specbits & (1 << (int) RID_THREAD
|
|
|
|
|
| 1 << (int) RID_STATIC
|
|
|
|
|
| 1 << (int) RID_EXTERN)) == (1 << (int) RID_THREAD))
|
|
|
|
|
nclasses++;
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Warn about storage classes that are invalid for certain
|
|
|
|
|
kinds of declarations (parameters, typenames, etc.). */
|
|
|
|
|
|
|
|
|
|
if (nclasses > 1)
|
|
|
|
|
error ("multiple storage classes in declaration of `%s'", name);
|
|
|
|
|
else if (funcdef_flag
|
|
|
|
|
&& (specbits
|
|
|
|
|
& ((1 << (int) RID_REGISTER)
|
|
|
|
|
| (1 << (int) RID_AUTO)
|
2002-05-22 03:11:29 +02:00
|
|
|
|
| (1 << (int) RID_TYPEDEF)
|
|
|
|
|
| (1 << (int) RID_THREAD))))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
if (specbits & 1 << (int) RID_AUTO
|
2003-07-24 18:59:32 +02:00
|
|
|
|
&& (pedantic || current_scope == global_scope))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
pedwarn ("function definition declared `auto'");
|
|
|
|
|
if (specbits & 1 << (int) RID_REGISTER)
|
|
|
|
|
error ("function definition declared `register'");
|
|
|
|
|
if (specbits & 1 << (int) RID_TYPEDEF)
|
|
|
|
|
error ("function definition declared `typedef'");
|
2002-05-22 03:11:29 +02:00
|
|
|
|
if (specbits & 1 << (int) RID_THREAD)
|
|
|
|
|
error ("function definition declared `__thread'");
|
2000-08-11 00:01:22 +02:00
|
|
|
|
specbits &= ~((1 << (int) RID_TYPEDEF) | (1 << (int) RID_REGISTER)
|
2002-05-22 03:11:29 +02:00
|
|
|
|
| (1 << (int) RID_AUTO) | (1 << (int) RID_THREAD));
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
else if (decl_context != NORMAL && nclasses > 0)
|
|
|
|
|
{
|
|
|
|
|
if (decl_context == PARM && specbits & 1 << (int) RID_REGISTER)
|
|
|
|
|
;
|
|
|
|
|
else
|
|
|
|
|
{
|
c-common.c (check_format_info): Don't call a variadic function with a non-literal format string.
* c-common.c (check_format_info): Don't call a variadic function
with a non-literal format string.
* c-decl.c (grokdeclarator, start_struct, finish_struct): Likewise.
* c-typeck.c (build_component_ref, build_unary_op, lvalue_or_else,
pedantic_lvalue_warning, error_init, pedwarn_init, warning_init):
Likewise.
* cccp.c (check_macro_name, do_xifdef, vwarning_with_line):
Likewise.
* collect2.c (collect_wait): Likewise.
* dbxout.c (dbxout_type): Likewise.
* gcc.c (do_spec_1): Likewise.
* genemit.c (gen_insn, gen_expand): Likewise.
* genrecog.c (write_switch, write_subroutine): Likewise.
* mips-tfile.c (catch_signal, botch): Likewise.
* print-rtl.c (print_rtx): Likewise.
* toplev.c (default_print_error_function, report_error_function,
_fatal_insn): Likewise.
From-SVN: r30666
1999-11-25 17:58:32 +01:00
|
|
|
|
switch (decl_context)
|
|
|
|
|
{
|
|
|
|
|
case FIELD:
|
2000-08-11 00:01:22 +02:00
|
|
|
|
error ("storage class specified for structure field `%s'",
|
|
|
|
|
name);
|
c-common.c (check_format_info): Don't call a variadic function with a non-literal format string.
* c-common.c (check_format_info): Don't call a variadic function
with a non-literal format string.
* c-decl.c (grokdeclarator, start_struct, finish_struct): Likewise.
* c-typeck.c (build_component_ref, build_unary_op, lvalue_or_else,
pedantic_lvalue_warning, error_init, pedwarn_init, warning_init):
Likewise.
* cccp.c (check_macro_name, do_xifdef, vwarning_with_line):
Likewise.
* collect2.c (collect_wait): Likewise.
* dbxout.c (dbxout_type): Likewise.
* gcc.c (do_spec_1): Likewise.
* genemit.c (gen_insn, gen_expand): Likewise.
* genrecog.c (write_switch, write_subroutine): Likewise.
* mips-tfile.c (catch_signal, botch): Likewise.
* print-rtl.c (print_rtx): Likewise.
* toplev.c (default_print_error_function, report_error_function,
_fatal_insn): Likewise.
From-SVN: r30666
1999-11-25 17:58:32 +01:00
|
|
|
|
break;
|
|
|
|
|
case PARM:
|
|
|
|
|
error ("storage class specified for parameter `%s'", name);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
error ("storage class specified for typename");
|
|
|
|
|
break;
|
|
|
|
|
}
|
2000-08-11 00:01:22 +02:00
|
|
|
|
specbits &= ~((1 << (int) RID_TYPEDEF) | (1 << (int) RID_REGISTER)
|
|
|
|
|
| (1 << (int) RID_AUTO) | (1 << (int) RID_STATIC)
|
2002-05-22 03:11:29 +02:00
|
|
|
|
| (1 << (int) RID_EXTERN) | (1 << (int) RID_THREAD));
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (specbits & 1 << (int) RID_EXTERN && initialized && ! funcdef_flag)
|
|
|
|
|
{
|
2003-07-24 18:59:32 +02:00
|
|
|
|
/* `extern' with initialization is invalid if not at file scope. */
|
|
|
|
|
if (current_scope == global_scope)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
warning ("`%s' initialized and declared `extern'", name);
|
|
|
|
|
else
|
|
|
|
|
error ("`%s' has both `extern' and initializer", name);
|
|
|
|
|
}
|
2003-07-24 18:59:32 +02:00
|
|
|
|
else if (current_scope == global_scope)
|
2002-05-22 03:11:29 +02:00
|
|
|
|
{
|
|
|
|
|
if (specbits & 1 << (int) RID_AUTO)
|
2003-07-24 18:59:32 +02:00
|
|
|
|
error ("file-scope declaration of `%s' specifies `auto'", name);
|
2002-05-22 03:11:29 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (specbits & 1 << (int) RID_EXTERN && funcdef_flag)
|
|
|
|
|
error ("nested function `%s' declared `extern'", name);
|
|
|
|
|
else if ((specbits & (1 << (int) RID_THREAD
|
|
|
|
|
| 1 << (int) RID_EXTERN
|
|
|
|
|
| 1 << (int) RID_STATIC))
|
|
|
|
|
== (1 << (int) RID_THREAD))
|
|
|
|
|
{
|
|
|
|
|
error ("function-scope `%s' implicitly auto and declared `__thread'",
|
|
|
|
|
name);
|
|
|
|
|
specbits &= ~(1 << (int) RID_THREAD);
|
|
|
|
|
}
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Now figure out the structure of the declarator proper.
|
|
|
|
|
Descend through it, creating more complex types, until we reach
|
|
|
|
|
the declared identifier (or NULL_TREE, in an absolute declarator). */
|
|
|
|
|
|
|
|
|
|
while (declarator && TREE_CODE (declarator) != IDENTIFIER_NODE)
|
|
|
|
|
{
|
|
|
|
|
if (type == error_mark_node)
|
|
|
|
|
{
|
|
|
|
|
declarator = TREE_OPERAND (declarator, 0);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Each level of DECLARATOR is either an ARRAY_REF (for ...[..]),
|
|
|
|
|
an INDIRECT_REF (for *...),
|
|
|
|
|
a CALL_EXPR (for ...(...)),
|
Table-driven attributes.
* c-decl.c, config/alpha/alpha.c, config/arc/arc.c,
config/arm/arm.c, config/arm/pe.c, config/avr/avr.c,
config/avr/avr.h, config/d30v/d30v.h, config/fr30/fr30.h,
config/h8300/h8300.c, config/i386/cygwin.h, config/i386/winnt.c,
config/m32r/m32r.c, config/mcore/mcore.c, config/sh/sh.c,
config/stormy16/stormy16.h, config/v850/v850.c, doc/c-tree.texi,
doc/tm.texi, ggc-common.c, integrate.c, print-tree.c, tree.c,
tree.h: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* tree.h (struct tree_decl): Change machine_attributes to
attributes.
* doc/c-tree.texi: Document that all attributes are now attached
to decls and types.
* c-common.c (add_attribute, attrtab, attrtab_idx,
default_valid_lang_attribute, valid_lang_attribute): Remove.
(attribute_tables, attributes_initialized,
c_common_attribute_table, default_lang_attribute_table): New
variables.
(handle_packed_attribute, handle_nocommon_attribute,
handle_common_attribute, handle_noreturn_attribute,
handle_unused_attribute, handle_const_attribute,
handle_transparent_union_attribute, handle_constructor_attribute,
handle_destructor_attribute, handle_mode_attribute,
handle_section_attribute, handle_aligned_attribute,
handle_weak_attribute, handle_alias_attribute,
handle_no_instrument_function_attribute,
handle_no_check_memory_usage_attribute, handle_malloc_attribute,
handle_no_limit_stack_attribute, handle_pure_attribute): New
functions.
(init_attributes, decl_attributes): Rewrite to implement
table-driven attributes.
* c-common.h (enum attribute_flags): Move to tree.h.
* c-format.c (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Rename to
handle_format_attribute and handle_format_arg_attribute. Update
for table-driven attributes.
* c-common.h (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Remove prototypes.
(handle_format_attribute, handle_format_arg_attribute): Add
prototypes.
* c-decl.c (grokdeclarator): Handle attributes nested inside
declarators.
* c-parse.in (setattrs, maybe_setattrs): Remove.
(maybe_type_quals_setattrs): Rename to maybe_type_quals_attrs.
Update to handle nested attributes properly.
(maybe_resetattrs, after_type_declarator,
parm_declarator_nostarttypename, notype_declarator, absdcl1_noea,
absdcl1_ea, direct_absdcl1): Update to handle nested attributes
properly.
(make_pointer_declarator): Update to handle nested attributes
properly.
* doc/extend.texi: Update documentation of limits of attributes
syntax. Warn about problems with attribute semantics in C++.
* target.h (struct target): Remove valid_decl_attribute and
valid_type_attribute. Add attribute_table and
function_attribute_inlinable_p.
* target-def.h (TARGET_VALID_DECL_ATTRIBUTE,
TARGET_VALID_TYPE_ATTRIBUTE): Remove.
(TARGET_ATTRIBUTE_TABLE, TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P):
Add.
(TARGET_INITIALIZER): Update.
* integrate.c (FUNCTION_ATTRIBUTE_INLINABLE_P): Remove default
definition.
(function_attribute_inlinable_p): New function. Check for the
presence of any machine attributes before using
targetm.function_attribute_inlinable_p.
(function_cannot_inline_p): Update.
* Makefile.in (integrate.o): Update dependencies.
* doc/tm.texi: Update documentation of target attributes and
example definition of TARGET_VALID_TYPE_ATTRIBUTE.
* tree.c (default_valid_attribute_p, valid_machine_attribute):
Remove.
(default_target_attribute_table,
default_function_attribute_inlinable_p): New.
(lookup_attribute): Update comment to clarify handling of multiple
attributes with the same name.
(merge_attributes, attribute_list_contained): Allow multiple
attributes with the same name but different arguments to appear in
the same attribute list.
* tree.h (default_valid_attribute_p): Remove prototype.
(struct attribute_spec): New.
(default_target_attribute_table): Declare.
(enum attribute_flags): Move from c-common.h. Add
ATTR_FLAG_TYPE_IN_PLACE.
(default_function_attribute_inlinable_p): Declare.
* config/alpha/alpha.c (vms_valid_decl_attribute_p): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(vms_attribute_table): New.
* config/arc/arc.c (arc_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arc_attribute_table, arc_handle_interrupt_attribute): New.
* config/arm/arm.c (arm_valid_type_attribute_p,
arm_valid_decl_attribute_p, arm_pe_valid_decl_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arm_attribute_table, arm_handle_fndecl_attribute,
arm_handle_isr_attribute): New.
* config/avr/avr.c (avr_valid_type_attribute,
avr_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE, TARGET_VALID_TYPE_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(avr_attribute_table, avr_handle_progmem_attribute,
avr_handle_fndecl_attribute): New.
* config/c4x/c4x.c (c4x_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(c4x_attribute_table, c4x_handle_fntype_attribute): New.
* config/h8300/h8300.c (h8300_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(h8300_attribute_table, h8300_handle_fndecl_attribute,
h8300_handle_eightbit_data_attribute,
h8300_handle_tiny_data_attribute): New.
* config/i386/i386-protos.h (ix86_valid_type_attribute_p,
i386_pe_valid_decl_attribute_p, i386_pe_valid_type_attribute_p):
Remove prototypes.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New
declarations.
* config/i386/i386.c (ix86_valid_type_attribute_p: Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ix86_attribute_table, ix86_handle_cdecl_attribute,
ix86_handle_regparm_attribute): New.
* config/i386/winnt.c (i386_pe_valid_decl_attribute_p,
i386_pe_valid_type_attribute_p): Remove.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New.
* config/ia64/ia64.c (ia64_valid_type_attribute): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ia64_attribute_table): New.
* config/m32r/m32r.c (m32r_valid_decl_attribute, interrupt_ident1,
interrupt_ident2, model_ident1, model_ident2): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(init_idents): Update.
(m32r_attribute_table, m32r_handle_model_attribute): New.
* config/m68hc11/m68hc11.c (m68hc11_valid_type_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(m68hc11_attribute_table, m68hc11_handle_fntype_attribute): New.
* config/mcore/mcore.c (mcore_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(mcore_attribute_table, mcore_handle_naked_attribute): New.
* config/ns32k/ns32k.c (ns32k_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ns32k_attribute_table, ns32k_handle_fntype_attribute): New.
* config/rs6000/rs6000.c (rs6000_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(rs6000_attribute_table, rs6000_handle_longcall_attribute): New.
* config/sh/sh.c (sh_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(sh_attribute_table, sh_handle_interrupt_handler_attribute,
sh_handle_sp_switch_attribute, sh_handle_trap_exit_attribute):
New.
* config/stormy16/stormy16.c (stormy16_valid_type_attribute):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define
(TARGET_ATTRIBUTE_TABLE): Define.
(stormy16_attribute_table, stormy16_handle_interrupt_attribute):
New.
* config/v850/v850.c (v850_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(v850_attribute_table, v850_handle_interrupt_attribute,
v850_handle_data_area_attribute): New.
* config/v850/v850-c.c (mark_current_function_as_interrupt):
Return void. Call decl_attributes instead of
valid_machine_attribute.
cp:
Table-driven attributes.
* decl.c: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* decl2.c (cplus_decl_attributes): Only take one attributes
parameter.
* cp-tree.c (cplus_decl_attributes): Update prototype.
* class.c (finish_struct), decl.c (start_decl, start_function),
decl2.c (grokfield), friend.c (do_friend), parse.y
(parse_bitfield): Update calls to cplus_decl_attributes.
* decl.c (grokdeclarator): Take a pointer to a single ordinary
attribute list.
* decl.h (grokdeclarator): Update prototype.
* decl2.c (grokfield): Take a single ordinary attribute list.
* friend.c (do_friend): Likewise.
* decl.c (shadow_tag, groktypename, start_decl,
start_handler_parms, grokdeclarator, grokparms, start_function,
start_method), decl2.c (grokfield, grokbitfield, grokoptypename),
parse.y (parse_field, parse_bitfield, component_decl_1), pt.c
(process_template_parm, do_decl_instantiation): Pass single
ordinary attribute lists around.
* decl.c (grokdeclarator): Correct handling of nested attributes.
Revert the patch
1998-10-18 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (grokdeclarator): Embedded attrs bind to the right,
not the left.
.
* cp-tree.h (cp_valid_lang_attribute): Remove declaration
(cp_attribute_table): Declare.
* decl.c (valid_lang_attribute): Don't define.
(lang_attribute_table): Define.
(init_decl_processing): Initialize lang_attribute_table instead of
valid_lang_attribute.
* tree.c (cp_valid_lang_attribute): Remove.
(handle_java_interface_attribute, handle_com_interface_attribute,
handle_init_priority_attribute): New functions.
(cp_attribute_table): New array.
* decl2.c (import_export_class): Don't use
targetm.valid_type_attribute.
testsuite:
Table-driven attributes.
* g++.dg/ext/attrib1.C: New test.
From-SVN: r45718
2001-09-21 03:27:06 +02:00
|
|
|
|
a TREE_LIST (for nested attributes),
|
1992-02-13 23:21:26 +01:00
|
|
|
|
an identifier (for the name being declared)
|
|
|
|
|
or a null pointer (for the place in an absolute declarator
|
|
|
|
|
where the name was omitted).
|
|
|
|
|
For the last two cases, we have just exited the loop.
|
|
|
|
|
|
|
|
|
|
At this point, TYPE is the type of elements of an array,
|
|
|
|
|
or for a function to return, or for a pointer to point to.
|
|
|
|
|
After this sequence of ifs, TYPE is the type of the
|
|
|
|
|
array or function or pointer, and DECLARATOR has had its
|
|
|
|
|
outermost layer removed. */
|
|
|
|
|
|
2001-05-25 13:12:47 +02:00
|
|
|
|
if (array_ptr_quals != NULL_TREE || array_parm_static)
|
|
|
|
|
{
|
|
|
|
|
/* Only the innermost declarator (making a parameter be of
|
|
|
|
|
array type which is converted to pointer type)
|
|
|
|
|
may have static or type qualifiers. */
|
|
|
|
|
error ("static or type qualifiers in non-parameter array declarator");
|
|
|
|
|
array_ptr_quals = NULL_TREE;
|
|
|
|
|
array_parm_static = 0;
|
|
|
|
|
}
|
|
|
|
|
|
Table-driven attributes.
* c-decl.c, config/alpha/alpha.c, config/arc/arc.c,
config/arm/arm.c, config/arm/pe.c, config/avr/avr.c,
config/avr/avr.h, config/d30v/d30v.h, config/fr30/fr30.h,
config/h8300/h8300.c, config/i386/cygwin.h, config/i386/winnt.c,
config/m32r/m32r.c, config/mcore/mcore.c, config/sh/sh.c,
config/stormy16/stormy16.h, config/v850/v850.c, doc/c-tree.texi,
doc/tm.texi, ggc-common.c, integrate.c, print-tree.c, tree.c,
tree.h: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* tree.h (struct tree_decl): Change machine_attributes to
attributes.
* doc/c-tree.texi: Document that all attributes are now attached
to decls and types.
* c-common.c (add_attribute, attrtab, attrtab_idx,
default_valid_lang_attribute, valid_lang_attribute): Remove.
(attribute_tables, attributes_initialized,
c_common_attribute_table, default_lang_attribute_table): New
variables.
(handle_packed_attribute, handle_nocommon_attribute,
handle_common_attribute, handle_noreturn_attribute,
handle_unused_attribute, handle_const_attribute,
handle_transparent_union_attribute, handle_constructor_attribute,
handle_destructor_attribute, handle_mode_attribute,
handle_section_attribute, handle_aligned_attribute,
handle_weak_attribute, handle_alias_attribute,
handle_no_instrument_function_attribute,
handle_no_check_memory_usage_attribute, handle_malloc_attribute,
handle_no_limit_stack_attribute, handle_pure_attribute): New
functions.
(init_attributes, decl_attributes): Rewrite to implement
table-driven attributes.
* c-common.h (enum attribute_flags): Move to tree.h.
* c-format.c (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Rename to
handle_format_attribute and handle_format_arg_attribute. Update
for table-driven attributes.
* c-common.h (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Remove prototypes.
(handle_format_attribute, handle_format_arg_attribute): Add
prototypes.
* c-decl.c (grokdeclarator): Handle attributes nested inside
declarators.
* c-parse.in (setattrs, maybe_setattrs): Remove.
(maybe_type_quals_setattrs): Rename to maybe_type_quals_attrs.
Update to handle nested attributes properly.
(maybe_resetattrs, after_type_declarator,
parm_declarator_nostarttypename, notype_declarator, absdcl1_noea,
absdcl1_ea, direct_absdcl1): Update to handle nested attributes
properly.
(make_pointer_declarator): Update to handle nested attributes
properly.
* doc/extend.texi: Update documentation of limits of attributes
syntax. Warn about problems with attribute semantics in C++.
* target.h (struct target): Remove valid_decl_attribute and
valid_type_attribute. Add attribute_table and
function_attribute_inlinable_p.
* target-def.h (TARGET_VALID_DECL_ATTRIBUTE,
TARGET_VALID_TYPE_ATTRIBUTE): Remove.
(TARGET_ATTRIBUTE_TABLE, TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P):
Add.
(TARGET_INITIALIZER): Update.
* integrate.c (FUNCTION_ATTRIBUTE_INLINABLE_P): Remove default
definition.
(function_attribute_inlinable_p): New function. Check for the
presence of any machine attributes before using
targetm.function_attribute_inlinable_p.
(function_cannot_inline_p): Update.
* Makefile.in (integrate.o): Update dependencies.
* doc/tm.texi: Update documentation of target attributes and
example definition of TARGET_VALID_TYPE_ATTRIBUTE.
* tree.c (default_valid_attribute_p, valid_machine_attribute):
Remove.
(default_target_attribute_table,
default_function_attribute_inlinable_p): New.
(lookup_attribute): Update comment to clarify handling of multiple
attributes with the same name.
(merge_attributes, attribute_list_contained): Allow multiple
attributes with the same name but different arguments to appear in
the same attribute list.
* tree.h (default_valid_attribute_p): Remove prototype.
(struct attribute_spec): New.
(default_target_attribute_table): Declare.
(enum attribute_flags): Move from c-common.h. Add
ATTR_FLAG_TYPE_IN_PLACE.
(default_function_attribute_inlinable_p): Declare.
* config/alpha/alpha.c (vms_valid_decl_attribute_p): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(vms_attribute_table): New.
* config/arc/arc.c (arc_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arc_attribute_table, arc_handle_interrupt_attribute): New.
* config/arm/arm.c (arm_valid_type_attribute_p,
arm_valid_decl_attribute_p, arm_pe_valid_decl_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arm_attribute_table, arm_handle_fndecl_attribute,
arm_handle_isr_attribute): New.
* config/avr/avr.c (avr_valid_type_attribute,
avr_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE, TARGET_VALID_TYPE_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(avr_attribute_table, avr_handle_progmem_attribute,
avr_handle_fndecl_attribute): New.
* config/c4x/c4x.c (c4x_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(c4x_attribute_table, c4x_handle_fntype_attribute): New.
* config/h8300/h8300.c (h8300_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(h8300_attribute_table, h8300_handle_fndecl_attribute,
h8300_handle_eightbit_data_attribute,
h8300_handle_tiny_data_attribute): New.
* config/i386/i386-protos.h (ix86_valid_type_attribute_p,
i386_pe_valid_decl_attribute_p, i386_pe_valid_type_attribute_p):
Remove prototypes.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New
declarations.
* config/i386/i386.c (ix86_valid_type_attribute_p: Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ix86_attribute_table, ix86_handle_cdecl_attribute,
ix86_handle_regparm_attribute): New.
* config/i386/winnt.c (i386_pe_valid_decl_attribute_p,
i386_pe_valid_type_attribute_p): Remove.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New.
* config/ia64/ia64.c (ia64_valid_type_attribute): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ia64_attribute_table): New.
* config/m32r/m32r.c (m32r_valid_decl_attribute, interrupt_ident1,
interrupt_ident2, model_ident1, model_ident2): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(init_idents): Update.
(m32r_attribute_table, m32r_handle_model_attribute): New.
* config/m68hc11/m68hc11.c (m68hc11_valid_type_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(m68hc11_attribute_table, m68hc11_handle_fntype_attribute): New.
* config/mcore/mcore.c (mcore_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(mcore_attribute_table, mcore_handle_naked_attribute): New.
* config/ns32k/ns32k.c (ns32k_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ns32k_attribute_table, ns32k_handle_fntype_attribute): New.
* config/rs6000/rs6000.c (rs6000_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(rs6000_attribute_table, rs6000_handle_longcall_attribute): New.
* config/sh/sh.c (sh_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(sh_attribute_table, sh_handle_interrupt_handler_attribute,
sh_handle_sp_switch_attribute, sh_handle_trap_exit_attribute):
New.
* config/stormy16/stormy16.c (stormy16_valid_type_attribute):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define
(TARGET_ATTRIBUTE_TABLE): Define.
(stormy16_attribute_table, stormy16_handle_interrupt_attribute):
New.
* config/v850/v850.c (v850_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(v850_attribute_table, v850_handle_interrupt_attribute,
v850_handle_data_area_attribute): New.
* config/v850/v850-c.c (mark_current_function_as_interrupt):
Return void. Call decl_attributes instead of
valid_machine_attribute.
cp:
Table-driven attributes.
* decl.c: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* decl2.c (cplus_decl_attributes): Only take one attributes
parameter.
* cp-tree.c (cplus_decl_attributes): Update prototype.
* class.c (finish_struct), decl.c (start_decl, start_function),
decl2.c (grokfield), friend.c (do_friend), parse.y
(parse_bitfield): Update calls to cplus_decl_attributes.
* decl.c (grokdeclarator): Take a pointer to a single ordinary
attribute list.
* decl.h (grokdeclarator): Update prototype.
* decl2.c (grokfield): Take a single ordinary attribute list.
* friend.c (do_friend): Likewise.
* decl.c (shadow_tag, groktypename, start_decl,
start_handler_parms, grokdeclarator, grokparms, start_function,
start_method), decl2.c (grokfield, grokbitfield, grokoptypename),
parse.y (parse_field, parse_bitfield, component_decl_1), pt.c
(process_template_parm, do_decl_instantiation): Pass single
ordinary attribute lists around.
* decl.c (grokdeclarator): Correct handling of nested attributes.
Revert the patch
1998-10-18 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (grokdeclarator): Embedded attrs bind to the right,
not the left.
.
* cp-tree.h (cp_valid_lang_attribute): Remove declaration
(cp_attribute_table): Declare.
* decl.c (valid_lang_attribute): Don't define.
(lang_attribute_table): Define.
(init_decl_processing): Initialize lang_attribute_table instead of
valid_lang_attribute.
* tree.c (cp_valid_lang_attribute): Remove.
(handle_java_interface_attribute, handle_com_interface_attribute,
handle_init_priority_attribute): New functions.
(cp_attribute_table): New array.
* decl2.c (import_export_class): Don't use
targetm.valid_type_attribute.
testsuite:
Table-driven attributes.
* g++.dg/ext/attrib1.C: New test.
From-SVN: r45718
2001-09-21 03:27:06 +02:00
|
|
|
|
if (TREE_CODE (declarator) == TREE_LIST)
|
|
|
|
|
{
|
|
|
|
|
/* We encode a declarator with embedded attributes using
|
|
|
|
|
a TREE_LIST. */
|
|
|
|
|
tree attrs = TREE_PURPOSE (declarator);
|
|
|
|
|
tree inner_decl;
|
|
|
|
|
int attr_flags = 0;
|
|
|
|
|
declarator = TREE_VALUE (declarator);
|
|
|
|
|
inner_decl = declarator;
|
|
|
|
|
while (inner_decl != NULL_TREE
|
|
|
|
|
&& TREE_CODE (inner_decl) == TREE_LIST)
|
|
|
|
|
inner_decl = TREE_VALUE (inner_decl);
|
|
|
|
|
if (inner_decl == NULL_TREE
|
|
|
|
|
|| TREE_CODE (inner_decl) == IDENTIFIER_NODE)
|
|
|
|
|
attr_flags |= (int) ATTR_FLAG_DECL_NEXT;
|
2002-02-15 17:08:21 +01:00
|
|
|
|
else if (TREE_CODE (inner_decl) == CALL_EXPR)
|
Table-driven attributes.
* c-decl.c, config/alpha/alpha.c, config/arc/arc.c,
config/arm/arm.c, config/arm/pe.c, config/avr/avr.c,
config/avr/avr.h, config/d30v/d30v.h, config/fr30/fr30.h,
config/h8300/h8300.c, config/i386/cygwin.h, config/i386/winnt.c,
config/m32r/m32r.c, config/mcore/mcore.c, config/sh/sh.c,
config/stormy16/stormy16.h, config/v850/v850.c, doc/c-tree.texi,
doc/tm.texi, ggc-common.c, integrate.c, print-tree.c, tree.c,
tree.h: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* tree.h (struct tree_decl): Change machine_attributes to
attributes.
* doc/c-tree.texi: Document that all attributes are now attached
to decls and types.
* c-common.c (add_attribute, attrtab, attrtab_idx,
default_valid_lang_attribute, valid_lang_attribute): Remove.
(attribute_tables, attributes_initialized,
c_common_attribute_table, default_lang_attribute_table): New
variables.
(handle_packed_attribute, handle_nocommon_attribute,
handle_common_attribute, handle_noreturn_attribute,
handle_unused_attribute, handle_const_attribute,
handle_transparent_union_attribute, handle_constructor_attribute,
handle_destructor_attribute, handle_mode_attribute,
handle_section_attribute, handle_aligned_attribute,
handle_weak_attribute, handle_alias_attribute,
handle_no_instrument_function_attribute,
handle_no_check_memory_usage_attribute, handle_malloc_attribute,
handle_no_limit_stack_attribute, handle_pure_attribute): New
functions.
(init_attributes, decl_attributes): Rewrite to implement
table-driven attributes.
* c-common.h (enum attribute_flags): Move to tree.h.
* c-format.c (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Rename to
handle_format_attribute and handle_format_arg_attribute. Update
for table-driven attributes.
* c-common.h (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Remove prototypes.
(handle_format_attribute, handle_format_arg_attribute): Add
prototypes.
* c-decl.c (grokdeclarator): Handle attributes nested inside
declarators.
* c-parse.in (setattrs, maybe_setattrs): Remove.
(maybe_type_quals_setattrs): Rename to maybe_type_quals_attrs.
Update to handle nested attributes properly.
(maybe_resetattrs, after_type_declarator,
parm_declarator_nostarttypename, notype_declarator, absdcl1_noea,
absdcl1_ea, direct_absdcl1): Update to handle nested attributes
properly.
(make_pointer_declarator): Update to handle nested attributes
properly.
* doc/extend.texi: Update documentation of limits of attributes
syntax. Warn about problems with attribute semantics in C++.
* target.h (struct target): Remove valid_decl_attribute and
valid_type_attribute. Add attribute_table and
function_attribute_inlinable_p.
* target-def.h (TARGET_VALID_DECL_ATTRIBUTE,
TARGET_VALID_TYPE_ATTRIBUTE): Remove.
(TARGET_ATTRIBUTE_TABLE, TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P):
Add.
(TARGET_INITIALIZER): Update.
* integrate.c (FUNCTION_ATTRIBUTE_INLINABLE_P): Remove default
definition.
(function_attribute_inlinable_p): New function. Check for the
presence of any machine attributes before using
targetm.function_attribute_inlinable_p.
(function_cannot_inline_p): Update.
* Makefile.in (integrate.o): Update dependencies.
* doc/tm.texi: Update documentation of target attributes and
example definition of TARGET_VALID_TYPE_ATTRIBUTE.
* tree.c (default_valid_attribute_p, valid_machine_attribute):
Remove.
(default_target_attribute_table,
default_function_attribute_inlinable_p): New.
(lookup_attribute): Update comment to clarify handling of multiple
attributes with the same name.
(merge_attributes, attribute_list_contained): Allow multiple
attributes with the same name but different arguments to appear in
the same attribute list.
* tree.h (default_valid_attribute_p): Remove prototype.
(struct attribute_spec): New.
(default_target_attribute_table): Declare.
(enum attribute_flags): Move from c-common.h. Add
ATTR_FLAG_TYPE_IN_PLACE.
(default_function_attribute_inlinable_p): Declare.
* config/alpha/alpha.c (vms_valid_decl_attribute_p): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(vms_attribute_table): New.
* config/arc/arc.c (arc_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arc_attribute_table, arc_handle_interrupt_attribute): New.
* config/arm/arm.c (arm_valid_type_attribute_p,
arm_valid_decl_attribute_p, arm_pe_valid_decl_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arm_attribute_table, arm_handle_fndecl_attribute,
arm_handle_isr_attribute): New.
* config/avr/avr.c (avr_valid_type_attribute,
avr_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE, TARGET_VALID_TYPE_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(avr_attribute_table, avr_handle_progmem_attribute,
avr_handle_fndecl_attribute): New.
* config/c4x/c4x.c (c4x_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(c4x_attribute_table, c4x_handle_fntype_attribute): New.
* config/h8300/h8300.c (h8300_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(h8300_attribute_table, h8300_handle_fndecl_attribute,
h8300_handle_eightbit_data_attribute,
h8300_handle_tiny_data_attribute): New.
* config/i386/i386-protos.h (ix86_valid_type_attribute_p,
i386_pe_valid_decl_attribute_p, i386_pe_valid_type_attribute_p):
Remove prototypes.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New
declarations.
* config/i386/i386.c (ix86_valid_type_attribute_p: Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ix86_attribute_table, ix86_handle_cdecl_attribute,
ix86_handle_regparm_attribute): New.
* config/i386/winnt.c (i386_pe_valid_decl_attribute_p,
i386_pe_valid_type_attribute_p): Remove.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New.
* config/ia64/ia64.c (ia64_valid_type_attribute): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ia64_attribute_table): New.
* config/m32r/m32r.c (m32r_valid_decl_attribute, interrupt_ident1,
interrupt_ident2, model_ident1, model_ident2): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(init_idents): Update.
(m32r_attribute_table, m32r_handle_model_attribute): New.
* config/m68hc11/m68hc11.c (m68hc11_valid_type_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(m68hc11_attribute_table, m68hc11_handle_fntype_attribute): New.
* config/mcore/mcore.c (mcore_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(mcore_attribute_table, mcore_handle_naked_attribute): New.
* config/ns32k/ns32k.c (ns32k_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ns32k_attribute_table, ns32k_handle_fntype_attribute): New.
* config/rs6000/rs6000.c (rs6000_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(rs6000_attribute_table, rs6000_handle_longcall_attribute): New.
* config/sh/sh.c (sh_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(sh_attribute_table, sh_handle_interrupt_handler_attribute,
sh_handle_sp_switch_attribute, sh_handle_trap_exit_attribute):
New.
* config/stormy16/stormy16.c (stormy16_valid_type_attribute):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define
(TARGET_ATTRIBUTE_TABLE): Define.
(stormy16_attribute_table, stormy16_handle_interrupt_attribute):
New.
* config/v850/v850.c (v850_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(v850_attribute_table, v850_handle_interrupt_attribute,
v850_handle_data_area_attribute): New.
* config/v850/v850-c.c (mark_current_function_as_interrupt):
Return void. Call decl_attributes instead of
valid_machine_attribute.
cp:
Table-driven attributes.
* decl.c: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* decl2.c (cplus_decl_attributes): Only take one attributes
parameter.
* cp-tree.c (cplus_decl_attributes): Update prototype.
* class.c (finish_struct), decl.c (start_decl, start_function),
decl2.c (grokfield), friend.c (do_friend), parse.y
(parse_bitfield): Update calls to cplus_decl_attributes.
* decl.c (grokdeclarator): Take a pointer to a single ordinary
attribute list.
* decl.h (grokdeclarator): Update prototype.
* decl2.c (grokfield): Take a single ordinary attribute list.
* friend.c (do_friend): Likewise.
* decl.c (shadow_tag, groktypename, start_decl,
start_handler_parms, grokdeclarator, grokparms, start_function,
start_method), decl2.c (grokfield, grokbitfield, grokoptypename),
parse.y (parse_field, parse_bitfield, component_decl_1), pt.c
(process_template_parm, do_decl_instantiation): Pass single
ordinary attribute lists around.
* decl.c (grokdeclarator): Correct handling of nested attributes.
Revert the patch
1998-10-18 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (grokdeclarator): Embedded attrs bind to the right,
not the left.
.
* cp-tree.h (cp_valid_lang_attribute): Remove declaration
(cp_attribute_table): Declare.
* decl.c (valid_lang_attribute): Don't define.
(lang_attribute_table): Define.
(init_decl_processing): Initialize lang_attribute_table instead of
valid_lang_attribute.
* tree.c (cp_valid_lang_attribute): Remove.
(handle_java_interface_attribute, handle_com_interface_attribute,
handle_init_priority_attribute): New functions.
(cp_attribute_table): New array.
* decl2.c (import_export_class): Don't use
targetm.valid_type_attribute.
testsuite:
Table-driven attributes.
* g++.dg/ext/attrib1.C: New test.
From-SVN: r45718
2001-09-21 03:27:06 +02:00
|
|
|
|
attr_flags |= (int) ATTR_FLAG_FUNCTION_NEXT;
|
2002-02-15 17:08:21 +01:00
|
|
|
|
else if (TREE_CODE (inner_decl) == ARRAY_REF)
|
Table-driven attributes.
* c-decl.c, config/alpha/alpha.c, config/arc/arc.c,
config/arm/arm.c, config/arm/pe.c, config/avr/avr.c,
config/avr/avr.h, config/d30v/d30v.h, config/fr30/fr30.h,
config/h8300/h8300.c, config/i386/cygwin.h, config/i386/winnt.c,
config/m32r/m32r.c, config/mcore/mcore.c, config/sh/sh.c,
config/stormy16/stormy16.h, config/v850/v850.c, doc/c-tree.texi,
doc/tm.texi, ggc-common.c, integrate.c, print-tree.c, tree.c,
tree.h: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* tree.h (struct tree_decl): Change machine_attributes to
attributes.
* doc/c-tree.texi: Document that all attributes are now attached
to decls and types.
* c-common.c (add_attribute, attrtab, attrtab_idx,
default_valid_lang_attribute, valid_lang_attribute): Remove.
(attribute_tables, attributes_initialized,
c_common_attribute_table, default_lang_attribute_table): New
variables.
(handle_packed_attribute, handle_nocommon_attribute,
handle_common_attribute, handle_noreturn_attribute,
handle_unused_attribute, handle_const_attribute,
handle_transparent_union_attribute, handle_constructor_attribute,
handle_destructor_attribute, handle_mode_attribute,
handle_section_attribute, handle_aligned_attribute,
handle_weak_attribute, handle_alias_attribute,
handle_no_instrument_function_attribute,
handle_no_check_memory_usage_attribute, handle_malloc_attribute,
handle_no_limit_stack_attribute, handle_pure_attribute): New
functions.
(init_attributes, decl_attributes): Rewrite to implement
table-driven attributes.
* c-common.h (enum attribute_flags): Move to tree.h.
* c-format.c (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Rename to
handle_format_attribute and handle_format_arg_attribute. Update
for table-driven attributes.
* c-common.h (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Remove prototypes.
(handle_format_attribute, handle_format_arg_attribute): Add
prototypes.
* c-decl.c (grokdeclarator): Handle attributes nested inside
declarators.
* c-parse.in (setattrs, maybe_setattrs): Remove.
(maybe_type_quals_setattrs): Rename to maybe_type_quals_attrs.
Update to handle nested attributes properly.
(maybe_resetattrs, after_type_declarator,
parm_declarator_nostarttypename, notype_declarator, absdcl1_noea,
absdcl1_ea, direct_absdcl1): Update to handle nested attributes
properly.
(make_pointer_declarator): Update to handle nested attributes
properly.
* doc/extend.texi: Update documentation of limits of attributes
syntax. Warn about problems with attribute semantics in C++.
* target.h (struct target): Remove valid_decl_attribute and
valid_type_attribute. Add attribute_table and
function_attribute_inlinable_p.
* target-def.h (TARGET_VALID_DECL_ATTRIBUTE,
TARGET_VALID_TYPE_ATTRIBUTE): Remove.
(TARGET_ATTRIBUTE_TABLE, TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P):
Add.
(TARGET_INITIALIZER): Update.
* integrate.c (FUNCTION_ATTRIBUTE_INLINABLE_P): Remove default
definition.
(function_attribute_inlinable_p): New function. Check for the
presence of any machine attributes before using
targetm.function_attribute_inlinable_p.
(function_cannot_inline_p): Update.
* Makefile.in (integrate.o): Update dependencies.
* doc/tm.texi: Update documentation of target attributes and
example definition of TARGET_VALID_TYPE_ATTRIBUTE.
* tree.c (default_valid_attribute_p, valid_machine_attribute):
Remove.
(default_target_attribute_table,
default_function_attribute_inlinable_p): New.
(lookup_attribute): Update comment to clarify handling of multiple
attributes with the same name.
(merge_attributes, attribute_list_contained): Allow multiple
attributes with the same name but different arguments to appear in
the same attribute list.
* tree.h (default_valid_attribute_p): Remove prototype.
(struct attribute_spec): New.
(default_target_attribute_table): Declare.
(enum attribute_flags): Move from c-common.h. Add
ATTR_FLAG_TYPE_IN_PLACE.
(default_function_attribute_inlinable_p): Declare.
* config/alpha/alpha.c (vms_valid_decl_attribute_p): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(vms_attribute_table): New.
* config/arc/arc.c (arc_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arc_attribute_table, arc_handle_interrupt_attribute): New.
* config/arm/arm.c (arm_valid_type_attribute_p,
arm_valid_decl_attribute_p, arm_pe_valid_decl_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arm_attribute_table, arm_handle_fndecl_attribute,
arm_handle_isr_attribute): New.
* config/avr/avr.c (avr_valid_type_attribute,
avr_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE, TARGET_VALID_TYPE_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(avr_attribute_table, avr_handle_progmem_attribute,
avr_handle_fndecl_attribute): New.
* config/c4x/c4x.c (c4x_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(c4x_attribute_table, c4x_handle_fntype_attribute): New.
* config/h8300/h8300.c (h8300_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(h8300_attribute_table, h8300_handle_fndecl_attribute,
h8300_handle_eightbit_data_attribute,
h8300_handle_tiny_data_attribute): New.
* config/i386/i386-protos.h (ix86_valid_type_attribute_p,
i386_pe_valid_decl_attribute_p, i386_pe_valid_type_attribute_p):
Remove prototypes.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New
declarations.
* config/i386/i386.c (ix86_valid_type_attribute_p: Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ix86_attribute_table, ix86_handle_cdecl_attribute,
ix86_handle_regparm_attribute): New.
* config/i386/winnt.c (i386_pe_valid_decl_attribute_p,
i386_pe_valid_type_attribute_p): Remove.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New.
* config/ia64/ia64.c (ia64_valid_type_attribute): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ia64_attribute_table): New.
* config/m32r/m32r.c (m32r_valid_decl_attribute, interrupt_ident1,
interrupt_ident2, model_ident1, model_ident2): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(init_idents): Update.
(m32r_attribute_table, m32r_handle_model_attribute): New.
* config/m68hc11/m68hc11.c (m68hc11_valid_type_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(m68hc11_attribute_table, m68hc11_handle_fntype_attribute): New.
* config/mcore/mcore.c (mcore_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(mcore_attribute_table, mcore_handle_naked_attribute): New.
* config/ns32k/ns32k.c (ns32k_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ns32k_attribute_table, ns32k_handle_fntype_attribute): New.
* config/rs6000/rs6000.c (rs6000_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(rs6000_attribute_table, rs6000_handle_longcall_attribute): New.
* config/sh/sh.c (sh_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(sh_attribute_table, sh_handle_interrupt_handler_attribute,
sh_handle_sp_switch_attribute, sh_handle_trap_exit_attribute):
New.
* config/stormy16/stormy16.c (stormy16_valid_type_attribute):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define
(TARGET_ATTRIBUTE_TABLE): Define.
(stormy16_attribute_table, stormy16_handle_interrupt_attribute):
New.
* config/v850/v850.c (v850_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(v850_attribute_table, v850_handle_interrupt_attribute,
v850_handle_data_area_attribute): New.
* config/v850/v850-c.c (mark_current_function_as_interrupt):
Return void. Call decl_attributes instead of
valid_machine_attribute.
cp:
Table-driven attributes.
* decl.c: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* decl2.c (cplus_decl_attributes): Only take one attributes
parameter.
* cp-tree.c (cplus_decl_attributes): Update prototype.
* class.c (finish_struct), decl.c (start_decl, start_function),
decl2.c (grokfield), friend.c (do_friend), parse.y
(parse_bitfield): Update calls to cplus_decl_attributes.
* decl.c (grokdeclarator): Take a pointer to a single ordinary
attribute list.
* decl.h (grokdeclarator): Update prototype.
* decl2.c (grokfield): Take a single ordinary attribute list.
* friend.c (do_friend): Likewise.
* decl.c (shadow_tag, groktypename, start_decl,
start_handler_parms, grokdeclarator, grokparms, start_function,
start_method), decl2.c (grokfield, grokbitfield, grokoptypename),
parse.y (parse_field, parse_bitfield, component_decl_1), pt.c
(process_template_parm, do_decl_instantiation): Pass single
ordinary attribute lists around.
* decl.c (grokdeclarator): Correct handling of nested attributes.
Revert the patch
1998-10-18 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (grokdeclarator): Embedded attrs bind to the right,
not the left.
.
* cp-tree.h (cp_valid_lang_attribute): Remove declaration
(cp_attribute_table): Declare.
* decl.c (valid_lang_attribute): Don't define.
(lang_attribute_table): Define.
(init_decl_processing): Initialize lang_attribute_table instead of
valid_lang_attribute.
* tree.c (cp_valid_lang_attribute): Remove.
(handle_java_interface_attribute, handle_com_interface_attribute,
handle_init_priority_attribute): New functions.
(cp_attribute_table): New array.
* decl2.c (import_export_class): Don't use
targetm.valid_type_attribute.
testsuite:
Table-driven attributes.
* g++.dg/ext/attrib1.C: New test.
From-SVN: r45718
2001-09-21 03:27:06 +02:00
|
|
|
|
attr_flags |= (int) ATTR_FLAG_ARRAY_NEXT;
|
|
|
|
|
returned_attrs = decl_attributes (&type,
|
|
|
|
|
chainon (returned_attrs, attrs),
|
|
|
|
|
attr_flags);
|
|
|
|
|
}
|
|
|
|
|
else if (TREE_CODE (declarator) == ARRAY_REF)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree itype = NULL_TREE;
|
|
|
|
|
tree size = TREE_OPERAND (declarator, 1);
|
1994-03-19 12:29:25 +01:00
|
|
|
|
/* The index is a signed object `sizetype' bits wide. */
|
c-common.c (unsigned_conversion_warning, [...]): Use new hooks.
* c-common.c (unsigned_conversion_warning, convert_and_check,
unsigned_type, signed_type, shorten_compare,
c_common_get_alias_set, c_common_nodes_and_builtins): Use new hooks.
(unsigned_type, signed_type, signed_or_unsigned_type): Rename.
* c-common.h (unsigned_type, signed_type, signed_or_unsigned_type):
New.
* c-decl.c (grokdeclarator): Update.
* c-format.c (check_format_types): Update.
* c-lang.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
* c-typeck.c (build_binary_op, convert_for_assignment): Update.
* convert.c (convert_to_integer): Use new hooks.
* expmed.c (make_tree): Use new hooks.
* expr.c (store_expr): Use new hooks.
* fold-const.c (operand_equal_for_comparison_p, build_range_check,
all_ones_mask_p, unextend, fold): Use new hooks.
* langhooks.h (struct lang_hooks_for_types): New hooks.
* tree.h (signed_or_unsigned_type, signed_type,
unsigned_type): Remove.
ada:
* gigi.h (unsigned_type, signed_type, signed_or_unsigned_type):
Rename.
* misc.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
* trans.c (tree_transform, convert_with_check): Update.
* utils.c (unsigned_type, signed_type, signed_or_unsigned_type):
Rename.
cp:
* cp-lang.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
* decl.c (grokdeclarator): Update.
* mangle.c (write_integer_cst): Update.
* typeck.c (build_binary_op): Update.
f:
* com.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
(unsigned_type, signed_type, signed_or_unsigned_type): Rename.
java:
* expr.c (build_java_binop): Update.
* java-tree.h (java_signed_type, java_unsigned_type,
java_signed_or_unsigned_type): Update.
* lang.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
* parse.y (patch_binop): Update.
* typeck.c (signed_or_unsigned_type, unsigned_type,
signed_type): Update.
objc:
* objc-lang.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
From-SVN: r51684
2002-04-01 10:46:10 +02:00
|
|
|
|
tree index_type = c_common_signed_type (sizetype);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2001-05-25 13:12:47 +02:00
|
|
|
|
array_ptr_quals = TREE_TYPE (declarator);
|
|
|
|
|
array_parm_static = TREE_STATIC (declarator);
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
declarator = TREE_OPERAND (declarator, 0);
|
|
|
|
|
|
|
|
|
|
/* Check for some types that there cannot be arrays of. */
|
|
|
|
|
|
2000-06-05 15:16:14 +02:00
|
|
|
|
if (VOID_TYPE_P (type))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
error ("declaration of `%s' as array of voids", name);
|
|
|
|
|
type = error_mark_node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (type) == FUNCTION_TYPE)
|
|
|
|
|
{
|
|
|
|
|
error ("declaration of `%s' as array of functions", name);
|
|
|
|
|
type = error_mark_node;
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-17 16:48:28 +02:00
|
|
|
|
if (pedantic && flexible_array_type_p (type))
|
|
|
|
|
pedwarn ("invalid use of structure with flexible array member");
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (size == error_mark_node)
|
|
|
|
|
type = error_mark_node;
|
|
|
|
|
|
|
|
|
|
if (type == error_mark_node)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* If size was specified, set ITYPE to a range-type for that size.
|
|
|
|
|
Otherwise, ITYPE remains null. finish_decl may figure it out
|
|
|
|
|
from an initial value. */
|
|
|
|
|
|
|
|
|
|
if (size)
|
|
|
|
|
{
|
|
|
|
|
/* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */
|
1992-07-10 03:50:35 +02:00
|
|
|
|
STRIP_TYPE_NOPS (size);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2001-06-12 14:15:46 +02:00
|
|
|
|
if (! INTEGRAL_TYPE_P (TREE_TYPE (size)))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
error ("size of array `%s' has non-integer type", name);
|
|
|
|
|
size = integer_one_node;
|
|
|
|
|
}
|
1994-03-14 14:47:18 +01:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (pedantic && integer_zerop (size))
|
c-common.c (combine_strings, [...]): Refer to ISO C or ISO C89 instead of ANSI C.
* c-common.c (combine_strings, check_format_info): Refer to ISO C
or ISO C89 instead of ANSI C.
* c-decl.c (grokdeclarator, xref_tag, finish_struct,
build_enumerator, do_case): Likewise.
* c-lex.c (parse_float, yylex): Likewise.
* c-parse.in: Likewise.
* c-typeck.c (common_type, build_array_ref, build_binary_op,
build_unary_op, pedantic_lvalue_warning, build_conditional_expr,
build_c_cast, convert_for_assignment, set_init_index,
set_init_label, c_expand_start_case): Likewise.
* toplev.c (documented_lang_options, display_help): Likewise.
From-SVN: r35576
2000-08-09 01:19:11 +02:00
|
|
|
|
pedwarn ("ISO C forbids zero-size array `%s'", name);
|
1994-03-14 14:47:18 +01:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (TREE_CODE (size) == INTEGER_CST)
|
|
|
|
|
{
|
1993-02-02 05:38:30 +01:00
|
|
|
|
constant_expression_warning (size);
|
1994-03-14 14:47:18 +01:00
|
|
|
|
if (tree_int_cst_sgn (size) < 0)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
error ("size of array `%s' is negative", name);
|
|
|
|
|
size = integer_one_node;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
1994-03-14 14:47:18 +01:00
|
|
|
|
/* Make sure the array size remains visibly nonconstant
|
|
|
|
|
even if it is (eg) a const variable with known value. */
|
|
|
|
|
size_varies = 1;
|
|
|
|
|
|
2002-04-25 00:26:10 +02:00
|
|
|
|
if (!flag_isoc99 && pedantic)
|
1993-03-16 05:53:55 +01:00
|
|
|
|
{
|
|
|
|
|
if (TREE_CONSTANT (size))
|
2002-07-21 23:35:17 +02:00
|
|
|
|
pedwarn ("ISO C90 forbids array `%s' whose size can't be evaluated",
|
2000-08-11 00:01:22 +02:00
|
|
|
|
name);
|
1993-03-16 05:53:55 +01:00
|
|
|
|
else
|
2002-07-21 23:35:17 +02:00
|
|
|
|
pedwarn ("ISO C90 forbids variable-size array `%s'",
|
2000-08-11 00:01:22 +02:00
|
|
|
|
name);
|
1993-03-16 05:53:55 +01:00
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
1994-03-14 14:47:18 +01:00
|
|
|
|
|
2000-11-19 09:36:18 +01:00
|
|
|
|
if (integer_zerop (size))
|
1997-11-02 22:19:36 +01:00
|
|
|
|
{
|
2000-11-19 09:36:18 +01:00
|
|
|
|
/* A zero-length array cannot be represented with an
|
|
|
|
|
unsigned index type, which is what we'll get with
|
2000-11-20 00:40:37 +01:00
|
|
|
|
build_index_type. Create an open-ended range instead. */
|
|
|
|
|
itype = build_range_type (sizetype, size, NULL_TREE);
|
1997-11-02 22:19:36 +01:00
|
|
|
|
}
|
2000-11-19 09:36:18 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Compute the maximum valid index, that is, size - 1.
|
|
|
|
|
Do the calculation in index_type, so that if it is
|
|
|
|
|
a variable the computations will be done in the
|
|
|
|
|
proper mode. */
|
|
|
|
|
itype = fold (build (MINUS_EXPR, index_type,
|
|
|
|
|
convert (index_type, size),
|
|
|
|
|
convert (index_type, size_one_node)));
|
|
|
|
|
|
|
|
|
|
/* If that overflowed, the array is too big.
|
|
|
|
|
??? While a size of INT_MAX+1 technically shouldn't
|
|
|
|
|
cause an overflow (because we subtract 1), the overflow
|
|
|
|
|
is recorded during the conversion to index_type, before
|
|
|
|
|
the subtraction. Handling this case seems like an
|
|
|
|
|
unnecessary complication. */
|
|
|
|
|
if (TREE_OVERFLOW (itype))
|
|
|
|
|
{
|
|
|
|
|
error ("size of array `%s' is too large", name);
|
|
|
|
|
type = error_mark_node;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
1997-11-02 22:19:36 +01:00
|
|
|
|
|
2000-11-19 09:36:18 +01:00
|
|
|
|
if (size_varies)
|
2003-04-01 09:35:11 +02:00
|
|
|
|
{
|
|
|
|
|
/* We must be able to distinguish the
|
|
|
|
|
SAVE_EXPR_CONTEXT for the variably-sized type
|
|
|
|
|
so that we can set it correctly in
|
|
|
|
|
set_save_expr_context. The convention is
|
|
|
|
|
that all SAVE_EXPRs that need to be reset
|
|
|
|
|
have NULL_TREE for their SAVE_EXPR_CONTEXT. */
|
|
|
|
|
tree cfd = current_function_decl;
|
|
|
|
|
if (decl_context == PARM)
|
|
|
|
|
current_function_decl = NULL_TREE;
|
|
|
|
|
itype = variable_size (itype);
|
|
|
|
|
if (decl_context == PARM)
|
|
|
|
|
current_function_decl = cfd;
|
|
|
|
|
}
|
2000-11-19 09:36:18 +01:00
|
|
|
|
itype = build_index_type (itype);
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
2000-11-20 00:40:37 +01:00
|
|
|
|
else if (decl_context == FIELD)
|
|
|
|
|
{
|
|
|
|
|
if (pedantic && !flag_isoc99 && !in_system_header)
|
2002-07-21 23:35:17 +02:00
|
|
|
|
pedwarn ("ISO C90 does not support flexible array members");
|
2000-11-20 00:40:37 +01:00
|
|
|
|
|
|
|
|
|
/* ISO C99 Flexible array members are effectively identical
|
|
|
|
|
to GCC's zero-length array extension. */
|
|
|
|
|
itype = build_range_type (sizetype, size_zero_node, NULL_TREE);
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2000-12-01 20:21:44 +01:00
|
|
|
|
/* If pedantic, complain about arrays of incomplete types. */
|
|
|
|
|
|
|
|
|
|
if (pedantic && !COMPLETE_TYPE_P (type))
|
|
|
|
|
pedwarn ("array type has incomplete element type");
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
1993-05-04 02:10:51 +02:00
|
|
|
|
/* Build the array type itself, then merge any constancy or
|
|
|
|
|
volatility into the target type. We must do it in this order
|
|
|
|
|
to ensure that the TYPE_MAIN_VARIANT field of the array type
|
|
|
|
|
is set correctly. */
|
|
|
|
|
|
|
|
|
|
type = build_array_type (type, itype);
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
if (type_quals)
|
|
|
|
|
type = c_build_qualified_type (type, type_quals);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
1992-03-23 03:07:53 +01:00
|
|
|
|
if (size_varies)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
C_TYPE_VARIABLE_SIZE (type) = 1;
|
2001-01-04 02:14:16 +01:00
|
|
|
|
|
|
|
|
|
/* The GCC extension for zero-length arrays differs from
|
|
|
|
|
ISO flexible array members in that sizeof yields zero. */
|
|
|
|
|
if (size && integer_zerop (size))
|
|
|
|
|
{
|
|
|
|
|
layout_type (type);
|
|
|
|
|
TYPE_SIZE (type) = bitsize_zero_node;
|
|
|
|
|
TYPE_SIZE_UNIT (type) = size_zero_node;
|
|
|
|
|
}
|
2001-05-25 13:12:47 +02:00
|
|
|
|
if (decl_context != PARM
|
|
|
|
|
&& (array_ptr_quals != NULL_TREE || array_parm_static))
|
|
|
|
|
{
|
|
|
|
|
error ("static or type qualifiers in non-parameter array declarator");
|
|
|
|
|
array_ptr_quals = NULL_TREE;
|
|
|
|
|
array_parm_static = 0;
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
else if (TREE_CODE (declarator) == CALL_EXPR)
|
|
|
|
|
{
|
|
|
|
|
tree arg_types;
|
|
|
|
|
|
|
|
|
|
/* Declaring a function type.
|
|
|
|
|
Make sure we have a valid type for the function to return. */
|
|
|
|
|
if (type == error_mark_node)
|
|
|
|
|
continue;
|
|
|
|
|
|
1992-03-23 03:07:53 +01:00
|
|
|
|
size_varies = 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* Warn about some types functions can't return. */
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (type) == FUNCTION_TYPE)
|
|
|
|
|
{
|
|
|
|
|
error ("`%s' declared as function returning a function", name);
|
|
|
|
|
type = integer_type_node;
|
|
|
|
|
}
|
|
|
|
|
if (TREE_CODE (type) == ARRAY_TYPE)
|
|
|
|
|
{
|
|
|
|
|
error ("`%s' declared as function returning an array", name);
|
|
|
|
|
type = integer_type_node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Construct the function type and go to the next
|
|
|
|
|
inner layer of declarator. */
|
|
|
|
|
|
|
|
|
|
arg_types = grokparms (TREE_OPERAND (declarator, 1),
|
|
|
|
|
funcdef_flag
|
|
|
|
|
/* Say it's a definition
|
|
|
|
|
only for the CALL_EXPR
|
|
|
|
|
closest to the identifier. */
|
|
|
|
|
&& TREE_CODE (TREE_OPERAND (declarator, 0)) == IDENTIFIER_NODE);
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
/* Type qualifiers before the return type of the function
|
|
|
|
|
qualify the return type, not the function type. */
|
|
|
|
|
if (type_quals)
|
2000-10-25 19:45:44 +02:00
|
|
|
|
{
|
|
|
|
|
/* Type qualifiers on a function return type are normally
|
|
|
|
|
permitted by the standard but have no effect, so give a
|
2003-01-24 16:17:26 +01:00
|
|
|
|
warning at -Wextra. Qualifiers on a void return type have
|
2000-10-25 19:45:44 +02:00
|
|
|
|
meaning as a GNU extension, and are banned on function
|
|
|
|
|
definitions in ISO C. FIXME: strictly we shouldn't
|
|
|
|
|
pedwarn for qualified void return types except on function
|
|
|
|
|
definitions, but not doing so could lead to the undesirable
|
|
|
|
|
state of a "volatile void" function return type not being
|
|
|
|
|
warned about, and a use of the function being compiled
|
|
|
|
|
with GNU semantics, with no diagnostics under -pedantic. */
|
|
|
|
|
if (VOID_TYPE_P (type) && pedantic && !in_system_header)
|
|
|
|
|
pedwarn ("ISO C forbids qualified void function return type");
|
|
|
|
|
else if (extra_warnings
|
|
|
|
|
&& !(VOID_TYPE_P (type)
|
|
|
|
|
&& type_quals == TYPE_QUAL_VOLATILE))
|
|
|
|
|
warning ("type qualifiers ignored on function return type");
|
|
|
|
|
|
|
|
|
|
type = c_build_qualified_type (type, type_quals);
|
|
|
|
|
}
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
type_quals = TYPE_UNQUALIFIED;
|
1993-08-06 03:11:37 +02:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
type = build_function_type (type, arg_types);
|
|
|
|
|
declarator = TREE_OPERAND (declarator, 0);
|
|
|
|
|
|
|
|
|
|
/* Set the TYPE_CONTEXTs for each tagged type which is local to
|
|
|
|
|
the formal parameter list of this FUNCTION_TYPE to point to
|
|
|
|
|
the FUNCTION_TYPE node itself. */
|
|
|
|
|
|
|
|
|
|
{
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree link;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
1998-01-26 19:13:41 +01:00
|
|
|
|
for (link = last_function_parm_tags;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
link;
|
|
|
|
|
link = TREE_CHAIN (link))
|
|
|
|
|
TYPE_CONTEXT (TREE_VALUE (link)) = type;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (TREE_CODE (declarator) == INDIRECT_REF)
|
|
|
|
|
{
|
|
|
|
|
/* Merge any constancy or volatility into the target type
|
|
|
|
|
for the pointer. */
|
|
|
|
|
|
|
|
|
|
if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
&& type_quals)
|
c-common.c (combine_strings, [...]): Refer to ISO C or ISO C89 instead of ANSI C.
* c-common.c (combine_strings, check_format_info): Refer to ISO C
or ISO C89 instead of ANSI C.
* c-decl.c (grokdeclarator, xref_tag, finish_struct,
build_enumerator, do_case): Likewise.
* c-lex.c (parse_float, yylex): Likewise.
* c-parse.in: Likewise.
* c-typeck.c (common_type, build_array_ref, build_binary_op,
build_unary_op, pedantic_lvalue_warning, build_conditional_expr,
build_c_cast, convert_for_assignment, set_init_index,
set_init_label, c_expand_start_case): Likewise.
* toplev.c (documented_lang_options, display_help): Likewise.
From-SVN: r35576
2000-08-09 01:19:11 +02:00
|
|
|
|
pedwarn ("ISO C forbids qualified function types");
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
if (type_quals)
|
|
|
|
|
type = c_build_qualified_type (type, type_quals);
|
|
|
|
|
type_quals = TYPE_UNQUALIFIED;
|
1992-03-23 03:07:53 +01:00
|
|
|
|
size_varies = 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
type = build_pointer_type (type);
|
|
|
|
|
|
|
|
|
|
/* Process a list of type modifier keywords
|
|
|
|
|
(such as const or volatile) that were given inside the `*'. */
|
|
|
|
|
|
|
|
|
|
if (TREE_TYPE (declarator))
|
|
|
|
|
{
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree typemodlist;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
int erred = 0;
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
|
|
|
|
|
constp = 0;
|
|
|
|
|
volatilep = 0;
|
|
|
|
|
restrictp = 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
for (typemodlist = TREE_TYPE (declarator); typemodlist;
|
|
|
|
|
typemodlist = TREE_CHAIN (typemodlist))
|
|
|
|
|
{
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
tree qualifier = TREE_VALUE (typemodlist);
|
|
|
|
|
|
Integrated preprocessor.
top level:
* Makefile.in: Remove all references to c-parse.gperf,
c-gperf.h, and c-parse.h. Remove -d from yacc command line
generating c-parse.c. Update dependencies.
* c-parse.gperf, c-gperf.h: Delete.
* c-common.c: Don't define parse_options, cpp_token, yy_cur,
yy_lim, or yy_get_token. Don't define get_directive_line if
USE_CPPLIB.
* c-common.h: Add multiple include guard. Define RID values
for every keyword in C, C++, and Objective C. Put all the
modifiers first.
(struct c_fileinfo, get_fileinfo, dump_time_statistics): New.
* c-decl.c (c_decode_option): Handle -lang-objc here.
(print_lang_identifier): Handle C_IS_RESERVED_WORD case.
(grokdeclarator): Adjust for new RID scheme.
(extract_interface_info): New stub.
* c-lang.c: Don't declare yy_cur or parse_options.
(lang_init_options): Call cpp_init. Don't call
cpp_options_init.
(lang_init): Don't call check_newline if USE_CPPLIB.
* c-lex.c: Don't include c-parse.h. Do include timevar.h.
Elide lots of unnecessary code if USE_CPPLIB. Delete code
rendered unnecessary by new architecture. Move routines not
shared with C++ to c-parse.in. Maintain a local idea of the
line number. Handle C++ as well as C.
[USE_CPPLIB]: Declare and register callbacks for #ident and
for entering/leaving files.
(init_c_lex, c_lex): Are now the entry points to this file.
(check_newline): Break out directive handling to
process_directive.
(read_ucs, is_extended_char, utf8_extend_token): Moved here
from C++ front end.
(readescape, parse_float): Overhaul.
(lex_number, lex_string, lex_charconst): Break out of c_lex
(n'ee yylex).
(get_fileinfo, update_header_times, dump_one_header,
dump_time_statistics): New and/or moved here from C++.
Support per-file data needed by C++ and per-header timing
statistics (C++ only, at the moment).
* c-lex.h: Update prototypes. Add multiple include guard.
* c-tree.h (struct lang_identifier): Add rid_code field.
(C_IS_RESERVED_WORD, C_RID_CODE): New.
* c-parse.in: Include c-pragma.h. Remove unnecesary calls to
reinit_parse_for_function and/or position_after_white_space.
(save_filename, save_lineno): Look ahead before saving.
(label -> identifier ':'): Save file and line before shifting ':'.
(reservedwords): No need to call get_identifier.
(init_parse, finish_parse, yyerror, yylex, yyprint,
make_pointer_declarator): Are now here for C/ObjC.
(rid_to_yy): Conversion table from RID constants to Yacc codes.
* c-pragma.c: Rewrite parsing logic to fit with cpplib's
#pragma registry. Provide dummy implementation of that
interface if !USE_CPPLIB.
* c-pragma.h: Update to match.
* flags.h: Add multiple include guard.
(flag_detailed_statistics): Moved here from C++.
* toplev.c: Define flag_detailed_statistics.
* gcc.c (C specs): Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* timevar.def (TV_CPP, TV_LEX): New.
* timevar.h: Add multiple include guard.
* objc/lang-specs.h: Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* objc/objc-act.c: Don't mention yy_cur or parse_options.
Initialize cpplib properly. Force lineno to 0 after first
call to check_newline. Don't handle -lang-objc here.
Move forget_protocol_qualifiers and remember_protocol_qualifiers here.
cp:
* Make-lang.in, Makefile.in: Remove all references to input.c,
gxx.gperf, and hash.h. Add ../c-lex.o to C_OBJS.
* gxx.gperf, hash.h, input.c: Delete.
* lang-specs.h: Pass -lang-c++ to cc1plus so cpplib is
initialized properly.
* class.c (fixup_pending_inline): Take a tree, not a
struct pending_inline *. All callers changed.
(init_class_processing): Set RID_PUBLIC, RID_PRIVATE,
RID_PROTECTED entries in ridpointers[] array here.
* decl.c (duplicate_decls): Do not refer to struct
pending_inline.
(record_builtin_type, init_decl_processing): Use RID_MAX not
CP_RID_MAX.
(grokdeclarator): Use C_IS_RESERVED_WORD.
* decl2.c (lang_decode_option): Ignore -lang-c++ for sake of
cpplib.
(grok_x_components): Do not inspect pending_inlines chain.
* cp-tree.h (struct lang_identifier): Add rid_code entry.
(C_IS_RESERVED_WORD, C_RID_CODE, C_RID_YYCODE): New.
(flag_no_gnu_keywords, flag_operator_names, rid_to_yy): Declare.
(DEFARG_LENGTH, struct pending_inline, TIME_IDENTIFIER_TIME,
TIME_IDENTIFIER_FILEINFO): Kill.
Update prototypes.
* lex.h: Expunge cp_rid. Rewrite RIDBIT macros to use just a
single 32-bit word.
* parse.y: Call do_pending_inlines unconditionally.
reinit_parse_for_method is now snarf_method. fn.defpen is no
longer necessary. Remove unnecessary <itype> annotation on
SCOPE. Do not refer to end_of_file or struct pending_inline.
* semantics.c (begin_inline_definitions): Call
do_pending_inlines unconditionally.
* lex.c: Remove all code now shared with C front end.
Initialize cpplib properly if USE_CPPLIB. Put reserved words
into the get_identifier table. Rewrite pragma handling to
work with the registry. Move code to save tokens for later
processing to spew.c.
* spew.c: Rewrite everything in terms of token streams instead
of text. Move routines here from lex.c / input.c as
appropriate. GC-mark trees hanging off the pending inlines
chain.
testsuite:
* g++.old-deja/g++.benjamin/13478.C: Put meaningful tags on
ERROR markers.
* g++.old-deja/g++.brendan/crash8.C: Move ERROR marker up one line.
* gcc.dg/c99-array-nonobj-1.c: Don't expect func[] cases to fail.
* gcc.dg/wtr-label-1.c: Don't use unconstrained .* in error regexps.
* gcc.dg/wtr-suffix-1.c: Correct error regexps.
* gcc.dg/cpp/unc1.c, gcc.dg/cpp/unc2.c, gcc.dg/cpp/unc3.c:
Preprocess only.
* gcc.dg/cpp/unc4.c: Adjust line number in dg-error line.
* gcc.dg/noncompile/const-ll-1.c: Generalize error regexp.
From-SVN: r36216
2000-09-07 02:37:14 +02:00
|
|
|
|
if (C_IS_RESERVED_WORD (qualifier))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
Integrated preprocessor.
top level:
* Makefile.in: Remove all references to c-parse.gperf,
c-gperf.h, and c-parse.h. Remove -d from yacc command line
generating c-parse.c. Update dependencies.
* c-parse.gperf, c-gperf.h: Delete.
* c-common.c: Don't define parse_options, cpp_token, yy_cur,
yy_lim, or yy_get_token. Don't define get_directive_line if
USE_CPPLIB.
* c-common.h: Add multiple include guard. Define RID values
for every keyword in C, C++, and Objective C. Put all the
modifiers first.
(struct c_fileinfo, get_fileinfo, dump_time_statistics): New.
* c-decl.c (c_decode_option): Handle -lang-objc here.
(print_lang_identifier): Handle C_IS_RESERVED_WORD case.
(grokdeclarator): Adjust for new RID scheme.
(extract_interface_info): New stub.
* c-lang.c: Don't declare yy_cur or parse_options.
(lang_init_options): Call cpp_init. Don't call
cpp_options_init.
(lang_init): Don't call check_newline if USE_CPPLIB.
* c-lex.c: Don't include c-parse.h. Do include timevar.h.
Elide lots of unnecessary code if USE_CPPLIB. Delete code
rendered unnecessary by new architecture. Move routines not
shared with C++ to c-parse.in. Maintain a local idea of the
line number. Handle C++ as well as C.
[USE_CPPLIB]: Declare and register callbacks for #ident and
for entering/leaving files.
(init_c_lex, c_lex): Are now the entry points to this file.
(check_newline): Break out directive handling to
process_directive.
(read_ucs, is_extended_char, utf8_extend_token): Moved here
from C++ front end.
(readescape, parse_float): Overhaul.
(lex_number, lex_string, lex_charconst): Break out of c_lex
(n'ee yylex).
(get_fileinfo, update_header_times, dump_one_header,
dump_time_statistics): New and/or moved here from C++.
Support per-file data needed by C++ and per-header timing
statistics (C++ only, at the moment).
* c-lex.h: Update prototypes. Add multiple include guard.
* c-tree.h (struct lang_identifier): Add rid_code field.
(C_IS_RESERVED_WORD, C_RID_CODE): New.
* c-parse.in: Include c-pragma.h. Remove unnecesary calls to
reinit_parse_for_function and/or position_after_white_space.
(save_filename, save_lineno): Look ahead before saving.
(label -> identifier ':'): Save file and line before shifting ':'.
(reservedwords): No need to call get_identifier.
(init_parse, finish_parse, yyerror, yylex, yyprint,
make_pointer_declarator): Are now here for C/ObjC.
(rid_to_yy): Conversion table from RID constants to Yacc codes.
* c-pragma.c: Rewrite parsing logic to fit with cpplib's
#pragma registry. Provide dummy implementation of that
interface if !USE_CPPLIB.
* c-pragma.h: Update to match.
* flags.h: Add multiple include guard.
(flag_detailed_statistics): Moved here from C++.
* toplev.c: Define flag_detailed_statistics.
* gcc.c (C specs): Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* timevar.def (TV_CPP, TV_LEX): New.
* timevar.h: Add multiple include guard.
* objc/lang-specs.h: Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* objc/objc-act.c: Don't mention yy_cur or parse_options.
Initialize cpplib properly. Force lineno to 0 after first
call to check_newline. Don't handle -lang-objc here.
Move forget_protocol_qualifiers and remember_protocol_qualifiers here.
cp:
* Make-lang.in, Makefile.in: Remove all references to input.c,
gxx.gperf, and hash.h. Add ../c-lex.o to C_OBJS.
* gxx.gperf, hash.h, input.c: Delete.
* lang-specs.h: Pass -lang-c++ to cc1plus so cpplib is
initialized properly.
* class.c (fixup_pending_inline): Take a tree, not a
struct pending_inline *. All callers changed.
(init_class_processing): Set RID_PUBLIC, RID_PRIVATE,
RID_PROTECTED entries in ridpointers[] array here.
* decl.c (duplicate_decls): Do not refer to struct
pending_inline.
(record_builtin_type, init_decl_processing): Use RID_MAX not
CP_RID_MAX.
(grokdeclarator): Use C_IS_RESERVED_WORD.
* decl2.c (lang_decode_option): Ignore -lang-c++ for sake of
cpplib.
(grok_x_components): Do not inspect pending_inlines chain.
* cp-tree.h (struct lang_identifier): Add rid_code entry.
(C_IS_RESERVED_WORD, C_RID_CODE, C_RID_YYCODE): New.
(flag_no_gnu_keywords, flag_operator_names, rid_to_yy): Declare.
(DEFARG_LENGTH, struct pending_inline, TIME_IDENTIFIER_TIME,
TIME_IDENTIFIER_FILEINFO): Kill.
Update prototypes.
* lex.h: Expunge cp_rid. Rewrite RIDBIT macros to use just a
single 32-bit word.
* parse.y: Call do_pending_inlines unconditionally.
reinit_parse_for_method is now snarf_method. fn.defpen is no
longer necessary. Remove unnecessary <itype> annotation on
SCOPE. Do not refer to end_of_file or struct pending_inline.
* semantics.c (begin_inline_definitions): Call
do_pending_inlines unconditionally.
* lex.c: Remove all code now shared with C front end.
Initialize cpplib properly if USE_CPPLIB. Put reserved words
into the get_identifier table. Rewrite pragma handling to
work with the registry. Move code to save tokens for later
processing to spew.c.
* spew.c: Rewrite everything in terms of token streams instead
of text. Move routines here from lex.c / input.c as
appropriate. GC-mark trees hanging off the pending inlines
chain.
testsuite:
* g++.old-deja/g++.benjamin/13478.C: Put meaningful tags on
ERROR markers.
* g++.old-deja/g++.brendan/crash8.C: Move ERROR marker up one line.
* gcc.dg/c99-array-nonobj-1.c: Don't expect func[] cases to fail.
* gcc.dg/wtr-label-1.c: Don't use unconstrained .* in error regexps.
* gcc.dg/wtr-suffix-1.c: Correct error regexps.
* gcc.dg/cpp/unc1.c, gcc.dg/cpp/unc2.c, gcc.dg/cpp/unc3.c:
Preprocess only.
* gcc.dg/cpp/unc4.c: Adjust line number in dg-error line.
* gcc.dg/noncompile/const-ll-1.c: Generalize error regexp.
From-SVN: r36216
2000-09-07 02:37:14 +02:00
|
|
|
|
if (C_RID_CODE (qualifier) == RID_CONST)
|
|
|
|
|
constp++;
|
|
|
|
|
else if (C_RID_CODE (qualifier) == RID_VOLATILE)
|
|
|
|
|
volatilep++;
|
|
|
|
|
else if (C_RID_CODE (qualifier) == RID_RESTRICT)
|
|
|
|
|
restrictp++;
|
|
|
|
|
else
|
|
|
|
|
erred++;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
Integrated preprocessor.
top level:
* Makefile.in: Remove all references to c-parse.gperf,
c-gperf.h, and c-parse.h. Remove -d from yacc command line
generating c-parse.c. Update dependencies.
* c-parse.gperf, c-gperf.h: Delete.
* c-common.c: Don't define parse_options, cpp_token, yy_cur,
yy_lim, or yy_get_token. Don't define get_directive_line if
USE_CPPLIB.
* c-common.h: Add multiple include guard. Define RID values
for every keyword in C, C++, and Objective C. Put all the
modifiers first.
(struct c_fileinfo, get_fileinfo, dump_time_statistics): New.
* c-decl.c (c_decode_option): Handle -lang-objc here.
(print_lang_identifier): Handle C_IS_RESERVED_WORD case.
(grokdeclarator): Adjust for new RID scheme.
(extract_interface_info): New stub.
* c-lang.c: Don't declare yy_cur or parse_options.
(lang_init_options): Call cpp_init. Don't call
cpp_options_init.
(lang_init): Don't call check_newline if USE_CPPLIB.
* c-lex.c: Don't include c-parse.h. Do include timevar.h.
Elide lots of unnecessary code if USE_CPPLIB. Delete code
rendered unnecessary by new architecture. Move routines not
shared with C++ to c-parse.in. Maintain a local idea of the
line number. Handle C++ as well as C.
[USE_CPPLIB]: Declare and register callbacks for #ident and
for entering/leaving files.
(init_c_lex, c_lex): Are now the entry points to this file.
(check_newline): Break out directive handling to
process_directive.
(read_ucs, is_extended_char, utf8_extend_token): Moved here
from C++ front end.
(readescape, parse_float): Overhaul.
(lex_number, lex_string, lex_charconst): Break out of c_lex
(n'ee yylex).
(get_fileinfo, update_header_times, dump_one_header,
dump_time_statistics): New and/or moved here from C++.
Support per-file data needed by C++ and per-header timing
statistics (C++ only, at the moment).
* c-lex.h: Update prototypes. Add multiple include guard.
* c-tree.h (struct lang_identifier): Add rid_code field.
(C_IS_RESERVED_WORD, C_RID_CODE): New.
* c-parse.in: Include c-pragma.h. Remove unnecesary calls to
reinit_parse_for_function and/or position_after_white_space.
(save_filename, save_lineno): Look ahead before saving.
(label -> identifier ':'): Save file and line before shifting ':'.
(reservedwords): No need to call get_identifier.
(init_parse, finish_parse, yyerror, yylex, yyprint,
make_pointer_declarator): Are now here for C/ObjC.
(rid_to_yy): Conversion table from RID constants to Yacc codes.
* c-pragma.c: Rewrite parsing logic to fit with cpplib's
#pragma registry. Provide dummy implementation of that
interface if !USE_CPPLIB.
* c-pragma.h: Update to match.
* flags.h: Add multiple include guard.
(flag_detailed_statistics): Moved here from C++.
* toplev.c: Define flag_detailed_statistics.
* gcc.c (C specs): Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* timevar.def (TV_CPP, TV_LEX): New.
* timevar.h: Add multiple include guard.
* objc/lang-specs.h: Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* objc/objc-act.c: Don't mention yy_cur or parse_options.
Initialize cpplib properly. Force lineno to 0 after first
call to check_newline. Don't handle -lang-objc here.
Move forget_protocol_qualifiers and remember_protocol_qualifiers here.
cp:
* Make-lang.in, Makefile.in: Remove all references to input.c,
gxx.gperf, and hash.h. Add ../c-lex.o to C_OBJS.
* gxx.gperf, hash.h, input.c: Delete.
* lang-specs.h: Pass -lang-c++ to cc1plus so cpplib is
initialized properly.
* class.c (fixup_pending_inline): Take a tree, not a
struct pending_inline *. All callers changed.
(init_class_processing): Set RID_PUBLIC, RID_PRIVATE,
RID_PROTECTED entries in ridpointers[] array here.
* decl.c (duplicate_decls): Do not refer to struct
pending_inline.
(record_builtin_type, init_decl_processing): Use RID_MAX not
CP_RID_MAX.
(grokdeclarator): Use C_IS_RESERVED_WORD.
* decl2.c (lang_decode_option): Ignore -lang-c++ for sake of
cpplib.
(grok_x_components): Do not inspect pending_inlines chain.
* cp-tree.h (struct lang_identifier): Add rid_code entry.
(C_IS_RESERVED_WORD, C_RID_CODE, C_RID_YYCODE): New.
(flag_no_gnu_keywords, flag_operator_names, rid_to_yy): Declare.
(DEFARG_LENGTH, struct pending_inline, TIME_IDENTIFIER_TIME,
TIME_IDENTIFIER_FILEINFO): Kill.
Update prototypes.
* lex.h: Expunge cp_rid. Rewrite RIDBIT macros to use just a
single 32-bit word.
* parse.y: Call do_pending_inlines unconditionally.
reinit_parse_for_method is now snarf_method. fn.defpen is no
longer necessary. Remove unnecessary <itype> annotation on
SCOPE. Do not refer to end_of_file or struct pending_inline.
* semantics.c (begin_inline_definitions): Call
do_pending_inlines unconditionally.
* lex.c: Remove all code now shared with C front end.
Initialize cpplib properly if USE_CPPLIB. Put reserved words
into the get_identifier table. Rewrite pragma handling to
work with the registry. Move code to save tokens for later
processing to spew.c.
* spew.c: Rewrite everything in terms of token streams instead
of text. Move routines here from lex.c / input.c as
appropriate. GC-mark trees hanging off the pending inlines
chain.
testsuite:
* g++.old-deja/g++.benjamin/13478.C: Put meaningful tags on
ERROR markers.
* g++.old-deja/g++.brendan/crash8.C: Move ERROR marker up one line.
* gcc.dg/c99-array-nonobj-1.c: Don't expect func[] cases to fail.
* gcc.dg/wtr-label-1.c: Don't use unconstrained .* in error regexps.
* gcc.dg/wtr-suffix-1.c: Correct error regexps.
* gcc.dg/cpp/unc1.c, gcc.dg/cpp/unc2.c, gcc.dg/cpp/unc3.c:
Preprocess only.
* gcc.dg/cpp/unc4.c: Adjust line number in dg-error line.
* gcc.dg/noncompile/const-ll-1.c: Generalize error regexp.
From-SVN: r36216
2000-09-07 02:37:14 +02:00
|
|
|
|
else
|
|
|
|
|
erred++;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
Integrated preprocessor.
top level:
* Makefile.in: Remove all references to c-parse.gperf,
c-gperf.h, and c-parse.h. Remove -d from yacc command line
generating c-parse.c. Update dependencies.
* c-parse.gperf, c-gperf.h: Delete.
* c-common.c: Don't define parse_options, cpp_token, yy_cur,
yy_lim, or yy_get_token. Don't define get_directive_line if
USE_CPPLIB.
* c-common.h: Add multiple include guard. Define RID values
for every keyword in C, C++, and Objective C. Put all the
modifiers first.
(struct c_fileinfo, get_fileinfo, dump_time_statistics): New.
* c-decl.c (c_decode_option): Handle -lang-objc here.
(print_lang_identifier): Handle C_IS_RESERVED_WORD case.
(grokdeclarator): Adjust for new RID scheme.
(extract_interface_info): New stub.
* c-lang.c: Don't declare yy_cur or parse_options.
(lang_init_options): Call cpp_init. Don't call
cpp_options_init.
(lang_init): Don't call check_newline if USE_CPPLIB.
* c-lex.c: Don't include c-parse.h. Do include timevar.h.
Elide lots of unnecessary code if USE_CPPLIB. Delete code
rendered unnecessary by new architecture. Move routines not
shared with C++ to c-parse.in. Maintain a local idea of the
line number. Handle C++ as well as C.
[USE_CPPLIB]: Declare and register callbacks for #ident and
for entering/leaving files.
(init_c_lex, c_lex): Are now the entry points to this file.
(check_newline): Break out directive handling to
process_directive.
(read_ucs, is_extended_char, utf8_extend_token): Moved here
from C++ front end.
(readescape, parse_float): Overhaul.
(lex_number, lex_string, lex_charconst): Break out of c_lex
(n'ee yylex).
(get_fileinfo, update_header_times, dump_one_header,
dump_time_statistics): New and/or moved here from C++.
Support per-file data needed by C++ and per-header timing
statistics (C++ only, at the moment).
* c-lex.h: Update prototypes. Add multiple include guard.
* c-tree.h (struct lang_identifier): Add rid_code field.
(C_IS_RESERVED_WORD, C_RID_CODE): New.
* c-parse.in: Include c-pragma.h. Remove unnecesary calls to
reinit_parse_for_function and/or position_after_white_space.
(save_filename, save_lineno): Look ahead before saving.
(label -> identifier ':'): Save file and line before shifting ':'.
(reservedwords): No need to call get_identifier.
(init_parse, finish_parse, yyerror, yylex, yyprint,
make_pointer_declarator): Are now here for C/ObjC.
(rid_to_yy): Conversion table from RID constants to Yacc codes.
* c-pragma.c: Rewrite parsing logic to fit with cpplib's
#pragma registry. Provide dummy implementation of that
interface if !USE_CPPLIB.
* c-pragma.h: Update to match.
* flags.h: Add multiple include guard.
(flag_detailed_statistics): Moved here from C++.
* toplev.c: Define flag_detailed_statistics.
* gcc.c (C specs): Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* timevar.def (TV_CPP, TV_LEX): New.
* timevar.h: Add multiple include guard.
* objc/lang-specs.h: Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* objc/objc-act.c: Don't mention yy_cur or parse_options.
Initialize cpplib properly. Force lineno to 0 after first
call to check_newline. Don't handle -lang-objc here.
Move forget_protocol_qualifiers and remember_protocol_qualifiers here.
cp:
* Make-lang.in, Makefile.in: Remove all references to input.c,
gxx.gperf, and hash.h. Add ../c-lex.o to C_OBJS.
* gxx.gperf, hash.h, input.c: Delete.
* lang-specs.h: Pass -lang-c++ to cc1plus so cpplib is
initialized properly.
* class.c (fixup_pending_inline): Take a tree, not a
struct pending_inline *. All callers changed.
(init_class_processing): Set RID_PUBLIC, RID_PRIVATE,
RID_PROTECTED entries in ridpointers[] array here.
* decl.c (duplicate_decls): Do not refer to struct
pending_inline.
(record_builtin_type, init_decl_processing): Use RID_MAX not
CP_RID_MAX.
(grokdeclarator): Use C_IS_RESERVED_WORD.
* decl2.c (lang_decode_option): Ignore -lang-c++ for sake of
cpplib.
(grok_x_components): Do not inspect pending_inlines chain.
* cp-tree.h (struct lang_identifier): Add rid_code entry.
(C_IS_RESERVED_WORD, C_RID_CODE, C_RID_YYCODE): New.
(flag_no_gnu_keywords, flag_operator_names, rid_to_yy): Declare.
(DEFARG_LENGTH, struct pending_inline, TIME_IDENTIFIER_TIME,
TIME_IDENTIFIER_FILEINFO): Kill.
Update prototypes.
* lex.h: Expunge cp_rid. Rewrite RIDBIT macros to use just a
single 32-bit word.
* parse.y: Call do_pending_inlines unconditionally.
reinit_parse_for_method is now snarf_method. fn.defpen is no
longer necessary. Remove unnecessary <itype> annotation on
SCOPE. Do not refer to end_of_file or struct pending_inline.
* semantics.c (begin_inline_definitions): Call
do_pending_inlines unconditionally.
* lex.c: Remove all code now shared with C front end.
Initialize cpplib properly if USE_CPPLIB. Put reserved words
into the get_identifier table. Rewrite pragma handling to
work with the registry. Move code to save tokens for later
processing to spew.c.
* spew.c: Rewrite everything in terms of token streams instead
of text. Move routines here from lex.c / input.c as
appropriate. GC-mark trees hanging off the pending inlines
chain.
testsuite:
* g++.old-deja/g++.benjamin/13478.C: Put meaningful tags on
ERROR markers.
* g++.old-deja/g++.brendan/crash8.C: Move ERROR marker up one line.
* gcc.dg/c99-array-nonobj-1.c: Don't expect func[] cases to fail.
* gcc.dg/wtr-label-1.c: Don't use unconstrained .* in error regexps.
* gcc.dg/wtr-suffix-1.c: Correct error regexps.
* gcc.dg/cpp/unc1.c, gcc.dg/cpp/unc2.c, gcc.dg/cpp/unc3.c:
Preprocess only.
* gcc.dg/cpp/unc4.c: Adjust line number in dg-error line.
* gcc.dg/noncompile/const-ll-1.c: Generalize error regexp.
From-SVN: r36216
2000-09-07 02:37:14 +02:00
|
|
|
|
|
|
|
|
|
if (erred)
|
|
|
|
|
error ("invalid type modifier within pointer declarator");
|
2000-06-26 18:42:23 +02:00
|
|
|
|
if (constp > 1 && ! flag_isoc99)
|
1992-07-06 00:22:43 +02:00
|
|
|
|
pedwarn ("duplicate `const'");
|
2000-06-26 18:42:23 +02:00
|
|
|
|
if (volatilep > 1 && ! flag_isoc99)
|
1992-07-06 00:22:43 +02:00
|
|
|
|
pedwarn ("duplicate `volatile'");
|
2000-06-26 18:42:23 +02:00
|
|
|
|
if (restrictp > 1 && ! flag_isoc99)
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
pedwarn ("duplicate `restrict'");
|
|
|
|
|
|
|
|
|
|
type_quals = ((constp ? TYPE_QUAL_CONST : 0)
|
|
|
|
|
| (restrictp ? TYPE_QUAL_RESTRICT : 0)
|
|
|
|
|
| (volatilep ? TYPE_QUAL_VOLATILE : 0));
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
declarator = TREE_OPERAND (declarator, 0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
abort ();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Now TYPE has the actual type. */
|
|
|
|
|
|
1997-11-02 22:19:36 +01:00
|
|
|
|
/* Did array size calculations overflow? */
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (type) == ARRAY_TYPE
|
tree.h (COMPLETE_TYPE_P): New macro.
gcc
* tree.h (COMPLETE_TYPE_P): New macro.
(COMPLETE_OR_VOID_TYPE_P): New macro.
(COMPLETE_OR_UNBOUND_ARRAY_TYPE_P): New macro.
* stor-layout.c (layout_type, case VOID_TYPE): Don't set TYPE_SIZE.
* c-aux-info.c (gen_type): Use them.
* c-common.c (c_expand_expr_stmt): Likewise.
* c-decl.c (poplevel, pushdecl, start_decl, finish_decl,
grokdeclarator, grokparms, finish_struct, start_function,
store_parm_decls, combine_parm_decls): Likewise.
* c-parse.y (cast_expr): Likewise.
* c-typeck.c (require_complete_type, c_sizeof, c_sizeof_nowarn,
c_size_in_bytes, c_alignof, build_component_ref,
build_indirect_ref, build_array_ref, convert_arguments,
build_binary_op, pointer_diff, build_unary_op, digest_init: Likewise.
* calls.c (initialize_argument_information): Likewise.
* convert.c (convert_to_integer): Likewise.
* dbxout.c (dbxout_typedefs, dbxout_type, dbxout_symbol): Likewise.
* dwarfout.c (location_or_const_value_attribute,
output_enumeration_type_die, output_structure_type_die,
output_union_type_die, output_type): Likewise.
* expr.c (safe_from_p, expand_expr): Likewise.
* function.c (assign_parms): Likewise.
* sdbout.c (sdbout_symbol, sdbout_one_type): Likewise.
* tree.c (build_array_type, build_function_type,
build_method_type, build_offset_type, build_complex_type): Likewise.
* c-parse.c, c-parse.h: Regenerated.
gcc/cp
* typeck.c (require_complete_type, complete_type,
complete_type_or_else, c_sizeof, c_sizeof_nowarn,
build_array_ref, convert_arguments, pointer_diff,
build_x_unary_op, build_unary_op, build_c_cast,
build_modify_expr): Use COMPLETE_TYPE_P etc.
* call.c (is_complete, convert_like_real,
build_new_method_call): Likewise.
* class.c (build_vbase_pointer_fields, check_bases,
build_base_field, finish_struct_1, pushclass): Likewise.
* cvt.c (cp_convert_to_pointer, convert_to_void): Likewise.
* decl.c (maybe_process_template_type_declaration, pushtag,
pushdecl, redeclaration_error_message, start_decl, start_decl_1,
layout_var_decl, check_initializer, cp_finish_decl,
grokdeclarator, require_complete_types_for_parms,
grok_op_properties, xref_tag, xref_basetypes,
check_function_type): Likewise.
* decl2.c (check_classfn, reparse_absdcl_as_casts): Likewise.
* friend.c (do_friend): Likewise.
* init.c (build_offset_ref): Likewise.
* parse.y (structsp): Likewise.
* pt.c (maybe_process_partial_specialization,
tsubst_friend_function, instantiate_class_template, tsubst,
do_type_instantiation, instantiate_pending_templates): Likewise.
* repo.c (repo_get_id): Likewise.
* rtti.c (build_typeid, get_typeid, build_dynamic_cast_1,
synthesize_tinfo_var, emit_support_tinfos): Likewise.
* search.c (lookup_fnfields_1, lookup_conversions): Likewise.
* semantics.c (begin_class_definition): Likewise.
* tree.c (build_cplus_method_type): Likewise.
* typeck2.c (digest_init, build_functional_cast,
add_exception_specifier): Likewise.
* parse.h, parse.c: Regenerated.
From-SVN: r32671
2000-03-21 19:10:48 +01:00
|
|
|
|
&& COMPLETE_TYPE_P (type)
|
1997-11-02 22:19:36 +01:00
|
|
|
|
&& TREE_OVERFLOW (TYPE_SIZE (type)))
|
2000-12-29 09:03:56 +01:00
|
|
|
|
{
|
|
|
|
|
error ("size of array `%s' is too large", name);
|
ChangeLog.2, [...]: Fix spelling errors and typos.
* ChangeLog.2, ChangeLog.3, ChangeLog.4, FSFChangeLog.10,
FSFChangeLog.11, c-common.c, c-common.def, c-common.h, c-decl.c,
c-dump.c, c-typeck.c, except.c, sdbout.c, simplify-rtx.c,
timevar.h, tree.h, varasm.c: Fix spelling errors and typos.
From-SVN: r46621
2001-10-30 00:01:45 +01:00
|
|
|
|
/* If we proceed with the array type as it is, we'll eventually
|
2000-12-29 09:03:56 +01:00
|
|
|
|
crash in tree_low_cst(). */
|
|
|
|
|
type = error_mark_node;
|
|
|
|
|
}
|
1997-11-02 22:19:36 +01:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* If this is declaring a typedef name, return a TYPE_DECL. */
|
|
|
|
|
|
|
|
|
|
if (specbits & (1 << (int) RID_TYPEDEF))
|
|
|
|
|
{
|
|
|
|
|
tree decl;
|
|
|
|
|
/* Note that the grammar rejects storage classes
|
|
|
|
|
in typenames, fields or parameters */
|
|
|
|
|
if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
&& type_quals)
|
c-common.c (combine_strings, [...]): Refer to ISO C or ISO C89 instead of ANSI C.
* c-common.c (combine_strings, check_format_info): Refer to ISO C
or ISO C89 instead of ANSI C.
* c-decl.c (grokdeclarator, xref_tag, finish_struct,
build_enumerator, do_case): Likewise.
* c-lex.c (parse_float, yylex): Likewise.
* c-parse.in: Likewise.
* c-typeck.c (common_type, build_array_ref, build_binary_op,
build_unary_op, pedantic_lvalue_warning, build_conditional_expr,
build_c_cast, convert_for_assignment, set_init_index,
set_init_label, c_expand_start_case): Likewise.
* toplev.c (documented_lang_options, display_help): Likewise.
From-SVN: r35576
2000-08-09 01:19:11 +02:00
|
|
|
|
pedwarn ("ISO C forbids qualified function types");
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
if (type_quals)
|
|
|
|
|
type = c_build_qualified_type (type, type_quals);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
decl = build_decl (TYPE_DECL, declarator, type);
|
|
|
|
|
if ((specbits & (1 << (int) RID_SIGNED))
|
|
|
|
|
|| (typedef_decl && C_TYPEDEF_EXPLICITLY_SIGNED (typedef_decl)))
|
|
|
|
|
C_TYPEDEF_EXPLICITLY_SIGNED (decl) = 1;
|
Table-driven attributes.
* c-decl.c, config/alpha/alpha.c, config/arc/arc.c,
config/arm/arm.c, config/arm/pe.c, config/avr/avr.c,
config/avr/avr.h, config/d30v/d30v.h, config/fr30/fr30.h,
config/h8300/h8300.c, config/i386/cygwin.h, config/i386/winnt.c,
config/m32r/m32r.c, config/mcore/mcore.c, config/sh/sh.c,
config/stormy16/stormy16.h, config/v850/v850.c, doc/c-tree.texi,
doc/tm.texi, ggc-common.c, integrate.c, print-tree.c, tree.c,
tree.h: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* tree.h (struct tree_decl): Change machine_attributes to
attributes.
* doc/c-tree.texi: Document that all attributes are now attached
to decls and types.
* c-common.c (add_attribute, attrtab, attrtab_idx,
default_valid_lang_attribute, valid_lang_attribute): Remove.
(attribute_tables, attributes_initialized,
c_common_attribute_table, default_lang_attribute_table): New
variables.
(handle_packed_attribute, handle_nocommon_attribute,
handle_common_attribute, handle_noreturn_attribute,
handle_unused_attribute, handle_const_attribute,
handle_transparent_union_attribute, handle_constructor_attribute,
handle_destructor_attribute, handle_mode_attribute,
handle_section_attribute, handle_aligned_attribute,
handle_weak_attribute, handle_alias_attribute,
handle_no_instrument_function_attribute,
handle_no_check_memory_usage_attribute, handle_malloc_attribute,
handle_no_limit_stack_attribute, handle_pure_attribute): New
functions.
(init_attributes, decl_attributes): Rewrite to implement
table-driven attributes.
* c-common.h (enum attribute_flags): Move to tree.h.
* c-format.c (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Rename to
handle_format_attribute and handle_format_arg_attribute. Update
for table-driven attributes.
* c-common.h (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Remove prototypes.
(handle_format_attribute, handle_format_arg_attribute): Add
prototypes.
* c-decl.c (grokdeclarator): Handle attributes nested inside
declarators.
* c-parse.in (setattrs, maybe_setattrs): Remove.
(maybe_type_quals_setattrs): Rename to maybe_type_quals_attrs.
Update to handle nested attributes properly.
(maybe_resetattrs, after_type_declarator,
parm_declarator_nostarttypename, notype_declarator, absdcl1_noea,
absdcl1_ea, direct_absdcl1): Update to handle nested attributes
properly.
(make_pointer_declarator): Update to handle nested attributes
properly.
* doc/extend.texi: Update documentation of limits of attributes
syntax. Warn about problems with attribute semantics in C++.
* target.h (struct target): Remove valid_decl_attribute and
valid_type_attribute. Add attribute_table and
function_attribute_inlinable_p.
* target-def.h (TARGET_VALID_DECL_ATTRIBUTE,
TARGET_VALID_TYPE_ATTRIBUTE): Remove.
(TARGET_ATTRIBUTE_TABLE, TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P):
Add.
(TARGET_INITIALIZER): Update.
* integrate.c (FUNCTION_ATTRIBUTE_INLINABLE_P): Remove default
definition.
(function_attribute_inlinable_p): New function. Check for the
presence of any machine attributes before using
targetm.function_attribute_inlinable_p.
(function_cannot_inline_p): Update.
* Makefile.in (integrate.o): Update dependencies.
* doc/tm.texi: Update documentation of target attributes and
example definition of TARGET_VALID_TYPE_ATTRIBUTE.
* tree.c (default_valid_attribute_p, valid_machine_attribute):
Remove.
(default_target_attribute_table,
default_function_attribute_inlinable_p): New.
(lookup_attribute): Update comment to clarify handling of multiple
attributes with the same name.
(merge_attributes, attribute_list_contained): Allow multiple
attributes with the same name but different arguments to appear in
the same attribute list.
* tree.h (default_valid_attribute_p): Remove prototype.
(struct attribute_spec): New.
(default_target_attribute_table): Declare.
(enum attribute_flags): Move from c-common.h. Add
ATTR_FLAG_TYPE_IN_PLACE.
(default_function_attribute_inlinable_p): Declare.
* config/alpha/alpha.c (vms_valid_decl_attribute_p): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(vms_attribute_table): New.
* config/arc/arc.c (arc_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arc_attribute_table, arc_handle_interrupt_attribute): New.
* config/arm/arm.c (arm_valid_type_attribute_p,
arm_valid_decl_attribute_p, arm_pe_valid_decl_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arm_attribute_table, arm_handle_fndecl_attribute,
arm_handle_isr_attribute): New.
* config/avr/avr.c (avr_valid_type_attribute,
avr_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE, TARGET_VALID_TYPE_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(avr_attribute_table, avr_handle_progmem_attribute,
avr_handle_fndecl_attribute): New.
* config/c4x/c4x.c (c4x_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(c4x_attribute_table, c4x_handle_fntype_attribute): New.
* config/h8300/h8300.c (h8300_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(h8300_attribute_table, h8300_handle_fndecl_attribute,
h8300_handle_eightbit_data_attribute,
h8300_handle_tiny_data_attribute): New.
* config/i386/i386-protos.h (ix86_valid_type_attribute_p,
i386_pe_valid_decl_attribute_p, i386_pe_valid_type_attribute_p):
Remove prototypes.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New
declarations.
* config/i386/i386.c (ix86_valid_type_attribute_p: Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ix86_attribute_table, ix86_handle_cdecl_attribute,
ix86_handle_regparm_attribute): New.
* config/i386/winnt.c (i386_pe_valid_decl_attribute_p,
i386_pe_valid_type_attribute_p): Remove.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New.
* config/ia64/ia64.c (ia64_valid_type_attribute): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ia64_attribute_table): New.
* config/m32r/m32r.c (m32r_valid_decl_attribute, interrupt_ident1,
interrupt_ident2, model_ident1, model_ident2): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(init_idents): Update.
(m32r_attribute_table, m32r_handle_model_attribute): New.
* config/m68hc11/m68hc11.c (m68hc11_valid_type_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(m68hc11_attribute_table, m68hc11_handle_fntype_attribute): New.
* config/mcore/mcore.c (mcore_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(mcore_attribute_table, mcore_handle_naked_attribute): New.
* config/ns32k/ns32k.c (ns32k_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ns32k_attribute_table, ns32k_handle_fntype_attribute): New.
* config/rs6000/rs6000.c (rs6000_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(rs6000_attribute_table, rs6000_handle_longcall_attribute): New.
* config/sh/sh.c (sh_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(sh_attribute_table, sh_handle_interrupt_handler_attribute,
sh_handle_sp_switch_attribute, sh_handle_trap_exit_attribute):
New.
* config/stormy16/stormy16.c (stormy16_valid_type_attribute):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define
(TARGET_ATTRIBUTE_TABLE): Define.
(stormy16_attribute_table, stormy16_handle_interrupt_attribute):
New.
* config/v850/v850.c (v850_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(v850_attribute_table, v850_handle_interrupt_attribute,
v850_handle_data_area_attribute): New.
* config/v850/v850-c.c (mark_current_function_as_interrupt):
Return void. Call decl_attributes instead of
valid_machine_attribute.
cp:
Table-driven attributes.
* decl.c: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* decl2.c (cplus_decl_attributes): Only take one attributes
parameter.
* cp-tree.c (cplus_decl_attributes): Update prototype.
* class.c (finish_struct), decl.c (start_decl, start_function),
decl2.c (grokfield), friend.c (do_friend), parse.y
(parse_bitfield): Update calls to cplus_decl_attributes.
* decl.c (grokdeclarator): Take a pointer to a single ordinary
attribute list.
* decl.h (grokdeclarator): Update prototype.
* decl2.c (grokfield): Take a single ordinary attribute list.
* friend.c (do_friend): Likewise.
* decl.c (shadow_tag, groktypename, start_decl,
start_handler_parms, grokdeclarator, grokparms, start_function,
start_method), decl2.c (grokfield, grokbitfield, grokoptypename),
parse.y (parse_field, parse_bitfield, component_decl_1), pt.c
(process_template_parm, do_decl_instantiation): Pass single
ordinary attribute lists around.
* decl.c (grokdeclarator): Correct handling of nested attributes.
Revert the patch
1998-10-18 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (grokdeclarator): Embedded attrs bind to the right,
not the left.
.
* cp-tree.h (cp_valid_lang_attribute): Remove declaration
(cp_attribute_table): Declare.
* decl.c (valid_lang_attribute): Don't define.
(lang_attribute_table): Define.
(init_decl_processing): Initialize lang_attribute_table instead of
valid_lang_attribute.
* tree.c (cp_valid_lang_attribute): Remove.
(handle_java_interface_attribute, handle_com_interface_attribute,
handle_init_priority_attribute): New functions.
(cp_attribute_table): New array.
* decl2.c (import_export_class): Don't use
targetm.valid_type_attribute.
testsuite:
Table-driven attributes.
* g++.dg/ext/attrib1.C: New test.
From-SVN: r45718
2001-09-21 03:27:06 +02:00
|
|
|
|
decl_attributes (&decl, returned_attrs, 0);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
return decl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Detect the case of an array type of unspecified size
|
|
|
|
|
which came, as such, direct from a typedef name.
|
|
|
|
|
We must copy the type, so that each identifier gets
|
|
|
|
|
a distinct type, so that each identifier's size can be
|
|
|
|
|
controlled separately by its own initializer. */
|
|
|
|
|
|
|
|
|
|
if (type != 0 && typedef_type != 0
|
2000-09-17 16:37:55 +02:00
|
|
|
|
&& TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type) == 0
|
|
|
|
|
&& TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (typedef_type))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
type = build_array_type (TREE_TYPE (type), 0);
|
1992-03-23 03:07:53 +01:00
|
|
|
|
if (size_varies)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
C_TYPE_VARIABLE_SIZE (type) = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If this is a type name (such as, in a cast or sizeof),
|
|
|
|
|
compute the type and return it now. */
|
|
|
|
|
|
|
|
|
|
if (decl_context == TYPENAME)
|
|
|
|
|
{
|
|
|
|
|
/* Note that the grammar rejects storage classes
|
|
|
|
|
in typenames, fields or parameters */
|
|
|
|
|
if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
&& type_quals)
|
c-common.c (combine_strings, [...]): Refer to ISO C or ISO C89 instead of ANSI C.
* c-common.c (combine_strings, check_format_info): Refer to ISO C
or ISO C89 instead of ANSI C.
* c-decl.c (grokdeclarator, xref_tag, finish_struct,
build_enumerator, do_case): Likewise.
* c-lex.c (parse_float, yylex): Likewise.
* c-parse.in: Likewise.
* c-typeck.c (common_type, build_array_ref, build_binary_op,
build_unary_op, pedantic_lvalue_warning, build_conditional_expr,
build_c_cast, convert_for_assignment, set_init_index,
set_init_label, c_expand_start_case): Likewise.
* toplev.c (documented_lang_options, display_help): Likewise.
From-SVN: r35576
2000-08-09 01:19:11 +02:00
|
|
|
|
pedwarn ("ISO C forbids const or volatile function types");
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
if (type_quals)
|
|
|
|
|
type = c_build_qualified_type (type, type_quals);
|
Table-driven attributes.
* c-decl.c, config/alpha/alpha.c, config/arc/arc.c,
config/arm/arm.c, config/arm/pe.c, config/avr/avr.c,
config/avr/avr.h, config/d30v/d30v.h, config/fr30/fr30.h,
config/h8300/h8300.c, config/i386/cygwin.h, config/i386/winnt.c,
config/m32r/m32r.c, config/mcore/mcore.c, config/sh/sh.c,
config/stormy16/stormy16.h, config/v850/v850.c, doc/c-tree.texi,
doc/tm.texi, ggc-common.c, integrate.c, print-tree.c, tree.c,
tree.h: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* tree.h (struct tree_decl): Change machine_attributes to
attributes.
* doc/c-tree.texi: Document that all attributes are now attached
to decls and types.
* c-common.c (add_attribute, attrtab, attrtab_idx,
default_valid_lang_attribute, valid_lang_attribute): Remove.
(attribute_tables, attributes_initialized,
c_common_attribute_table, default_lang_attribute_table): New
variables.
(handle_packed_attribute, handle_nocommon_attribute,
handle_common_attribute, handle_noreturn_attribute,
handle_unused_attribute, handle_const_attribute,
handle_transparent_union_attribute, handle_constructor_attribute,
handle_destructor_attribute, handle_mode_attribute,
handle_section_attribute, handle_aligned_attribute,
handle_weak_attribute, handle_alias_attribute,
handle_no_instrument_function_attribute,
handle_no_check_memory_usage_attribute, handle_malloc_attribute,
handle_no_limit_stack_attribute, handle_pure_attribute): New
functions.
(init_attributes, decl_attributes): Rewrite to implement
table-driven attributes.
* c-common.h (enum attribute_flags): Move to tree.h.
* c-format.c (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Rename to
handle_format_attribute and handle_format_arg_attribute. Update
for table-driven attributes.
* c-common.h (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Remove prototypes.
(handle_format_attribute, handle_format_arg_attribute): Add
prototypes.
* c-decl.c (grokdeclarator): Handle attributes nested inside
declarators.
* c-parse.in (setattrs, maybe_setattrs): Remove.
(maybe_type_quals_setattrs): Rename to maybe_type_quals_attrs.
Update to handle nested attributes properly.
(maybe_resetattrs, after_type_declarator,
parm_declarator_nostarttypename, notype_declarator, absdcl1_noea,
absdcl1_ea, direct_absdcl1): Update to handle nested attributes
properly.
(make_pointer_declarator): Update to handle nested attributes
properly.
* doc/extend.texi: Update documentation of limits of attributes
syntax. Warn about problems with attribute semantics in C++.
* target.h (struct target): Remove valid_decl_attribute and
valid_type_attribute. Add attribute_table and
function_attribute_inlinable_p.
* target-def.h (TARGET_VALID_DECL_ATTRIBUTE,
TARGET_VALID_TYPE_ATTRIBUTE): Remove.
(TARGET_ATTRIBUTE_TABLE, TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P):
Add.
(TARGET_INITIALIZER): Update.
* integrate.c (FUNCTION_ATTRIBUTE_INLINABLE_P): Remove default
definition.
(function_attribute_inlinable_p): New function. Check for the
presence of any machine attributes before using
targetm.function_attribute_inlinable_p.
(function_cannot_inline_p): Update.
* Makefile.in (integrate.o): Update dependencies.
* doc/tm.texi: Update documentation of target attributes and
example definition of TARGET_VALID_TYPE_ATTRIBUTE.
* tree.c (default_valid_attribute_p, valid_machine_attribute):
Remove.
(default_target_attribute_table,
default_function_attribute_inlinable_p): New.
(lookup_attribute): Update comment to clarify handling of multiple
attributes with the same name.
(merge_attributes, attribute_list_contained): Allow multiple
attributes with the same name but different arguments to appear in
the same attribute list.
* tree.h (default_valid_attribute_p): Remove prototype.
(struct attribute_spec): New.
(default_target_attribute_table): Declare.
(enum attribute_flags): Move from c-common.h. Add
ATTR_FLAG_TYPE_IN_PLACE.
(default_function_attribute_inlinable_p): Declare.
* config/alpha/alpha.c (vms_valid_decl_attribute_p): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(vms_attribute_table): New.
* config/arc/arc.c (arc_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arc_attribute_table, arc_handle_interrupt_attribute): New.
* config/arm/arm.c (arm_valid_type_attribute_p,
arm_valid_decl_attribute_p, arm_pe_valid_decl_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arm_attribute_table, arm_handle_fndecl_attribute,
arm_handle_isr_attribute): New.
* config/avr/avr.c (avr_valid_type_attribute,
avr_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE, TARGET_VALID_TYPE_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(avr_attribute_table, avr_handle_progmem_attribute,
avr_handle_fndecl_attribute): New.
* config/c4x/c4x.c (c4x_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(c4x_attribute_table, c4x_handle_fntype_attribute): New.
* config/h8300/h8300.c (h8300_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(h8300_attribute_table, h8300_handle_fndecl_attribute,
h8300_handle_eightbit_data_attribute,
h8300_handle_tiny_data_attribute): New.
* config/i386/i386-protos.h (ix86_valid_type_attribute_p,
i386_pe_valid_decl_attribute_p, i386_pe_valid_type_attribute_p):
Remove prototypes.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New
declarations.
* config/i386/i386.c (ix86_valid_type_attribute_p: Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ix86_attribute_table, ix86_handle_cdecl_attribute,
ix86_handle_regparm_attribute): New.
* config/i386/winnt.c (i386_pe_valid_decl_attribute_p,
i386_pe_valid_type_attribute_p): Remove.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New.
* config/ia64/ia64.c (ia64_valid_type_attribute): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ia64_attribute_table): New.
* config/m32r/m32r.c (m32r_valid_decl_attribute, interrupt_ident1,
interrupt_ident2, model_ident1, model_ident2): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(init_idents): Update.
(m32r_attribute_table, m32r_handle_model_attribute): New.
* config/m68hc11/m68hc11.c (m68hc11_valid_type_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(m68hc11_attribute_table, m68hc11_handle_fntype_attribute): New.
* config/mcore/mcore.c (mcore_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(mcore_attribute_table, mcore_handle_naked_attribute): New.
* config/ns32k/ns32k.c (ns32k_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ns32k_attribute_table, ns32k_handle_fntype_attribute): New.
* config/rs6000/rs6000.c (rs6000_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(rs6000_attribute_table, rs6000_handle_longcall_attribute): New.
* config/sh/sh.c (sh_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(sh_attribute_table, sh_handle_interrupt_handler_attribute,
sh_handle_sp_switch_attribute, sh_handle_trap_exit_attribute):
New.
* config/stormy16/stormy16.c (stormy16_valid_type_attribute):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define
(TARGET_ATTRIBUTE_TABLE): Define.
(stormy16_attribute_table, stormy16_handle_interrupt_attribute):
New.
* config/v850/v850.c (v850_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(v850_attribute_table, v850_handle_interrupt_attribute,
v850_handle_data_area_attribute): New.
* config/v850/v850-c.c (mark_current_function_as_interrupt):
Return void. Call decl_attributes instead of
valid_machine_attribute.
cp:
Table-driven attributes.
* decl.c: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* decl2.c (cplus_decl_attributes): Only take one attributes
parameter.
* cp-tree.c (cplus_decl_attributes): Update prototype.
* class.c (finish_struct), decl.c (start_decl, start_function),
decl2.c (grokfield), friend.c (do_friend), parse.y
(parse_bitfield): Update calls to cplus_decl_attributes.
* decl.c (grokdeclarator): Take a pointer to a single ordinary
attribute list.
* decl.h (grokdeclarator): Update prototype.
* decl2.c (grokfield): Take a single ordinary attribute list.
* friend.c (do_friend): Likewise.
* decl.c (shadow_tag, groktypename, start_decl,
start_handler_parms, grokdeclarator, grokparms, start_function,
start_method), decl2.c (grokfield, grokbitfield, grokoptypename),
parse.y (parse_field, parse_bitfield, component_decl_1), pt.c
(process_template_parm, do_decl_instantiation): Pass single
ordinary attribute lists around.
* decl.c (grokdeclarator): Correct handling of nested attributes.
Revert the patch
1998-10-18 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (grokdeclarator): Embedded attrs bind to the right,
not the left.
.
* cp-tree.h (cp_valid_lang_attribute): Remove declaration
(cp_attribute_table): Declare.
* decl.c (valid_lang_attribute): Don't define.
(lang_attribute_table): Define.
(init_decl_processing): Initialize lang_attribute_table instead of
valid_lang_attribute.
* tree.c (cp_valid_lang_attribute): Remove.
(handle_java_interface_attribute, handle_com_interface_attribute,
handle_init_priority_attribute): New functions.
(cp_attribute_table): New array.
* decl2.c (import_export_class): Don't use
targetm.valid_type_attribute.
testsuite:
Table-driven attributes.
* g++.dg/ext/attrib1.C: New test.
From-SVN: r45718
2001-09-21 03:27:06 +02:00
|
|
|
|
decl_attributes (&type, returned_attrs, 0);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
|
1993-08-06 03:11:37 +02:00
|
|
|
|
/* Aside from typedefs and type names (handle above),
|
|
|
|
|
`void' at top level (not within pointer)
|
|
|
|
|
is allowed only in public variables.
|
1992-02-13 23:21:26 +01:00
|
|
|
|
We don't complain about parms either, but that is because
|
|
|
|
|
a better error message can be made later. */
|
|
|
|
|
|
2000-06-05 15:16:14 +02:00
|
|
|
|
if (VOID_TYPE_P (type) && decl_context != PARM
|
1993-08-06 03:11:37 +02:00
|
|
|
|
&& ! ((decl_context != FIELD && TREE_CODE (type) != FUNCTION_TYPE)
|
|
|
|
|
&& ((specbits & (1 << (int) RID_EXTERN))
|
2003-07-24 18:59:32 +02:00
|
|
|
|
|| (current_scope == global_scope
|
1993-08-06 03:11:37 +02:00
|
|
|
|
&& !(specbits
|
|
|
|
|
& ((1 << (int) RID_STATIC) | (1 << (int) RID_REGISTER)))))))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
1995-02-11 21:16:04 +01:00
|
|
|
|
error ("variable or field `%s' declared void", name);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
type = integer_type_node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Now create the decl, which may be a VAR_DECL, a PARM_DECL
|
|
|
|
|
or a FUNCTION_DECL, depending on DECL_CONTEXT and TYPE. */
|
|
|
|
|
|
|
|
|
|
{
|
Table-driven attributes.
* c-decl.c, config/alpha/alpha.c, config/arc/arc.c,
config/arm/arm.c, config/arm/pe.c, config/avr/avr.c,
config/avr/avr.h, config/d30v/d30v.h, config/fr30/fr30.h,
config/h8300/h8300.c, config/i386/cygwin.h, config/i386/winnt.c,
config/m32r/m32r.c, config/mcore/mcore.c, config/sh/sh.c,
config/stormy16/stormy16.h, config/v850/v850.c, doc/c-tree.texi,
doc/tm.texi, ggc-common.c, integrate.c, print-tree.c, tree.c,
tree.h: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* tree.h (struct tree_decl): Change machine_attributes to
attributes.
* doc/c-tree.texi: Document that all attributes are now attached
to decls and types.
* c-common.c (add_attribute, attrtab, attrtab_idx,
default_valid_lang_attribute, valid_lang_attribute): Remove.
(attribute_tables, attributes_initialized,
c_common_attribute_table, default_lang_attribute_table): New
variables.
(handle_packed_attribute, handle_nocommon_attribute,
handle_common_attribute, handle_noreturn_attribute,
handle_unused_attribute, handle_const_attribute,
handle_transparent_union_attribute, handle_constructor_attribute,
handle_destructor_attribute, handle_mode_attribute,
handle_section_attribute, handle_aligned_attribute,
handle_weak_attribute, handle_alias_attribute,
handle_no_instrument_function_attribute,
handle_no_check_memory_usage_attribute, handle_malloc_attribute,
handle_no_limit_stack_attribute, handle_pure_attribute): New
functions.
(init_attributes, decl_attributes): Rewrite to implement
table-driven attributes.
* c-common.h (enum attribute_flags): Move to tree.h.
* c-format.c (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Rename to
handle_format_attribute and handle_format_arg_attribute. Update
for table-driven attributes.
* c-common.h (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Remove prototypes.
(handle_format_attribute, handle_format_arg_attribute): Add
prototypes.
* c-decl.c (grokdeclarator): Handle attributes nested inside
declarators.
* c-parse.in (setattrs, maybe_setattrs): Remove.
(maybe_type_quals_setattrs): Rename to maybe_type_quals_attrs.
Update to handle nested attributes properly.
(maybe_resetattrs, after_type_declarator,
parm_declarator_nostarttypename, notype_declarator, absdcl1_noea,
absdcl1_ea, direct_absdcl1): Update to handle nested attributes
properly.
(make_pointer_declarator): Update to handle nested attributes
properly.
* doc/extend.texi: Update documentation of limits of attributes
syntax. Warn about problems with attribute semantics in C++.
* target.h (struct target): Remove valid_decl_attribute and
valid_type_attribute. Add attribute_table and
function_attribute_inlinable_p.
* target-def.h (TARGET_VALID_DECL_ATTRIBUTE,
TARGET_VALID_TYPE_ATTRIBUTE): Remove.
(TARGET_ATTRIBUTE_TABLE, TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P):
Add.
(TARGET_INITIALIZER): Update.
* integrate.c (FUNCTION_ATTRIBUTE_INLINABLE_P): Remove default
definition.
(function_attribute_inlinable_p): New function. Check for the
presence of any machine attributes before using
targetm.function_attribute_inlinable_p.
(function_cannot_inline_p): Update.
* Makefile.in (integrate.o): Update dependencies.
* doc/tm.texi: Update documentation of target attributes and
example definition of TARGET_VALID_TYPE_ATTRIBUTE.
* tree.c (default_valid_attribute_p, valid_machine_attribute):
Remove.
(default_target_attribute_table,
default_function_attribute_inlinable_p): New.
(lookup_attribute): Update comment to clarify handling of multiple
attributes with the same name.
(merge_attributes, attribute_list_contained): Allow multiple
attributes with the same name but different arguments to appear in
the same attribute list.
* tree.h (default_valid_attribute_p): Remove prototype.
(struct attribute_spec): New.
(default_target_attribute_table): Declare.
(enum attribute_flags): Move from c-common.h. Add
ATTR_FLAG_TYPE_IN_PLACE.
(default_function_attribute_inlinable_p): Declare.
* config/alpha/alpha.c (vms_valid_decl_attribute_p): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(vms_attribute_table): New.
* config/arc/arc.c (arc_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arc_attribute_table, arc_handle_interrupt_attribute): New.
* config/arm/arm.c (arm_valid_type_attribute_p,
arm_valid_decl_attribute_p, arm_pe_valid_decl_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arm_attribute_table, arm_handle_fndecl_attribute,
arm_handle_isr_attribute): New.
* config/avr/avr.c (avr_valid_type_attribute,
avr_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE, TARGET_VALID_TYPE_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(avr_attribute_table, avr_handle_progmem_attribute,
avr_handle_fndecl_attribute): New.
* config/c4x/c4x.c (c4x_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(c4x_attribute_table, c4x_handle_fntype_attribute): New.
* config/h8300/h8300.c (h8300_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(h8300_attribute_table, h8300_handle_fndecl_attribute,
h8300_handle_eightbit_data_attribute,
h8300_handle_tiny_data_attribute): New.
* config/i386/i386-protos.h (ix86_valid_type_attribute_p,
i386_pe_valid_decl_attribute_p, i386_pe_valid_type_attribute_p):
Remove prototypes.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New
declarations.
* config/i386/i386.c (ix86_valid_type_attribute_p: Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ix86_attribute_table, ix86_handle_cdecl_attribute,
ix86_handle_regparm_attribute): New.
* config/i386/winnt.c (i386_pe_valid_decl_attribute_p,
i386_pe_valid_type_attribute_p): Remove.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New.
* config/ia64/ia64.c (ia64_valid_type_attribute): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ia64_attribute_table): New.
* config/m32r/m32r.c (m32r_valid_decl_attribute, interrupt_ident1,
interrupt_ident2, model_ident1, model_ident2): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(init_idents): Update.
(m32r_attribute_table, m32r_handle_model_attribute): New.
* config/m68hc11/m68hc11.c (m68hc11_valid_type_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(m68hc11_attribute_table, m68hc11_handle_fntype_attribute): New.
* config/mcore/mcore.c (mcore_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(mcore_attribute_table, mcore_handle_naked_attribute): New.
* config/ns32k/ns32k.c (ns32k_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ns32k_attribute_table, ns32k_handle_fntype_attribute): New.
* config/rs6000/rs6000.c (rs6000_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(rs6000_attribute_table, rs6000_handle_longcall_attribute): New.
* config/sh/sh.c (sh_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(sh_attribute_table, sh_handle_interrupt_handler_attribute,
sh_handle_sp_switch_attribute, sh_handle_trap_exit_attribute):
New.
* config/stormy16/stormy16.c (stormy16_valid_type_attribute):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define
(TARGET_ATTRIBUTE_TABLE): Define.
(stormy16_attribute_table, stormy16_handle_interrupt_attribute):
New.
* config/v850/v850.c (v850_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(v850_attribute_table, v850_handle_interrupt_attribute,
v850_handle_data_area_attribute): New.
* config/v850/v850-c.c (mark_current_function_as_interrupt):
Return void. Call decl_attributes instead of
valid_machine_attribute.
cp:
Table-driven attributes.
* decl.c: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* decl2.c (cplus_decl_attributes): Only take one attributes
parameter.
* cp-tree.c (cplus_decl_attributes): Update prototype.
* class.c (finish_struct), decl.c (start_decl, start_function),
decl2.c (grokfield), friend.c (do_friend), parse.y
(parse_bitfield): Update calls to cplus_decl_attributes.
* decl.c (grokdeclarator): Take a pointer to a single ordinary
attribute list.
* decl.h (grokdeclarator): Update prototype.
* decl2.c (grokfield): Take a single ordinary attribute list.
* friend.c (do_friend): Likewise.
* decl.c (shadow_tag, groktypename, start_decl,
start_handler_parms, grokdeclarator, grokparms, start_function,
start_method), decl2.c (grokfield, grokbitfield, grokoptypename),
parse.y (parse_field, parse_bitfield, component_decl_1), pt.c
(process_template_parm, do_decl_instantiation): Pass single
ordinary attribute lists around.
* decl.c (grokdeclarator): Correct handling of nested attributes.
Revert the patch
1998-10-18 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (grokdeclarator): Embedded attrs bind to the right,
not the left.
.
* cp-tree.h (cp_valid_lang_attribute): Remove declaration
(cp_attribute_table): Declare.
* decl.c (valid_lang_attribute): Don't define.
(lang_attribute_table): Define.
(init_decl_processing): Initialize lang_attribute_table instead of
valid_lang_attribute.
* tree.c (cp_valid_lang_attribute): Remove.
(handle_java_interface_attribute, handle_com_interface_attribute,
handle_init_priority_attribute): New functions.
(cp_attribute_table): New array.
* decl2.c (import_export_class): Don't use
targetm.valid_type_attribute.
testsuite:
Table-driven attributes.
* g++.dg/ext/attrib1.C: New test.
From-SVN: r45718
2001-09-21 03:27:06 +02:00
|
|
|
|
tree decl;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
if (decl_context == PARM)
|
|
|
|
|
{
|
2001-06-09 00:33:46 +02:00
|
|
|
|
tree type_as_written;
|
1999-09-08 06:51:16 +02:00
|
|
|
|
tree promoted_type;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* A parameter declared as an array of T is really a pointer to T.
|
|
|
|
|
One declared as a function is really a pointer to a function. */
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (type) == ARRAY_TYPE)
|
|
|
|
|
{
|
|
|
|
|
/* Transfer const-ness of array into that of type pointed to. */
|
1993-09-06 00:35:15 +02:00
|
|
|
|
type = TREE_TYPE (type);
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
if (type_quals)
|
|
|
|
|
type = c_build_qualified_type (type, type_quals);
|
1993-09-06 00:35:15 +02:00
|
|
|
|
type = build_pointer_type (type);
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
type_quals = TYPE_UNQUALIFIED;
|
2001-05-25 13:12:47 +02:00
|
|
|
|
if (array_ptr_quals)
|
|
|
|
|
{
|
|
|
|
|
tree new_ptr_quals, new_ptr_attrs;
|
|
|
|
|
int erred = 0;
|
|
|
|
|
split_specs_attrs (array_ptr_quals, &new_ptr_quals, &new_ptr_attrs);
|
|
|
|
|
/* We don't yet implement attributes in this context. */
|
|
|
|
|
if (new_ptr_attrs != NULL_TREE)
|
|
|
|
|
warning ("attributes in parameter array declarator ignored");
|
|
|
|
|
|
|
|
|
|
constp = 0;
|
|
|
|
|
volatilep = 0;
|
|
|
|
|
restrictp = 0;
|
|
|
|
|
for (; new_ptr_quals; new_ptr_quals = TREE_CHAIN (new_ptr_quals))
|
|
|
|
|
{
|
|
|
|
|
tree qualifier = TREE_VALUE (new_ptr_quals);
|
|
|
|
|
|
|
|
|
|
if (C_IS_RESERVED_WORD (qualifier))
|
|
|
|
|
{
|
|
|
|
|
if (C_RID_CODE (qualifier) == RID_CONST)
|
|
|
|
|
constp++;
|
|
|
|
|
else if (C_RID_CODE (qualifier) == RID_VOLATILE)
|
|
|
|
|
volatilep++;
|
|
|
|
|
else if (C_RID_CODE (qualifier) == RID_RESTRICT)
|
|
|
|
|
restrictp++;
|
|
|
|
|
else
|
|
|
|
|
erred++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
erred++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (erred)
|
|
|
|
|
error ("invalid type modifier within array declarator");
|
|
|
|
|
|
|
|
|
|
type_quals = ((constp ? TYPE_QUAL_CONST : 0)
|
|
|
|
|
| (restrictp ? TYPE_QUAL_RESTRICT : 0)
|
|
|
|
|
| (volatilep ? TYPE_QUAL_VOLATILE : 0));
|
|
|
|
|
}
|
1992-03-23 03:07:53 +01:00
|
|
|
|
size_varies = 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
else if (TREE_CODE (type) == FUNCTION_TYPE)
|
|
|
|
|
{
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
if (pedantic && type_quals)
|
c-common.c (combine_strings, [...]): Refer to ISO C or ISO C89 instead of ANSI C.
* c-common.c (combine_strings, check_format_info): Refer to ISO C
or ISO C89 instead of ANSI C.
* c-decl.c (grokdeclarator, xref_tag, finish_struct,
build_enumerator, do_case): Likewise.
* c-lex.c (parse_float, yylex): Likewise.
* c-parse.in: Likewise.
* c-typeck.c (common_type, build_array_ref, build_binary_op,
build_unary_op, pedantic_lvalue_warning, build_conditional_expr,
build_c_cast, convert_for_assignment, set_init_index,
set_init_label, c_expand_start_case): Likewise.
* toplev.c (documented_lang_options, display_help): Likewise.
From-SVN: r35576
2000-08-09 01:19:11 +02:00
|
|
|
|
pedwarn ("ISO C forbids qualified function types");
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
if (type_quals)
|
|
|
|
|
type = c_build_qualified_type (type, type_quals);
|
1993-09-06 00:35:15 +02:00
|
|
|
|
type = build_pointer_type (type);
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
type_quals = TYPE_UNQUALIFIED;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
2001-06-09 00:33:46 +02:00
|
|
|
|
else if (type_quals)
|
|
|
|
|
type = c_build_qualified_type (type, type_quals);
|
2003-06-19 21:43:59 +02:00
|
|
|
|
|
2001-06-09 00:33:46 +02:00
|
|
|
|
type_as_written = type;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
decl = build_decl (PARM_DECL, declarator, type);
|
1992-03-23 03:07:53 +01:00
|
|
|
|
if (size_varies)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
C_DECL_VARIABLE_SIZE (decl) = 1;
|
|
|
|
|
|
|
|
|
|
/* Compute the type actually passed in the parmlist,
|
|
|
|
|
for the case where there is no prototype.
|
|
|
|
|
(For example, shorts and chars are passed as ints.)
|
|
|
|
|
When there is a prototype, this is overridden later. */
|
|
|
|
|
|
1999-09-08 06:51:16 +02:00
|
|
|
|
if (type == error_mark_node)
|
|
|
|
|
promoted_type = type;
|
|
|
|
|
else
|
2002-04-19 08:22:18 +02:00
|
|
|
|
promoted_type = c_type_promotes_to (type);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
1999-09-08 06:51:16 +02:00
|
|
|
|
DECL_ARG_TYPE (decl) = promoted_type;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
DECL_ARG_TYPE_AS_WRITTEN (decl) = type_as_written;
|
|
|
|
|
}
|
|
|
|
|
else if (decl_context == FIELD)
|
|
|
|
|
{
|
|
|
|
|
/* Structure field. It may not be a function. */
|
2002-02-02 01:14:41 +01:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (TREE_CODE (type) == FUNCTION_TYPE)
|
|
|
|
|
{
|
1995-02-11 21:16:04 +01:00
|
|
|
|
error ("field `%s' declared as a function", name);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
type = build_pointer_type (type);
|
|
|
|
|
}
|
tree.h (COMPLETE_TYPE_P): New macro.
gcc
* tree.h (COMPLETE_TYPE_P): New macro.
(COMPLETE_OR_VOID_TYPE_P): New macro.
(COMPLETE_OR_UNBOUND_ARRAY_TYPE_P): New macro.
* stor-layout.c (layout_type, case VOID_TYPE): Don't set TYPE_SIZE.
* c-aux-info.c (gen_type): Use them.
* c-common.c (c_expand_expr_stmt): Likewise.
* c-decl.c (poplevel, pushdecl, start_decl, finish_decl,
grokdeclarator, grokparms, finish_struct, start_function,
store_parm_decls, combine_parm_decls): Likewise.
* c-parse.y (cast_expr): Likewise.
* c-typeck.c (require_complete_type, c_sizeof, c_sizeof_nowarn,
c_size_in_bytes, c_alignof, build_component_ref,
build_indirect_ref, build_array_ref, convert_arguments,
build_binary_op, pointer_diff, build_unary_op, digest_init: Likewise.
* calls.c (initialize_argument_information): Likewise.
* convert.c (convert_to_integer): Likewise.
* dbxout.c (dbxout_typedefs, dbxout_type, dbxout_symbol): Likewise.
* dwarfout.c (location_or_const_value_attribute,
output_enumeration_type_die, output_structure_type_die,
output_union_type_die, output_type): Likewise.
* expr.c (safe_from_p, expand_expr): Likewise.
* function.c (assign_parms): Likewise.
* sdbout.c (sdbout_symbol, sdbout_one_type): Likewise.
* tree.c (build_array_type, build_function_type,
build_method_type, build_offset_type, build_complex_type): Likewise.
* c-parse.c, c-parse.h: Regenerated.
gcc/cp
* typeck.c (require_complete_type, complete_type,
complete_type_or_else, c_sizeof, c_sizeof_nowarn,
build_array_ref, convert_arguments, pointer_diff,
build_x_unary_op, build_unary_op, build_c_cast,
build_modify_expr): Use COMPLETE_TYPE_P etc.
* call.c (is_complete, convert_like_real,
build_new_method_call): Likewise.
* class.c (build_vbase_pointer_fields, check_bases,
build_base_field, finish_struct_1, pushclass): Likewise.
* cvt.c (cp_convert_to_pointer, convert_to_void): Likewise.
* decl.c (maybe_process_template_type_declaration, pushtag,
pushdecl, redeclaration_error_message, start_decl, start_decl_1,
layout_var_decl, check_initializer, cp_finish_decl,
grokdeclarator, require_complete_types_for_parms,
grok_op_properties, xref_tag, xref_basetypes,
check_function_type): Likewise.
* decl2.c (check_classfn, reparse_absdcl_as_casts): Likewise.
* friend.c (do_friend): Likewise.
* init.c (build_offset_ref): Likewise.
* parse.y (structsp): Likewise.
* pt.c (maybe_process_partial_specialization,
tsubst_friend_function, instantiate_class_template, tsubst,
do_type_instantiation, instantiate_pending_templates): Likewise.
* repo.c (repo_get_id): Likewise.
* rtti.c (build_typeid, get_typeid, build_dynamic_cast_1,
synthesize_tinfo_var, emit_support_tinfos): Likewise.
* search.c (lookup_fnfields_1, lookup_conversions): Likewise.
* semantics.c (begin_class_definition): Likewise.
* tree.c (build_cplus_method_type): Likewise.
* typeck2.c (digest_init, build_functional_cast,
add_exception_specifier): Likewise.
* parse.h, parse.c: Regenerated.
From-SVN: r32671
2000-03-21 19:10:48 +01:00
|
|
|
|
else if (TREE_CODE (type) != ERROR_MARK
|
|
|
|
|
&& !COMPLETE_OR_UNBOUND_ARRAY_TYPE_P (type))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
1995-02-11 21:16:04 +01:00
|
|
|
|
error ("field `%s' has incomplete type", name);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
type = error_mark_node;
|
|
|
|
|
}
|
|
|
|
|
/* Move type qualifiers down to element of an array. */
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
if (TREE_CODE (type) == ARRAY_TYPE && type_quals)
|
2003-07-29 00:19:46 +02:00
|
|
|
|
type = build_array_type (c_build_qualified_type (TREE_TYPE (type),
|
|
|
|
|
type_quals),
|
|
|
|
|
TYPE_DOMAIN (type));
|
1992-02-13 23:21:26 +01:00
|
|
|
|
decl = build_decl (FIELD_DECL, declarator, type);
|
2000-06-03 03:57:46 +02:00
|
|
|
|
DECL_NONADDRESSABLE_P (decl) = bitfield;
|
|
|
|
|
|
1992-03-23 03:07:53 +01:00
|
|
|
|
if (size_varies)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
C_DECL_VARIABLE_SIZE (decl) = 1;
|
|
|
|
|
}
|
|
|
|
|
else if (TREE_CODE (type) == FUNCTION_TYPE)
|
|
|
|
|
{
|
1992-09-16 02:54:45 +02:00
|
|
|
|
/* Every function declaration is "external"
|
|
|
|
|
except for those which are inside a function body
|
|
|
|
|
in which `auto' is used.
|
|
|
|
|
That is a case not specified by ANSI C,
|
|
|
|
|
and we use it for forward declarations for nested functions. */
|
|
|
|
|
int extern_ref = (!(specbits & (1 << (int) RID_AUTO))
|
2003-07-24 18:59:32 +02:00
|
|
|
|
|| current_scope == global_scope);
|
1992-09-16 02:54:45 +02:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (specbits & (1 << (int) RID_AUTO)
|
2003-07-24 18:59:32 +02:00
|
|
|
|
&& (pedantic || current_scope == global_scope))
|
1995-02-11 21:16:04 +01:00
|
|
|
|
pedwarn ("invalid storage class for function `%s'", name);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (specbits & (1 << (int) RID_REGISTER))
|
1995-02-11 21:16:04 +01:00
|
|
|
|
error ("invalid storage class for function `%s'", name);
|
2002-05-22 03:11:29 +02:00
|
|
|
|
if (specbits & (1 << (int) RID_THREAD))
|
|
|
|
|
error ("invalid storage class for function `%s'", name);
|
2003-07-24 18:59:32 +02:00
|
|
|
|
/* Function declaration not at file scope.
|
1992-02-13 23:21:26 +01:00
|
|
|
|
Storage classes other than `extern' are not allowed
|
|
|
|
|
and `extern' makes no difference. */
|
2003-07-24 18:59:32 +02:00
|
|
|
|
if (current_scope != global_scope
|
1992-02-13 23:21:26 +01:00
|
|
|
|
&& (specbits & ((1 << (int) RID_STATIC) | (1 << (int) RID_INLINE)))
|
|
|
|
|
&& pedantic)
|
1995-02-11 21:16:04 +01:00
|
|
|
|
pedwarn ("invalid storage class for function `%s'", name);
|
1992-09-16 02:54:45 +02:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
decl = build_decl (FUNCTION_DECL, declarator, type);
|
Table-driven attributes.
* c-decl.c, config/alpha/alpha.c, config/arc/arc.c,
config/arm/arm.c, config/arm/pe.c, config/avr/avr.c,
config/avr/avr.h, config/d30v/d30v.h, config/fr30/fr30.h,
config/h8300/h8300.c, config/i386/cygwin.h, config/i386/winnt.c,
config/m32r/m32r.c, config/mcore/mcore.c, config/sh/sh.c,
config/stormy16/stormy16.h, config/v850/v850.c, doc/c-tree.texi,
doc/tm.texi, ggc-common.c, integrate.c, print-tree.c, tree.c,
tree.h: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* tree.h (struct tree_decl): Change machine_attributes to
attributes.
* doc/c-tree.texi: Document that all attributes are now attached
to decls and types.
* c-common.c (add_attribute, attrtab, attrtab_idx,
default_valid_lang_attribute, valid_lang_attribute): Remove.
(attribute_tables, attributes_initialized,
c_common_attribute_table, default_lang_attribute_table): New
variables.
(handle_packed_attribute, handle_nocommon_attribute,
handle_common_attribute, handle_noreturn_attribute,
handle_unused_attribute, handle_const_attribute,
handle_transparent_union_attribute, handle_constructor_attribute,
handle_destructor_attribute, handle_mode_attribute,
handle_section_attribute, handle_aligned_attribute,
handle_weak_attribute, handle_alias_attribute,
handle_no_instrument_function_attribute,
handle_no_check_memory_usage_attribute, handle_malloc_attribute,
handle_no_limit_stack_attribute, handle_pure_attribute): New
functions.
(init_attributes, decl_attributes): Rewrite to implement
table-driven attributes.
* c-common.h (enum attribute_flags): Move to tree.h.
* c-format.c (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Rename to
handle_format_attribute and handle_format_arg_attribute. Update
for table-driven attributes.
* c-common.h (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Remove prototypes.
(handle_format_attribute, handle_format_arg_attribute): Add
prototypes.
* c-decl.c (grokdeclarator): Handle attributes nested inside
declarators.
* c-parse.in (setattrs, maybe_setattrs): Remove.
(maybe_type_quals_setattrs): Rename to maybe_type_quals_attrs.
Update to handle nested attributes properly.
(maybe_resetattrs, after_type_declarator,
parm_declarator_nostarttypename, notype_declarator, absdcl1_noea,
absdcl1_ea, direct_absdcl1): Update to handle nested attributes
properly.
(make_pointer_declarator): Update to handle nested attributes
properly.
* doc/extend.texi: Update documentation of limits of attributes
syntax. Warn about problems with attribute semantics in C++.
* target.h (struct target): Remove valid_decl_attribute and
valid_type_attribute. Add attribute_table and
function_attribute_inlinable_p.
* target-def.h (TARGET_VALID_DECL_ATTRIBUTE,
TARGET_VALID_TYPE_ATTRIBUTE): Remove.
(TARGET_ATTRIBUTE_TABLE, TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P):
Add.
(TARGET_INITIALIZER): Update.
* integrate.c (FUNCTION_ATTRIBUTE_INLINABLE_P): Remove default
definition.
(function_attribute_inlinable_p): New function. Check for the
presence of any machine attributes before using
targetm.function_attribute_inlinable_p.
(function_cannot_inline_p): Update.
* Makefile.in (integrate.o): Update dependencies.
* doc/tm.texi: Update documentation of target attributes and
example definition of TARGET_VALID_TYPE_ATTRIBUTE.
* tree.c (default_valid_attribute_p, valid_machine_attribute):
Remove.
(default_target_attribute_table,
default_function_attribute_inlinable_p): New.
(lookup_attribute): Update comment to clarify handling of multiple
attributes with the same name.
(merge_attributes, attribute_list_contained): Allow multiple
attributes with the same name but different arguments to appear in
the same attribute list.
* tree.h (default_valid_attribute_p): Remove prototype.
(struct attribute_spec): New.
(default_target_attribute_table): Declare.
(enum attribute_flags): Move from c-common.h. Add
ATTR_FLAG_TYPE_IN_PLACE.
(default_function_attribute_inlinable_p): Declare.
* config/alpha/alpha.c (vms_valid_decl_attribute_p): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(vms_attribute_table): New.
* config/arc/arc.c (arc_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arc_attribute_table, arc_handle_interrupt_attribute): New.
* config/arm/arm.c (arm_valid_type_attribute_p,
arm_valid_decl_attribute_p, arm_pe_valid_decl_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arm_attribute_table, arm_handle_fndecl_attribute,
arm_handle_isr_attribute): New.
* config/avr/avr.c (avr_valid_type_attribute,
avr_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE, TARGET_VALID_TYPE_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(avr_attribute_table, avr_handle_progmem_attribute,
avr_handle_fndecl_attribute): New.
* config/c4x/c4x.c (c4x_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(c4x_attribute_table, c4x_handle_fntype_attribute): New.
* config/h8300/h8300.c (h8300_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(h8300_attribute_table, h8300_handle_fndecl_attribute,
h8300_handle_eightbit_data_attribute,
h8300_handle_tiny_data_attribute): New.
* config/i386/i386-protos.h (ix86_valid_type_attribute_p,
i386_pe_valid_decl_attribute_p, i386_pe_valid_type_attribute_p):
Remove prototypes.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New
declarations.
* config/i386/i386.c (ix86_valid_type_attribute_p: Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ix86_attribute_table, ix86_handle_cdecl_attribute,
ix86_handle_regparm_attribute): New.
* config/i386/winnt.c (i386_pe_valid_decl_attribute_p,
i386_pe_valid_type_attribute_p): Remove.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New.
* config/ia64/ia64.c (ia64_valid_type_attribute): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ia64_attribute_table): New.
* config/m32r/m32r.c (m32r_valid_decl_attribute, interrupt_ident1,
interrupt_ident2, model_ident1, model_ident2): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(init_idents): Update.
(m32r_attribute_table, m32r_handle_model_attribute): New.
* config/m68hc11/m68hc11.c (m68hc11_valid_type_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(m68hc11_attribute_table, m68hc11_handle_fntype_attribute): New.
* config/mcore/mcore.c (mcore_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(mcore_attribute_table, mcore_handle_naked_attribute): New.
* config/ns32k/ns32k.c (ns32k_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ns32k_attribute_table, ns32k_handle_fntype_attribute): New.
* config/rs6000/rs6000.c (rs6000_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(rs6000_attribute_table, rs6000_handle_longcall_attribute): New.
* config/sh/sh.c (sh_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(sh_attribute_table, sh_handle_interrupt_handler_attribute,
sh_handle_sp_switch_attribute, sh_handle_trap_exit_attribute):
New.
* config/stormy16/stormy16.c (stormy16_valid_type_attribute):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define
(TARGET_ATTRIBUTE_TABLE): Define.
(stormy16_attribute_table, stormy16_handle_interrupt_attribute):
New.
* config/v850/v850.c (v850_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(v850_attribute_table, v850_handle_interrupt_attribute,
v850_handle_data_area_attribute): New.
* config/v850/v850-c.c (mark_current_function_as_interrupt):
Return void. Call decl_attributes instead of
valid_machine_attribute.
cp:
Table-driven attributes.
* decl.c: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* decl2.c (cplus_decl_attributes): Only take one attributes
parameter.
* cp-tree.c (cplus_decl_attributes): Update prototype.
* class.c (finish_struct), decl.c (start_decl, start_function),
decl2.c (grokfield), friend.c (do_friend), parse.y
(parse_bitfield): Update calls to cplus_decl_attributes.
* decl.c (grokdeclarator): Take a pointer to a single ordinary
attribute list.
* decl.h (grokdeclarator): Update prototype.
* decl2.c (grokfield): Take a single ordinary attribute list.
* friend.c (do_friend): Likewise.
* decl.c (shadow_tag, groktypename, start_decl,
start_handler_parms, grokdeclarator, grokparms, start_function,
start_method), decl2.c (grokfield, grokbitfield, grokoptypename),
parse.y (parse_field, parse_bitfield, component_decl_1), pt.c
(process_template_parm, do_decl_instantiation): Pass single
ordinary attribute lists around.
* decl.c (grokdeclarator): Correct handling of nested attributes.
Revert the patch
1998-10-18 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (grokdeclarator): Embedded attrs bind to the right,
not the left.
.
* cp-tree.h (cp_valid_lang_attribute): Remove declaration
(cp_attribute_table): Declare.
* decl.c (valid_lang_attribute): Don't define.
(lang_attribute_table): Define.
(init_decl_processing): Initialize lang_attribute_table instead of
valid_lang_attribute.
* tree.c (cp_valid_lang_attribute): Remove.
(handle_java_interface_attribute, handle_com_interface_attribute,
handle_init_priority_attribute): New functions.
(cp_attribute_table): New array.
* decl2.c (import_export_class): Don't use
targetm.valid_type_attribute.
testsuite:
Table-driven attributes.
* g++.dg/ext/attrib1.C: New test.
From-SVN: r45718
2001-09-21 03:27:06 +02:00
|
|
|
|
decl = build_decl_attribute_variant (decl, decl_attr);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-19 16:47:15 +02:00
|
|
|
|
DECL_LANG_SPECIFIC (decl)
|
|
|
|
|
= ggc_alloc_cleared (sizeof (struct lang_decl));
|
2001-10-08 18:37:06 +02:00
|
|
|
|
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
if (pedantic && type_quals && ! DECL_IN_SYSTEM_HEADER (decl))
|
c-common.c (combine_strings, [...]): Refer to ISO C or ISO C89 instead of ANSI C.
* c-common.c (combine_strings, check_format_info): Refer to ISO C
or ISO C89 instead of ANSI C.
* c-decl.c (grokdeclarator, xref_tag, finish_struct,
build_enumerator, do_case): Likewise.
* c-lex.c (parse_float, yylex): Likewise.
* c-parse.in: Likewise.
* c-typeck.c (common_type, build_array_ref, build_binary_op,
build_unary_op, pedantic_lvalue_warning, build_conditional_expr,
build_c_cast, convert_for_assignment, set_init_index,
set_init_label, c_expand_start_case): Likewise.
* toplev.c (documented_lang_options, display_help): Likewise.
From-SVN: r35576
2000-08-09 01:19:11 +02:00
|
|
|
|
pedwarn ("ISO C forbids qualified function types");
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
/* GNU C interprets a `volatile void' return type to indicate
|
|
|
|
|
that the function does not return. */
|
|
|
|
|
if ((type_quals & TYPE_QUAL_VOLATILE)
|
2000-06-05 15:16:14 +02:00
|
|
|
|
&& !VOID_TYPE_P (TREE_TYPE (TREE_TYPE (decl))))
|
1994-02-01 17:21:23 +01:00
|
|
|
|
warning ("`noreturn' function returns non-void value");
|
1993-08-06 03:11:37 +02:00
|
|
|
|
|
1992-09-16 02:54:45 +02:00
|
|
|
|
if (extern_ref)
|
1992-07-12 04:56:45 +02:00
|
|
|
|
DECL_EXTERNAL (decl) = 1;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Record absence of global scope for `static' or `auto'. */
|
|
|
|
|
TREE_PUBLIC (decl)
|
|
|
|
|
= !(specbits & ((1 << (int) RID_STATIC) | (1 << (int) RID_AUTO)));
|
1995-02-11 21:16:04 +01:00
|
|
|
|
|
2002-02-06 21:40:18 +01:00
|
|
|
|
if (defaulted_int)
|
|
|
|
|
C_FUNCTION_IMPLICIT_INT (decl) = 1;
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Record presence of `inline', if it is reasonable. */
|
2001-10-08 18:37:06 +02:00
|
|
|
|
if (MAIN_NAME_P (declarator))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2001-10-08 18:37:06 +02:00
|
|
|
|
if (inlinep)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
warning ("cannot inline function `main'");
|
2001-10-08 18:37:06 +02:00
|
|
|
|
}
|
|
|
|
|
else if (inlinep)
|
|
|
|
|
{
|
2003-08-05 16:11:53 +02:00
|
|
|
|
/* Record that the function is declared `inline'. */
|
2001-10-08 18:37:06 +02:00
|
|
|
|
DECL_DECLARED_INLINE_P (decl) = 1;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2001-12-24 09:45:59 +01:00
|
|
|
|
/* Do not mark bare declarations as DECL_INLINE. Doing so
|
|
|
|
|
in the presence of multiple declarations can result in
|
|
|
|
|
the abstract origin pointing between the declarations,
|
|
|
|
|
which will confuse dwarf2out. */
|
|
|
|
|
if (initialized)
|
|
|
|
|
{
|
|
|
|
|
DECL_INLINE (decl) = 1;
|
|
|
|
|
if (specbits & (1 << (int) RID_EXTERN))
|
|
|
|
|
current_extern_inline = 1;
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
2001-10-08 18:37:06 +02:00
|
|
|
|
/* If -finline-functions, assume it can be inlined. This does
|
|
|
|
|
two things: let the function be deferred until it is actually
|
|
|
|
|
needed, and let dwarf2 know that the function is inlinable. */
|
2001-12-24 09:45:59 +01:00
|
|
|
|
else if (flag_inline_trees == 2 && initialized)
|
2003-08-05 16:11:53 +02:00
|
|
|
|
DECL_INLINE (decl) = 1;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* It's a variable. */
|
1992-09-16 02:54:45 +02:00
|
|
|
|
/* An uninitialized decl with `extern' is a reference. */
|
|
|
|
|
int extern_ref = !initialized && (specbits & (1 << (int) RID_EXTERN));
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* Move type qualifiers down to element of an array. */
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
if (TREE_CODE (type) == ARRAY_TYPE && type_quals)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2000-12-08 02:10:40 +01:00
|
|
|
|
int saved_align = TYPE_ALIGN(type);
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
type = build_array_type (c_build_qualified_type (TREE_TYPE (type),
|
|
|
|
|
type_quals),
|
1992-02-13 23:21:26 +01:00
|
|
|
|
TYPE_DOMAIN (type));
|
2000-12-08 02:10:40 +01:00
|
|
|
|
TYPE_ALIGN (type) = saved_align;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
2001-06-09 00:33:46 +02:00
|
|
|
|
else if (type_quals)
|
|
|
|
|
type = c_build_qualified_type (type, type_quals);
|
2003-04-15 03:37:03 +02:00
|
|
|
|
|
|
|
|
|
/* It is invalid to create an `extern' declaration for a
|
|
|
|
|
variable if there is a global declaration that is
|
|
|
|
|
`static'. */
|
2003-07-24 18:59:32 +02:00
|
|
|
|
if (extern_ref && current_scope != global_scope)
|
2003-04-15 03:37:03 +02:00
|
|
|
|
{
|
|
|
|
|
tree global_decl;
|
|
|
|
|
|
|
|
|
|
global_decl = identifier_global_value (declarator);
|
2003-06-19 21:43:59 +02:00
|
|
|
|
if (global_decl
|
2003-04-15 03:37:03 +02:00
|
|
|
|
&& TREE_CODE (global_decl) == VAR_DECL
|
|
|
|
|
&& !TREE_PUBLIC (global_decl))
|
|
|
|
|
error ("variable previously declared `static' redeclared "
|
|
|
|
|
"`extern'");
|
|
|
|
|
}
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
decl = build_decl (VAR_DECL, declarator, type);
|
1992-03-23 03:07:53 +01:00
|
|
|
|
if (size_varies)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
C_DECL_VARIABLE_SIZE (decl) = 1;
|
|
|
|
|
|
|
|
|
|
if (inlinep)
|
2003-07-19 12:19:19 +02:00
|
|
|
|
pedwarn ("%Hvariable '%D' declared `inline'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (decl), decl);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
1992-09-16 02:54:45 +02:00
|
|
|
|
DECL_EXTERNAL (decl) = extern_ref;
|
2002-05-22 03:11:29 +02:00
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
/* At file scope, the presence of a `static' or `register' storage
|
1992-07-01 23:40:06 +02:00
|
|
|
|
class specifier, or the absence of all storage class specifiers
|
|
|
|
|
makes this declaration a definition (perhaps tentative). Also,
|
|
|
|
|
the absence of both `static' and `register' makes it public. */
|
2003-07-24 18:59:32 +02:00
|
|
|
|
if (current_scope == global_scope)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2002-05-22 03:11:29 +02:00
|
|
|
|
TREE_PUBLIC (decl) = !(specbits & ((1 << (int) RID_STATIC)
|
|
|
|
|
| (1 << (int) RID_REGISTER)));
|
|
|
|
|
TREE_STATIC (decl) = !extern_ref;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
2003-07-24 18:59:32 +02:00
|
|
|
|
/* Not at file scope, only `static' makes a static definition. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TREE_STATIC (decl) = (specbits & (1 << (int) RID_STATIC)) != 0;
|
2002-05-22 03:11:29 +02:00
|
|
|
|
TREE_PUBLIC (decl) = extern_ref;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (specbits & 1 << (int) RID_THREAD)
|
|
|
|
|
{
|
|
|
|
|
if (targetm.have_tls)
|
|
|
|
|
DECL_THREAD_LOCAL (decl) = 1;
|
|
|
|
|
else
|
|
|
|
|
/* A mere warning is sure to result in improper semantics
|
|
|
|
|
at runtime. Don't bother to allow this to compile. */
|
|
|
|
|
error ("thread-local storage not supported for this target");
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Record `register' declaration for warnings on &
|
|
|
|
|
and in case doing stupid register allocation. */
|
|
|
|
|
|
|
|
|
|
if (specbits & (1 << (int) RID_REGISTER))
|
1992-07-12 04:56:45 +02:00
|
|
|
|
DECL_REGISTER (decl) = 1;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* Record constancy and volatility. */
|
invoke.texi: Document -flang-isoc9x.
* invoke.texi: Document -flang-isoc9x.
* Makefile.in (OBJS): Add splay-tree.o.
(c-common.o): Depend on rtl.h.
(splay-tree.o): List dependencies and provide build rule.
* rtl.h (record_alias_subset): New function.
* alias.c: Include splay-tree.h.
(alias_set_entry): New type.
(CHECK_ALIAS_SETS_FOR_CONSISTENCY): Remove.
(DIFFERENT_ALIAS_SETS_P): Use mem_in_disjoint_alias_sets_p.
(mems_in_disjoin_alias_sets_p): New function.
(alias_set_compare): Likewise.
(insert_subset_children): Likewise.
(get_alias_set_entry): Likewise.
* tree.h (TYPE_RESTRICT): New macro.
(TYPE_UNQUALIFIED): New manifest constant.
(TYPE_QUAL_CONST): Likewise
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(tree_type): Add restrict_flag. Reduce count of free bits.
(DECL_POINTER_ALIAS_SET): New macro.
(DECL_POINTER_ALIAS_SET_KNOWN_P): Likewise.
(tree_decl): Add pointer_alias_set.
(build_qualified_type): New function.
(build_type_variant): Define in terms of build_qualified_type.
* tree.c (set_type_quals): New function.
(make_node): Initializae DECL_POINTER_ALIAS_SET.
(build_type_attribute_variant): Use build_qualified_type and
set_type_quals.
(build_type_variant): Rename, and modify, to become...
(build_qualified_type): New function.
(build_complex_type): Use set_type_quals.
* c-tree.h (C_TYPE_OBJECT_P): New macro.
(C_TYPE_FUNCTION_P): Likewise.
(C_TYPE_INCOMPLETE_P): Likewise.
(C_TYPE_OBJECT_OR_INCOMPLETE_P): Likewise.
(c_apply_type_quals_to_decl): New function.
(c_build_qualified_type): New function.
(c_build_type_variant): Define in terms of c_build_qualified_type.
(flag_isoc9x): Declare.
* c-typeck.c (qualify_type): Use c_build_qualified_type.
(common_type): Change to use TYPE_QUALS.
(comptypes): Likewise.
(convert_for_assignment): Likewise.
* c-aux-info.c (gen_type): Likewise. Deal with `restrict'.
* c-decl.c (flag_isoc9x): Define.
(c_decode_option): Handle -flang-isoc9x.
(grokdeclarator): Update to handle restrict. Use TYPE_QUALS,
c_build_qualified_type, etc. Use c_apply_type_quals_to_decl.
* c-lex.c (init_lex): Deal with restrict.
(init_lex): Don't treat restrict as a reserved word in
-traditional mode, or without -flang-isoc9x.
* c-lex.h (rid): Add RID_RESTRICT.
* c-parse.gperf (restrict, __restrict, __restrict__): Make
equivalent to RID_RESTRICT.
* c-parse.in (TYPE_QUAL): Update comment.
* c-common.c: Include rtl.h.
(c_find_base_decl): New function.
(c_build_type_variant): Rename, and modify, to become ...
(c_build_qualified_type): New function.
(c_apply_type_quals_to_decl): Likewise.
(c_get_alias_set): For INDIRECT_REFs, check to see if we can find
a particular alias set for the reference.
* toplev.c (documented_lang_options): Add -flang-isoc9x.
From-SVN: r23212
1998-10-21 11:53:40 +02:00
|
|
|
|
c_apply_type_quals_to_decl (type_quals, decl);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* If a type has volatile components, it should be stored in memory.
|
|
|
|
|
Otherwise, the fact that those components are volatile
|
|
|
|
|
will be ignored, and would even crash the compiler. */
|
|
|
|
|
if (C_TYPE_FIELDS_VOLATILE (TREE_TYPE (decl)))
|
c-decl.c (grokdeclarator): Update.
* c-decl.c (grokdeclarator): Update.
* c-lang.c (LANG_HOOKS_MARK_ADDRESSABLE): Redefine.
* c-tree.h (c_mark_addressable): New.
* c-typeck.c (default_function_array_conversion, build_unary_op,
build_array_ref, convert_for_assignment): Update.
(mark_addressable): Rename.
* calls.c (try_to_integrate, expand_call): Use langhook.
* expr.c (expand_expr): Use langhook.
* langhooks-def.h (LANG_HOOKS_INITIALIZER): Update.
* langhooks.h (struct lang_hooks): New hook.
* stmt.c (expand_asm_operands): Use langhook.
* tree.h (mark_addressable): Remove.
ada:
* decl.c (gnat_to_gnu_entity): Update.
* gigi.h (mark_addressable): Rename.
* misc.c (LANG_HOOKS_MARK_ADDRESSABLE): Redefine.
* trans.c (tree_transform): Update.
* utils.c (create_var_decl): Update.
* util2.c (build_binary_op, build_unary_op,
fill_vms_descriptor): Update.
(mark_addressable): Rename, update.
cp:
* call.c (build_addr_func): Update.
* class.c (resolve_address_of_overloaded_function): Update.
* cp-lang.c (LANG_HOOKS_MARK_ADDRESSABLE): Redefine.
* cp-tree.h (cxx_mark_addressable): New.
* decl.c (register_dtor_fn, cxx_maybe_build_cleanup): Update.
* decl2.c (build_cleanup): Update.
* except.c (build_throw): Update.
* init.c (resolve_offset_ref): Update.
* pt.c (convert_nontype_argument): Update.
* semantics.c (finish_asm_stmt, simplify_affr_init_exprs_r): Update.
* typeck.c (decay_conversion, build_array_ref, build_unary_op,
unary_complex_lvalue): Update.
(mark_addressable): Rename.
f:
* com.c (LANG_HOOKS_MARK_ADDRESSABLE): Redefine.
(mark_addressable): Rename.
(ffecom_arrayref_, ffecom_1): Update.
java:
* java-tree.h (java_mark_addressable): New.
* lang.c (LANG_HOOKS_MARK_ADDRESSABLE): Redefine.
* typeck.c (mark_addressable): Rename, update.
objc:
* objc-lang.c (LANG_HOOKS_MARK_ADDRESSABLE): Redefine.
From-SVN: r51705
2002-04-01 22:26:18 +02:00
|
|
|
|
c_mark_addressable (decl);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-22 04:23:27 +02:00
|
|
|
|
#ifdef ENABLE_CHECKING
|
|
|
|
|
/* This is the earliest point at which we might know the assembler
|
|
|
|
|
name of a variable. Thus, if it's known before this, die horribly. */
|
|
|
|
|
if (DECL_ASSEMBLER_NAME_SET_P (decl))
|
|
|
|
|
abort ();
|
|
|
|
|
#endif
|
|
|
|
|
|
Table-driven attributes.
* c-decl.c, config/alpha/alpha.c, config/arc/arc.c,
config/arm/arm.c, config/arm/pe.c, config/avr/avr.c,
config/avr/avr.h, config/d30v/d30v.h, config/fr30/fr30.h,
config/h8300/h8300.c, config/i386/cygwin.h, config/i386/winnt.c,
config/m32r/m32r.c, config/mcore/mcore.c, config/sh/sh.c,
config/stormy16/stormy16.h, config/v850/v850.c, doc/c-tree.texi,
doc/tm.texi, ggc-common.c, integrate.c, print-tree.c, tree.c,
tree.h: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* tree.h (struct tree_decl): Change machine_attributes to
attributes.
* doc/c-tree.texi: Document that all attributes are now attached
to decls and types.
* c-common.c (add_attribute, attrtab, attrtab_idx,
default_valid_lang_attribute, valid_lang_attribute): Remove.
(attribute_tables, attributes_initialized,
c_common_attribute_table, default_lang_attribute_table): New
variables.
(handle_packed_attribute, handle_nocommon_attribute,
handle_common_attribute, handle_noreturn_attribute,
handle_unused_attribute, handle_const_attribute,
handle_transparent_union_attribute, handle_constructor_attribute,
handle_destructor_attribute, handle_mode_attribute,
handle_section_attribute, handle_aligned_attribute,
handle_weak_attribute, handle_alias_attribute,
handle_no_instrument_function_attribute,
handle_no_check_memory_usage_attribute, handle_malloc_attribute,
handle_no_limit_stack_attribute, handle_pure_attribute): New
functions.
(init_attributes, decl_attributes): Rewrite to implement
table-driven attributes.
* c-common.h (enum attribute_flags): Move to tree.h.
* c-format.c (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Rename to
handle_format_attribute and handle_format_arg_attribute. Update
for table-driven attributes.
* c-common.h (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Remove prototypes.
(handle_format_attribute, handle_format_arg_attribute): Add
prototypes.
* c-decl.c (grokdeclarator): Handle attributes nested inside
declarators.
* c-parse.in (setattrs, maybe_setattrs): Remove.
(maybe_type_quals_setattrs): Rename to maybe_type_quals_attrs.
Update to handle nested attributes properly.
(maybe_resetattrs, after_type_declarator,
parm_declarator_nostarttypename, notype_declarator, absdcl1_noea,
absdcl1_ea, direct_absdcl1): Update to handle nested attributes
properly.
(make_pointer_declarator): Update to handle nested attributes
properly.
* doc/extend.texi: Update documentation of limits of attributes
syntax. Warn about problems with attribute semantics in C++.
* target.h (struct target): Remove valid_decl_attribute and
valid_type_attribute. Add attribute_table and
function_attribute_inlinable_p.
* target-def.h (TARGET_VALID_DECL_ATTRIBUTE,
TARGET_VALID_TYPE_ATTRIBUTE): Remove.
(TARGET_ATTRIBUTE_TABLE, TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P):
Add.
(TARGET_INITIALIZER): Update.
* integrate.c (FUNCTION_ATTRIBUTE_INLINABLE_P): Remove default
definition.
(function_attribute_inlinable_p): New function. Check for the
presence of any machine attributes before using
targetm.function_attribute_inlinable_p.
(function_cannot_inline_p): Update.
* Makefile.in (integrate.o): Update dependencies.
* doc/tm.texi: Update documentation of target attributes and
example definition of TARGET_VALID_TYPE_ATTRIBUTE.
* tree.c (default_valid_attribute_p, valid_machine_attribute):
Remove.
(default_target_attribute_table,
default_function_attribute_inlinable_p): New.
(lookup_attribute): Update comment to clarify handling of multiple
attributes with the same name.
(merge_attributes, attribute_list_contained): Allow multiple
attributes with the same name but different arguments to appear in
the same attribute list.
* tree.h (default_valid_attribute_p): Remove prototype.
(struct attribute_spec): New.
(default_target_attribute_table): Declare.
(enum attribute_flags): Move from c-common.h. Add
ATTR_FLAG_TYPE_IN_PLACE.
(default_function_attribute_inlinable_p): Declare.
* config/alpha/alpha.c (vms_valid_decl_attribute_p): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(vms_attribute_table): New.
* config/arc/arc.c (arc_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arc_attribute_table, arc_handle_interrupt_attribute): New.
* config/arm/arm.c (arm_valid_type_attribute_p,
arm_valid_decl_attribute_p, arm_pe_valid_decl_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arm_attribute_table, arm_handle_fndecl_attribute,
arm_handle_isr_attribute): New.
* config/avr/avr.c (avr_valid_type_attribute,
avr_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE, TARGET_VALID_TYPE_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(avr_attribute_table, avr_handle_progmem_attribute,
avr_handle_fndecl_attribute): New.
* config/c4x/c4x.c (c4x_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(c4x_attribute_table, c4x_handle_fntype_attribute): New.
* config/h8300/h8300.c (h8300_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(h8300_attribute_table, h8300_handle_fndecl_attribute,
h8300_handle_eightbit_data_attribute,
h8300_handle_tiny_data_attribute): New.
* config/i386/i386-protos.h (ix86_valid_type_attribute_p,
i386_pe_valid_decl_attribute_p, i386_pe_valid_type_attribute_p):
Remove prototypes.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New
declarations.
* config/i386/i386.c (ix86_valid_type_attribute_p: Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ix86_attribute_table, ix86_handle_cdecl_attribute,
ix86_handle_regparm_attribute): New.
* config/i386/winnt.c (i386_pe_valid_decl_attribute_p,
i386_pe_valid_type_attribute_p): Remove.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New.
* config/ia64/ia64.c (ia64_valid_type_attribute): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ia64_attribute_table): New.
* config/m32r/m32r.c (m32r_valid_decl_attribute, interrupt_ident1,
interrupt_ident2, model_ident1, model_ident2): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(init_idents): Update.
(m32r_attribute_table, m32r_handle_model_attribute): New.
* config/m68hc11/m68hc11.c (m68hc11_valid_type_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(m68hc11_attribute_table, m68hc11_handle_fntype_attribute): New.
* config/mcore/mcore.c (mcore_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(mcore_attribute_table, mcore_handle_naked_attribute): New.
* config/ns32k/ns32k.c (ns32k_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ns32k_attribute_table, ns32k_handle_fntype_attribute): New.
* config/rs6000/rs6000.c (rs6000_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(rs6000_attribute_table, rs6000_handle_longcall_attribute): New.
* config/sh/sh.c (sh_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(sh_attribute_table, sh_handle_interrupt_handler_attribute,
sh_handle_sp_switch_attribute, sh_handle_trap_exit_attribute):
New.
* config/stormy16/stormy16.c (stormy16_valid_type_attribute):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define
(TARGET_ATTRIBUTE_TABLE): Define.
(stormy16_attribute_table, stormy16_handle_interrupt_attribute):
New.
* config/v850/v850.c (v850_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(v850_attribute_table, v850_handle_interrupt_attribute,
v850_handle_data_area_attribute): New.
* config/v850/v850-c.c (mark_current_function_as_interrupt):
Return void. Call decl_attributes instead of
valid_machine_attribute.
cp:
Table-driven attributes.
* decl.c: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* decl2.c (cplus_decl_attributes): Only take one attributes
parameter.
* cp-tree.c (cplus_decl_attributes): Update prototype.
* class.c (finish_struct), decl.c (start_decl, start_function),
decl2.c (grokfield), friend.c (do_friend), parse.y
(parse_bitfield): Update calls to cplus_decl_attributes.
* decl.c (grokdeclarator): Take a pointer to a single ordinary
attribute list.
* decl.h (grokdeclarator): Update prototype.
* decl2.c (grokfield): Take a single ordinary attribute list.
* friend.c (do_friend): Likewise.
* decl.c (shadow_tag, groktypename, start_decl,
start_handler_parms, grokdeclarator, grokparms, start_function,
start_method), decl2.c (grokfield, grokbitfield, grokoptypename),
parse.y (parse_field, parse_bitfield, component_decl_1), pt.c
(process_template_parm, do_decl_instantiation): Pass single
ordinary attribute lists around.
* decl.c (grokdeclarator): Correct handling of nested attributes.
Revert the patch
1998-10-18 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (grokdeclarator): Embedded attrs bind to the right,
not the left.
.
* cp-tree.h (cp_valid_lang_attribute): Remove declaration
(cp_attribute_table): Declare.
* decl.c (valid_lang_attribute): Don't define.
(lang_attribute_table): Define.
(init_decl_processing): Initialize lang_attribute_table instead of
valid_lang_attribute.
* tree.c (cp_valid_lang_attribute): Remove.
(handle_java_interface_attribute, handle_com_interface_attribute,
handle_init_priority_attribute): New functions.
(cp_attribute_table): New array.
* decl2.c (import_export_class): Don't use
targetm.valid_type_attribute.
testsuite:
Table-driven attributes.
* g++.dg/ext/attrib1.C: New test.
From-SVN: r45718
2001-09-21 03:27:06 +02:00
|
|
|
|
decl_attributes (&decl, returned_attrs, 0);
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
return decl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Decode the parameter-list info for a function type or function definition.
|
|
|
|
|
The argument is the value returned by `get_parm_info' (or made in parse.y
|
|
|
|
|
if there is an identifier list instead of a parameter decl list).
|
|
|
|
|
These two functions are separate because when a function returns
|
|
|
|
|
or receives functions then each is called multiple times but the order
|
|
|
|
|
of calls is different. The last call to `grokparms' is always the one
|
|
|
|
|
that contains the formal parameter names of a function definition.
|
|
|
|
|
|
|
|
|
|
Store in `last_function_parms' a chain of the decls of parms.
|
|
|
|
|
Also store in `last_function_parm_tags' a chain of the struct, union,
|
|
|
|
|
and enum tags declared among the parms.
|
|
|
|
|
|
|
|
|
|
Return a list of arg types to use in the FUNCTION_TYPE for this function.
|
|
|
|
|
|
|
|
|
|
FUNCDEF_FLAG is nonzero for a function definition, 0 for
|
|
|
|
|
a mere declaration. A nonempty identifier-list gets an error message
|
|
|
|
|
when FUNCDEF_FLAG is zero. */
|
|
|
|
|
|
|
|
|
|
static tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
grokparms (tree parms_info, int funcdef_flag)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
tree first_parm = TREE_CHAIN (parms_info);
|
|
|
|
|
|
|
|
|
|
last_function_parms = TREE_PURPOSE (parms_info);
|
|
|
|
|
last_function_parm_tags = TREE_VALUE (parms_info);
|
2003-08-01 20:41:40 +02:00
|
|
|
|
last_function_parm_others = TREE_TYPE (parms_info);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
1992-07-31 08:14:04 +02:00
|
|
|
|
if (warn_strict_prototypes && first_parm == 0 && !funcdef_flag
|
|
|
|
|
&& !in_system_header)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
warning ("function declaration isn't a prototype");
|
|
|
|
|
|
|
|
|
|
if (first_parm != 0
|
|
|
|
|
&& TREE_CODE (TREE_VALUE (first_parm)) == IDENTIFIER_NODE)
|
|
|
|
|
{
|
|
|
|
|
if (! funcdef_flag)
|
|
|
|
|
pedwarn ("parameter names (without types) in function declaration");
|
|
|
|
|
|
|
|
|
|
last_function_parms = first_parm;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tree parm;
|
|
|
|
|
tree typelt;
|
2003-07-17 22:12:21 +02:00
|
|
|
|
/* If the arg types are incomplete in a declaration,
|
1992-02-13 23:21:26 +01:00
|
|
|
|
they must include undefined tags.
|
|
|
|
|
These tags can never be defined in the scope of the declaration,
|
|
|
|
|
so the types can never be completed,
|
|
|
|
|
and no call can be compiled successfully. */
|
2003-07-29 00:19:46 +02:00
|
|
|
|
|
2003-07-17 22:12:21 +02:00
|
|
|
|
for (parm = last_function_parms, typelt = first_parm;
|
|
|
|
|
parm;
|
|
|
|
|
parm = TREE_CHAIN (parm))
|
|
|
|
|
/* Skip over any enumeration constants declared here. */
|
|
|
|
|
if (TREE_CODE (parm) == PARM_DECL)
|
|
|
|
|
{
|
|
|
|
|
/* Barf if the parameter itself has an incomplete type. */
|
|
|
|
|
tree type = TREE_VALUE (typelt);
|
|
|
|
|
if (type == error_mark_node)
|
|
|
|
|
continue;
|
|
|
|
|
if (!COMPLETE_TYPE_P (type))
|
|
|
|
|
{
|
|
|
|
|
if (funcdef_flag && DECL_NAME (parm) != 0)
|
|
|
|
|
error ("parameter `%s' has incomplete type",
|
|
|
|
|
IDENTIFIER_POINTER (DECL_NAME (parm)));
|
|
|
|
|
else
|
|
|
|
|
warning ("parameter has incomplete type");
|
|
|
|
|
if (funcdef_flag)
|
|
|
|
|
{
|
|
|
|
|
TREE_VALUE (typelt) = error_mark_node;
|
|
|
|
|
TREE_TYPE (parm) = error_mark_node;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
typelt = TREE_CHAIN (typelt);
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2000-08-11 00:01:22 +02:00
|
|
|
|
return first_parm;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return a tree_list node with info on a parameter list just parsed.
|
2003-07-29 00:19:46 +02:00
|
|
|
|
The TREE_PURPOSE is a list of decls of those parms.
|
1992-02-13 23:21:26 +01:00
|
|
|
|
The TREE_VALUE is a list of structure, union and enum tags defined.
|
|
|
|
|
The TREE_CHAIN is a list of argument types to go in the FUNCTION_TYPE.
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
The TREE_TYPE is a list of non-parameter decls which appeared with the
|
|
|
|
|
parameters.
|
1992-02-13 23:21:26 +01:00
|
|
|
|
This tree_list node is later fed to `grokparms'.
|
|
|
|
|
|
|
|
|
|
VOID_AT_END nonzero means append `void' to the end of the type-list.
|
|
|
|
|
Zero means the parmlist ended with an ellipsis so don't append `void'. */
|
|
|
|
|
|
|
|
|
|
tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
get_parm_info (int void_at_end)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
tree decl, type, list;
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree types = 0;
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
tree *last_type = &types;
|
|
|
|
|
tree tags = current_scope->tags;
|
|
|
|
|
tree parms = current_scope->parms;
|
|
|
|
|
tree others = current_scope->names;
|
|
|
|
|
static bool explained_incomplete_types = false;
|
|
|
|
|
bool gave_void_only_once_err = false;
|
|
|
|
|
|
|
|
|
|
/* Just "void" (and no ellipsis) is special. There are really no parms.
|
|
|
|
|
But if the "void" is qualified (by "const" or "volatile"), or has a
|
|
|
|
|
storage class specifier ("register"), then the behavior is undefined;
|
|
|
|
|
issue an error. Typedefs for "void" are OK (see DR#157). */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (void_at_end && parms != 0
|
|
|
|
|
&& TREE_CHAIN (parms) == 0
|
2000-06-05 15:16:14 +02:00
|
|
|
|
&& VOID_TYPE_P (TREE_TYPE (parms))
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
&& !DECL_NAME (parms))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
if (TREE_THIS_VOLATILE (parms)
|
|
|
|
|
|| TREE_READONLY (parms)
|
|
|
|
|
|| DECL_REGISTER (parms))
|
|
|
|
|
error ("\"void\" as only parameter may not be qualified");
|
|
|
|
|
|
|
|
|
|
return tree_cons (0, 0, tree_cons (0, void_type_node, 0));
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
/* Sanity check all of the parameter declarations. */
|
|
|
|
|
for (decl = parms; decl; decl = TREE_CHAIN (decl))
|
|
|
|
|
{
|
1992-06-04 23:30:48 +02:00
|
|
|
|
if (TREE_CODE (decl) != PARM_DECL)
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
abort ();
|
|
|
|
|
if (TREE_ASM_WRITTEN (decl))
|
|
|
|
|
abort ();
|
|
|
|
|
|
|
|
|
|
/* Since there is a prototype, args are passed in their
|
|
|
|
|
declared types. The back end may override this. */
|
|
|
|
|
type = TREE_TYPE (decl);
|
|
|
|
|
DECL_ARG_TYPE (decl) = type;
|
|
|
|
|
|
|
|
|
|
/* Check for (..., void, ...) and issue an error. */
|
|
|
|
|
if (VOID_TYPE_P (type) && !DECL_NAME (decl) && !gave_void_only_once_err)
|
1992-04-17 04:05:56 +02:00
|
|
|
|
{
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
error ("\"void\" must be the only parameter");
|
|
|
|
|
gave_void_only_once_err = true;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
type = build_tree_list (0, type);
|
|
|
|
|
*last_type = type;
|
|
|
|
|
last_type = &TREE_CHAIN (type);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
/* Check the list of non-parameter decls for any forward parm decls
|
|
|
|
|
that never got real decls. */
|
|
|
|
|
for (decl = others; decl; decl = TREE_CHAIN (decl))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (TREE_CODE (decl) == PARM_DECL)
|
|
|
|
|
{
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
if (!TREE_ASM_WRITTEN (decl))
|
|
|
|
|
abort ();
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
error ("%Hparameter \"%D\" has just a forward declaration",
|
|
|
|
|
&DECL_SOURCE_LOCATION (decl), decl);
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
/* Warn about any struct, union or enum tags defined within this
|
|
|
|
|
list. The scope of such types is limited to this declaration,
|
|
|
|
|
which is rarely if ever desirable (it's impossible to call such
|
|
|
|
|
a function with type-correct arguments). */
|
|
|
|
|
for (decl = tags; decl; decl = TREE_CHAIN (decl))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
enum tree_code code = TREE_CODE (TREE_VALUE (decl));
|
|
|
|
|
const char *keyword;
|
1992-04-18 19:24:48 +02:00
|
|
|
|
/* An anonymous union parm type is meaningful as a GNU extension.
|
|
|
|
|
So don't warn for that. */
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
if (code == UNION_TYPE && TREE_PURPOSE (decl) == 0 && !pedantic)
|
1992-04-18 19:24:48 +02:00
|
|
|
|
continue;
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
|
|
|
|
|
/* The keyword should not be translated. */
|
|
|
|
|
switch (code)
|
2000-08-11 00:01:22 +02:00
|
|
|
|
{
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
case RECORD_TYPE: keyword = "struct"; break;
|
|
|
|
|
case UNION_TYPE: keyword = "union"; break;
|
|
|
|
|
case ENUMERAL_TYPE: keyword = "enum"; break;
|
|
|
|
|
default: abort ();
|
2000-06-29 01:46:27 +02:00
|
|
|
|
}
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
|
|
|
|
|
if (TREE_PURPOSE (decl))
|
|
|
|
|
/* The first %s will be one of 'struct', 'union', or 'enum'. */
|
|
|
|
|
warning ("\"%s %s\" declared inside parameter list",
|
|
|
|
|
keyword, IDENTIFIER_POINTER (TREE_PURPOSE (decl)));
|
|
|
|
|
else
|
|
|
|
|
/* The %s will be one of 'struct', 'union', or 'enum'. */
|
|
|
|
|
warning ("anonymous %s declared inside parameter list", keyword);
|
|
|
|
|
|
|
|
|
|
if (! explained_incomplete_types)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
warning ("its scope is only this definition or declaration,"
|
|
|
|
|
" which is probably not what you want");
|
|
|
|
|
explained_incomplete_types = true;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (void_at_end)
|
|
|
|
|
{
|
|
|
|
|
type = build_tree_list (0, void_type_node);
|
|
|
|
|
*last_type = type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
list = tree_cons (parms, tags, types);
|
|
|
|
|
TREE_TYPE (list) = others;
|
|
|
|
|
return list;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Get the struct, enum or union (CODE says which) with tag NAME.
|
|
|
|
|
Define the tag as a forward-reference if it is not defined. */
|
|
|
|
|
|
|
|
|
|
tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
xref_tag (enum tree_code code, tree name)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
/* If a cross reference is requested, look up the type
|
|
|
|
|
already defined for this tag and return it. */
|
|
|
|
|
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
tree ref = lookup_tag (code, name, 0);
|
2001-06-11 13:50:29 +02:00
|
|
|
|
/* If this is the right type of tag, return what we found.
|
|
|
|
|
(This reference will be shadowed by shadow_tag later if appropriate.)
|
|
|
|
|
If this is the wrong type of tag, do not return it. If it was the
|
2003-07-24 18:59:32 +02:00
|
|
|
|
wrong type in the same scope, we will have had an error
|
|
|
|
|
message already; if in a different scope and declaring
|
2001-06-11 13:50:29 +02:00
|
|
|
|
a name, pending_xref_error will give an error message; but if in a
|
2003-07-24 18:59:32 +02:00
|
|
|
|
different scope and not declaring a name, this tag should
|
2001-06-11 13:50:29 +02:00
|
|
|
|
shadow the previous declaration of a different type of tag, and
|
|
|
|
|
this would not work properly if we return the reference found.
|
|
|
|
|
(For example, with "struct foo" in an outer scope, "union foo;"
|
|
|
|
|
must shadow that tag with a new one of union type.) */
|
|
|
|
|
if (ref && TREE_CODE (ref) == code)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
return ref;
|
|
|
|
|
|
|
|
|
|
/* If no such tag is yet defined, create a forward-reference node
|
|
|
|
|
and record it as the "definition".
|
|
|
|
|
When a real declaration of this type is found,
|
|
|
|
|
the forward-reference will be altered into a real type. */
|
|
|
|
|
|
|
|
|
|
ref = make_node (code);
|
|
|
|
|
if (code == ENUMERAL_TYPE)
|
|
|
|
|
{
|
|
|
|
|
/* Give the type a default layout like unsigned int
|
|
|
|
|
to avoid crashing if it does not get defined. */
|
|
|
|
|
TYPE_MODE (ref) = TYPE_MODE (unsigned_type_node);
|
|
|
|
|
TYPE_ALIGN (ref) = TYPE_ALIGN (unsigned_type_node);
|
2000-06-14 07:30:09 +02:00
|
|
|
|
TYPE_USER_ALIGN (ref) = 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
TREE_UNSIGNED (ref) = 1;
|
|
|
|
|
TYPE_PRECISION (ref) = TYPE_PRECISION (unsigned_type_node);
|
|
|
|
|
TYPE_MIN_VALUE (ref) = TYPE_MIN_VALUE (unsigned_type_node);
|
|
|
|
|
TYPE_MAX_VALUE (ref) = TYPE_MAX_VALUE (unsigned_type_node);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pushtag (name, ref);
|
|
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
/* Make sure that the tag NAME is defined *in the current scope*
|
1992-02-13 23:21:26 +01:00
|
|
|
|
at least as a forward reference.
|
c-common.c, [...]: Remove all references to obstack functions obsoleted by GC...
* c-common.c, c-decl.c, c-lang.c, c-lex.c, c-parse.in, c-pragma.c,
c-typeck.c, objc/objc-act.c: Remove all references to obstack
functions obsoleted by GC, such as push_obstacks_nochange,
end_temporary_allocation, savealloc, saveable_tree_cons, etc.
and code which existed only to decide whether or not to call
them. Remove now-unused NESTED argument from start_function;
all callers changed. Do not change behavior based on ggc_p.
The use of the ixp_obstack in c-iterate.c and the util_obstack
in objc/objc-act.c remain; these are not obsoleted by garbage
collection.
* c-tree.h: Update prototype for start_function.
* c-parse.y, c-parse.c, objc/objc-parse.c, objc/objc-parse.y: Rebuild.
From-SVN: r31611
2000-01-25 18:13:14 +01:00
|
|
|
|
CODE says which kind of tag NAME ought to be. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
start_struct (enum tree_code code, tree name)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-24 18:59:32 +02:00
|
|
|
|
/* If there is already a tag defined at this scope
|
1992-02-13 23:21:26 +01:00
|
|
|
|
(as a forward reference), just return it. */
|
|
|
|
|
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree ref = 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
if (name != 0)
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
ref = lookup_tag (code, name, 1);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (ref && TREE_CODE (ref) == code)
|
|
|
|
|
{
|
|
|
|
|
if (TYPE_FIELDS (ref))
|
2001-10-30 13:14:28 +01:00
|
|
|
|
{
|
|
|
|
|
if (code == UNION_TYPE)
|
2002-11-26 18:36:14 +01:00
|
|
|
|
error ("redefinition of `union %s'", IDENTIFIER_POINTER (name));
|
2001-10-30 13:14:28 +01:00
|
|
|
|
else
|
2002-11-26 18:36:14 +01:00
|
|
|
|
error ("redefinition of `struct %s'", IDENTIFIER_POINTER (name));
|
2003-06-19 21:43:59 +02:00
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
2002-11-26 18:36:14 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Otherwise create a forward-reference just so the tag is in scope. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2002-11-26 18:36:14 +01:00
|
|
|
|
ref = make_node (code);
|
|
|
|
|
pushtag (name, ref);
|
|
|
|
|
}
|
2003-06-19 21:43:59 +02:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
C_TYPE_BEING_DEFINED (ref) = 1;
|
1996-06-03 13:57:03 +02:00
|
|
|
|
TYPE_PACKED (ref) = flag_pack_struct;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
return ref;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Process the specs, declarator (NULL if omitted) and width (NULL if omitted)
|
|
|
|
|
of a structure component, returning a FIELD_DECL node.
|
2002-02-02 01:14:41 +01:00
|
|
|
|
WIDTH is non-NULL for bit fields only, and is an INTEGER_CST node.
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
This is done during the parsing of the struct declaration.
|
|
|
|
|
The FIELD_DECL nodes are chained together and the lot of them
|
|
|
|
|
are ultimately passed to `build_struct' to make the RECORD_TYPE node. */
|
|
|
|
|
|
|
|
|
|
tree
|
c-tree.h (grokfield): Remove unused filename and line parameters.
* c-tree.h (grokfield): Remove unused filename and line parameters.
* c-decl.c (grokfield): Remove unused filename and line parameters.
* c-parse.in (component_decl): Adjust field grokking rules, adjust
grokfield calls.
(component_declarator): Likewise.
(component_notype_declarator): Likewise.
* objc/objc-act.c (build_module_descriptor): Adjust grokfield
calls.
(build_protocol_template, build_method_prototype_list_template,
build_method_prototype_template, build_category_template,
build_selector_template, build_class_template,
build_super_template, build_ivar_template,
build_ivar_list_template, build_method_list_template,
build_method_template, add_instance_variable): Likewise.
From-SVN: r68560
2003-06-27 11:05:45 +02:00
|
|
|
|
grokfield (tree declarator, tree declspecs, tree width)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
tree value;
|
|
|
|
|
|
2001-10-08 21:44:53 +02:00
|
|
|
|
if (declarator == NULL_TREE && width == NULL_TREE)
|
|
|
|
|
{
|
2002-06-16 21:09:30 +02:00
|
|
|
|
/* This is an unnamed decl.
|
|
|
|
|
|
|
|
|
|
If we have something of the form "union { list } ;" then this
|
|
|
|
|
is the anonymous union extension. Similarly for struct.
|
|
|
|
|
|
|
|
|
|
If this is something of the form "struct foo;", then
|
|
|
|
|
If MS extensions are enabled, this is handled as an
|
|
|
|
|
anonymous struct.
|
|
|
|
|
Otherwise this is a forward declaration of a structure tag.
|
|
|
|
|
|
|
|
|
|
If this is something of the form "foo;" and foo is a TYPE_DECL, then
|
|
|
|
|
If MS extensions are enabled and foo names a structure, then
|
|
|
|
|
again this is an anonymous struct.
|
|
|
|
|
Otherwise this is an error.
|
|
|
|
|
|
2003-01-18 03:26:43 +01:00
|
|
|
|
Oh what a horrid tangled web we weave. I wonder if MS consciously
|
2002-06-16 21:09:30 +02:00
|
|
|
|
took this from Plan 9 or if it was an accident of implementation
|
|
|
|
|
that took root before someone noticed the bug... */
|
|
|
|
|
|
2002-06-10 23:52:43 +02:00
|
|
|
|
tree type = TREE_VALUE (declspecs);
|
|
|
|
|
|
2002-06-16 21:09:30 +02:00
|
|
|
|
if (flag_ms_extensions && TREE_CODE (type) == TYPE_DECL)
|
2002-06-10 23:52:43 +02:00
|
|
|
|
type = TREE_TYPE (type);
|
2002-06-16 21:09:30 +02:00
|
|
|
|
if (TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE)
|
|
|
|
|
{
|
|
|
|
|
if (flag_ms_extensions)
|
|
|
|
|
; /* ok */
|
|
|
|
|
else if (flag_iso)
|
|
|
|
|
goto warn_unnamed_field;
|
|
|
|
|
else if (TYPE_NAME (type) == NULL)
|
|
|
|
|
; /* ok */
|
|
|
|
|
else
|
|
|
|
|
goto warn_unnamed_field;
|
|
|
|
|
}
|
|
|
|
|
else
|
2001-10-08 21:44:53 +02:00
|
|
|
|
{
|
2002-06-16 21:09:30 +02:00
|
|
|
|
warn_unnamed_field:
|
|
|
|
|
warning ("declaration does not declare anything");
|
2001-10-08 21:44:53 +02:00
|
|
|
|
return NULL_TREE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-02 01:14:41 +01:00
|
|
|
|
value = grokdeclarator (declarator, declspecs, width ? BITFIELD : FIELD, 0);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
1992-07-07 00:35:53 +02:00
|
|
|
|
finish_decl (value, NULL_TREE, NULL_TREE);
|
2002-02-02 01:14:41 +01:00
|
|
|
|
DECL_INITIAL (value) = width;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
c-common.c (enum c_language_kind, flag_objc): Remove.
* c-common.c (enum c_language_kind, flag_objc): Remove.
(fix_string_type, check_case_value, c_common_nodes_and_builtins,
c_add_case_label, finish_label_addr_expr, boolean_increment):
Use c_dialect_ macros.
* c-common.h (enum c_language_kind): Extend.
(c_dialect_cxx, c_dialect_objc): New.
(flag_objc): Remove.
(c_common_init_options): Update prototype.
* c-cppbuiltin.c (define__GNUC__, c_cpp_builtins): Use c_dialect_
macros.
* c-decl.c (finsih_decl, grokfield, finish_struct): Use c_dialect_
macros.
* c-format.c (C_STD_VER, C_STD_NAME): Similarly.
* c-lang.c (c_init_options): Remove.
(c_language): Define.
(LANG_HOOKS_INIT_OPTIONS): Use common hook.
* c-lex.c (lex_charconst): Use c_dialect_cxx().
* c-opts.c (lang_flags): Make function-local.
(c_common_init_options): Use c_dialect_ macros. Handle
C++ diagnostic requirements.
(c_common_handle_option, c_common_post_options): Use flag_cxx.
* c-parse.in (init_reswords): Use c_dialect_objc ().
* c-pch.c (get_ident): Use c_language.
* c-pretty-print.c (pp_c_bool_literal): Use c_dialect_ macros.
* c-typeck.c (comptypes, build_c_cast): Similarly.
* objc/objc-lang.c (c_language): Define.
(LANG_HOOKS_INIT_OPTIONS): Use common hook.
(objc_init_options): Remove.
cp:
* Make-lang.in: Update.
* cp-lang.c (c_language): Define.
(LANG_HOOKS_INIT_OPTIONS): Use common hook.
* cp-tree.h (cxx_init_options): Remove.
* lex.c: Don't include diagnostic.h.
(cxx_init_options): Remove.
From-SVN: r68734
2003-06-30 21:36:25 +02:00
|
|
|
|
if (c_dialect_objc ())
|
2002-08-10 04:18:28 +02:00
|
|
|
|
objc_check_decl (value);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-12 05:25:38 +02:00
|
|
|
|
/* Generate an error for any duplicate field names in FIELDLIST. Munge
|
|
|
|
|
the list such that this does not present a problem later. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
detect_field_duplicates (tree fieldlist)
|
|
|
|
|
{
|
|
|
|
|
tree x, y;
|
|
|
|
|
int timeout = 10;
|
|
|
|
|
|
|
|
|
|
/* First, see if there are more than "a few" fields.
|
|
|
|
|
This is trivially true if there are zero or one fields. */
|
|
|
|
|
if (!fieldlist)
|
|
|
|
|
return;
|
|
|
|
|
x = TREE_CHAIN (fieldlist);
|
|
|
|
|
if (!x)
|
|
|
|
|
return;
|
|
|
|
|
do {
|
|
|
|
|
timeout--;
|
|
|
|
|
x = TREE_CHAIN (x);
|
|
|
|
|
} while (timeout > 0 && x);
|
|
|
|
|
|
|
|
|
|
/* If there were "few" fields, avoid the overhead of allocating
|
|
|
|
|
a hash table. Instead just do the nested traversal thing. */
|
|
|
|
|
if (timeout > 0)
|
|
|
|
|
{
|
|
|
|
|
for (x = TREE_CHAIN (fieldlist); x ; x = TREE_CHAIN (x))
|
|
|
|
|
if (DECL_NAME (x))
|
|
|
|
|
{
|
|
|
|
|
for (y = fieldlist; y != x; y = TREE_CHAIN (y))
|
|
|
|
|
if (DECL_NAME (y) == DECL_NAME (x))
|
|
|
|
|
{
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hduplicate member '%D'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (x), x);
|
2003-05-12 05:25:38 +02:00
|
|
|
|
DECL_NAME (x) = NULL_TREE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
htab_t htab = htab_create (37, htab_hash_pointer, htab_eq_pointer, NULL);
|
|
|
|
|
void **slot;
|
|
|
|
|
|
|
|
|
|
for (x = fieldlist; x ; x = TREE_CHAIN (x))
|
|
|
|
|
if ((y = DECL_NAME (x)) != 0)
|
|
|
|
|
{
|
|
|
|
|
slot = htab_find_slot (htab, y, INSERT);
|
|
|
|
|
if (*slot)
|
|
|
|
|
{
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hduplicate member '%D'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (x), x);
|
2003-05-12 05:25:38 +02:00
|
|
|
|
DECL_NAME (x) = NULL_TREE;
|
|
|
|
|
}
|
|
|
|
|
*slot = y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
htab_delete (htab);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Fill in the fields of a RECORD_TYPE or UNION_TYPE node, T.
|
1992-10-06 01:23:17 +01:00
|
|
|
|
FIELDLIST is a chain of FIELD_DECL nodes for the fields.
|
c-common.c, [...]: Remove all references to obstack functions obsoleted by GC...
* c-common.c, c-decl.c, c-lang.c, c-lex.c, c-parse.in, c-pragma.c,
c-typeck.c, objc/objc-act.c: Remove all references to obstack
functions obsoleted by GC, such as push_obstacks_nochange,
end_temporary_allocation, savealloc, saveable_tree_cons, etc.
and code which existed only to decide whether or not to call
them. Remove now-unused NESTED argument from start_function;
all callers changed. Do not change behavior based on ggc_p.
The use of the ixp_obstack in c-iterate.c and the util_obstack
in objc/objc-act.c remain; these are not obsoleted by garbage
collection.
* c-tree.h: Update prototype for start_function.
* c-parse.y, c-parse.c, objc/objc-parse.c, objc/objc-parse.y: Rebuild.
From-SVN: r31611
2000-01-25 18:13:14 +01:00
|
|
|
|
ATTRIBUTES are attributes to be applied to the structure. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
finish_struct (tree t, tree fieldlist, tree attributes)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree x;
|
2003-07-24 18:59:32 +02:00
|
|
|
|
int toplevel = global_scope == current_scope;
|
2001-01-05 06:58:23 +01:00
|
|
|
|
int saw_named_field;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* If this type was previously laid out as a forward reference,
|
|
|
|
|
make sure we lay it out again. */
|
|
|
|
|
|
|
|
|
|
TYPE_SIZE (t) = 0;
|
|
|
|
|
|
Table-driven attributes.
* c-decl.c, config/alpha/alpha.c, config/arc/arc.c,
config/arm/arm.c, config/arm/pe.c, config/avr/avr.c,
config/avr/avr.h, config/d30v/d30v.h, config/fr30/fr30.h,
config/h8300/h8300.c, config/i386/cygwin.h, config/i386/winnt.c,
config/m32r/m32r.c, config/mcore/mcore.c, config/sh/sh.c,
config/stormy16/stormy16.h, config/v850/v850.c, doc/c-tree.texi,
doc/tm.texi, ggc-common.c, integrate.c, print-tree.c, tree.c,
tree.h: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* tree.h (struct tree_decl): Change machine_attributes to
attributes.
* doc/c-tree.texi: Document that all attributes are now attached
to decls and types.
* c-common.c (add_attribute, attrtab, attrtab_idx,
default_valid_lang_attribute, valid_lang_attribute): Remove.
(attribute_tables, attributes_initialized,
c_common_attribute_table, default_lang_attribute_table): New
variables.
(handle_packed_attribute, handle_nocommon_attribute,
handle_common_attribute, handle_noreturn_attribute,
handle_unused_attribute, handle_const_attribute,
handle_transparent_union_attribute, handle_constructor_attribute,
handle_destructor_attribute, handle_mode_attribute,
handle_section_attribute, handle_aligned_attribute,
handle_weak_attribute, handle_alias_attribute,
handle_no_instrument_function_attribute,
handle_no_check_memory_usage_attribute, handle_malloc_attribute,
handle_no_limit_stack_attribute, handle_pure_attribute): New
functions.
(init_attributes, decl_attributes): Rewrite to implement
table-driven attributes.
* c-common.h (enum attribute_flags): Move to tree.h.
* c-format.c (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Rename to
handle_format_attribute and handle_format_arg_attribute. Update
for table-driven attributes.
* c-common.h (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Remove prototypes.
(handle_format_attribute, handle_format_arg_attribute): Add
prototypes.
* c-decl.c (grokdeclarator): Handle attributes nested inside
declarators.
* c-parse.in (setattrs, maybe_setattrs): Remove.
(maybe_type_quals_setattrs): Rename to maybe_type_quals_attrs.
Update to handle nested attributes properly.
(maybe_resetattrs, after_type_declarator,
parm_declarator_nostarttypename, notype_declarator, absdcl1_noea,
absdcl1_ea, direct_absdcl1): Update to handle nested attributes
properly.
(make_pointer_declarator): Update to handle nested attributes
properly.
* doc/extend.texi: Update documentation of limits of attributes
syntax. Warn about problems with attribute semantics in C++.
* target.h (struct target): Remove valid_decl_attribute and
valid_type_attribute. Add attribute_table and
function_attribute_inlinable_p.
* target-def.h (TARGET_VALID_DECL_ATTRIBUTE,
TARGET_VALID_TYPE_ATTRIBUTE): Remove.
(TARGET_ATTRIBUTE_TABLE, TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P):
Add.
(TARGET_INITIALIZER): Update.
* integrate.c (FUNCTION_ATTRIBUTE_INLINABLE_P): Remove default
definition.
(function_attribute_inlinable_p): New function. Check for the
presence of any machine attributes before using
targetm.function_attribute_inlinable_p.
(function_cannot_inline_p): Update.
* Makefile.in (integrate.o): Update dependencies.
* doc/tm.texi: Update documentation of target attributes and
example definition of TARGET_VALID_TYPE_ATTRIBUTE.
* tree.c (default_valid_attribute_p, valid_machine_attribute):
Remove.
(default_target_attribute_table,
default_function_attribute_inlinable_p): New.
(lookup_attribute): Update comment to clarify handling of multiple
attributes with the same name.
(merge_attributes, attribute_list_contained): Allow multiple
attributes with the same name but different arguments to appear in
the same attribute list.
* tree.h (default_valid_attribute_p): Remove prototype.
(struct attribute_spec): New.
(default_target_attribute_table): Declare.
(enum attribute_flags): Move from c-common.h. Add
ATTR_FLAG_TYPE_IN_PLACE.
(default_function_attribute_inlinable_p): Declare.
* config/alpha/alpha.c (vms_valid_decl_attribute_p): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(vms_attribute_table): New.
* config/arc/arc.c (arc_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arc_attribute_table, arc_handle_interrupt_attribute): New.
* config/arm/arm.c (arm_valid_type_attribute_p,
arm_valid_decl_attribute_p, arm_pe_valid_decl_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arm_attribute_table, arm_handle_fndecl_attribute,
arm_handle_isr_attribute): New.
* config/avr/avr.c (avr_valid_type_attribute,
avr_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE, TARGET_VALID_TYPE_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(avr_attribute_table, avr_handle_progmem_attribute,
avr_handle_fndecl_attribute): New.
* config/c4x/c4x.c (c4x_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(c4x_attribute_table, c4x_handle_fntype_attribute): New.
* config/h8300/h8300.c (h8300_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(h8300_attribute_table, h8300_handle_fndecl_attribute,
h8300_handle_eightbit_data_attribute,
h8300_handle_tiny_data_attribute): New.
* config/i386/i386-protos.h (ix86_valid_type_attribute_p,
i386_pe_valid_decl_attribute_p, i386_pe_valid_type_attribute_p):
Remove prototypes.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New
declarations.
* config/i386/i386.c (ix86_valid_type_attribute_p: Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ix86_attribute_table, ix86_handle_cdecl_attribute,
ix86_handle_regparm_attribute): New.
* config/i386/winnt.c (i386_pe_valid_decl_attribute_p,
i386_pe_valid_type_attribute_p): Remove.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New.
* config/ia64/ia64.c (ia64_valid_type_attribute): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ia64_attribute_table): New.
* config/m32r/m32r.c (m32r_valid_decl_attribute, interrupt_ident1,
interrupt_ident2, model_ident1, model_ident2): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(init_idents): Update.
(m32r_attribute_table, m32r_handle_model_attribute): New.
* config/m68hc11/m68hc11.c (m68hc11_valid_type_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(m68hc11_attribute_table, m68hc11_handle_fntype_attribute): New.
* config/mcore/mcore.c (mcore_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(mcore_attribute_table, mcore_handle_naked_attribute): New.
* config/ns32k/ns32k.c (ns32k_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ns32k_attribute_table, ns32k_handle_fntype_attribute): New.
* config/rs6000/rs6000.c (rs6000_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(rs6000_attribute_table, rs6000_handle_longcall_attribute): New.
* config/sh/sh.c (sh_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(sh_attribute_table, sh_handle_interrupt_handler_attribute,
sh_handle_sp_switch_attribute, sh_handle_trap_exit_attribute):
New.
* config/stormy16/stormy16.c (stormy16_valid_type_attribute):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define
(TARGET_ATTRIBUTE_TABLE): Define.
(stormy16_attribute_table, stormy16_handle_interrupt_attribute):
New.
* config/v850/v850.c (v850_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(v850_attribute_table, v850_handle_interrupt_attribute,
v850_handle_data_area_attribute): New.
* config/v850/v850-c.c (mark_current_function_as_interrupt):
Return void. Call decl_attributes instead of
valid_machine_attribute.
cp:
Table-driven attributes.
* decl.c: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* decl2.c (cplus_decl_attributes): Only take one attributes
parameter.
* cp-tree.c (cplus_decl_attributes): Update prototype.
* class.c (finish_struct), decl.c (start_decl, start_function),
decl2.c (grokfield), friend.c (do_friend), parse.y
(parse_bitfield): Update calls to cplus_decl_attributes.
* decl.c (grokdeclarator): Take a pointer to a single ordinary
attribute list.
* decl.h (grokdeclarator): Update prototype.
* decl2.c (grokfield): Take a single ordinary attribute list.
* friend.c (do_friend): Likewise.
* decl.c (shadow_tag, groktypename, start_decl,
start_handler_parms, grokdeclarator, grokparms, start_function,
start_method), decl2.c (grokfield, grokbitfield, grokoptypename),
parse.y (parse_field, parse_bitfield, component_decl_1), pt.c
(process_template_parm, do_decl_instantiation): Pass single
ordinary attribute lists around.
* decl.c (grokdeclarator): Correct handling of nested attributes.
Revert the patch
1998-10-18 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (grokdeclarator): Embedded attrs bind to the right,
not the left.
.
* cp-tree.h (cp_valid_lang_attribute): Remove declaration
(cp_attribute_table): Declare.
* decl.c (valid_lang_attribute): Don't define.
(lang_attribute_table): Define.
(init_decl_processing): Initialize lang_attribute_table instead of
valid_lang_attribute.
* tree.c (cp_valid_lang_attribute): Remove.
(handle_java_interface_attribute, handle_com_interface_attribute,
handle_init_priority_attribute): New functions.
(cp_attribute_table): New array.
* decl2.c (import_export_class): Don't use
targetm.valid_type_attribute.
testsuite:
Table-driven attributes.
* g++.dg/ext/attrib1.C: New test.
From-SVN: r45718
2001-09-21 03:27:06 +02:00
|
|
|
|
decl_attributes (&t, attributes, (int) ATTR_FLAG_TYPE_IN_PLACE);
|
1995-04-26 23:24:01 +02:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Nameless union parm types are useful as GCC extension. */
|
|
|
|
|
if (! (TREE_CODE (t) == UNION_TYPE && TYPE_NAME (t) == 0) && !pedantic)
|
|
|
|
|
/* Otherwise, warn about any struct or union def. in parmlist. */
|
|
|
|
|
if (in_parm_level_p ())
|
|
|
|
|
{
|
|
|
|
|
if (pedantic)
|
c-common.c (check_format_info): Don't call a variadic function with a non-literal format string.
* c-common.c (check_format_info): Don't call a variadic function
with a non-literal format string.
* c-decl.c (grokdeclarator, start_struct, finish_struct): Likewise.
* c-typeck.c (build_component_ref, build_unary_op, lvalue_or_else,
pedantic_lvalue_warning, error_init, pedwarn_init, warning_init):
Likewise.
* cccp.c (check_macro_name, do_xifdef, vwarning_with_line):
Likewise.
* collect2.c (collect_wait): Likewise.
* dbxout.c (dbxout_type): Likewise.
* gcc.c (do_spec_1): Likewise.
* genemit.c (gen_insn, gen_expand): Likewise.
* genrecog.c (write_switch, write_subroutine): Likewise.
* mips-tfile.c (catch_signal, botch): Likewise.
* print-rtl.c (print_rtx): Likewise.
* toplev.c (default_print_error_function, report_error_function,
_fatal_insn): Likewise.
From-SVN: r30666
1999-11-25 17:58:32 +01:00
|
|
|
|
pedwarn ("%s defined inside parms",
|
2000-06-29 01:46:27 +02:00
|
|
|
|
TREE_CODE (t) == UNION_TYPE ? _("union") : _("structure"));
|
c-common.c, [...]: Delete code implementing -traditional mode.
* c-common.c, c-common.h, c-decl.c, c-lex.c, c-parse.in,
c-tree.h, c-typeck.c, cppexp.c, cpplex.c, cpplib.c, cpplib.h,
cppmacro.c, objc/lang-specs.h, objc/objc-act.c,
builtin-types.def, builtins.def, dwarf2out.c, dwarfout.c,
gcc.c, toplev.c: Delete code implementing -traditional mode.
* ada/misc.c, ch/ch-tree.h, ch/decl.c, cp/decl2.c, f/com.c,
f/lex.c, f/top.c, java/builtins.c, java/decl.c: Delete
traditional-mode-related code copied from the C front end
but not used, or used only to permit the compiler to link.
* doc/bugreport.texi, doc/cpp.texi, doc/extend.texi,
doc/invoke.texi, doc/standards.texi, doc/trouble.texi:
Document removal of -traditional mode for compilation, and
remove documentation only relevant to that mode.
* config/nextstep.h, config/ptx4.h, config/svr4.h,
config/convex/convex.h, config/d30v/d30v.h,
config/i386/dgux.h, config/i386/osf1elf.h,
config/i386/osfelf.h, config/i386/osfrose.h,
config/i386/sco5.h, config/i386/sol2.h, config/m68k/a-ux.h,
config/m68k/hp310.h, config/m88k/dgux.h,
config/m88k/dguxbcs.h, config/m88k/luna.h, config/m88k/m88k.c,
config/m88k/m88k.h, config/m88k/openbsd.h,
config/mips/abi64.h, config/mips/osfrose.h,
config/mips/svr4-5.h, config/mips/svr4-t.h,
config/sparc/sol2-sld-64.h, config/sparc/sol2.h,
config/stormy16/stormy16.h: Remove all references to
-traditional from target specs. Delete all mention of the
no-longer-necessary TRADITIONAL_RETURN_FLOAT macro. Also
delete a couple of commented-out definitions of
DOLLARS_IN_IDENTIFIERS, with (incorrect) commentary referring
to -traditional.
* system.h: Poison TRADITIONAL_RETURN_FLOAT.
* doc/tm.texi: Remove mention of TRADITIONAL_RETURN_FLOAT macro.
* testsuite/gcc.c-torture/execute/920730-1t.c,
testsuite/gcc.c-torture/execute/920730-1t.x,
testsuite/gcc.dg/ext-glob.c: Delete test cases, only relevant
to -traditional.
From-SVN: r50110
2002-02-27 19:48:07 +01:00
|
|
|
|
else
|
c-common.c (check_format_info): Don't call a variadic function with a non-literal format string.
* c-common.c (check_format_info): Don't call a variadic function
with a non-literal format string.
* c-decl.c (grokdeclarator, start_struct, finish_struct): Likewise.
* c-typeck.c (build_component_ref, build_unary_op, lvalue_or_else,
pedantic_lvalue_warning, error_init, pedwarn_init, warning_init):
Likewise.
* cccp.c (check_macro_name, do_xifdef, vwarning_with_line):
Likewise.
* collect2.c (collect_wait): Likewise.
* dbxout.c (dbxout_type): Likewise.
* gcc.c (do_spec_1): Likewise.
* genemit.c (gen_insn, gen_expand): Likewise.
* genrecog.c (write_switch, write_subroutine): Likewise.
* mips-tfile.c (catch_signal, botch): Likewise.
* print-rtl.c (print_rtx): Likewise.
* toplev.c (default_print_error_function, report_error_function,
_fatal_insn): Likewise.
From-SVN: r30666
1999-11-25 17:58:32 +01:00
|
|
|
|
warning ("%s defined inside parms",
|
2000-06-29 01:46:27 +02:00
|
|
|
|
TREE_CODE (t) == UNION_TYPE ? _("union") : _("structure"));
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-11 23:46:05 +02:00
|
|
|
|
if (pedantic)
|
|
|
|
|
{
|
|
|
|
|
for (x = fieldlist; x; x = TREE_CHAIN (x))
|
|
|
|
|
if (DECL_NAME (x) != 0)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (x == 0)
|
2000-06-29 01:46:27 +02:00
|
|
|
|
pedwarn ("%s has no %s",
|
|
|
|
|
TREE_CODE (t) == UNION_TYPE ? _("union") : _("struct"),
|
|
|
|
|
fieldlist ? _("named members") : _("members"));
|
1996-08-11 23:46:05 +02:00
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2002-02-02 01:14:41 +01:00
|
|
|
|
/* Install struct as DECL_CONTEXT of each field decl.
|
|
|
|
|
Also process specified field sizes,m which is found in the DECL_INITIAL.
|
|
|
|
|
Store 0 there, except for ": 0" fields (so we can find them
|
|
|
|
|
and delete them, below). */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2001-01-05 06:58:23 +01:00
|
|
|
|
saw_named_field = 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
for (x = fieldlist; x; x = TREE_CHAIN (x))
|
|
|
|
|
{
|
|
|
|
|
DECL_CONTEXT (x) = t;
|
1995-05-12 00:43:43 +02:00
|
|
|
|
DECL_PACKED (x) |= TYPE_PACKED (t);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* If any field is const, the structure type is pseudo-const. */
|
|
|
|
|
if (TREE_READONLY (x))
|
|
|
|
|
C_TYPE_FIELDS_READONLY (t) = 1;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* A field that is pseudo-const makes the structure likewise. */
|
|
|
|
|
tree t1 = TREE_TYPE (x);
|
|
|
|
|
while (TREE_CODE (t1) == ARRAY_TYPE)
|
|
|
|
|
t1 = TREE_TYPE (t1);
|
|
|
|
|
if ((TREE_CODE (t1) == RECORD_TYPE || TREE_CODE (t1) == UNION_TYPE)
|
|
|
|
|
&& C_TYPE_FIELDS_READONLY (t1))
|
|
|
|
|
C_TYPE_FIELDS_READONLY (t) = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Any field that is volatile means variables of this type must be
|
|
|
|
|
treated in some ways as volatile. */
|
|
|
|
|
if (TREE_THIS_VOLATILE (x))
|
|
|
|
|
C_TYPE_FIELDS_VOLATILE (t) = 1;
|
|
|
|
|
|
|
|
|
|
/* Any field of nominal variable size implies structure is too. */
|
|
|
|
|
if (C_DECL_VARIABLE_SIZE (x))
|
|
|
|
|
C_TYPE_VARIABLE_SIZE (t) = 1;
|
|
|
|
|
|
1992-07-15 20:39:52 +02:00
|
|
|
|
/* Detect invalid nested redefinition. */
|
|
|
|
|
if (TREE_TYPE (x) == t)
|
|
|
|
|
error ("nested redefinition of `%s'",
|
|
|
|
|
IDENTIFIER_POINTER (TYPE_NAME (t)));
|
|
|
|
|
|
2002-02-02 01:14:41 +01:00
|
|
|
|
/* Detect invalid bit-field size. */
|
|
|
|
|
if (DECL_INITIAL (x))
|
|
|
|
|
STRIP_NOPS (DECL_INITIAL (x));
|
|
|
|
|
if (DECL_INITIAL (x))
|
|
|
|
|
{
|
|
|
|
|
if (TREE_CODE (DECL_INITIAL (x)) == INTEGER_CST)
|
|
|
|
|
constant_expression_warning (DECL_INITIAL (x));
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hbit-field '%D' width not an integer constant",
|
|
|
|
|
&DECL_SOURCE_LOCATION (x), x);
|
2002-02-02 01:14:41 +01:00
|
|
|
|
DECL_INITIAL (x) = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Detect invalid bit-field type. */
|
|
|
|
|
if (DECL_INITIAL (x)
|
|
|
|
|
&& TREE_CODE (TREE_TYPE (x)) != INTEGER_TYPE
|
|
|
|
|
&& TREE_CODE (TREE_TYPE (x)) != BOOLEAN_TYPE
|
|
|
|
|
&& TREE_CODE (TREE_TYPE (x)) != ENUMERAL_TYPE)
|
|
|
|
|
{
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hbit-field '%D' has invalid type",
|
|
|
|
|
&DECL_SOURCE_LOCATION (x), x);
|
2002-02-02 01:14:41 +01:00
|
|
|
|
DECL_INITIAL (x) = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (DECL_INITIAL (x) && pedantic
|
|
|
|
|
&& TYPE_MAIN_VARIANT (TREE_TYPE (x)) != integer_type_node
|
|
|
|
|
&& TYPE_MAIN_VARIANT (TREE_TYPE (x)) != unsigned_type_node
|
2003-07-24 22:48:13 +02:00
|
|
|
|
&& TYPE_MAIN_VARIANT (TREE_TYPE (x)) != boolean_type_node
|
2002-02-02 01:14:41 +01:00
|
|
|
|
/* Accept an enum that's equivalent to int or unsigned int. */
|
|
|
|
|
&& !(TREE_CODE (TREE_TYPE (x)) == ENUMERAL_TYPE
|
|
|
|
|
&& (TYPE_PRECISION (TREE_TYPE (x))
|
|
|
|
|
== TYPE_PRECISION (integer_type_node))))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
pedwarn ("%Hbit-field '%D' type invalid in ISO C",
|
|
|
|
|
&DECL_SOURCE_LOCATION (x), x);
|
2002-02-02 01:14:41 +01:00
|
|
|
|
|
|
|
|
|
/* Detect and ignore out of range field width and process valid
|
|
|
|
|
field widths. */
|
|
|
|
|
if (DECL_INITIAL (x))
|
|
|
|
|
{
|
|
|
|
|
int max_width
|
2003-07-24 22:48:13 +02:00
|
|
|
|
= (TYPE_MAIN_VARIANT (TREE_TYPE (x)) == boolean_type_node
|
2002-02-02 01:14:41 +01:00
|
|
|
|
? CHAR_TYPE_SIZE : TYPE_PRECISION (TREE_TYPE (x)));
|
|
|
|
|
|
|
|
|
|
if (tree_int_cst_sgn (DECL_INITIAL (x)) < 0)
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hnegative width in bit-field '%D'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (x), x);
|
2002-02-02 01:14:41 +01:00
|
|
|
|
else if (0 < compare_tree_int (DECL_INITIAL (x), max_width))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
pedwarn ("%Hwidth of '%D' exceeds its type",
|
|
|
|
|
&DECL_SOURCE_LOCATION (x), x);
|
2002-02-02 01:14:41 +01:00
|
|
|
|
else if (integer_zerop (DECL_INITIAL (x)) && DECL_NAME (x) != 0)
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hzero width for bit-field '%D'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (x), x);
|
2002-02-02 01:14:41 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* The test above has assured us that TREE_INT_CST_HIGH is 0. */
|
|
|
|
|
unsigned HOST_WIDE_INT width
|
|
|
|
|
= tree_low_cst (DECL_INITIAL (x), 1);
|
|
|
|
|
|
|
|
|
|
if (TREE_CODE (TREE_TYPE (x)) == ENUMERAL_TYPE
|
|
|
|
|
&& (width < min_precision (TYPE_MIN_VALUE (TREE_TYPE (x)),
|
|
|
|
|
TREE_UNSIGNED (TREE_TYPE (x)))
|
|
|
|
|
|| (width
|
|
|
|
|
< min_precision (TYPE_MAX_VALUE (TREE_TYPE (x)),
|
|
|
|
|
TREE_UNSIGNED (TREE_TYPE (x))))))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
warning ("%H'%D' is narrower than values of its type",
|
|
|
|
|
&DECL_SOURCE_LOCATION (x), x);
|
2002-02-02 01:14:41 +01:00
|
|
|
|
|
|
|
|
|
DECL_SIZE (x) = bitsize_int (width);
|
|
|
|
|
DECL_BIT_FIELD (x) = 1;
|
|
|
|
|
SET_DECL_C_BIT_FIELD (x);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DECL_INITIAL (x) = 0;
|
|
|
|
|
|
2001-01-05 06:58:23 +01:00
|
|
|
|
/* Detect flexible array member in an invalid context. */
|
|
|
|
|
if (TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE
|
|
|
|
|
&& TYPE_SIZE (TREE_TYPE (x)) == NULL_TREE
|
|
|
|
|
&& TYPE_DOMAIN (TREE_TYPE (x)) != NULL_TREE
|
|
|
|
|
&& TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (x))) == NULL_TREE)
|
|
|
|
|
{
|
|
|
|
|
if (TREE_CODE (t) == UNION_TYPE)
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hflexible array member in union",
|
|
|
|
|
&DECL_SOURCE_LOCATION (x));
|
2001-01-05 06:58:23 +01:00
|
|
|
|
else if (TREE_CHAIN (x) != NULL_TREE)
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hflexible array member not at end of struct",
|
|
|
|
|
&DECL_SOURCE_LOCATION (x));
|
2001-01-05 06:58:23 +01:00
|
|
|
|
else if (! saw_named_field)
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hflexible array member in otherwise empty struct",
|
|
|
|
|
&DECL_SOURCE_LOCATION (x));
|
2001-01-05 06:58:23 +01:00
|
|
|
|
}
|
2002-08-17 16:48:28 +02:00
|
|
|
|
|
|
|
|
|
if (pedantic && TREE_CODE (t) == RECORD_TYPE
|
|
|
|
|
&& flexible_array_type_p (TREE_TYPE (x)))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
pedwarn ("%Hinvalid use of structure with flexible array member",
|
|
|
|
|
&DECL_SOURCE_LOCATION (x));
|
2002-08-17 16:48:28 +02:00
|
|
|
|
|
2001-01-05 06:58:23 +01:00
|
|
|
|
if (DECL_NAME (x))
|
|
|
|
|
saw_named_field = 1;
|
tree.h (INT_CST_LT, [...]): Remove unneeded casts.
* tree.h (INT_CST_LT, INT_CST_LT_UNSIGNED): Remove unneeded casts.
(struct tree_int_cst): int_cst_low is now unsigned HOST_WIDE_INT.
(attribute_hash_list, type_hash_canon): hashcode is now unsigned.
(type_hash_lookup, type_hash_add, type_hash_list): Likewise.
(min_precision): Result is unsignd.
(add_double, neg_double, mul_double): Low word is unsigned.
(lshift_double, rshift_double, lrotate_double): Likewise.
(rrotate_double, div_and_round_double): Likewise.
(tree_floor_log2, compare_tree_int): New functions.
(preserve_rtl_expr_temps): New declaration.
* c-common.c (declare_hidden_char_array): Use compare_tree_int.
(decl_attributes): Use tree_log2 to find alignment.
Check for TREE_INT_CST_HIGH for format args.
(min_precision): Now unsigned.
Use tree_floor_log2.
(truthvalue_conversion): Delete long-disabled code.
* c-decl.c (finish_struct): Clean up tests on field width.
(finish_function): Use compare_tree_int.
* c-pragma.c (handle_pragma_token): Use tree_log2 for alignment.
* c-typeck.c (comptypes): Use tree_int_cst_equal.
(default_conversion, digest_init): Use compare_tree_int.
(build_binary_op): Use integer_all_onesp and compare_tree_int.
Fix type errors in forming masks.
* calls.c (initialize_argument_information): Use compare_tree_int.
* dbxout.c (dbxout_type): Cast TREE_INT_CST_LOW to HOST_WIDE_INT.
* except.c (expand_eh_region_start_tree): Use compare_tree_int.
* expr.c (is_zeros_p, case INTEGER_CST): Use integer_zerop.
(store_field): Use compare_tree_int.
(expand_expr, case CONSTRUCTOR): Use TYPE_SIZE_UNIT.
(expand_expr, case ARRAY_REF): Use compare_tree_int.
(do_jump, case BIT_AND_EXPR): Use tree_floor_log2.
(do_store_flag): Use compare_tree_int.
* fold-const.c (encode, decode): Low part is always unsigned.
(force_fit_type, add_double, neg_double, mul_double): Likewise.
(lshift_double, rshift_double, lrotate_double): Likewise.
(rrotate_double, div_and_round_double, int_const_binop): Likewise.
(fold_convert): Use compare_tree_int.
(operand_equal_p, case INTEGER_CST): Use tree_int_cst_equal.
(invert_truthvalue, case INTEGER_CST): Likewise.
(fold): Use compare_tree_int; add casts for unsigned TREE_INT_CST_LOW.
* mkdeps.c (deps_dummy_targets): Make I unsigned.
* rtl.h (add_double, neg_double, mul_double): Low words are unsigned.
(lshift_double, rshift_double, lrotate_double, rrotate_double):
Likewise.
* stmt.c (expand_decl): Use compare_tree_int and mode_for_size_tree.
(expand_end_case): Use compare_tree_int.
(estimate_case_costs): Cast TREE_INT_CST_LOW to HOST_WIDE_INT.
* stor-layout.c (mode_for_size_tree): Use compare_tree_int.
(layout_decl): Likewise.
(layout_record, layout_union): Make sizes unsigned.
(layout_type, case VOID_TYPE): TYPE_SIZE must be bitsizetype.
(layout_type, case QUAL_UNION_TYPE): Use compare_tree_int.
* tree.c (struct type_hash): hashcode is unsigned.
(build_type_attribute_variant, type_hash_list): Likewise.
(type_hash_lookup, type_hash_add, type_hash_canon): Likewise.
(attribute_hash_list, build_array_type, build_method_type): Likewise.
(build_complex_type): Likewise.
(real_value_from_int_cst): Remove unneeded casts.
(integer_all_onesp): Add casts.
(tree_floor_log2, compare_tree_int): New functions.
(build_index_type): Use tree_int_cst_sgn.
* varasm.c (assemble_variable): Use compare_tree_int.
* ch/actions.c (chill_convert_for_assignment): INDEX is unsigned
HOST_WIDE_INT.
* ch/ch-tree.h (DECL_NESTING_LEVEL): Use TREE_INT_CST_HIGH
since unsigned.
* ch/except.c (chill_handle_on_labels): ALTERNATIVE is unsigned.
Use compare_tree_int.
(expand_goto_except_cleanup): Likewise.
* cp/class.c (dfs_modify_vtables): I is now unsigned.
(check_bitfield_decl): Use tree_int_cst_sgn and compare_tree_int.
(build_base_field): Add casts of TREE_INT_CST_LOW to HOST_WIDE_INT.
* cp/error.c (dump_expr): Cast TREE_INT_CST_HIGH to unsigned.
* cp/init.c (build_vec_init): Cast TREE_INT_CST_LOW to HOST_WIDE_INT.
* cp/method.c (build_overload_int): Cast TREE_INT_CST_HIGH to unsigned.
* cp/typeck.c (build_binary_op, case TRUNC_DIV_EXPR):
Call integer_all_onesp.
* cp/typeck2.c (process_init_constructor): Use compare_tree_int.
* f/com.c (ffecom_f2c_set_lio_code_): Use compare_tree_int.
(ffecom_sym_transform_, ffecom_transform_common_): Likewise.
(ffecom_transform_equiv_): Likewise.
* java/decl.c (emit_init_test_initialization): Mark KEY as unused.
* java/expr.c (build_newarray): Cast TREE_INT_CST_LOW to HOST_WIDE_INT.
(build_anewarray): Likewise.
* java/parse.y (patch_newarray): Likewise.
* java/parse.c: Regenerated.
From-SVN: r32383
2000-03-07 12:41:32 +01:00
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-05-12 05:25:38 +02:00
|
|
|
|
detect_field_duplicates (fieldlist);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* Now we have the nearly final fieldlist. Record it,
|
|
|
|
|
then lay out the structure or union (including the fields). */
|
|
|
|
|
|
|
|
|
|
TYPE_FIELDS (t) = fieldlist;
|
|
|
|
|
|
|
|
|
|
layout_type (t);
|
|
|
|
|
|
1999-10-08 02:10:09 +02:00
|
|
|
|
/* Delete all zero-width bit-fields from the fieldlist */
|
|
|
|
|
{
|
|
|
|
|
tree *fieldlistp = &fieldlist;
|
1999-10-10 21:23:38 +02:00
|
|
|
|
while (*fieldlistp)
|
|
|
|
|
if (TREE_CODE (*fieldlistp) == FIELD_DECL && DECL_INITIAL (*fieldlistp))
|
1999-10-08 02:10:09 +02:00
|
|
|
|
*fieldlistp = TREE_CHAIN (*fieldlistp);
|
|
|
|
|
else
|
|
|
|
|
fieldlistp = &TREE_CHAIN (*fieldlistp);
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2001-01-05 06:58:23 +01:00
|
|
|
|
/* Now we have the truly final field list.
|
|
|
|
|
Store it in this type and in the variants. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
TYPE_FIELDS (t) = fieldlist;
|
|
|
|
|
|
2003-07-16 20:45:56 +02:00
|
|
|
|
/* If there are lots of fields, sort so we can look through them fast.
|
|
|
|
|
We arbitrarily consider 16 or more elts to be "a lot". */
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
int len = 0;
|
|
|
|
|
|
|
|
|
|
for (x = fieldlist; x; x = TREE_CHAIN (x))
|
|
|
|
|
{
|
|
|
|
|
if (len > 15 || DECL_NAME (x) == NULL)
|
|
|
|
|
break;
|
|
|
|
|
len += 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (len > 15)
|
|
|
|
|
{
|
|
|
|
|
tree *field_array;
|
|
|
|
|
struct lang_type *space;
|
|
|
|
|
struct sorted_fields_type *space2;
|
|
|
|
|
|
|
|
|
|
len += list_length (x);
|
|
|
|
|
|
|
|
|
|
/* Use the same allocation policy here that make_node uses, to
|
|
|
|
|
ensure that this lives as long as the rest of the struct decl.
|
|
|
|
|
All decls in an inline function need to be saved. */
|
|
|
|
|
|
|
|
|
|
space = ggc_alloc (sizeof (struct lang_type));
|
|
|
|
|
space2 = ggc_alloc (sizeof (struct sorted_fields_type) + len * sizeof (tree));
|
|
|
|
|
|
|
|
|
|
len = 0;
|
|
|
|
|
space->s = space2;
|
|
|
|
|
field_array = &space2->elts[0];
|
|
|
|
|
for (x = fieldlist; x; x = TREE_CHAIN (x))
|
|
|
|
|
{
|
|
|
|
|
field_array[len++] = x;
|
|
|
|
|
|
2003-07-23 01:15:30 +02:00
|
|
|
|
/* If there is anonymous struct or union, break out of the loop. */
|
2003-07-16 20:45:56 +02:00
|
|
|
|
if (DECL_NAME (x) == NULL)
|
|
|
|
|
break;
|
|
|
|
|
}
|
2003-07-23 01:15:30 +02:00
|
|
|
|
/* Found no anonymous struct/union. Add the TYPE_LANG_SPECIFIC. */
|
2003-07-16 20:45:56 +02:00
|
|
|
|
if (x == NULL)
|
|
|
|
|
{
|
|
|
|
|
TYPE_LANG_SPECIFIC (t) = space;
|
|
|
|
|
TYPE_LANG_SPECIFIC (t)->s->len = len;
|
|
|
|
|
field_array = TYPE_LANG_SPECIFIC (t)->s->elts;
|
|
|
|
|
qsort (field_array, len, sizeof (tree), field_decl_cmp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
for (x = TYPE_MAIN_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x))
|
|
|
|
|
{
|
|
|
|
|
TYPE_FIELDS (x) = TYPE_FIELDS (t);
|
|
|
|
|
TYPE_LANG_SPECIFIC (x) = TYPE_LANG_SPECIFIC (t);
|
|
|
|
|
TYPE_ALIGN (x) = TYPE_ALIGN (t);
|
2000-06-14 07:30:09 +02:00
|
|
|
|
TYPE_USER_ALIGN (x) = TYPE_USER_ALIGN (t);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
1995-08-30 01:15:47 +02:00
|
|
|
|
/* If this was supposed to be a transparent union, but we can't
|
|
|
|
|
make it one, warn and turn off the flag. */
|
|
|
|
|
if (TREE_CODE (t) == UNION_TYPE
|
|
|
|
|
&& TYPE_TRANSPARENT_UNION (t)
|
|
|
|
|
&& TYPE_MODE (t) != DECL_MODE (TYPE_FIELDS (t)))
|
|
|
|
|
{
|
|
|
|
|
TYPE_TRANSPARENT_UNION (t) = 0;
|
1996-02-02 18:42:40 +01:00
|
|
|
|
warning ("union cannot be made transparent");
|
1995-08-30 01:15:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* If this structure or union completes the type of any previous
|
|
|
|
|
variable declaration, lay it out and output its rtl. */
|
2003-08-30 23:21:40 +02:00
|
|
|
|
for (x = C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t));
|
|
|
|
|
x;
|
|
|
|
|
x = TREE_CHAIN (x))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-08-30 23:21:40 +02:00
|
|
|
|
tree decl = TREE_VALUE (x);
|
|
|
|
|
if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
|
|
|
|
|
layout_array_type (TREE_TYPE (decl));
|
|
|
|
|
if (TREE_CODE (decl) != TYPE_DECL)
|
|
|
|
|
{
|
|
|
|
|
layout_decl (decl, 0);
|
|
|
|
|
if (c_dialect_objc ())
|
|
|
|
|
objc_check_decl (decl);
|
|
|
|
|
rest_of_decl_compilation (decl, NULL, toplevel, 0);
|
|
|
|
|
if (! toplevel)
|
|
|
|
|
expand_decl (decl);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-08-30 23:21:40 +02:00
|
|
|
|
C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t)) = 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* Finish debugging output for this type. */
|
|
|
|
|
rest_of_type_compilation (t, toplevel);
|
|
|
|
|
|
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Lay out the type T, and its element type, and so on. */
|
|
|
|
|
|
|
|
|
|
static void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
layout_array_type (tree t)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
|
|
|
|
|
layout_array_type (TREE_TYPE (t));
|
|
|
|
|
layout_type (t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Begin compiling the definition of an enumeration type.
|
|
|
|
|
NAME is its name (or null if anonymous).
|
|
|
|
|
Returns the type object, as yet incomplete.
|
|
|
|
|
Also records info about it so that build_enumerator
|
|
|
|
|
may be used to declare the individual values as they are read. */
|
|
|
|
|
|
|
|
|
|
tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
start_enum (tree name)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree enumtype = 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* If this is the real definition for a previous forward reference,
|
|
|
|
|
fill in the contents in the same object that used to be the
|
|
|
|
|
forward reference. */
|
|
|
|
|
|
|
|
|
|
if (name != 0)
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
enumtype = lookup_tag (ENUMERAL_TYPE, name, 1);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
if (enumtype == 0 || TREE_CODE (enumtype) != ENUMERAL_TYPE)
|
|
|
|
|
{
|
|
|
|
|
enumtype = make_node (ENUMERAL_TYPE);
|
|
|
|
|
pushtag (name, enumtype);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
C_TYPE_BEING_DEFINED (enumtype) = 1;
|
|
|
|
|
|
|
|
|
|
if (TYPE_VALUES (enumtype) != 0)
|
|
|
|
|
{
|
|
|
|
|
/* This enum is a named one that has been declared already. */
|
|
|
|
|
error ("redeclaration of `enum %s'", IDENTIFIER_POINTER (name));
|
|
|
|
|
|
|
|
|
|
/* Completely replace its old definition.
|
|
|
|
|
The old enumerators remain defined, however. */
|
|
|
|
|
TYPE_VALUES (enumtype) = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum_next_value = integer_zero_node;
|
1992-05-18 07:09:24 +02:00
|
|
|
|
enum_overflow = 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
1996-06-03 13:57:03 +02:00
|
|
|
|
if (flag_short_enums)
|
|
|
|
|
TYPE_PACKED (enumtype) = 1;
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
return enumtype;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* After processing and defining all the values of an enumeration type,
|
|
|
|
|
install their decls in the enumeration type and finish it off.
|
1995-04-26 23:24:01 +02:00
|
|
|
|
ENUMTYPE is the type object, VALUES a list of decl-value pairs,
|
|
|
|
|
and ATTRIBUTES are the specified attributes.
|
1992-02-13 23:21:26 +01:00
|
|
|
|
Returns ENUMTYPE. */
|
|
|
|
|
|
|
|
|
|
tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
finish_enum (tree enumtype, tree values, tree attributes)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree pair, tem;
|
2000-07-26 05:50:56 +02:00
|
|
|
|
tree minnode = 0, maxnode = 0, enum_value_type;
|
2000-01-05 20:26:23 +01:00
|
|
|
|
int precision, unsign;
|
2003-07-24 18:59:32 +02:00
|
|
|
|
int toplevel = (global_scope == current_scope);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
if (in_parm_level_p ())
|
|
|
|
|
warning ("enum defined inside parms");
|
|
|
|
|
|
Table-driven attributes.
* c-decl.c, config/alpha/alpha.c, config/arc/arc.c,
config/arm/arm.c, config/arm/pe.c, config/avr/avr.c,
config/avr/avr.h, config/d30v/d30v.h, config/fr30/fr30.h,
config/h8300/h8300.c, config/i386/cygwin.h, config/i386/winnt.c,
config/m32r/m32r.c, config/mcore/mcore.c, config/sh/sh.c,
config/stormy16/stormy16.h, config/v850/v850.c, doc/c-tree.texi,
doc/tm.texi, ggc-common.c, integrate.c, print-tree.c, tree.c,
tree.h: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* tree.h (struct tree_decl): Change machine_attributes to
attributes.
* doc/c-tree.texi: Document that all attributes are now attached
to decls and types.
* c-common.c (add_attribute, attrtab, attrtab_idx,
default_valid_lang_attribute, valid_lang_attribute): Remove.
(attribute_tables, attributes_initialized,
c_common_attribute_table, default_lang_attribute_table): New
variables.
(handle_packed_attribute, handle_nocommon_attribute,
handle_common_attribute, handle_noreturn_attribute,
handle_unused_attribute, handle_const_attribute,
handle_transparent_union_attribute, handle_constructor_attribute,
handle_destructor_attribute, handle_mode_attribute,
handle_section_attribute, handle_aligned_attribute,
handle_weak_attribute, handle_alias_attribute,
handle_no_instrument_function_attribute,
handle_no_check_memory_usage_attribute, handle_malloc_attribute,
handle_no_limit_stack_attribute, handle_pure_attribute): New
functions.
(init_attributes, decl_attributes): Rewrite to implement
table-driven attributes.
* c-common.h (enum attribute_flags): Move to tree.h.
* c-format.c (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Rename to
handle_format_attribute and handle_format_arg_attribute. Update
for table-driven attributes.
* c-common.h (decl_handle_format_attribute,
decl_handle_format_arg_attribute): Remove prototypes.
(handle_format_attribute, handle_format_arg_attribute): Add
prototypes.
* c-decl.c (grokdeclarator): Handle attributes nested inside
declarators.
* c-parse.in (setattrs, maybe_setattrs): Remove.
(maybe_type_quals_setattrs): Rename to maybe_type_quals_attrs.
Update to handle nested attributes properly.
(maybe_resetattrs, after_type_declarator,
parm_declarator_nostarttypename, notype_declarator, absdcl1_noea,
absdcl1_ea, direct_absdcl1): Update to handle nested attributes
properly.
(make_pointer_declarator): Update to handle nested attributes
properly.
* doc/extend.texi: Update documentation of limits of attributes
syntax. Warn about problems with attribute semantics in C++.
* target.h (struct target): Remove valid_decl_attribute and
valid_type_attribute. Add attribute_table and
function_attribute_inlinable_p.
* target-def.h (TARGET_VALID_DECL_ATTRIBUTE,
TARGET_VALID_TYPE_ATTRIBUTE): Remove.
(TARGET_ATTRIBUTE_TABLE, TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P):
Add.
(TARGET_INITIALIZER): Update.
* integrate.c (FUNCTION_ATTRIBUTE_INLINABLE_P): Remove default
definition.
(function_attribute_inlinable_p): New function. Check for the
presence of any machine attributes before using
targetm.function_attribute_inlinable_p.
(function_cannot_inline_p): Update.
* Makefile.in (integrate.o): Update dependencies.
* doc/tm.texi: Update documentation of target attributes and
example definition of TARGET_VALID_TYPE_ATTRIBUTE.
* tree.c (default_valid_attribute_p, valid_machine_attribute):
Remove.
(default_target_attribute_table,
default_function_attribute_inlinable_p): New.
(lookup_attribute): Update comment to clarify handling of multiple
attributes with the same name.
(merge_attributes, attribute_list_contained): Allow multiple
attributes with the same name but different arguments to appear in
the same attribute list.
* tree.h (default_valid_attribute_p): Remove prototype.
(struct attribute_spec): New.
(default_target_attribute_table): Declare.
(enum attribute_flags): Move from c-common.h. Add
ATTR_FLAG_TYPE_IN_PLACE.
(default_function_attribute_inlinable_p): Declare.
* config/alpha/alpha.c (vms_valid_decl_attribute_p): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(vms_attribute_table): New.
* config/arc/arc.c (arc_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arc_attribute_table, arc_handle_interrupt_attribute): New.
* config/arm/arm.c (arm_valid_type_attribute_p,
arm_valid_decl_attribute_p, arm_pe_valid_decl_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(arm_attribute_table, arm_handle_fndecl_attribute,
arm_handle_isr_attribute): New.
* config/avr/avr.c (avr_valid_type_attribute,
avr_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE, TARGET_VALID_TYPE_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(avr_attribute_table, avr_handle_progmem_attribute,
avr_handle_fndecl_attribute): New.
* config/c4x/c4x.c (c4x_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(c4x_attribute_table, c4x_handle_fntype_attribute): New.
* config/h8300/h8300.c (h8300_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(h8300_attribute_table, h8300_handle_fndecl_attribute,
h8300_handle_eightbit_data_attribute,
h8300_handle_tiny_data_attribute): New.
* config/i386/i386-protos.h (ix86_valid_type_attribute_p,
i386_pe_valid_decl_attribute_p, i386_pe_valid_type_attribute_p):
Remove prototypes.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New
declarations.
* config/i386/i386.c (ix86_valid_type_attribute_p: Remove.
(TARGET_VALID_TYPE_ATTRIBUTE, TARGET_VALID_DECL_ATTRIBUTE): Don't
define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ix86_attribute_table, ix86_handle_cdecl_attribute,
ix86_handle_regparm_attribute): New.
* config/i386/winnt.c (i386_pe_valid_decl_attribute_p,
i386_pe_valid_type_attribute_p): Remove.
(ix86_handle_dll_attribute, ix86_handle_shared_attribute): New.
* config/ia64/ia64.c (ia64_valid_type_attribute): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ia64_attribute_table): New.
* config/m32r/m32r.c (m32r_valid_decl_attribute, interrupt_ident1,
interrupt_ident2, model_ident1, model_ident2): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(init_idents): Update.
(m32r_attribute_table, m32r_handle_model_attribute): New.
* config/m68hc11/m68hc11.c (m68hc11_valid_type_attribute_p):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(m68hc11_attribute_table, m68hc11_handle_fntype_attribute): New.
* config/mcore/mcore.c (mcore_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(mcore_attribute_table, mcore_handle_naked_attribute): New.
* config/ns32k/ns32k.c (ns32k_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(ns32k_attribute_table, ns32k_handle_fntype_attribute): New.
* config/rs6000/rs6000.c (rs6000_valid_type_attribute_p): Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(rs6000_attribute_table, rs6000_handle_longcall_attribute): New.
* config/sh/sh.c (sh_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(sh_attribute_table, sh_handle_interrupt_handler_attribute,
sh_handle_sp_switch_attribute, sh_handle_trap_exit_attribute):
New.
* config/stormy16/stormy16.c (stormy16_valid_type_attribute):
Remove.
(TARGET_VALID_TYPE_ATTRIBUTE): Don't define
(TARGET_ATTRIBUTE_TABLE): Define.
(stormy16_attribute_table, stormy16_handle_interrupt_attribute):
New.
* config/v850/v850.c (v850_valid_decl_attribute): Remove.
(TARGET_VALID_DECL_ATTRIBUTE): Don't define.
(TARGET_ATTRIBUTE_TABLE): Define.
(v850_attribute_table, v850_handle_interrupt_attribute,
v850_handle_data_area_attribute): New.
* config/v850/v850-c.c (mark_current_function_as_interrupt):
Return void. Call decl_attributes instead of
valid_machine_attribute.
cp:
Table-driven attributes.
* decl.c: Rename DECL_MACHINE_ATTRIBUTES to DECL_ATTRIBUTES.
* decl2.c (cplus_decl_attributes): Only take one attributes
parameter.
* cp-tree.c (cplus_decl_attributes): Update prototype.
* class.c (finish_struct), decl.c (start_decl, start_function),
decl2.c (grokfield), friend.c (do_friend), parse.y
(parse_bitfield): Update calls to cplus_decl_attributes.
* decl.c (grokdeclarator): Take a pointer to a single ordinary
attribute list.
* decl.h (grokdeclarator): Update prototype.
* decl2.c (grokfield): Take a single ordinary attribute list.
* friend.c (do_friend): Likewise.
* decl.c (shadow_tag, groktypename, start_decl,
start_handler_parms, grokdeclarator, grokparms, start_function,
start_method), decl2.c (grokfield, grokbitfield, grokoptypename),
parse.y (parse_field, parse_bitfield, component_decl_1), pt.c
(process_template_parm, do_decl_instantiation): Pass single
ordinary attribute lists around.
* decl.c (grokdeclarator): Correct handling of nested attributes.
Revert the patch
1998-10-18 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (grokdeclarator): Embedded attrs bind to the right,
not the left.
.
* cp-tree.h (cp_valid_lang_attribute): Remove declaration
(cp_attribute_table): Declare.
* decl.c (valid_lang_attribute): Don't define.
(lang_attribute_table): Define.
(init_decl_processing): Initialize lang_attribute_table instead of
valid_lang_attribute.
* tree.c (cp_valid_lang_attribute): Remove.
(handle_java_interface_attribute, handle_com_interface_attribute,
handle_init_priority_attribute): New functions.
(cp_attribute_table): New array.
* decl2.c (import_export_class): Don't use
targetm.valid_type_attribute.
testsuite:
Table-driven attributes.
* g++.dg/ext/attrib1.C: New test.
From-SVN: r45718
2001-09-21 03:27:06 +02:00
|
|
|
|
decl_attributes (&enumtype, attributes, (int) ATTR_FLAG_TYPE_IN_PLACE);
|
1995-04-26 23:24:01 +02:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Calculate the maximum value of any enumerator in this type. */
|
|
|
|
|
|
1994-05-16 14:25:28 +02:00
|
|
|
|
if (values == error_mark_node)
|
|
|
|
|
minnode = maxnode = integer_zero_node;
|
|
|
|
|
else
|
1996-04-15 01:01:38 +02:00
|
|
|
|
{
|
2000-01-05 20:26:23 +01:00
|
|
|
|
minnode = maxnode = TREE_VALUE (values);
|
|
|
|
|
for (pair = TREE_CHAIN (values); pair; pair = TREE_CHAIN (pair))
|
1996-04-15 01:01:38 +02:00
|
|
|
|
{
|
2000-01-05 20:26:23 +01:00
|
|
|
|
tree value = TREE_VALUE (pair);
|
|
|
|
|
if (tree_int_cst_lt (maxnode, value))
|
|
|
|
|
maxnode = value;
|
|
|
|
|
if (tree_int_cst_lt (value, minnode))
|
|
|
|
|
minnode = value;
|
1996-04-15 01:01:38 +02:00
|
|
|
|
}
|
2000-01-05 20:26:23 +01:00
|
|
|
|
}
|
1996-04-15 01:01:38 +02:00
|
|
|
|
|
2000-01-05 20:26:23 +01:00
|
|
|
|
/* Construct the final type of this enumeration. It is the same
|
|
|
|
|
as one of the integral types - the narrowest one that fits, except
|
|
|
|
|
that normally we only go as narrow as int - and signed iff any of
|
|
|
|
|
the values are negative. */
|
|
|
|
|
unsign = (tree_int_cst_sgn (minnode) >= 0);
|
|
|
|
|
precision = MAX (min_precision (minnode, unsign),
|
|
|
|
|
min_precision (maxnode, unsign));
|
2001-02-07 23:04:10 +01:00
|
|
|
|
if (TYPE_PACKED (enumtype) || precision > TYPE_PRECISION (integer_type_node))
|
2000-01-05 20:26:23 +01:00
|
|
|
|
{
|
Makefile.in (convert.o, [...]): Update.
* Makefile.in (convert.o, calls.o, expmed.o): Update.
* attribs.c (handle_mode_attribute, handle_vector_size_attribute):
Use new hooks.
* builtin-types.def (BT_PTRMODE): Update.
* c-common.c (type_for_size): Rename c_common_type_for_size.
(type_for_mode): Similarly.
(shorten_compare, pointer_int_sum, c_common_nodes_and_builtins):
Use new hook.
* c-bommon.h (c_common_type_for_size, c_common_type_for_mode): New.
* c-decl.c (finish_enum, build_enumerator): Use new hooks.
* c-lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE):
Redefine.
* c-typeck.c (common_type, comptypes, default_conversion):
Use new hooks.
* calls.c: Include langhooks.h.
(emit_library_call_value_1): Use new hooks. Avoid redundant
calls.
* convert.c: Include langhooks.h
(convert_to_pointer, convert_to_integer): Use new hooks.
* except.c (init_eh): Similarly.
* expmed.c: Include langhooks.h.
(expand_mult_add): Use new hooks.
* expr.c (store_expr, store_constructor, expand_expr, do_jump,
try_casesi): Similarly.
* fold-const.c (optimize_bit_field_compare, make_range,
decode_field_reference, fold_truthop, fold): Similarly.
* function.c (assign_stack_local_1, assign_stack_temp_for_type,
put_var_into_stack): Similarly.
* langhooks-def.h (LANG_HOOKS_TYPE_FOR_MODE,
LANG_HOOKS_TYPE_FOR_SIZE): New.
(LANG_HOOKS_TYPES_INITIALIZER): Update.
* langhooks.h (lang_hooks_for_types): New hooks.
* stmt.c (expand_decl_cleanup, emit_case_nodes): Use new hooks.
* tree.c (get_unwidened, get_narrower): Similarly.
* tree.h (type_for_mode, type_for_size): Remove.
* varasm.c (force_const_mem): Use new hooks.
ada:
* gigi.h (type_for_size, type_for_mode): Rename.
* misc.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE):
Redefine.
* trans.c (tree_transform): Update.
* utils.c (gnat_init_decl_processing, init_gigi_decls,
builtin_function, float_type_for_size, signed_or_unsigned_type,
build_vms_descriptor, unchecked_convert): Update.
(type_for_mode, type_for_size): Rename.
* utils2.c (nonbinary_modular_operation): Update.
cp:
* cp-lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE):
Redefine.
* cvt.c (cp_convert_to_pointer, type_promotes_to): Use new hooks.
* decl.c (finish_enum): Similarly.
* error.c (dump_type): Similarly.
* lex.c (cxx_init): Similarly.
* mangle.c (write_builtin_type): Similarly.
* typeck.c (comptypes): Similarly.
f:
* com.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE):
Redefine.
(type_for_mode, type_for_size): Rename.
(signed_or_unsigned_type, signed_type, truthvalue_conversion,
unsigned_type): Use new hooks.
java:
* Make-lang.in (builtins.o): Update.
* boehm.c (get_boehm_type_descriptor): Update.
* builtins.c: Include langhooks.h.
* decl.c (java_init_decl_processing): Update.
* java-tree.h (java_type_for_mode, java_type_for_size): New.
* lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIaZE):
Redefine.
* typeck.c (type_for_mode, type_for_size): Update.
objc:
* objc-act.c (handle_impent): Update.
* objc-lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIaZE):
Redefine.
From-SVN: r51571
2002-03-29 22:46:27 +01:00
|
|
|
|
tree narrowest = c_common_type_for_size (precision, unsign);
|
2001-02-07 23:04:10 +01:00
|
|
|
|
if (narrowest == 0)
|
|
|
|
|
{
|
|
|
|
|
warning ("enumeration values exceed range of largest integer");
|
|
|
|
|
narrowest = long_long_integer_type_node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
precision = TYPE_PRECISION (narrowest);
|
1996-04-15 01:01:38 +02:00
|
|
|
|
}
|
2001-02-07 23:04:10 +01:00
|
|
|
|
else
|
|
|
|
|
precision = TYPE_PRECISION (integer_type_node);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2000-07-26 05:50:56 +02:00
|
|
|
|
if (precision == TYPE_PRECISION (integer_type_node))
|
Makefile.in (convert.o, [...]): Update.
* Makefile.in (convert.o, calls.o, expmed.o): Update.
* attribs.c (handle_mode_attribute, handle_vector_size_attribute):
Use new hooks.
* builtin-types.def (BT_PTRMODE): Update.
* c-common.c (type_for_size): Rename c_common_type_for_size.
(type_for_mode): Similarly.
(shorten_compare, pointer_int_sum, c_common_nodes_and_builtins):
Use new hook.
* c-bommon.h (c_common_type_for_size, c_common_type_for_mode): New.
* c-decl.c (finish_enum, build_enumerator): Use new hooks.
* c-lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE):
Redefine.
* c-typeck.c (common_type, comptypes, default_conversion):
Use new hooks.
* calls.c: Include langhooks.h.
(emit_library_call_value_1): Use new hooks. Avoid redundant
calls.
* convert.c: Include langhooks.h
(convert_to_pointer, convert_to_integer): Use new hooks.
* except.c (init_eh): Similarly.
* expmed.c: Include langhooks.h.
(expand_mult_add): Use new hooks.
* expr.c (store_expr, store_constructor, expand_expr, do_jump,
try_casesi): Similarly.
* fold-const.c (optimize_bit_field_compare, make_range,
decode_field_reference, fold_truthop, fold): Similarly.
* function.c (assign_stack_local_1, assign_stack_temp_for_type,
put_var_into_stack): Similarly.
* langhooks-def.h (LANG_HOOKS_TYPE_FOR_MODE,
LANG_HOOKS_TYPE_FOR_SIZE): New.
(LANG_HOOKS_TYPES_INITIALIZER): Update.
* langhooks.h (lang_hooks_for_types): New hooks.
* stmt.c (expand_decl_cleanup, emit_case_nodes): Use new hooks.
* tree.c (get_unwidened, get_narrower): Similarly.
* tree.h (type_for_mode, type_for_size): Remove.
* varasm.c (force_const_mem): Use new hooks.
ada:
* gigi.h (type_for_size, type_for_mode): Rename.
* misc.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE):
Redefine.
* trans.c (tree_transform): Update.
* utils.c (gnat_init_decl_processing, init_gigi_decls,
builtin_function, float_type_for_size, signed_or_unsigned_type,
build_vms_descriptor, unchecked_convert): Update.
(type_for_mode, type_for_size): Rename.
* utils2.c (nonbinary_modular_operation): Update.
cp:
* cp-lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE):
Redefine.
* cvt.c (cp_convert_to_pointer, type_promotes_to): Use new hooks.
* decl.c (finish_enum): Similarly.
* error.c (dump_type): Similarly.
* lex.c (cxx_init): Similarly.
* mangle.c (write_builtin_type): Similarly.
* typeck.c (comptypes): Similarly.
f:
* com.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE):
Redefine.
(type_for_mode, type_for_size): Rename.
(signed_or_unsigned_type, signed_type, truthvalue_conversion,
unsigned_type): Use new hooks.
java:
* Make-lang.in (builtins.o): Update.
* boehm.c (get_boehm_type_descriptor): Update.
* builtins.c: Include langhooks.h.
* decl.c (java_init_decl_processing): Update.
* java-tree.h (java_type_for_mode, java_type_for_size): New.
* lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIaZE):
Redefine.
* typeck.c (type_for_mode, type_for_size): Update.
objc:
* objc-act.c (handle_impent): Update.
* objc-lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIaZE):
Redefine.
From-SVN: r51571
2002-03-29 22:46:27 +01:00
|
|
|
|
enum_value_type = c_common_type_for_size (precision, 0);
|
2000-07-26 05:50:56 +02:00
|
|
|
|
else
|
|
|
|
|
enum_value_type = enumtype;
|
|
|
|
|
|
2000-01-05 20:26:23 +01:00
|
|
|
|
TYPE_MIN_VALUE (enumtype) = minnode;
|
|
|
|
|
TYPE_MAX_VALUE (enumtype) = maxnode;
|
|
|
|
|
TYPE_PRECISION (enumtype) = precision;
|
|
|
|
|
TREE_UNSIGNED (enumtype) = unsign;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
TYPE_SIZE (enumtype) = 0;
|
|
|
|
|
layout_type (enumtype);
|
|
|
|
|
|
1994-05-16 14:25:28 +02:00
|
|
|
|
if (values != error_mark_node)
|
1993-09-07 14:26:20 +02:00
|
|
|
|
{
|
2000-01-05 20:26:23 +01:00
|
|
|
|
/* Change the type of the enumerators to be the enum type. We
|
|
|
|
|
need to do this irrespective of the size of the enum, for
|
|
|
|
|
proper type checking. Replace the DECL_INITIALs of the
|
|
|
|
|
enumerators, and the value slots of the list, with copies
|
|
|
|
|
that have the enum type; they cannot be modified in place
|
|
|
|
|
because they may be shared (e.g. integer_zero_node) Finally,
|
|
|
|
|
change the purpose slots to point to the names of the decls. */
|
1994-05-16 14:25:28 +02:00
|
|
|
|
for (pair = values; pair; pair = TREE_CHAIN (pair))
|
|
|
|
|
{
|
2000-01-05 20:26:23 +01:00
|
|
|
|
tree enu = TREE_PURPOSE (pair);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2000-01-05 20:26:23 +01:00
|
|
|
|
TREE_TYPE (enu) = enumtype;
|
2000-07-26 05:50:56 +02:00
|
|
|
|
|
|
|
|
|
/* The ISO C Standard mandates enumerators to have type int,
|
|
|
|
|
even though the underlying type of an enum type is
|
|
|
|
|
unspecified. Here we convert any enumerators that fit in
|
|
|
|
|
an int to type int, to avoid promotions to unsigned types
|
|
|
|
|
when comparing integers with enumerators that fit in the
|
|
|
|
|
int range. When -pedantic is given, build_enumerator()
|
|
|
|
|
would have already taken care of those that don't fit. */
|
|
|
|
|
if (int_fits_type_p (DECL_INITIAL (enu), enum_value_type))
|
|
|
|
|
DECL_INITIAL (enu) = convert (enum_value_type, DECL_INITIAL (enu));
|
|
|
|
|
else
|
|
|
|
|
DECL_INITIAL (enu) = convert (enumtype, DECL_INITIAL (enu));
|
2000-01-05 20:26:23 +01:00
|
|
|
|
|
|
|
|
|
TREE_PURPOSE (pair) = DECL_NAME (enu);
|
|
|
|
|
TREE_VALUE (pair) = DECL_INITIAL (enu);
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
1994-05-16 14:25:28 +02:00
|
|
|
|
TYPE_VALUES (enumtype) = values;
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
1993-04-09 02:00:06 +02:00
|
|
|
|
/* Fix up all variant types of this enum type. */
|
|
|
|
|
for (tem = TYPE_MAIN_VARIANT (enumtype); tem; tem = TYPE_NEXT_VARIANT (tem))
|
|
|
|
|
{
|
2000-01-05 20:26:23 +01:00
|
|
|
|
if (tem == enumtype)
|
|
|
|
|
continue;
|
1993-04-09 02:00:06 +02:00
|
|
|
|
TYPE_VALUES (tem) = TYPE_VALUES (enumtype);
|
|
|
|
|
TYPE_MIN_VALUE (tem) = TYPE_MIN_VALUE (enumtype);
|
|
|
|
|
TYPE_MAX_VALUE (tem) = TYPE_MAX_VALUE (enumtype);
|
|
|
|
|
TYPE_SIZE (tem) = TYPE_SIZE (enumtype);
|
1998-08-17 22:26:47 +02:00
|
|
|
|
TYPE_SIZE_UNIT (tem) = TYPE_SIZE_UNIT (enumtype);
|
1993-04-09 02:00:06 +02:00
|
|
|
|
TYPE_MODE (tem) = TYPE_MODE (enumtype);
|
|
|
|
|
TYPE_PRECISION (tem) = TYPE_PRECISION (enumtype);
|
|
|
|
|
TYPE_ALIGN (tem) = TYPE_ALIGN (enumtype);
|
2000-06-14 07:30:09 +02:00
|
|
|
|
TYPE_USER_ALIGN (tem) = TYPE_USER_ALIGN (enumtype);
|
1993-04-09 02:00:06 +02:00
|
|
|
|
TREE_UNSIGNED (tem) = TREE_UNSIGNED (enumtype);
|
|
|
|
|
}
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Finish debugging output for this type. */
|
|
|
|
|
rest_of_type_compilation (enumtype, toplevel);
|
|
|
|
|
|
|
|
|
|
return enumtype;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Build and install a CONST_DECL for one value of the
|
|
|
|
|
current enumeration type (one that was begun with start_enum).
|
|
|
|
|
Return a tree-list containing the CONST_DECL and its value.
|
|
|
|
|
Assignment of sequential values by default is handled here. */
|
|
|
|
|
|
|
|
|
|
tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
build_enumerator (tree name, tree value)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree decl, type;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* Validate and default VALUE. */
|
|
|
|
|
|
|
|
|
|
/* Remove no-op casts from the value. */
|
1992-07-09 08:11:19 +02:00
|
|
|
|
if (value)
|
1992-07-10 03:50:35 +02:00
|
|
|
|
STRIP_TYPE_NOPS (value);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
1993-02-02 05:38:30 +01:00
|
|
|
|
if (value != 0)
|
1993-02-03 00:35:04 +01:00
|
|
|
|
{
|
|
|
|
|
if (TREE_CODE (value) == INTEGER_CST)
|
1993-09-04 01:02:27 +02:00
|
|
|
|
{
|
|
|
|
|
value = default_conversion (value);
|
|
|
|
|
constant_expression_warning (value);
|
|
|
|
|
}
|
1993-02-03 00:35:04 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
error ("enumerator value for `%s' not integer constant",
|
|
|
|
|
IDENTIFIER_POINTER (name));
|
|
|
|
|
value = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* Default based on previous value. */
|
|
|
|
|
/* It should no longer be possible to have NON_LVALUE_EXPR
|
|
|
|
|
in the default. */
|
|
|
|
|
if (value == 0)
|
1992-05-18 07:09:24 +02:00
|
|
|
|
{
|
|
|
|
|
value = enum_next_value;
|
|
|
|
|
if (enum_overflow)
|
|
|
|
|
error ("overflow in enumeration values");
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
if (pedantic && ! int_fits_type_p (value, integer_type_node))
|
|
|
|
|
{
|
c-common.c (combine_strings, [...]): Refer to ISO C or ISO C89 instead of ANSI C.
* c-common.c (combine_strings, check_format_info): Refer to ISO C
or ISO C89 instead of ANSI C.
* c-decl.c (grokdeclarator, xref_tag, finish_struct,
build_enumerator, do_case): Likewise.
* c-lex.c (parse_float, yylex): Likewise.
* c-parse.in: Likewise.
* c-typeck.c (common_type, build_array_ref, build_binary_op,
build_unary_op, pedantic_lvalue_warning, build_conditional_expr,
build_c_cast, convert_for_assignment, set_init_index,
set_init_label, c_expand_start_case): Likewise.
* toplev.c (documented_lang_options, display_help): Likewise.
From-SVN: r35576
2000-08-09 01:19:11 +02:00
|
|
|
|
pedwarn ("ISO C restricts enumerator values to range of `int'");
|
2000-07-26 05:50:56 +02:00
|
|
|
|
value = convert (integer_type_node, value);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set basis for default for next value. */
|
|
|
|
|
enum_next_value = build_binary_op (PLUS_EXPR, value, integer_one_node, 0);
|
1992-05-18 07:09:24 +02:00
|
|
|
|
enum_overflow = tree_int_cst_lt (enum_next_value, value);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* Now create a declaration for the enum value name. */
|
|
|
|
|
|
1993-09-07 14:26:20 +02:00
|
|
|
|
type = TREE_TYPE (value);
|
Makefile.in (convert.o, [...]): Update.
* Makefile.in (convert.o, calls.o, expmed.o): Update.
* attribs.c (handle_mode_attribute, handle_vector_size_attribute):
Use new hooks.
* builtin-types.def (BT_PTRMODE): Update.
* c-common.c (type_for_size): Rename c_common_type_for_size.
(type_for_mode): Similarly.
(shorten_compare, pointer_int_sum, c_common_nodes_and_builtins):
Use new hook.
* c-bommon.h (c_common_type_for_size, c_common_type_for_mode): New.
* c-decl.c (finish_enum, build_enumerator): Use new hooks.
* c-lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE):
Redefine.
* c-typeck.c (common_type, comptypes, default_conversion):
Use new hooks.
* calls.c: Include langhooks.h.
(emit_library_call_value_1): Use new hooks. Avoid redundant
calls.
* convert.c: Include langhooks.h
(convert_to_pointer, convert_to_integer): Use new hooks.
* except.c (init_eh): Similarly.
* expmed.c: Include langhooks.h.
(expand_mult_add): Use new hooks.
* expr.c (store_expr, store_constructor, expand_expr, do_jump,
try_casesi): Similarly.
* fold-const.c (optimize_bit_field_compare, make_range,
decode_field_reference, fold_truthop, fold): Similarly.
* function.c (assign_stack_local_1, assign_stack_temp_for_type,
put_var_into_stack): Similarly.
* langhooks-def.h (LANG_HOOKS_TYPE_FOR_MODE,
LANG_HOOKS_TYPE_FOR_SIZE): New.
(LANG_HOOKS_TYPES_INITIALIZER): Update.
* langhooks.h (lang_hooks_for_types): New hooks.
* stmt.c (expand_decl_cleanup, emit_case_nodes): Use new hooks.
* tree.c (get_unwidened, get_narrower): Similarly.
* tree.h (type_for_mode, type_for_size): Remove.
* varasm.c (force_const_mem): Use new hooks.
ada:
* gigi.h (type_for_size, type_for_mode): Rename.
* misc.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE):
Redefine.
* trans.c (tree_transform): Update.
* utils.c (gnat_init_decl_processing, init_gigi_decls,
builtin_function, float_type_for_size, signed_or_unsigned_type,
build_vms_descriptor, unchecked_convert): Update.
(type_for_mode, type_for_size): Rename.
* utils2.c (nonbinary_modular_operation): Update.
cp:
* cp-lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE):
Redefine.
* cvt.c (cp_convert_to_pointer, type_promotes_to): Use new hooks.
* decl.c (finish_enum): Similarly.
* error.c (dump_type): Similarly.
* lex.c (cxx_init): Similarly.
* mangle.c (write_builtin_type): Similarly.
* typeck.c (comptypes): Similarly.
f:
* com.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE):
Redefine.
(type_for_mode, type_for_size): Rename.
(signed_or_unsigned_type, signed_type, truthvalue_conversion,
unsigned_type): Use new hooks.
java:
* Make-lang.in (builtins.o): Update.
* boehm.c (get_boehm_type_descriptor): Update.
* builtins.c: Include langhooks.h.
* decl.c (java_init_decl_processing): Update.
* java-tree.h (java_type_for_mode, java_type_for_size): New.
* lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIaZE):
Redefine.
* typeck.c (type_for_mode, type_for_size): Update.
objc:
* objc-act.c (handle_impent): Update.
* objc-lang.c (LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIaZE):
Redefine.
From-SVN: r51571
2002-03-29 22:46:27 +01:00
|
|
|
|
type = c_common_type_for_size (MAX (TYPE_PRECISION (type),
|
|
|
|
|
TYPE_PRECISION (integer_type_node)),
|
|
|
|
|
(TYPE_PRECISION (type)
|
|
|
|
|
>= TYPE_PRECISION (integer_type_node)
|
|
|
|
|
&& TREE_UNSIGNED (type)));
|
1993-09-07 14:26:20 +02:00
|
|
|
|
|
|
|
|
|
decl = build_decl (CONST_DECL, name, type);
|
2000-05-24 11:08:42 +02:00
|
|
|
|
DECL_INITIAL (decl) = convert (type, value);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
pushdecl (decl);
|
|
|
|
|
|
c-common.c, [...]: Remove all references to obstack functions obsoleted by GC...
* c-common.c, c-decl.c, c-lang.c, c-lex.c, c-parse.in, c-pragma.c,
c-typeck.c, objc/objc-act.c: Remove all references to obstack
functions obsoleted by GC, such as push_obstacks_nochange,
end_temporary_allocation, savealloc, saveable_tree_cons, etc.
and code which existed only to decide whether or not to call
them. Remove now-unused NESTED argument from start_function;
all callers changed. Do not change behavior based on ggc_p.
The use of the ixp_obstack in c-iterate.c and the util_obstack
in objc/objc-act.c remain; these are not obsoleted by garbage
collection.
* c-tree.h: Update prototype for start_function.
* c-parse.y, c-parse.c, objc/objc-parse.c, objc/objc-parse.y: Rebuild.
From-SVN: r31611
2000-01-25 18:13:14 +01:00
|
|
|
|
return tree_cons (decl, value, NULL_TREE);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
2000-09-17 09:38:23 +02:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* Create the FUNCTION_DECL for a function definition.
|
c-common.c (decl_attributes): Only take a single attributes parameter.
* c-common.c (decl_attributes): Only take a single attributes
parameter.
* c-common.h (decl_attributes): Update prototype.
* c-decl.c (start_decl, start_function): Only take a single
attributes parameter. Update calls to decl_attributes.
(finish_struct, finish_enum): Update calls to decl_attributes.
(push_parm_decl): Expect unified list of attributes. Update call
to decl_attributes.
* c-parse.in (fndef, initdcl, notype_initdcl, nested_function,
notype_nested_function, component_declarator,
component_notype_declarator, label): Update calls to
decl_attributes.
(absdcl_maybe_attribute, parm, firstparm, myparm): Unify attribute
lists that are passed to push_parm_decl.
* c-tree.h (start_function, start_decl): Update prototypes.
* config/sh/sh-protos.h, config/sh/sh.c
(sh_pragma_insert_attributes): Only take a single attributes
parameter.
* config/sh/sh.h (PRAGMA_INSERT_ATTRIBUTES): Likewise.
* doc/tm.texi (INSERT_ATTRIBUTES): Update.
* objc/objc-act.c (define_decl, generate_objc_symtab_decl,
build_module_descriptor, generate_static_references,
generate_strings, build_selector_translation_table,
generate_descriptor_table, generate_protocols,
generate_ivars_list, generate_dispatch_table,
generate_protocol_list, generate_category,
generate_shared_structures, really_start_method, add_objc_decls,
generate_classref_translation_entry): Update calls to start_decl
and start_function.
(build_tmp_function_decl, start_method_def): Unify attribute lists
that are passed to push_parm_decl.
cp:
* decl.c (grokdeclarator), decl2.c (cplus_decl_attributes): Update
calls to decl_attributes.
testsuite:
* gcc.c-torture/compile/20010701-1.c,
g++.old-deja/g++.ext/attrib6.C: New tests.
From-SVN: r43850
2001-07-08 21:58:19 +02:00
|
|
|
|
DECLSPECS, DECLARATOR and ATTRIBUTES are the parts of
|
1995-06-14 14:07:24 +02:00
|
|
|
|
the declaration; they describe the function's name and the type it returns,
|
1992-02-13 23:21:26 +01:00
|
|
|
|
but twisted together in a fashion that parallels the syntax of C.
|
|
|
|
|
|
|
|
|
|
This function creates a binding context for the function body
|
|
|
|
|
as well as setting up the FUNCTION_DECL in current_function_decl.
|
|
|
|
|
|
|
|
|
|
Returns 1 on success. If the DECLARATOR is not suitable for a function
|
|
|
|
|
(it defines a datum instead), we return 0, which tells
|
c-common.c, [...]: Remove all references to obstack functions obsoleted by GC...
* c-common.c, c-decl.c, c-lang.c, c-lex.c, c-parse.in, c-pragma.c,
c-typeck.c, objc/objc-act.c: Remove all references to obstack
functions obsoleted by GC, such as push_obstacks_nochange,
end_temporary_allocation, savealloc, saveable_tree_cons, etc.
and code which existed only to decide whether or not to call
them. Remove now-unused NESTED argument from start_function;
all callers changed. Do not change behavior based on ggc_p.
The use of the ixp_obstack in c-iterate.c and the util_obstack
in objc/objc-act.c remain; these are not obsoleted by garbage
collection.
* c-tree.h: Update prototype for start_function.
* c-parse.y, c-parse.c, objc/objc-parse.c, objc/objc-parse.y: Rebuild.
From-SVN: r31611
2000-01-25 18:13:14 +01:00
|
|
|
|
yyparse to report a parse error. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
int
|
2003-06-19 21:43:59 +02:00
|
|
|
|
start_function (tree declspecs, tree declarator, tree attributes)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
tree decl1, old_decl;
|
|
|
|
|
tree restype;
|
1994-10-18 20:42:11 +01:00
|
|
|
|
int old_immediate_size_expand = immediate_size_expand;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
1996-07-04 00:07:53 +02:00
|
|
|
|
current_function_returns_value = 0; /* Assume, until we see it does. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
current_function_returns_null = 0;
|
2002-02-06 21:40:18 +01:00
|
|
|
|
current_function_returns_abnormally = 0;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
warn_about_return_type = 0;
|
|
|
|
|
current_extern_inline = 0;
|
|
|
|
|
|
1994-10-18 20:42:11 +01:00
|
|
|
|
/* Don't expand any sizes in the return type of the function. */
|
|
|
|
|
immediate_size_expand = 0;
|
|
|
|
|
|
2002-02-02 01:14:41 +01:00
|
|
|
|
decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* If the declarator is not suitable for a function definition,
|
|
|
|
|
cause a syntax error. */
|
|
|
|
|
if (decl1 == 0)
|
1997-11-02 22:19:36 +01:00
|
|
|
|
{
|
|
|
|
|
immediate_size_expand = old_immediate_size_expand;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
c-common.c (decl_attributes): Take a pointer to the node to which attributes are to be attached...
* c-common.c (decl_attributes): Take a pointer to the node to
which attributes are to be attached, and a flags argument.
* c-common.h (enum attribute_flags): New.
(decl_attributes): Update prototype.
* c-decl.c (start_decl, push_parm_decl, finish_struct,
finish_enum, start_function): Update calls to decl_attributes.
* c-parse.in (component_declarator, component_notype_declarator,
label): Update calls to decl_attributes.
cp:
* decl2.c (cplus_decl_attributes): Take a pointer to the node to
which attributes are to be attached, and a flags argument. Update
call to decl_attributes.
(grokfield): Update call to decl_attributes.
* class.c (finish_struct): Update call to cplus_decl_attributes.
* cp-tree.h (cplus_decl_attributes): Update prototype.
* decl.c (start_decl, grokdeclarator, start_function): Update
calls to decl_attributes and cplus_decl_attributes.
* friend.c (do_friend): Update call to cplus_decl_attributes.
* parse.y (parse_bitfield): Update call to cplus_decl_attributes.
From-SVN: r43995
2001-07-13 22:40:43 +02:00
|
|
|
|
decl_attributes (&decl1, attributes, 0);
|
1995-03-10 03:31:02 +01:00
|
|
|
|
|
2001-10-18 20:29:02 +02:00
|
|
|
|
if (DECL_DECLARED_INLINE_P (decl1)
|
|
|
|
|
&& DECL_UNINLINABLE (decl1)
|
|
|
|
|
&& lookup_attribute ("noinline", DECL_ATTRIBUTES (decl1)))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
warning ("%Hinline function '%D' given attribute noinline",
|
|
|
|
|
&DECL_SOURCE_LOCATION (decl1), decl1);
|
2001-10-18 20:29:02 +02:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
announce_function (decl1);
|
|
|
|
|
|
tree.h (COMPLETE_TYPE_P): New macro.
gcc
* tree.h (COMPLETE_TYPE_P): New macro.
(COMPLETE_OR_VOID_TYPE_P): New macro.
(COMPLETE_OR_UNBOUND_ARRAY_TYPE_P): New macro.
* stor-layout.c (layout_type, case VOID_TYPE): Don't set TYPE_SIZE.
* c-aux-info.c (gen_type): Use them.
* c-common.c (c_expand_expr_stmt): Likewise.
* c-decl.c (poplevel, pushdecl, start_decl, finish_decl,
grokdeclarator, grokparms, finish_struct, start_function,
store_parm_decls, combine_parm_decls): Likewise.
* c-parse.y (cast_expr): Likewise.
* c-typeck.c (require_complete_type, c_sizeof, c_sizeof_nowarn,
c_size_in_bytes, c_alignof, build_component_ref,
build_indirect_ref, build_array_ref, convert_arguments,
build_binary_op, pointer_diff, build_unary_op, digest_init: Likewise.
* calls.c (initialize_argument_information): Likewise.
* convert.c (convert_to_integer): Likewise.
* dbxout.c (dbxout_typedefs, dbxout_type, dbxout_symbol): Likewise.
* dwarfout.c (location_or_const_value_attribute,
output_enumeration_type_die, output_structure_type_die,
output_union_type_die, output_type): Likewise.
* expr.c (safe_from_p, expand_expr): Likewise.
* function.c (assign_parms): Likewise.
* sdbout.c (sdbout_symbol, sdbout_one_type): Likewise.
* tree.c (build_array_type, build_function_type,
build_method_type, build_offset_type, build_complex_type): Likewise.
* c-parse.c, c-parse.h: Regenerated.
gcc/cp
* typeck.c (require_complete_type, complete_type,
complete_type_or_else, c_sizeof, c_sizeof_nowarn,
build_array_ref, convert_arguments, pointer_diff,
build_x_unary_op, build_unary_op, build_c_cast,
build_modify_expr): Use COMPLETE_TYPE_P etc.
* call.c (is_complete, convert_like_real,
build_new_method_call): Likewise.
* class.c (build_vbase_pointer_fields, check_bases,
build_base_field, finish_struct_1, pushclass): Likewise.
* cvt.c (cp_convert_to_pointer, convert_to_void): Likewise.
* decl.c (maybe_process_template_type_declaration, pushtag,
pushdecl, redeclaration_error_message, start_decl, start_decl_1,
layout_var_decl, check_initializer, cp_finish_decl,
grokdeclarator, require_complete_types_for_parms,
grok_op_properties, xref_tag, xref_basetypes,
check_function_type): Likewise.
* decl2.c (check_classfn, reparse_absdcl_as_casts): Likewise.
* friend.c (do_friend): Likewise.
* init.c (build_offset_ref): Likewise.
* parse.y (structsp): Likewise.
* pt.c (maybe_process_partial_specialization,
tsubst_friend_function, instantiate_class_template, tsubst,
do_type_instantiation, instantiate_pending_templates): Likewise.
* repo.c (repo_get_id): Likewise.
* rtti.c (build_typeid, get_typeid, build_dynamic_cast_1,
synthesize_tinfo_var, emit_support_tinfos): Likewise.
* search.c (lookup_fnfields_1, lookup_conversions): Likewise.
* semantics.c (begin_class_definition): Likewise.
* tree.c (build_cplus_method_type): Likewise.
* typeck2.c (digest_init, build_functional_cast,
add_exception_specifier): Likewise.
* parse.h, parse.c: Regenerated.
From-SVN: r32671
2000-03-21 19:10:48 +01:00
|
|
|
|
if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (TREE_TYPE (decl1))))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2000-06-26 18:42:23 +02:00
|
|
|
|
error ("return type is an incomplete type");
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Make it return void instead. */
|
|
|
|
|
TREE_TYPE (decl1)
|
|
|
|
|
= build_function_type (void_type_node,
|
|
|
|
|
TYPE_ARG_TYPES (TREE_TYPE (decl1)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (warn_about_return_type)
|
2000-06-26 18:42:23 +02:00
|
|
|
|
pedwarn_c99 ("return type defaults to `int'");
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* Save the parm names or decls from this function's declarator
|
|
|
|
|
where store_parm_decls will find them. */
|
|
|
|
|
current_function_parms = last_function_parms;
|
|
|
|
|
current_function_parm_tags = last_function_parm_tags;
|
2003-08-01 20:41:40 +02:00
|
|
|
|
current_function_parm_others = last_function_parm_others;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* Make the init_value nonzero so pushdecl knows this is not tentative.
|
|
|
|
|
error_mark_node is replaced below (in poplevel) with the BLOCK. */
|
|
|
|
|
DECL_INITIAL (decl1) = error_mark_node;
|
|
|
|
|
|
|
|
|
|
/* If this definition isn't a prototype and we had a prototype declaration
|
|
|
|
|
before, copy the arg type info from that prototype.
|
|
|
|
|
But not if what we had before was a builtin function. */
|
|
|
|
|
old_decl = lookup_name_current_level (DECL_NAME (decl1));
|
|
|
|
|
if (old_decl != 0 && TREE_CODE (TREE_TYPE (old_decl)) == FUNCTION_TYPE
|
|
|
|
|
&& !DECL_BUILT_IN (old_decl)
|
1992-12-05 01:18:55 +01:00
|
|
|
|
&& (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (decl1)))
|
|
|
|
|
== TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (old_decl))))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
&& TYPE_ARG_TYPES (TREE_TYPE (decl1)) == 0)
|
1993-03-18 23:01:56 +01:00
|
|
|
|
{
|
|
|
|
|
TREE_TYPE (decl1) = TREE_TYPE (old_decl);
|
2003-05-08 17:04:44 +02:00
|
|
|
|
current_function_prototype_locus = DECL_SOURCE_LOCATION (old_decl);
|
1993-03-18 23:01:56 +01:00
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* Optionally warn of old-fashioned def with no previous prototype. */
|
|
|
|
|
if (warn_strict_prototypes
|
|
|
|
|
&& TYPE_ARG_TYPES (TREE_TYPE (decl1)) == 0
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
&& C_DECL_ISNT_PROTOTYPE (old_decl))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
warning ("function declaration isn't a prototype");
|
|
|
|
|
/* Optionally warn of any global def with no previous prototype. */
|
|
|
|
|
else if (warn_missing_prototypes
|
|
|
|
|
&& TREE_PUBLIC (decl1)
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
&& ! MAIN_NAME_P (DECL_NAME (decl1))
|
|
|
|
|
&& C_DECL_ISNT_PROTOTYPE (old_decl))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
warning ("%Hno previous prototype for '%D'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (decl1), decl1);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Optionally warn of any def with no previous prototype
|
|
|
|
|
if the function has already been used. */
|
|
|
|
|
else if (warn_missing_prototypes
|
|
|
|
|
&& old_decl != 0 && TREE_USED (old_decl)
|
1994-07-21 23:55:22 +02:00
|
|
|
|
&& TYPE_ARG_TYPES (TREE_TYPE (old_decl)) == 0)
|
2003-07-19 12:19:19 +02:00
|
|
|
|
warning ("%H'%D' was used with no prototype before its definition",
|
|
|
|
|
&DECL_SOURCE_LOCATION (decl1), decl1);
|
1994-04-06 13:31:44 +02:00
|
|
|
|
/* Optionally warn of any global def with no previous declaration. */
|
|
|
|
|
else if (warn_missing_declarations
|
|
|
|
|
&& TREE_PUBLIC (decl1)
|
|
|
|
|
&& old_decl == 0
|
2000-08-24 22:09:27 +02:00
|
|
|
|
&& ! MAIN_NAME_P (DECL_NAME (decl1)))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
warning ("%Hno previous declaration for '%D'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (decl1), decl1);
|
1994-04-06 13:31:44 +02:00
|
|
|
|
/* Optionally warn of any def with no previous declaration
|
|
|
|
|
if the function has already been used. */
|
|
|
|
|
else if (warn_missing_declarations
|
1994-07-21 23:55:22 +02:00
|
|
|
|
&& old_decl != 0 && TREE_USED (old_decl)
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
&& C_DECL_IMPLICIT (old_decl))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
warning ("%H`%D' was used with no declaration before its definition",
|
|
|
|
|
&DECL_SOURCE_LOCATION (decl1), decl1);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* This is a definition, not a reference.
|
1992-07-12 04:56:45 +02:00
|
|
|
|
So normally clear DECL_EXTERNAL.
|
1992-02-13 23:21:26 +01:00
|
|
|
|
However, `extern inline' acts like a declaration
|
1992-07-12 04:56:45 +02:00
|
|
|
|
except for defining how to inline. So set DECL_EXTERNAL in that case. */
|
|
|
|
|
DECL_EXTERNAL (decl1) = current_extern_inline;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* This function exists in static storage.
|
|
|
|
|
(This does not mean `static' in the C sense!) */
|
|
|
|
|
TREE_STATIC (decl1) = 1;
|
|
|
|
|
|
|
|
|
|
/* A nested function is not global. */
|
|
|
|
|
if (current_function_decl != 0)
|
|
|
|
|
TREE_PUBLIC (decl1) = 0;
|
|
|
|
|
|
2003-07-22 04:23:27 +02:00
|
|
|
|
#ifdef ENABLE_CHECKING
|
|
|
|
|
/* This is the earliest point at which we might know the assembler
|
|
|
|
|
name of the function. Thus, if it's set before this, die horribly. */
|
|
|
|
|
if (DECL_ASSEMBLER_NAME_SET_P (decl1))
|
|
|
|
|
abort ();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* If #pragma weak was used, mark the decl weak now. */
|
2003-07-24 18:59:32 +02:00
|
|
|
|
if (current_scope == global_scope)
|
2003-07-22 04:23:27 +02:00
|
|
|
|
maybe_apply_pragma_weak (decl1);
|
|
|
|
|
|
2000-08-11 00:01:22 +02:00
|
|
|
|
/* Warn for unlikely, improbable, or stupid declarations of `main'. */
|
2000-08-24 22:09:27 +02:00
|
|
|
|
if (warn_main > 0 && MAIN_NAME_P (DECL_NAME (decl1)))
|
1997-01-19 21:04:35 +01:00
|
|
|
|
{
|
|
|
|
|
tree args;
|
|
|
|
|
int argct = 0;
|
2003-07-19 12:19:19 +02:00
|
|
|
|
const location_t *locus = &DECL_SOURCE_LOCATION (decl1);
|
1997-01-19 21:04:35 +01:00
|
|
|
|
|
|
|
|
|
if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (decl1)))
|
2000-08-11 00:01:22 +02:00
|
|
|
|
!= integer_type_node)
|
2003-07-19 12:19:19 +02:00
|
|
|
|
pedwarn ("%Hreturn type of '%D' is not `int'", locus, decl1);
|
1997-01-19 21:04:35 +01:00
|
|
|
|
|
|
|
|
|
for (args = TYPE_ARG_TYPES (TREE_TYPE (decl1)); args;
|
|
|
|
|
args = TREE_CHAIN (args))
|
|
|
|
|
{
|
|
|
|
|
tree type = args ? TREE_VALUE (args) : 0;
|
|
|
|
|
|
|
|
|
|
if (type == void_type_node)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
++argct;
|
|
|
|
|
switch (argct)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
if (TYPE_MAIN_VARIANT (type) != integer_type_node)
|
2003-07-19 12:19:19 +02:00
|
|
|
|
pedwarn ("%Hfirst argument of '%D' should be `int'",
|
|
|
|
|
locus, decl1);
|
1997-01-19 21:04:35 +01:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
if (TREE_CODE (type) != POINTER_TYPE
|
|
|
|
|
|| TREE_CODE (TREE_TYPE (type)) != POINTER_TYPE
|
|
|
|
|
|| (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (type)))
|
|
|
|
|
!= char_type_node))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
pedwarn ("%Hsecond argument of '%D' should be 'char **'",
|
|
|
|
|
locus, decl1);
|
1997-01-19 21:04:35 +01:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
if (TREE_CODE (type) != POINTER_TYPE
|
|
|
|
|
|| TREE_CODE (TREE_TYPE (type)) != POINTER_TYPE
|
|
|
|
|
|| (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (type)))
|
|
|
|
|
!= char_type_node))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
pedwarn ("%Hthird argument of '%D' should probably be "
|
|
|
|
|
"'char **'", locus, decl1);
|
1997-01-19 21:04:35 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
1997-02-02 13:15:44 +01:00
|
|
|
|
}
|
1997-01-19 21:04:35 +01:00
|
|
|
|
|
1997-02-02 13:15:44 +01:00
|
|
|
|
/* It is intentional that this message does not mention the third
|
2001-01-02 16:58:16 +01:00
|
|
|
|
argument because it's only mentioned in an appendix of the
|
|
|
|
|
standard. */
|
1997-02-02 13:15:44 +01:00
|
|
|
|
if (argct > 0 && (argct < 2 || argct > 3))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
pedwarn ("%H'%D' takes only zero or two arguments", locus, decl1);
|
1997-01-19 21:04:35 +01:00
|
|
|
|
|
|
|
|
|
if (! TREE_PUBLIC (decl1))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
pedwarn ("%H'%D' is normally a non-static function", locus, decl1);
|
1997-01-19 21:04:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Record the decl so that the function name is defined.
|
|
|
|
|
If we already have a decl for this name, and it is a FUNCTION_DECL,
|
|
|
|
|
use the old decl. */
|
|
|
|
|
|
|
|
|
|
current_function_decl = pushdecl (decl1);
|
|
|
|
|
|
|
|
|
|
pushlevel (0);
|
2003-07-17 22:12:21 +02:00
|
|
|
|
declare_parm_level ();
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2001-01-11 00:06:30 +01:00
|
|
|
|
make_decl_rtl (current_function_decl, NULL);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
restype = TREE_TYPE (TREE_TYPE (current_function_decl));
|
|
|
|
|
/* Promote the value to int before returning it. */
|
2001-05-01 01:59:10 +02:00
|
|
|
|
if (c_promoting_integer_type_p (restype))
|
1992-08-07 06:06:43 +02:00
|
|
|
|
{
|
c-common.c, [...]: Delete code implementing -traditional mode.
* c-common.c, c-common.h, c-decl.c, c-lex.c, c-parse.in,
c-tree.h, c-typeck.c, cppexp.c, cpplex.c, cpplib.c, cpplib.h,
cppmacro.c, objc/lang-specs.h, objc/objc-act.c,
builtin-types.def, builtins.def, dwarf2out.c, dwarfout.c,
gcc.c, toplev.c: Delete code implementing -traditional mode.
* ada/misc.c, ch/ch-tree.h, ch/decl.c, cp/decl2.c, f/com.c,
f/lex.c, f/top.c, java/builtins.c, java/decl.c: Delete
traditional-mode-related code copied from the C front end
but not used, or used only to permit the compiler to link.
* doc/bugreport.texi, doc/cpp.texi, doc/extend.texi,
doc/invoke.texi, doc/standards.texi, doc/trouble.texi:
Document removal of -traditional mode for compilation, and
remove documentation only relevant to that mode.
* config/nextstep.h, config/ptx4.h, config/svr4.h,
config/convex/convex.h, config/d30v/d30v.h,
config/i386/dgux.h, config/i386/osf1elf.h,
config/i386/osfelf.h, config/i386/osfrose.h,
config/i386/sco5.h, config/i386/sol2.h, config/m68k/a-ux.h,
config/m68k/hp310.h, config/m88k/dgux.h,
config/m88k/dguxbcs.h, config/m88k/luna.h, config/m88k/m88k.c,
config/m88k/m88k.h, config/m88k/openbsd.h,
config/mips/abi64.h, config/mips/osfrose.h,
config/mips/svr4-5.h, config/mips/svr4-t.h,
config/sparc/sol2-sld-64.h, config/sparc/sol2.h,
config/stormy16/stormy16.h: Remove all references to
-traditional from target specs. Delete all mention of the
no-longer-necessary TRADITIONAL_RETURN_FLOAT macro. Also
delete a couple of commented-out definitions of
DOLLARS_IN_IDENTIFIERS, with (incorrect) commentary referring
to -traditional.
* system.h: Poison TRADITIONAL_RETURN_FLOAT.
* doc/tm.texi: Remove mention of TRADITIONAL_RETURN_FLOAT macro.
* testsuite/gcc.c-torture/execute/920730-1t.c,
testsuite/gcc.c-torture/execute/920730-1t.x,
testsuite/gcc.dg/ext-glob.c: Delete test cases, only relevant
to -traditional.
From-SVN: r50110
2002-02-27 19:48:07 +01:00
|
|
|
|
/* It retains unsignedness if not really getting wider. */
|
1992-08-07 06:06:43 +02:00
|
|
|
|
if (TREE_UNSIGNED (restype)
|
c-common.c, [...]: Delete code implementing -traditional mode.
* c-common.c, c-common.h, c-decl.c, c-lex.c, c-parse.in,
c-tree.h, c-typeck.c, cppexp.c, cpplex.c, cpplib.c, cpplib.h,
cppmacro.c, objc/lang-specs.h, objc/objc-act.c,
builtin-types.def, builtins.def, dwarf2out.c, dwarfout.c,
gcc.c, toplev.c: Delete code implementing -traditional mode.
* ada/misc.c, ch/ch-tree.h, ch/decl.c, cp/decl2.c, f/com.c,
f/lex.c, f/top.c, java/builtins.c, java/decl.c: Delete
traditional-mode-related code copied from the C front end
but not used, or used only to permit the compiler to link.
* doc/bugreport.texi, doc/cpp.texi, doc/extend.texi,
doc/invoke.texi, doc/standards.texi, doc/trouble.texi:
Document removal of -traditional mode for compilation, and
remove documentation only relevant to that mode.
* config/nextstep.h, config/ptx4.h, config/svr4.h,
config/convex/convex.h, config/d30v/d30v.h,
config/i386/dgux.h, config/i386/osf1elf.h,
config/i386/osfelf.h, config/i386/osfrose.h,
config/i386/sco5.h, config/i386/sol2.h, config/m68k/a-ux.h,
config/m68k/hp310.h, config/m88k/dgux.h,
config/m88k/dguxbcs.h, config/m88k/luna.h, config/m88k/m88k.c,
config/m88k/m88k.h, config/m88k/openbsd.h,
config/mips/abi64.h, config/mips/osfrose.h,
config/mips/svr4-5.h, config/mips/svr4-t.h,
config/sparc/sol2-sld-64.h, config/sparc/sol2.h,
config/stormy16/stormy16.h: Remove all references to
-traditional from target specs. Delete all mention of the
no-longer-necessary TRADITIONAL_RETURN_FLOAT macro. Also
delete a couple of commented-out definitions of
DOLLARS_IN_IDENTIFIERS, with (incorrect) commentary referring
to -traditional.
* system.h: Poison TRADITIONAL_RETURN_FLOAT.
* doc/tm.texi: Remove mention of TRADITIONAL_RETURN_FLOAT macro.
* testsuite/gcc.c-torture/execute/920730-1t.c,
testsuite/gcc.c-torture/execute/920730-1t.x,
testsuite/gcc.dg/ext-glob.c: Delete test cases, only relevant
to -traditional.
From-SVN: r50110
2002-02-27 19:48:07 +01:00
|
|
|
|
&& (TYPE_PRECISION (restype)
|
|
|
|
|
== TYPE_PRECISION (integer_type_node)))
|
1992-08-07 06:06:43 +02:00
|
|
|
|
restype = unsigned_type_node;
|
|
|
|
|
else
|
|
|
|
|
restype = integer_type_node;
|
|
|
|
|
}
|
1992-07-07 00:35:53 +02:00
|
|
|
|
DECL_RESULT (current_function_decl)
|
|
|
|
|
= build_decl (RESULT_DECL, NULL_TREE, restype);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* If this fcn was already referenced via a block-scope `extern' decl
|
|
|
|
|
(or an implicit decl), propagate certain information about the usage. */
|
|
|
|
|
if (TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (current_function_decl)))
|
|
|
|
|
TREE_ADDRESSABLE (current_function_decl) = 1;
|
|
|
|
|
|
1994-10-18 20:42:11 +01:00
|
|
|
|
immediate_size_expand = old_immediate_size_expand;
|
|
|
|
|
|
Lazy __FUNCTION__ generation.
gcc:
Lazy __FUNCTION__ generation.
* c-common.h (RID_FUNCTION_NAME, RID_PRETTY_FUNCTION_NAME,
RID_C99_FUNCTION_NAME): New _RIDs.
(CTI_FUNCTION_ID, CTI_PRETTY_FUNCTION_ID, CTI_FUNC_ID): Remove.
(CTI_FUNCTION_NAME_DECL, CTI_PRETTY_FUNCTION_NAME_DECL,
CTI_C99_FUNCTION_NAME_DECL, CTI_SAVED_FUNCTION_NAME_DECLS): New
global tree slots.
(function_id_node, pretty_function_id_node, func_id_node): Remove.
(c99_function_name_decl_node, function_name_decl_node,
pretty_function_name_decl_node, saved_function_name_decls):
Declare.
(struct language_function): Remove x_function_name_declared_p.
(make_fname_decl): Remove a parameter.
(declare_function_names): Remove prototype.
(start_fname_decls, finish_fname_decls): Prototype.
(fname_as_string): Likewise.
(fname_string, fname_decl): Likewise.
* c-common.c (make_fname_decl): Adjust.
(struct fname_var_t): New struct.
(fname_vars): New static array.
(declare_function_name): Remove.
(start_fname_decls, finish_fname_decls): New functions.
(fname_as_string): New function from remnants of
declare_function_name.
(fname_string, fname_decl): New functions.
* c-decl.c (c_function_name_declared_p): Remove.
(init_decl_processing): Don't generate __FUNCTION__ et al ids,
don't call declare_function_name. Call start_fname_decls.
(c_make_fname_decl): Adjust parameters. Generate the name. Don't
clobber the line number. Call finish_decl.
(start_function): Call start_fname_decls.
(finish_function): Call finish_fname_decls.
Remove c_function_name_declared_p.
(push_c_function_context): Don't push c_function_name_declared_p.
(pop_c_function_context): Don't pop c_function_name_declared_p.
(c_begin_compound_stmt): Don't check c_function_name_declared_p.
* c-parse.in (STRING_FUNC_NAME, VAR_FUNC_NAME): New tokens.
(program): Call finish_fname_decls for C.
(primary): Add VAR_FUNC_NAME.
(reswords): Add slots for __FUNCTION__ et al.
(rid_to_yy): Add mappings for __FUNCTION__ et al.
(yylexname): If it's a STRING_FUNC_NAME generate the function name
now. Don't look for VAR_DECLs containing __FUNCTION__ et al.
* c-semantics.c (prune_unused_decls): Remove.
(finish_stmt_tree): Don't call prune_unused_decls.
(genrtl_decl_stmt): Don't prune unused decls here.
cp:
Lazy __FUNCTION__ generation.
* cp-tree.def (FUNCTION_NAME): Remove.
* cp-tree.h (function_name_declared_p): Remove.
(cp_fname_init): Prototype.
* decl.c (init_decl_processing): Don't generate __FUNCTION__ et al ids,
don't call declare_function_name. Call start_fname_decls.
(cp_make_fname_decl): Adjust parameters. Generate the name. Don't
clobber the line number.
(cp_fname_init): New function.
(start_function): Call start_fname_decls.
(finish_function): Call finish_fname_decls.
* lex.c (reswords): Add slots for __FUNCTION__ et al.
(rid_to_yy): Add mappings for __FUNCTION__ et al.
* optimize.c (maybe_clone_body): Remove function_name_declared_p.
* parse.y (VAR_FUNC_NAME): New token.
(primary): Add VAR_FUNC_NAME.
* pt.c (tsubst_decl): Adjust a DECL_PRETTY_FUNCTION_P's
generation.
(tsubst, FUNCTION_NAME case): Remove.
(tsubst_copy, FUNCTION_NAME case): Remove.
(tsubst_expr, DECL_STMT case): Be careful with a
DECL_PRETTY_FUNCTION_P.
(instantiate_decl): Remove function_name_declared_p.
* semantics.c (begin_compound_statement): Don't call
declare_function_name here.
(setup_vtbl_ptr). Don't save & restore function_name_declared_p.
(finish_translation_unit): Call finish_fname_decls.
(expand_body): Remove function_name_declared_p.
* typeck2.c (digest_init): Allow any ERROR_MARK.
testsuite:
* gcc.dg/c99-func-2.c: Remove xfail.
* gcc.dg/c99-func-3.c: Remove xfail.
* gcc.dg/c99-func-4.c: Remove xfail.
From-SVN: r41520
2001-04-24 10:22:06 +02:00
|
|
|
|
start_fname_decls ();
|
2003-06-19 21:43:59 +02:00
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-27 22:07:04 +02:00
|
|
|
|
/* Subroutine of store_parm_decls which handles new-style function
|
|
|
|
|
definitions (prototype format). The parms already have decls, so we
|
|
|
|
|
need only record them as in effect and complain if any redundant
|
|
|
|
|
old-style parm decls were written. */
|
|
|
|
|
static void
|
|
|
|
|
store_parm_decls_newstyle (void)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-08-01 20:41:40 +02:00
|
|
|
|
tree decl, last;
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree fndecl = current_function_decl;
|
2003-07-27 22:07:04 +02:00
|
|
|
|
tree parms = current_function_parms;
|
|
|
|
|
tree tags = current_function_parm_tags;
|
2003-08-01 20:41:40 +02:00
|
|
|
|
tree others = current_function_parm_others;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
if (current_scope->parms || current_scope->names || current_scope->tags)
|
2003-07-27 22:07:04 +02:00
|
|
|
|
{
|
|
|
|
|
error ("%Hold-style parameter declarations in prototyped "
|
|
|
|
|
"function definition", &DECL_SOURCE_LOCATION (fndecl));
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-27 22:07:04 +02:00
|
|
|
|
/* Get rid of the old-style declarations. */
|
|
|
|
|
poplevel (0, 0, 0);
|
|
|
|
|
pushlevel (0);
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
/* Now make all the parameter declarations visible in the function body.
|
|
|
|
|
We can bypass most of the grunt work of pushdecl. */
|
2003-08-01 20:41:40 +02:00
|
|
|
|
for (last = 0, decl = parms; decl; last = decl, decl = TREE_CHAIN (decl))
|
2003-07-27 22:07:04 +02:00
|
|
|
|
{
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
DECL_CONTEXT (decl) = current_function_decl;
|
2003-07-27 22:07:04 +02:00
|
|
|
|
if (DECL_NAME (decl) == 0)
|
|
|
|
|
error ("%Hparameter name omitted", &DECL_SOURCE_LOCATION (decl));
|
|
|
|
|
else
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
{
|
|
|
|
|
if (IDENTIFIER_SYMBOL_VALUE (DECL_NAME (decl)))
|
|
|
|
|
current_scope->shadowed
|
|
|
|
|
= tree_cons (DECL_NAME (decl),
|
|
|
|
|
IDENTIFIER_SYMBOL_VALUE (DECL_NAME (decl)),
|
|
|
|
|
current_scope->shadowed);
|
|
|
|
|
IDENTIFIER_SYMBOL_VALUE (DECL_NAME (decl)) = decl;
|
|
|
|
|
}
|
2003-07-27 22:07:04 +02:00
|
|
|
|
}
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
current_scope->parms = parms;
|
2003-08-01 20:41:40 +02:00
|
|
|
|
current_scope->parms_last = last;
|
2001-12-06 00:20:00 +01:00
|
|
|
|
|
2003-07-27 22:07:04 +02:00
|
|
|
|
/* Record the parameter list in the function declaration. */
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
DECL_ARGUMENTS (fndecl) = parms;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-27 22:07:04 +02:00
|
|
|
|
/* Now make all the ancillary declarations visible, likewise. */
|
2003-08-01 20:41:40 +02:00
|
|
|
|
for (last = 0, decl = others; decl; last = decl, decl = TREE_CHAIN (decl))
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
{
|
|
|
|
|
DECL_CONTEXT (decl) = current_function_decl;
|
|
|
|
|
if (DECL_NAME (decl)
|
|
|
|
|
&& TYPE_MAIN_VARIANT (TREE_TYPE (decl)) != void_type_node)
|
|
|
|
|
{
|
|
|
|
|
if (IDENTIFIER_SYMBOL_VALUE (DECL_NAME (decl)))
|
|
|
|
|
current_scope->shadowed
|
|
|
|
|
= tree_cons (DECL_NAME (decl),
|
|
|
|
|
IDENTIFIER_SYMBOL_VALUE (DECL_NAME (decl)),
|
|
|
|
|
current_scope->shadowed);
|
|
|
|
|
IDENTIFIER_SYMBOL_VALUE (DECL_NAME (decl)) = decl;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-08-01 20:41:40 +02:00
|
|
|
|
current_scope->names = others;
|
|
|
|
|
current_scope->names_last = last;
|
2001-12-06 00:20:00 +01:00
|
|
|
|
|
2003-07-27 22:07:04 +02:00
|
|
|
|
/* And all the tag declarations. */
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
for (decl = tags; decl; decl = TREE_CHAIN (decl))
|
|
|
|
|
if (TREE_PURPOSE (decl))
|
|
|
|
|
{
|
|
|
|
|
if (IDENTIFIER_TAG_VALUE (TREE_PURPOSE (decl)))
|
|
|
|
|
current_scope->shadowed_tags
|
|
|
|
|
= tree_cons (TREE_PURPOSE (decl),
|
|
|
|
|
IDENTIFIER_SYMBOL_VALUE (TREE_PURPOSE (decl)),
|
|
|
|
|
current_scope->shadowed_tags);
|
|
|
|
|
IDENTIFIER_TAG_VALUE (TREE_PURPOSE (decl)) = TREE_VALUE (decl);
|
|
|
|
|
}
|
|
|
|
|
current_scope->tags = tags;
|
2003-07-27 22:07:04 +02:00
|
|
|
|
}
|
2001-06-05 08:51:02 +02:00
|
|
|
|
|
2003-07-27 22:07:04 +02:00
|
|
|
|
/* Subroutine of store_parm_decls which handles old-style function
|
|
|
|
|
definitions (separate parameter list and declarations). */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-27 22:07:04 +02:00
|
|
|
|
static void
|
|
|
|
|
store_parm_decls_oldstyle (void)
|
|
|
|
|
{
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
tree parm, decl, last;
|
2003-07-27 22:07:04 +02:00
|
|
|
|
tree fndecl = current_function_decl;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-27 22:07:04 +02:00
|
|
|
|
/* This is the identifier list from the function declarator. */
|
|
|
|
|
tree parmids = current_function_parms;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-27 22:07:04 +02:00
|
|
|
|
/* We use DECL_WEAK as a flag to show which parameters have been
|
2003-08-01 20:41:40 +02:00
|
|
|
|
seen already, since it is not used on PARM_DECL. */
|
|
|
|
|
#ifdef ENABLE_CHECKING
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
for (parm = current_scope->parms; parm; parm = TREE_CHAIN (parm))
|
2003-08-01 20:41:40 +02:00
|
|
|
|
if (DECL_WEAK (parm))
|
|
|
|
|
abort ();
|
|
|
|
|
#endif
|
2003-07-27 22:07:04 +02:00
|
|
|
|
|
|
|
|
|
/* Match each formal parameter name with its declaration. Save each
|
|
|
|
|
decl in the appropriate TREE_PURPOSE slot of the parmids chain. */
|
|
|
|
|
for (parm = parmids; parm; parm = TREE_CHAIN (parm))
|
|
|
|
|
{
|
|
|
|
|
if (TREE_VALUE (parm) == 0)
|
1992-10-06 01:23:17 +01:00
|
|
|
|
{
|
2003-07-27 22:07:04 +02:00
|
|
|
|
error ("%Hparameter name missing from parameter list",
|
|
|
|
|
&DECL_SOURCE_LOCATION (fndecl));
|
|
|
|
|
TREE_PURPOSE (parm) = 0;
|
|
|
|
|
continue;
|
1992-10-06 01:23:17 +01:00
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-27 22:07:04 +02:00
|
|
|
|
decl = IDENTIFIER_SYMBOL_VALUE (TREE_VALUE (parm));
|
|
|
|
|
if (decl && DECL_CONTEXT (decl) == fndecl)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-27 22:07:04 +02:00
|
|
|
|
const location_t *locus = &DECL_SOURCE_LOCATION (decl);
|
|
|
|
|
/* If we got something other than a PARM_DECL it is an error. */
|
|
|
|
|
if (TREE_CODE (decl) != PARM_DECL)
|
|
|
|
|
error ("%H\"%D\" declared as a non-parameter", locus, decl);
|
|
|
|
|
/* If the declaration is already marked, we have a duplicate
|
|
|
|
|
name. Complain and ignore the duplicate. */
|
|
|
|
|
else if (DECL_WEAK (decl))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-27 22:07:04 +02:00
|
|
|
|
error ("%Hmultiple parameters named \"%D\"", locus, decl);
|
|
|
|
|
TREE_PURPOSE (parm) = 0;
|
|
|
|
|
continue;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
2003-07-27 22:07:04 +02:00
|
|
|
|
/* If the declaration says "void", complain and turn it into
|
|
|
|
|
an int. */
|
|
|
|
|
else if (VOID_TYPE_P (TREE_TYPE (decl)))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-27 22:07:04 +02:00
|
|
|
|
error ("%Hparameter \"%D\" declared void", locus, decl);
|
|
|
|
|
TREE_TYPE (decl) = integer_type_node;
|
|
|
|
|
DECL_ARG_TYPE (decl) = integer_type_node;
|
|
|
|
|
layout_decl (decl, 0);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-07-27 22:07:04 +02:00
|
|
|
|
/* If no declaration found, default to int. */
|
|
|
|
|
else
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-27 22:07:04 +02:00
|
|
|
|
const location_t *locus = &DECL_SOURCE_LOCATION (fndecl);
|
|
|
|
|
decl = build_decl (PARM_DECL, TREE_VALUE (parm), integer_type_node);
|
|
|
|
|
DECL_ARG_TYPE (decl) = TREE_TYPE (decl);
|
|
|
|
|
DECL_SOURCE_LOCATION (decl) = *locus;
|
|
|
|
|
pushdecl (decl);
|
|
|
|
|
|
|
|
|
|
if (flag_isoc99)
|
|
|
|
|
pedwarn ("%Htype of \"%D\" defaults to \"int\"", locus, decl);
|
|
|
|
|
else if (extra_warnings)
|
|
|
|
|
warning ("%Htype of \"%D\" defaults to \"int\"", locus, decl);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-27 22:07:04 +02:00
|
|
|
|
TREE_PURPOSE (parm) = decl;
|
|
|
|
|
DECL_WEAK (decl) = 1;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
/* Now examine the parms chain for incomplete declarations
|
|
|
|
|
and declarations with no corresponding names. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
for (parm = current_scope->parms; parm; parm = TREE_CHAIN (parm))
|
2003-07-27 22:07:04 +02:00
|
|
|
|
{
|
|
|
|
|
const location_t *locus = &DECL_SOURCE_LOCATION (parm);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-27 22:07:04 +02:00
|
|
|
|
if (!COMPLETE_TYPE_P (TREE_TYPE (parm)))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-27 22:07:04 +02:00
|
|
|
|
error ("%Hparameter \"%D\" has incomplete type", locus, parm);
|
|
|
|
|
TREE_TYPE (parm) = error_mark_node;
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-27 22:07:04 +02:00
|
|
|
|
if (! DECL_WEAK (parm))
|
|
|
|
|
{
|
|
|
|
|
error ("%Hdeclaration for parameter \"%D\" but no such parameter",
|
|
|
|
|
locus, parm);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-27 22:07:04 +02:00
|
|
|
|
/* Pretend the parameter was not missing.
|
|
|
|
|
This gets us to a standard state and minimizes
|
|
|
|
|
further error messages. */
|
|
|
|
|
parmids = chainon (parmids, tree_cons (parm, 0, 0));
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
2003-07-27 22:07:04 +02:00
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-27 22:07:04 +02:00
|
|
|
|
/* Chain the declarations together in the order of the list of
|
|
|
|
|
names. Store that chain in the function decl, replacing the
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
list of names. Update the current scope to match. */
|
2003-07-27 22:07:04 +02:00
|
|
|
|
DECL_ARGUMENTS (fndecl) = 0;
|
|
|
|
|
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
for (parm = parmids; parm; parm = TREE_CHAIN (parm))
|
|
|
|
|
if (TREE_PURPOSE (parm))
|
|
|
|
|
break;
|
|
|
|
|
if (parm && TREE_PURPOSE (parm))
|
|
|
|
|
{
|
|
|
|
|
last = TREE_PURPOSE (parm);
|
|
|
|
|
DECL_ARGUMENTS (fndecl) = last;
|
|
|
|
|
current_scope->parms = last;
|
|
|
|
|
DECL_WEAK (last) = 0;
|
|
|
|
|
|
|
|
|
|
for (parm = TREE_CHAIN (parm); parm; parm = TREE_CHAIN (parm))
|
|
|
|
|
if (TREE_PURPOSE (parm))
|
|
|
|
|
{
|
|
|
|
|
TREE_CHAIN (last) = TREE_PURPOSE (parm);
|
|
|
|
|
last = TREE_PURPOSE (parm);
|
|
|
|
|
DECL_WEAK (last) = 0;
|
|
|
|
|
}
|
2003-08-01 20:41:40 +02:00
|
|
|
|
current_scope->parms_last = last;
|
c-decl.c (last_function_parm_vars, [...]): New static variables.
* c-decl.c (last_function_parm_vars, current_function_parm_vars):
New static variables.
(struct c_scope): Add parms and warned_forward_parm_decls
fields; remove parm_order.
(storedecls, storetags): Delete.
(poplevel): Also clear bindings on the parms chain.
(pushdecl): Handle forward declarations of parameters, and
chain PARM_DECLs on the parms list, not the names list.
(lookup_name_current_level): Check for PARM_DECLs on the parms
list too.
(push_parm_decl): Don't update parm_order.
(clear_parm_order): Rename mark_forward_parm_decls. Issue the
warning, only once per parameter list, and set TREE_ASM_WRITTEN
on the decls here. Then move the forward decls to the names list.
(grokparms): Set last_function_parm_vars.
(get_parm_info): Don't use gettags or getdecls. No need to
extract non-parms from the parms list, or reorganize the parms
list. Feed nonparms back in the TREE_TYPE of the list node
returned. Issue only one error per parameter list for "void"
appearing more than once in said parameter list. Collapse
parmlist_tags_warning into this function to avoid double scan
of tags list.
(start_function): Set current_function_parm_vars.
(store_parm_decls_newstyle): Bypass pushdecl, manipulate scope
directly. Get non-parms from current_function_parm_vars; no
need to extract them from the parms chain. Properly bind tags
in the new scope.
(store_parm_decls_oldstyle): No need to extract non-parameters
from the parms chain, nor to store them back afterward. Move
declaration to top of function, restructure code reordering
DECL_ARGUMENTS.
(store_parm_decls): No need to save and restore warn_shadow.
* c-parse.in: Don't call parmlist_tags_warning nor
clear_parm_order. Call mark_forward_parm_decls when forward
parm decls are encountered.
* c-tree.h: Prototype mark_forward_parm_decls; not
clear_parm_order or parmlist_tags_warning.
testsuite:
* gcc.dg/struct-in-proto-1.c: New test.
From-SVN: r69945
2003-07-30 01:58:08 +02:00
|
|
|
|
TREE_CHAIN (last) = 0;
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-27 22:07:04 +02:00
|
|
|
|
/* If there was a previous prototype,
|
|
|
|
|
set the DECL_ARG_TYPE of each argument according to
|
|
|
|
|
the type previously specified, and report any mismatches. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-27 22:07:04 +02:00
|
|
|
|
if (TYPE_ARG_TYPES (TREE_TYPE (fndecl)))
|
|
|
|
|
{
|
|
|
|
|
tree type;
|
|
|
|
|
for (parm = DECL_ARGUMENTS (fndecl),
|
|
|
|
|
type = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
|
|
|
|
|
parm || (type && (TYPE_MAIN_VARIANT (TREE_VALUE (type))
|
|
|
|
|
!= void_type_node));
|
|
|
|
|
parm = TREE_CHAIN (parm), type = TREE_CHAIN (type))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-27 22:07:04 +02:00
|
|
|
|
if (parm == 0 || type == 0
|
|
|
|
|
|| TYPE_MAIN_VARIANT (TREE_VALUE (type)) == void_type_node)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-27 22:07:04 +02:00
|
|
|
|
error ("number of arguments doesn't match prototype");
|
|
|
|
|
error ("%Hprototype declaration",
|
|
|
|
|
¤t_function_prototype_locus);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
/* Type for passing arg must be consistent with that
|
|
|
|
|
declared for the arg. ISO C says we take the unqualified
|
|
|
|
|
type for parameters declared with qualified type. */
|
|
|
|
|
if (! comptypes (TYPE_MAIN_VARIANT (DECL_ARG_TYPE (parm)),
|
|
|
|
|
TYPE_MAIN_VARIANT (TREE_VALUE (type)),
|
|
|
|
|
COMPARE_STRICT))
|
|
|
|
|
{
|
|
|
|
|
if (TYPE_MAIN_VARIANT (TREE_TYPE (parm))
|
|
|
|
|
== TYPE_MAIN_VARIANT (TREE_VALUE (type)))
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2003-07-27 22:07:04 +02:00
|
|
|
|
/* Adjust argument to match prototype. E.g. a previous
|
|
|
|
|
`int foo(float);' prototype causes
|
|
|
|
|
`int foo(x) float x; {...}' to be treated like
|
|
|
|
|
`int foo(float x) {...}'. This is particularly
|
|
|
|
|
useful for argument types like uid_t. */
|
|
|
|
|
DECL_ARG_TYPE (parm) = TREE_TYPE (parm);
|
|
|
|
|
|
targhooks.c: New file.
* targhooks.c: New file.
* targhooks.h: New file.
* Makefile.in: Add targhooks.o support.
(function.o): Depend on$(TARGET_H).
(stmt.o): Likewise.
(combine.o): Depend on $(TREE_H) and $(TARGET_H).
* builtins.c (apply_args_size, expand_builtin_apply_args_1,
expand_builtin_apply): Convert to calls.struct_value_rtx hook.
(expand_builtin_saveregs): Convert to
calls.expand_builtin_saveregs hook.
* c-decl.c (start_decl): Handle new calls.promote_prototypes hook
here, instead of ...
(get_parm_info) ... here.
(store_parm_decls_oldstyle): Convert to calls.promote_prototypes
hook.
(finish_function): Handle calls.promote_prototypes hook here too.
* c-typeck.c (convert_arguments): Convert to
calls.promote_prototypes hook.
(c_convert_parm_for_inlining): Likewise.
* calls.c (initialize_argument_information): Convert to
calls.promote_function_args hook.
(expand_call): Convert to calls.struct_value_rtx,
calls.strict_argument_naming,
calls.pretend_outgoing_varargs_named, and
calls.promote_function_return hooks. Pass fndecl to
aggregate_value_p. Initialize CUMULATIVE_ARGS before calling
hooks, so they can use that.
(emit_library_call_value_1): Likewise.
* combine.c (setup_incoming_promotions): Convert to
calls.promote_function_args hook.
* emit-rtl.c: Convert to calls.struct_value_rtx hook.
* expr.c (expand_assignment): Pass call to aggregate_value_p.
(expand_expr): Likewise.
* expr.h: Remove support for SETUP_INCOMING_VARARGS,
STRICT_ARGUMENT_NAMING, PRETEND_OUTGOING_VARARGS_NAMED,
RETURN_IN_MEMORY macro defaults.
* final.c (profile_function): Convert to calls.struct_value_rtx
hook.
* function.c (aggregate_value_p): Accept function type tree as
second parameter; try to deduce fntype from it. Convert to
calls.return_in_memory hook.
(assign_parms): Convert to calls.setup_incoming_varargs,
calls.strict_argument_naming, calls.promote_function_args,
calls.pretend_outgoing_varargs_named hooks. Pass fndecl to
aggregate_value_p.
(expand_function_start): Likewise. Convert to
calls.struct_value_rtx hook.
(expand_function_end): Convert to calls.promote_function_return hook.
(allocate_struct_function): Pass fndecl to aggregate_value_p.
* hard-reg-set.h: Update comments to new hook names.
* integrate.c (expand_inline_function): Pass fndecl to aggregate_value_p.
* reg-stack.c (stack_result): Likewise.
* rtl.h (struct_value_rtx, struct_value_incoming_rtx): Delete.
* stmt.c (expand_value_return): Convert to
calls.promote_function_return hook.
* target-def.h: Add TARGET_PROMOTE_FUNCTION_ARGS,
TARGET_PROMOTE_FUNCTION_RETURN, TARGET_PROMOTE_PROTOTYPES,
TARGET_STRUCT_VALUE_RTX, TARGET_RETURN_IN_MEMORY,
TARGET_EXPAND_BUILTIN_SAVEREGS, TARGET_SETUP_INCOMING_VARARGS,
TARGET_STRICT_ARGUMENT_NAMING,
TARGET_PRETEND_OUTGOING_VARARGS_NAMED, and TARGET_CALLS.
* target.h: Likewise.
* tree.h (aggregate_value_p): Also takes a tree to deduce function
attributes from (for target hooks).
* doc/tm.texi (PROMOTE_FUNCTION_ARGS, PROMOTE_FUNCTION_RETURN,
PROMOTE_PROTOTYPES, RETURN_IN_MEMORY, STRUCT_VALUE_REGNUM,
STRUCT_VALUE, STRUCT_VALUE_INCOMING_REGNUM, STRUCT_VALUE_INCOMING,
EXPAND_BUILTIN_SAVEREGS, SETUP_INCOMING_VARARGS,
STRICT_ARGUMENT_NAMING, PRETEND_OUTGOING_VARARGS_NAMED): Convert
to hooks.
* config/alpha/alpha.c (alpha_output_mi_thunk_osf): Pass function
to aggregate_value_p.
* config/arm/arm.c (arm_init_cumulative_args,
arm_output_mi_thunk): Likewise.
* config/i386/i386.c (ix86_return_pops_args, x86_this_parameter):
Likewise.
* config/mips/mips.c (mips_save_reg_p, mips_expand_prologue,
mips_can_use_return_insn): Likewise.
* config/rs6000/rs6000.c (rs6000_output_mi_thunk): Likewise.
* config/s390/s390.c (s390_output_mi_thunk): Likewise.
* config/sparc/sparc.c (sparc_output_mi_thunk): Pass function to
aggregate_value_p.
* config/story16/stormy16.c (xstormy16_asm_output_mi_thunk): Pass
function to aggregate_value_p.
* objc/objc-act.c (generate_struct_by_value_array): Pass NULL to
aggregate_value_p.
* config/sh/sh-protos.h (sh_builtin_saveregs): Remove.
(sh_attr_renesas_p, sh_cfun_attr_renesas_p, sh_function_arg,
sh_function_arg_advance, sh_pass_in_reg_p): New. * config/sh/sh.c
(sh_handle_renesas_attribute, sh_promote_prototypes,
sh_struct_value_rtx, sh_return_in_memory, sh_builtin_saveregs,
sh_setup_incoming_varargs, sh_strict_argument_naming,
sh_pretend_outgoing_varargs_named): New decls.
(targetm): Add new hooks.
(calc_live_regs): Save MACL and MACH if the function has the
renesas attribute.
(sh_expand_prologue): Support renesas attribute.
(sh_builtin_saveregs): Make static.
(sh_build_va_list): Support renesas attribute.
(sh_va_start): Likewise.
(sh_va_arg): Likewise.
(sh_promote_prototypes): New.
(sh_function_arg): New, moved from sh.h. Support renesas
attribute.
(sh_function_arg_advance): Likewise.
(sh_return_in_memory): Likewise.
(sh_strict_argument_naming): Likewise.
(sh_pretend_outgoing_varargs_named): Likewise.
(sh_struct_value_rtx): New.
(sh_attribute): Add renesas attribute.
(sh_handle_renesas_attribute): New.
(sh_attr_renesas_p, sh_cfun_attr_renesas_p): New.
(sh_ms_bitfield_layout_p): Support renesas attribute also.
(sh_output_mi_thunk): Pass function to aggregate_value_p. *
config/sh/sh.h (TARGET_SWITCHES): Add -mrenesas as an alias for
-mhitachi.
(STRUCT_VALUE_REGNUM, STRUCT_VALUE, RETURN_IN_MEMORY): Moved to
target hooks.
(sh_args): Add renesas_abi flag.
(INIT_CUMULATIVE_ARGS): Set it. Pass fndecl to aggregate_value_p.
(FUNCTION_ARG_ADVANCE, FUNCTION_ARG): Move to sh.c.
(PASS_IN_REG_P): Support renesas attribute. Pass DF and TF on the
stack for the renesas abi.
(STRICT_ARGUMENT_NAMING, PRETEND_OUTGOING_VARARGS_NAMED,
SETUP_INCOMING_VARARGS, EXPAND_BUILTIN_SAVEREGS,
PROMOTE_PROTOTYPES): Moved to sh.c. * config/sh/sh.md (call): Set
call cookie to indicate renesas calls.
* decl.c (finish_function): Pass fndecl to aggregate_value_p.
* misc.c (default_pass_by_ref): Convert to calls.return_in_memory
hook.
From-SVN: r71048
2003-09-04 05:18:05 +02:00
|
|
|
|
if (targetm.calls.promote_prototypes (TREE_TYPE (current_function_decl))
|
2003-07-27 22:07:04 +02:00
|
|
|
|
&& INTEGRAL_TYPE_P (TREE_TYPE (parm))
|
|
|
|
|
&& TYPE_PRECISION (TREE_TYPE (parm))
|
|
|
|
|
< TYPE_PRECISION (integer_type_node))
|
|
|
|
|
DECL_ARG_TYPE (parm) = integer_type_node;
|
|
|
|
|
|
|
|
|
|
if (pedantic)
|
1993-03-18 23:01:56 +01:00
|
|
|
|
{
|
2003-07-27 22:07:04 +02:00
|
|
|
|
pedwarn ("promoted argument \"%D\" "
|
|
|
|
|
"doesn't match prototype", parm);
|
|
|
|
|
pedwarn ("%Hprototype declaration",
|
|
|
|
|
¤t_function_prototype_locus);
|
1993-03-18 23:01:56 +01:00
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
2003-07-27 22:07:04 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
error ("argument \"%D\" doesn't match prototype", parm);
|
|
|
|
|
error ("%Hprototype declaration",
|
|
|
|
|
¤t_function_prototype_locus);
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-07-27 22:07:04 +02:00
|
|
|
|
TYPE_ACTUAL_ARG_TYPES (TREE_TYPE (fndecl)) = 0;
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-27 22:07:04 +02:00
|
|
|
|
/* Otherwise, create a prototype that would match. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-27 22:07:04 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tree actual = 0, last = 0, type;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-27 22:07:04 +02:00
|
|
|
|
for (parm = DECL_ARGUMENTS (fndecl); parm; parm = TREE_CHAIN (parm))
|
|
|
|
|
{
|
|
|
|
|
type = tree_cons (NULL_TREE, DECL_ARG_TYPE (parm), NULL_TREE);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
if (last)
|
|
|
|
|
TREE_CHAIN (last) = type;
|
|
|
|
|
else
|
|
|
|
|
actual = type;
|
2003-07-27 22:07:04 +02:00
|
|
|
|
last = type;
|
|
|
|
|
}
|
|
|
|
|
type = tree_cons (NULL_TREE, void_type_node, NULL_TREE);
|
|
|
|
|
if (last)
|
|
|
|
|
TREE_CHAIN (last) = type;
|
|
|
|
|
else
|
|
|
|
|
actual = type;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-27 22:07:04 +02:00
|
|
|
|
/* We are going to assign a new value for the TYPE_ACTUAL_ARG_TYPES
|
|
|
|
|
of the type of this function, but we need to avoid having this
|
|
|
|
|
affect the types of other similarly-typed functions, so we must
|
|
|
|
|
first force the generation of an identical (but separate) type
|
|
|
|
|
node for the relevant function type. The new node we create
|
|
|
|
|
will be a variant of the main variant of the original function
|
|
|
|
|
type. */
|
1992-03-08 23:08:20 +01:00
|
|
|
|
|
2003-07-27 22:07:04 +02:00
|
|
|
|
TREE_TYPE (fndecl) = build_type_copy (TREE_TYPE (fndecl));
|
1992-03-08 23:08:20 +01:00
|
|
|
|
|
2003-07-27 22:07:04 +02:00
|
|
|
|
TYPE_ACTUAL_ARG_TYPES (TREE_TYPE (fndecl)) = actual;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Store the parameter declarations into the current function declaration.
|
|
|
|
|
This is called after parsing the parameter declarations, before
|
|
|
|
|
digesting the body of the function.
|
|
|
|
|
|
|
|
|
|
For an old-style definition, construct a prototype out of the old-style
|
|
|
|
|
parameter declarations and inject it into the function's type. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
store_parm_decls (void)
|
|
|
|
|
{
|
|
|
|
|
tree fndecl = current_function_decl;
|
|
|
|
|
|
|
|
|
|
/* The function containing FNDECL, if any. */
|
|
|
|
|
tree context = decl_function_context (fndecl);
|
|
|
|
|
|
|
|
|
|
/* True if this definition is written with a prototype. */
|
|
|
|
|
bool prototype = (current_function_parms
|
|
|
|
|
&& TREE_CODE (current_function_parms) != TREE_LIST);
|
|
|
|
|
|
|
|
|
|
if (prototype)
|
|
|
|
|
store_parm_decls_newstyle ();
|
|
|
|
|
else
|
|
|
|
|
store_parm_decls_oldstyle ();
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-28 02:12:32 +02:00
|
|
|
|
/* The next call to pushlevel will be a function body. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2003-07-28 02:12:32 +02:00
|
|
|
|
next_is_function_body = true;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* Write a record describing this function definition to the prototypes
|
|
|
|
|
file (if requested). */
|
|
|
|
|
|
|
|
|
|
gen_aux_info_record (fndecl, 1, 0, prototype);
|
|
|
|
|
|
|
|
|
|
/* Initialize the RTL code for the function. */
|
2003-08-30 01:21:13 +02:00
|
|
|
|
allocate_struct_function (fndecl);
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2000-09-17 09:38:23 +02:00
|
|
|
|
/* Begin the statement tree for this function. */
|
2003-07-27 22:07:04 +02:00
|
|
|
|
begin_stmt_tree (&DECL_SAVED_TREE (fndecl));
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2001-06-05 08:51:02 +02:00
|
|
|
|
/* If this is a nested function, save away the sizes of any
|
|
|
|
|
variable-size types so that we can expand them when generating
|
|
|
|
|
RTL. */
|
|
|
|
|
if (context)
|
|
|
|
|
{
|
|
|
|
|
tree t;
|
|
|
|
|
|
2003-06-19 21:43:59 +02:00
|
|
|
|
DECL_LANG_SPECIFIC (fndecl)->pending_sizes
|
2001-06-05 08:51:02 +02:00
|
|
|
|
= nreverse (get_pending_sizes ());
|
|
|
|
|
for (t = DECL_LANG_SPECIFIC (fndecl)->pending_sizes;
|
|
|
|
|
t;
|
|
|
|
|
t = TREE_CHAIN (t))
|
|
|
|
|
SAVE_EXPR_CONTEXT (TREE_VALUE (t)) = context;
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-17 09:38:23 +02:00
|
|
|
|
/* This function is being processed in whole-function mode. */
|
|
|
|
|
cfun->x_whole_function_mode_p = 1;
|
1992-05-18 07:09:24 +02:00
|
|
|
|
|
2000-09-17 09:38:23 +02:00
|
|
|
|
/* Even though we're inside a function body, we still don't want to
|
|
|
|
|
call expand_expr to calculate the size of a variable-sized array.
|
|
|
|
|
We haven't necessarily assigned RTL to all variables yet, so it's
|
|
|
|
|
not safe to try to expand expressions involving them. */
|
|
|
|
|
immediate_size_expand = 0;
|
|
|
|
|
cfun->x_dont_save_pending_sizes_p = 1;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Finish up a function declaration and compile that function
|
|
|
|
|
all the way to assembler language output. The free the storage
|
|
|
|
|
for the function definition.
|
|
|
|
|
|
2003-09-03 16:57:29 +02:00
|
|
|
|
This is called after parsing the body of the function definition. */
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
void
|
2003-09-03 16:57:29 +02:00
|
|
|
|
finish_function ()
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2001-10-11 05:16:15 +02:00
|
|
|
|
tree fndecl = current_function_decl;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
/* When a function declaration is totally empty, e.g.
|
|
|
|
|
void foo(void) { }
|
|
|
|
|
(the argument list is irrelevant) the compstmt rule will not
|
|
|
|
|
bother calling pushlevel/poplevel, which means we get here with
|
2003-07-28 02:12:32 +02:00
|
|
|
|
the scope stack out of sync. Detect this situation by noticing
|
|
|
|
|
that current_scope is still as store_parm_decls left it, and do
|
|
|
|
|
a dummy push/pop to get back to consistency.
|
|
|
|
|
Note that the call to pushlevel does not actually push another
|
|
|
|
|
scope - see there for details. */
|
|
|
|
|
|
|
|
|
|
if (current_scope->parm_flag && next_is_function_body)
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
{
|
|
|
|
|
pushlevel (0);
|
2003-07-28 02:12:32 +02:00
|
|
|
|
poplevel (0, 0, 0);
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
targhooks.c: New file.
* targhooks.c: New file.
* targhooks.h: New file.
* Makefile.in: Add targhooks.o support.
(function.o): Depend on$(TARGET_H).
(stmt.o): Likewise.
(combine.o): Depend on $(TREE_H) and $(TARGET_H).
* builtins.c (apply_args_size, expand_builtin_apply_args_1,
expand_builtin_apply): Convert to calls.struct_value_rtx hook.
(expand_builtin_saveregs): Convert to
calls.expand_builtin_saveregs hook.
* c-decl.c (start_decl): Handle new calls.promote_prototypes hook
here, instead of ...
(get_parm_info) ... here.
(store_parm_decls_oldstyle): Convert to calls.promote_prototypes
hook.
(finish_function): Handle calls.promote_prototypes hook here too.
* c-typeck.c (convert_arguments): Convert to
calls.promote_prototypes hook.
(c_convert_parm_for_inlining): Likewise.
* calls.c (initialize_argument_information): Convert to
calls.promote_function_args hook.
(expand_call): Convert to calls.struct_value_rtx,
calls.strict_argument_naming,
calls.pretend_outgoing_varargs_named, and
calls.promote_function_return hooks. Pass fndecl to
aggregate_value_p. Initialize CUMULATIVE_ARGS before calling
hooks, so they can use that.
(emit_library_call_value_1): Likewise.
* combine.c (setup_incoming_promotions): Convert to
calls.promote_function_args hook.
* emit-rtl.c: Convert to calls.struct_value_rtx hook.
* expr.c (expand_assignment): Pass call to aggregate_value_p.
(expand_expr): Likewise.
* expr.h: Remove support for SETUP_INCOMING_VARARGS,
STRICT_ARGUMENT_NAMING, PRETEND_OUTGOING_VARARGS_NAMED,
RETURN_IN_MEMORY macro defaults.
* final.c (profile_function): Convert to calls.struct_value_rtx
hook.
* function.c (aggregate_value_p): Accept function type tree as
second parameter; try to deduce fntype from it. Convert to
calls.return_in_memory hook.
(assign_parms): Convert to calls.setup_incoming_varargs,
calls.strict_argument_naming, calls.promote_function_args,
calls.pretend_outgoing_varargs_named hooks. Pass fndecl to
aggregate_value_p.
(expand_function_start): Likewise. Convert to
calls.struct_value_rtx hook.
(expand_function_end): Convert to calls.promote_function_return hook.
(allocate_struct_function): Pass fndecl to aggregate_value_p.
* hard-reg-set.h: Update comments to new hook names.
* integrate.c (expand_inline_function): Pass fndecl to aggregate_value_p.
* reg-stack.c (stack_result): Likewise.
* rtl.h (struct_value_rtx, struct_value_incoming_rtx): Delete.
* stmt.c (expand_value_return): Convert to
calls.promote_function_return hook.
* target-def.h: Add TARGET_PROMOTE_FUNCTION_ARGS,
TARGET_PROMOTE_FUNCTION_RETURN, TARGET_PROMOTE_PROTOTYPES,
TARGET_STRUCT_VALUE_RTX, TARGET_RETURN_IN_MEMORY,
TARGET_EXPAND_BUILTIN_SAVEREGS, TARGET_SETUP_INCOMING_VARARGS,
TARGET_STRICT_ARGUMENT_NAMING,
TARGET_PRETEND_OUTGOING_VARARGS_NAMED, and TARGET_CALLS.
* target.h: Likewise.
* tree.h (aggregate_value_p): Also takes a tree to deduce function
attributes from (for target hooks).
* doc/tm.texi (PROMOTE_FUNCTION_ARGS, PROMOTE_FUNCTION_RETURN,
PROMOTE_PROTOTYPES, RETURN_IN_MEMORY, STRUCT_VALUE_REGNUM,
STRUCT_VALUE, STRUCT_VALUE_INCOMING_REGNUM, STRUCT_VALUE_INCOMING,
EXPAND_BUILTIN_SAVEREGS, SETUP_INCOMING_VARARGS,
STRICT_ARGUMENT_NAMING, PRETEND_OUTGOING_VARARGS_NAMED): Convert
to hooks.
* config/alpha/alpha.c (alpha_output_mi_thunk_osf): Pass function
to aggregate_value_p.
* config/arm/arm.c (arm_init_cumulative_args,
arm_output_mi_thunk): Likewise.
* config/i386/i386.c (ix86_return_pops_args, x86_this_parameter):
Likewise.
* config/mips/mips.c (mips_save_reg_p, mips_expand_prologue,
mips_can_use_return_insn): Likewise.
* config/rs6000/rs6000.c (rs6000_output_mi_thunk): Likewise.
* config/s390/s390.c (s390_output_mi_thunk): Likewise.
* config/sparc/sparc.c (sparc_output_mi_thunk): Pass function to
aggregate_value_p.
* config/story16/stormy16.c (xstormy16_asm_output_mi_thunk): Pass
function to aggregate_value_p.
* objc/objc-act.c (generate_struct_by_value_array): Pass NULL to
aggregate_value_p.
* config/sh/sh-protos.h (sh_builtin_saveregs): Remove.
(sh_attr_renesas_p, sh_cfun_attr_renesas_p, sh_function_arg,
sh_function_arg_advance, sh_pass_in_reg_p): New. * config/sh/sh.c
(sh_handle_renesas_attribute, sh_promote_prototypes,
sh_struct_value_rtx, sh_return_in_memory, sh_builtin_saveregs,
sh_setup_incoming_varargs, sh_strict_argument_naming,
sh_pretend_outgoing_varargs_named): New decls.
(targetm): Add new hooks.
(calc_live_regs): Save MACL and MACH if the function has the
renesas attribute.
(sh_expand_prologue): Support renesas attribute.
(sh_builtin_saveregs): Make static.
(sh_build_va_list): Support renesas attribute.
(sh_va_start): Likewise.
(sh_va_arg): Likewise.
(sh_promote_prototypes): New.
(sh_function_arg): New, moved from sh.h. Support renesas
attribute.
(sh_function_arg_advance): Likewise.
(sh_return_in_memory): Likewise.
(sh_strict_argument_naming): Likewise.
(sh_pretend_outgoing_varargs_named): Likewise.
(sh_struct_value_rtx): New.
(sh_attribute): Add renesas attribute.
(sh_handle_renesas_attribute): New.
(sh_attr_renesas_p, sh_cfun_attr_renesas_p): New.
(sh_ms_bitfield_layout_p): Support renesas attribute also.
(sh_output_mi_thunk): Pass function to aggregate_value_p. *
config/sh/sh.h (TARGET_SWITCHES): Add -mrenesas as an alias for
-mhitachi.
(STRUCT_VALUE_REGNUM, STRUCT_VALUE, RETURN_IN_MEMORY): Moved to
target hooks.
(sh_args): Add renesas_abi flag.
(INIT_CUMULATIVE_ARGS): Set it. Pass fndecl to aggregate_value_p.
(FUNCTION_ARG_ADVANCE, FUNCTION_ARG): Move to sh.c.
(PASS_IN_REG_P): Support renesas attribute. Pass DF and TF on the
stack for the renesas abi.
(STRICT_ARGUMENT_NAMING, PRETEND_OUTGOING_VARARGS_NAMED,
SETUP_INCOMING_VARARGS, EXPAND_BUILTIN_SAVEREGS,
PROMOTE_PROTOTYPES): Moved to sh.c. * config/sh/sh.md (call): Set
call cookie to indicate renesas calls.
* decl.c (finish_function): Pass fndecl to aggregate_value_p.
* misc.c (default_pass_by_ref): Convert to calls.return_in_memory
hook.
From-SVN: r71048
2003-09-04 05:18:05 +02:00
|
|
|
|
if (TREE_CODE (fndecl) == FUNCTION_DECL
|
|
|
|
|
&& targetm.calls.promote_prototypes (TREE_TYPE (fndecl)))
|
|
|
|
|
{
|
|
|
|
|
tree args = DECL_ARGUMENTS (fndecl);
|
|
|
|
|
for (; args; args = TREE_CHAIN (args))
|
|
|
|
|
{
|
|
|
|
|
tree type = TREE_TYPE (args);
|
|
|
|
|
if (INTEGRAL_TYPE_P (type)
|
|
|
|
|
&& TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
|
|
|
|
|
DECL_ARG_TYPE (args) = integer_type_node;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1992-07-05 23:12:43 +02:00
|
|
|
|
BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
|
|
|
|
/* Must mark the RESULT_DECL as being in this function. */
|
|
|
|
|
|
|
|
|
|
DECL_CONTEXT (DECL_RESULT (fndecl)) = fndecl;
|
|
|
|
|
|
2000-08-24 22:09:27 +02:00
|
|
|
|
if (MAIN_NAME_P (DECL_NAME (fndecl)) && flag_hosted)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
1992-07-15 20:34:18 +02:00
|
|
|
|
if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (fndecl)))
|
|
|
|
|
!= integer_type_node)
|
1997-01-19 21:04:35 +01:00
|
|
|
|
{
|
1999-04-12 16:05:29 +02:00
|
|
|
|
/* If warn_main is 1 (-Wmain) or 2 (-Wall), we have already warned.
|
2000-08-11 00:01:22 +02:00
|
|
|
|
If warn_main is -1 (-Wno-main) we don't want to be warned. */
|
2003-07-19 12:19:19 +02:00
|
|
|
|
if (!warn_main)
|
|
|
|
|
pedwarn ("%Hreturn type of '%D' is not `int'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (fndecl), fndecl);
|
1997-01-19 21:04:35 +01:00
|
|
|
|
}
|
1992-07-07 03:09:25 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
1996-04-08 20:44:21 +02:00
|
|
|
|
#ifdef DEFAULT_MAIN_RETURN
|
1992-07-07 03:09:25 +02:00
|
|
|
|
/* Make it so that `main' always returns success by default. */
|
|
|
|
|
DEFAULT_MAIN_RETURN;
|
2000-07-27 21:51:41 +02:00
|
|
|
|
#else
|
|
|
|
|
if (flag_isoc99)
|
|
|
|
|
c_expand_return (integer_zero_node);
|
1996-04-08 20:44:21 +02:00
|
|
|
|
#endif
|
1992-07-07 03:09:25 +02:00
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
2003-06-19 21:43:59 +02:00
|
|
|
|
|
Lazy __FUNCTION__ generation.
gcc:
Lazy __FUNCTION__ generation.
* c-common.h (RID_FUNCTION_NAME, RID_PRETTY_FUNCTION_NAME,
RID_C99_FUNCTION_NAME): New _RIDs.
(CTI_FUNCTION_ID, CTI_PRETTY_FUNCTION_ID, CTI_FUNC_ID): Remove.
(CTI_FUNCTION_NAME_DECL, CTI_PRETTY_FUNCTION_NAME_DECL,
CTI_C99_FUNCTION_NAME_DECL, CTI_SAVED_FUNCTION_NAME_DECLS): New
global tree slots.
(function_id_node, pretty_function_id_node, func_id_node): Remove.
(c99_function_name_decl_node, function_name_decl_node,
pretty_function_name_decl_node, saved_function_name_decls):
Declare.
(struct language_function): Remove x_function_name_declared_p.
(make_fname_decl): Remove a parameter.
(declare_function_names): Remove prototype.
(start_fname_decls, finish_fname_decls): Prototype.
(fname_as_string): Likewise.
(fname_string, fname_decl): Likewise.
* c-common.c (make_fname_decl): Adjust.
(struct fname_var_t): New struct.
(fname_vars): New static array.
(declare_function_name): Remove.
(start_fname_decls, finish_fname_decls): New functions.
(fname_as_string): New function from remnants of
declare_function_name.
(fname_string, fname_decl): New functions.
* c-decl.c (c_function_name_declared_p): Remove.
(init_decl_processing): Don't generate __FUNCTION__ et al ids,
don't call declare_function_name. Call start_fname_decls.
(c_make_fname_decl): Adjust parameters. Generate the name. Don't
clobber the line number. Call finish_decl.
(start_function): Call start_fname_decls.
(finish_function): Call finish_fname_decls.
Remove c_function_name_declared_p.
(push_c_function_context): Don't push c_function_name_declared_p.
(pop_c_function_context): Don't pop c_function_name_declared_p.
(c_begin_compound_stmt): Don't check c_function_name_declared_p.
* c-parse.in (STRING_FUNC_NAME, VAR_FUNC_NAME): New tokens.
(program): Call finish_fname_decls for C.
(primary): Add VAR_FUNC_NAME.
(reswords): Add slots for __FUNCTION__ et al.
(rid_to_yy): Add mappings for __FUNCTION__ et al.
(yylexname): If it's a STRING_FUNC_NAME generate the function name
now. Don't look for VAR_DECLs containing __FUNCTION__ et al.
* c-semantics.c (prune_unused_decls): Remove.
(finish_stmt_tree): Don't call prune_unused_decls.
(genrtl_decl_stmt): Don't prune unused decls here.
cp:
Lazy __FUNCTION__ generation.
* cp-tree.def (FUNCTION_NAME): Remove.
* cp-tree.h (function_name_declared_p): Remove.
(cp_fname_init): Prototype.
* decl.c (init_decl_processing): Don't generate __FUNCTION__ et al ids,
don't call declare_function_name. Call start_fname_decls.
(cp_make_fname_decl): Adjust parameters. Generate the name. Don't
clobber the line number.
(cp_fname_init): New function.
(start_function): Call start_fname_decls.
(finish_function): Call finish_fname_decls.
* lex.c (reswords): Add slots for __FUNCTION__ et al.
(rid_to_yy): Add mappings for __FUNCTION__ et al.
* optimize.c (maybe_clone_body): Remove function_name_declared_p.
* parse.y (VAR_FUNC_NAME): New token.
(primary): Add VAR_FUNC_NAME.
* pt.c (tsubst_decl): Adjust a DECL_PRETTY_FUNCTION_P's
generation.
(tsubst, FUNCTION_NAME case): Remove.
(tsubst_copy, FUNCTION_NAME case): Remove.
(tsubst_expr, DECL_STMT case): Be careful with a
DECL_PRETTY_FUNCTION_P.
(instantiate_decl): Remove function_name_declared_p.
* semantics.c (begin_compound_statement): Don't call
declare_function_name here.
(setup_vtbl_ptr). Don't save & restore function_name_declared_p.
(finish_translation_unit): Call finish_fname_decls.
(expand_body): Remove function_name_declared_p.
* typeck2.c (digest_init): Allow any ERROR_MARK.
testsuite:
* gcc.dg/c99-func-2.c: Remove xfail.
* gcc.dg/c99-func-3.c: Remove xfail.
* gcc.dg/c99-func-4.c: Remove xfail.
From-SVN: r41520
2001-04-24 10:22:06 +02:00
|
|
|
|
finish_fname_decls ();
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2000-09-17 09:38:23 +02:00
|
|
|
|
/* Tie off the statement tree for this function. */
|
|
|
|
|
finish_stmt_tree (&DECL_SAVED_TREE (fndecl));
|
2002-02-06 21:40:18 +01:00
|
|
|
|
|
|
|
|
|
/* Complain if there's just no return statement. */
|
2002-02-28 14:30:04 +01:00
|
|
|
|
if (warn_return_type
|
|
|
|
|
&& TREE_CODE (TREE_TYPE (TREE_TYPE (fndecl))) != VOID_TYPE
|
2002-02-06 21:40:18 +01:00
|
|
|
|
&& !current_function_returns_value && !current_function_returns_null
|
|
|
|
|
/* Don't complain if we abort. */
|
|
|
|
|
&& !current_function_returns_abnormally
|
|
|
|
|
/* Don't warn for main(). */
|
|
|
|
|
&& !MAIN_NAME_P (DECL_NAME (fndecl))
|
|
|
|
|
/* Or if they didn't actually specify a return type. */
|
|
|
|
|
&& !C_FUNCTION_IMPLICIT_INT (fndecl)
|
2002-02-28 14:30:04 +01:00
|
|
|
|
/* Normally, with -Wreturn-type, flow will complain. Unless we're an
|
2002-02-06 21:40:18 +01:00
|
|
|
|
inline function, as we might never be compiled separately. */
|
2002-02-28 14:30:04 +01:00
|
|
|
|
&& DECL_INLINE (fndecl))
|
2002-02-06 21:40:18 +01:00
|
|
|
|
warning ("no return statement in function returning non-void");
|
|
|
|
|
|
2003-08-30 01:21:13 +02:00
|
|
|
|
/* We're leaving the context of this function, so zap cfun. It's still in
|
|
|
|
|
DECL_SAVED_INSNS, and we'll restore it in tree_rest_of_compilation. */
|
2000-09-17 09:38:23 +02:00
|
|
|
|
cfun = NULL;
|
|
|
|
|
|
2003-09-03 16:57:29 +02:00
|
|
|
|
/* ??? Objc emits functions after finalizing the compilation unit.
|
|
|
|
|
This should be cleaned up later and this conditional removed. */
|
|
|
|
|
if (!cgraph_global_info_ready)
|
|
|
|
|
cgraph_finalize_function (fndecl, DECL_SAVED_TREE (fndecl));
|
|
|
|
|
else
|
|
|
|
|
c_expand_body (fndecl);
|
|
|
|
|
current_function_decl = NULL;
|
2000-09-17 09:38:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-12 01:02:36 +01:00
|
|
|
|
/* Generate the RTL for a deferred function FNDECL. */
|
|
|
|
|
|
|
|
|
|
void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
c_expand_deferred_function (tree fndecl)
|
2001-11-12 01:02:36 +01:00
|
|
|
|
{
|
2001-11-21 12:09:01 +01:00
|
|
|
|
/* DECL_INLINE or DECL_RESULT might got cleared after the inline
|
|
|
|
|
function was deferred, e.g. in duplicate_decls. */
|
|
|
|
|
if (DECL_INLINE (fndecl) && DECL_RESULT (fndecl))
|
|
|
|
|
{
|
2003-02-12 22:48:59 +01:00
|
|
|
|
if (flag_inline_trees)
|
|
|
|
|
{
|
|
|
|
|
timevar_push (TV_INTEGRATION);
|
|
|
|
|
optimize_inline_calls (fndecl);
|
|
|
|
|
timevar_pop (TV_INTEGRATION);
|
|
|
|
|
}
|
|
|
|
|
c_expand_body (fndecl);
|
2001-11-21 12:09:01 +01:00
|
|
|
|
current_function_decl = NULL;
|
|
|
|
|
}
|
2001-11-12 01:02:36 +01:00
|
|
|
|
}
|
|
|
|
|
|
2002-09-22 04:03:17 +02:00
|
|
|
|
/* Generate the RTL for the body of FNDECL. If NESTED_P is nonzero,
|
2000-09-17 09:38:23 +02:00
|
|
|
|
then we are already in the process of generating RTL for another
|
2003-09-03 16:57:29 +02:00
|
|
|
|
function. */
|
2000-09-17 09:38:23 +02:00
|
|
|
|
|
|
|
|
|
static void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
c_expand_body_1 (tree fndecl, int nested_p)
|
2000-09-17 09:38:23 +02:00
|
|
|
|
{
|
|
|
|
|
if (nested_p)
|
2001-06-05 08:51:02 +02:00
|
|
|
|
{
|
|
|
|
|
/* Make sure that we will evaluate variable-sized types involved
|
|
|
|
|
in our function's type. */
|
|
|
|
|
expand_pending_sizes (DECL_LANG_SPECIFIC (fndecl)->pending_sizes);
|
|
|
|
|
}
|
2000-09-17 09:38:23 +02:00
|
|
|
|
|
2003-08-30 01:21:13 +02:00
|
|
|
|
tree_rest_of_compilation (fndecl);
|
1999-09-10 05:16:49 +02:00
|
|
|
|
|
2003-01-24 16:17:26 +01:00
|
|
|
|
/* With just -Wextra, complain only if function returns both with
|
1992-02-13 23:21:26 +01:00
|
|
|
|
and without a value. */
|
2000-10-06 08:01:27 +02:00
|
|
|
|
if (extra_warnings
|
|
|
|
|
&& current_function_returns_value
|
|
|
|
|
&& current_function_returns_null)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
warning ("this function may return with or without a value");
|
|
|
|
|
|
1995-01-14 02:09:01 +01:00
|
|
|
|
if (DECL_STATIC_CONSTRUCTOR (fndecl))
|
|
|
|
|
{
|
2001-08-10 00:33:35 +02:00
|
|
|
|
if (targetm.have_ctors_dtors)
|
|
|
|
|
(* targetm.asm_out.constructor) (XEXP (DECL_RTL (fndecl), 0),
|
|
|
|
|
DEFAULT_INIT_PRIORITY);
|
1995-01-14 02:09:01 +01:00
|
|
|
|
else
|
2001-08-10 00:33:35 +02:00
|
|
|
|
static_ctors = tree_cons (NULL_TREE, fndecl, static_ctors);
|
1995-01-14 02:09:01 +01:00
|
|
|
|
}
|
2001-08-07 02:13:35 +02:00
|
|
|
|
|
1995-01-14 02:09:01 +01:00
|
|
|
|
if (DECL_STATIC_DESTRUCTOR (fndecl))
|
|
|
|
|
{
|
2001-08-10 00:33:35 +02:00
|
|
|
|
if (targetm.have_ctors_dtors)
|
|
|
|
|
(* targetm.asm_out.destructor) (XEXP (DECL_RTL (fndecl), 0),
|
|
|
|
|
DEFAULT_INIT_PRIORITY);
|
1995-01-14 02:09:01 +01:00
|
|
|
|
else
|
2001-08-10 00:33:35 +02:00
|
|
|
|
static_dtors = tree_cons (NULL_TREE, fndecl, static_dtors);
|
1995-01-14 02:09:01 +01:00
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
}
|
2003-02-12 22:48:59 +01:00
|
|
|
|
|
|
|
|
|
/* Like c_expand_body_1 but only for unnested functions. */
|
|
|
|
|
|
|
|
|
|
void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
c_expand_body (tree fndecl)
|
2003-02-12 22:48:59 +01:00
|
|
|
|
{
|
|
|
|
|
c_expand_body_1 (fndecl, 0);
|
|
|
|
|
}
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2000-11-19 00:18:36 +01:00
|
|
|
|
/* Check the declarations given in a for-loop for satisfying the C99
|
|
|
|
|
constraints. */
|
|
|
|
|
void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
check_for_loop_decls (void)
|
2000-11-19 00:18:36 +01:00
|
|
|
|
{
|
|
|
|
|
tree t;
|
|
|
|
|
|
|
|
|
|
if (!flag_isoc99)
|
|
|
|
|
{
|
|
|
|
|
/* If we get here, declarations have been used in a for loop without
|
|
|
|
|
the C99 for loop scope. This doesn't make much sense, so don't
|
|
|
|
|
allow it. */
|
2003-08-01 20:41:40 +02:00
|
|
|
|
error ("'for' loop initial declaration used outside C99 mode");
|
2000-11-19 00:18:36 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/* C99 subclause 6.8.5 paragraph 3:
|
|
|
|
|
|
|
|
|
|
[#3] The declaration part of a for statement shall only
|
|
|
|
|
declare identifiers for objects having storage class auto or
|
|
|
|
|
register.
|
|
|
|
|
|
|
|
|
|
It isn't clear whether, in this sentence, "identifiers" binds to
|
|
|
|
|
"shall only declare" or to "objects" - that is, whether all identifiers
|
|
|
|
|
declared must be identifiers for objects, or whether the restriction
|
|
|
|
|
only applies to those that are. (A question on this in comp.std.c
|
|
|
|
|
in November 2000 received no answer.) We implement the strictest
|
|
|
|
|
interpretation, to avoid creating an extension which later causes
|
|
|
|
|
problems. */
|
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
for (t = current_scope->tags; t; t = TREE_CHAIN (t))
|
2000-11-19 00:18:36 +01:00
|
|
|
|
{
|
|
|
|
|
if (TREE_PURPOSE (t) != 0)
|
2001-10-30 13:14:28 +01:00
|
|
|
|
{
|
|
|
|
|
enum tree_code code = TREE_CODE (TREE_VALUE (t));
|
2003-06-19 21:43:59 +02:00
|
|
|
|
|
2001-10-30 13:14:28 +01:00
|
|
|
|
if (code == RECORD_TYPE)
|
2003-08-01 20:41:40 +02:00
|
|
|
|
error ("'struct %s' declared in 'for' loop initial declaration",
|
2001-10-30 13:14:28 +01:00
|
|
|
|
IDENTIFIER_POINTER (TREE_PURPOSE (t)));
|
|
|
|
|
else if (code == UNION_TYPE)
|
2003-08-01 20:41:40 +02:00
|
|
|
|
error ("'union %s' declared in 'for' loop initial declaration",
|
2001-10-30 13:14:28 +01:00
|
|
|
|
IDENTIFIER_POINTER (TREE_PURPOSE (t)));
|
|
|
|
|
else
|
2003-08-01 20:41:40 +02:00
|
|
|
|
error ("'enum %s' declared in 'for' loop initial declaration",
|
2001-10-30 13:14:28 +01:00
|
|
|
|
IDENTIFIER_POINTER (TREE_PURPOSE (t)));
|
|
|
|
|
}
|
2000-11-19 00:18:36 +01:00
|
|
|
|
}
|
2001-10-30 13:14:28 +01:00
|
|
|
|
|
2000-11-19 00:18:36 +01:00
|
|
|
|
for (t = getdecls (); t; t = TREE_CHAIN (t))
|
|
|
|
|
{
|
2003-07-19 12:19:19 +02:00
|
|
|
|
const location_t *locus = &DECL_SOURCE_LOCATION (t);
|
2000-11-19 00:18:36 +01:00
|
|
|
|
if (TREE_CODE (t) != VAR_DECL && DECL_NAME (t))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hdeclaration of non-variable '%D' in 'for' loop "
|
|
|
|
|
"initial declaration", locus, t);
|
2000-11-19 00:18:36 +01:00
|
|
|
|
else if (TREE_STATIC (t))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hdeclaration of static variable '%D' in 'for' loop "
|
2003-08-01 20:41:40 +02:00
|
|
|
|
"initial declaration", locus, t);
|
2000-11-19 00:18:36 +01:00
|
|
|
|
else if (DECL_EXTERNAL (t))
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hdeclaration of 'extern' variable '%D' in 'for' loop "
|
|
|
|
|
"initial declaration", locus, t);
|
2000-11-19 00:18:36 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1992-02-13 23:21:26 +01:00
|
|
|
|
/* Save and restore the variables in this file and elsewhere
|
|
|
|
|
that keep track of the progress of compilation of the current function.
|
|
|
|
|
Used for nested functions. */
|
|
|
|
|
|
2002-06-04 09:11:05 +02:00
|
|
|
|
struct language_function GTY(())
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2002-06-04 09:11:05 +02:00
|
|
|
|
struct c_language_function base;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
int returns_value;
|
|
|
|
|
int returns_null;
|
2002-02-06 21:40:18 +01:00
|
|
|
|
int returns_abnormally;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
int warn_about_return_type;
|
|
|
|
|
int extern_inline;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Save and reinitialize the variables
|
|
|
|
|
used during compilation of a C function. */
|
|
|
|
|
|
|
|
|
|
void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
c_push_function_context (struct function *f)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2002-06-04 09:11:05 +02:00
|
|
|
|
struct language_function *p;
|
2003-07-19 16:47:15 +02:00
|
|
|
|
p = ggc_alloc (sizeof (struct language_function));
|
2002-06-04 09:11:05 +02:00
|
|
|
|
f->language = p;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2000-09-17 09:38:23 +02:00
|
|
|
|
p->base.x_stmt_tree = c_stmt_tree;
|
|
|
|
|
p->base.x_scope_stmt_stack = c_scope_stmt_stack;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
p->returns_value = current_function_returns_value;
|
|
|
|
|
p->returns_null = current_function_returns_null;
|
2002-02-06 21:40:18 +01:00
|
|
|
|
p->returns_abnormally = current_function_returns_abnormally;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
p->warn_about_return_type = warn_about_return_type;
|
|
|
|
|
p->extern_inline = current_extern_inline;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Restore the variables used during compilation of a C function. */
|
|
|
|
|
|
|
|
|
|
void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
c_pop_function_context (struct function *f)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
2002-06-04 09:11:05 +02:00
|
|
|
|
struct language_function *p = f->language;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
|
2000-09-17 09:38:23 +02:00
|
|
|
|
if (DECL_SAVED_INSNS (current_function_decl) == 0
|
|
|
|
|
&& DECL_SAVED_TREE (current_function_decl) == NULL_TREE)
|
1992-02-13 23:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
/* Stop pointing to the local nodes about to be freed. */
|
|
|
|
|
/* But DECL_INITIAL must remain nonzero so we know this
|
|
|
|
|
was an actual function definition. */
|
|
|
|
|
DECL_INITIAL (current_function_decl) = error_mark_node;
|
|
|
|
|
DECL_ARGUMENTS (current_function_decl) = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-17 09:38:23 +02:00
|
|
|
|
c_stmt_tree = p->base.x_stmt_tree;
|
|
|
|
|
c_scope_stmt_stack = p->base.x_scope_stmt_stack;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
current_function_returns_value = p->returns_value;
|
|
|
|
|
current_function_returns_null = p->returns_null;
|
2002-02-06 21:40:18 +01:00
|
|
|
|
current_function_returns_abnormally = p->returns_abnormally;
|
1992-02-13 23:21:26 +01:00
|
|
|
|
warn_about_return_type = p->warn_about_return_type;
|
|
|
|
|
current_extern_inline = p->extern_inline;
|
|
|
|
|
|
2002-06-04 09:11:05 +02:00
|
|
|
|
f->language = NULL;
|
1999-09-06 23:28:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
2002-02-28 08:39:44 +01:00
|
|
|
|
/* Copy the DECL_LANG_SPECIFIC data associated with DECL. */
|
1994-05-14 03:56:51 +02:00
|
|
|
|
|
|
|
|
|
void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
c_dup_lang_specific_decl (tree decl)
|
1994-05-14 03:56:51 +02:00
|
|
|
|
{
|
2000-09-17 09:38:23 +02:00
|
|
|
|
struct lang_decl *ld;
|
|
|
|
|
|
|
|
|
|
if (!DECL_LANG_SPECIFIC (decl))
|
|
|
|
|
return;
|
|
|
|
|
|
2003-07-19 16:47:15 +02:00
|
|
|
|
ld = ggc_alloc (sizeof (struct lang_decl));
|
|
|
|
|
memcpy (ld, DECL_LANG_SPECIFIC (decl), sizeof (struct lang_decl));
|
2000-09-17 09:38:23 +02:00
|
|
|
|
DECL_LANG_SPECIFIC (decl) = ld;
|
1994-05-14 03:56:51 +02:00
|
|
|
|
}
|
1999-09-06 23:28:22 +02:00
|
|
|
|
|
2000-07-02 07:23:01 +02:00
|
|
|
|
/* The functions below are required for functionality of doing
|
|
|
|
|
function at once processing in the C front end. Currently these
|
|
|
|
|
functions are not called from anywhere in the C front end, but as
|
2000-08-11 00:01:22 +02:00
|
|
|
|
these changes continue, that will change. */
|
2000-07-02 07:23:01 +02:00
|
|
|
|
|
2002-09-22 04:03:17 +02:00
|
|
|
|
/* Returns nonzero if the current statement is a full expression,
|
2000-07-02 07:23:01 +02:00
|
|
|
|
i.e. temporaries created during that statement should be destroyed
|
|
|
|
|
at the end of the statement. */
|
|
|
|
|
|
|
|
|
|
int
|
2003-06-19 21:43:59 +02:00
|
|
|
|
stmts_are_full_exprs_p (void)
|
2000-07-02 07:23:01 +02:00
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-07 03:36:11 +02:00
|
|
|
|
/* Returns the stmt_tree (if any) to which statements are currently
|
|
|
|
|
being added. If there is no active statement-tree, NULL is
|
|
|
|
|
returned. */
|
|
|
|
|
|
|
|
|
|
stmt_tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
current_stmt_tree (void)
|
2000-09-07 03:36:11 +02:00
|
|
|
|
{
|
2000-09-17 09:38:23 +02:00
|
|
|
|
return &c_stmt_tree;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Returns the stack of SCOPE_STMTs for the current function. */
|
|
|
|
|
|
|
|
|
|
tree *
|
2003-06-19 21:43:59 +02:00
|
|
|
|
current_scope_stmt_stack (void)
|
2000-09-17 09:38:23 +02:00
|
|
|
|
{
|
|
|
|
|
return &c_scope_stmt_stack;
|
2000-09-07 03:36:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
2000-07-02 07:23:01 +02:00
|
|
|
|
/* Nonzero if TYPE is an anonymous union or struct type. Always 0 in
|
2000-08-11 00:01:22 +02:00
|
|
|
|
C. */
|
2000-07-02 07:23:01 +02:00
|
|
|
|
|
2000-08-11 00:01:22 +02:00
|
|
|
|
int
|
2003-06-19 21:43:59 +02:00
|
|
|
|
anon_aggr_type_p (tree node ATTRIBUTE_UNUSED)
|
2000-07-02 07:23:01 +02:00
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-17 09:38:23 +02:00
|
|
|
|
/* Dummy function in place of callback used by C++. */
|
2000-07-02 07:23:01 +02:00
|
|
|
|
|
2000-09-17 09:38:23 +02:00
|
|
|
|
void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
extract_interface_info (void)
|
2000-07-02 07:23:01 +02:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-17 09:38:23 +02:00
|
|
|
|
/* Return a new COMPOUND_STMT, after adding it to the current
|
|
|
|
|
statement tree. */
|
2000-07-02 07:23:01 +02:00
|
|
|
|
|
2000-09-17 09:38:23 +02:00
|
|
|
|
tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
c_begin_compound_stmt (void)
|
2000-07-02 07:23:01 +02:00
|
|
|
|
{
|
2000-09-17 09:38:23 +02:00
|
|
|
|
tree stmt;
|
2000-08-11 00:01:22 +02:00
|
|
|
|
|
2000-09-17 09:38:23 +02:00
|
|
|
|
/* Create the COMPOUND_STMT. */
|
|
|
|
|
stmt = add_stmt (build_stmt (COMPOUND_STMT, NULL_TREE));
|
2001-01-02 08:00:49 +01:00
|
|
|
|
|
2000-09-17 09:38:23 +02:00
|
|
|
|
return stmt;
|
2000-07-02 07:23:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
2000-09-17 09:38:23 +02:00
|
|
|
|
/* Expand T (a DECL_STMT) if it declares an entity not handled by the
|
|
|
|
|
common code. */
|
2000-07-02 07:23:01 +02:00
|
|
|
|
|
|
|
|
|
void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
c_expand_decl_stmt (tree t)
|
Integrated preprocessor.
top level:
* Makefile.in: Remove all references to c-parse.gperf,
c-gperf.h, and c-parse.h. Remove -d from yacc command line
generating c-parse.c. Update dependencies.
* c-parse.gperf, c-gperf.h: Delete.
* c-common.c: Don't define parse_options, cpp_token, yy_cur,
yy_lim, or yy_get_token. Don't define get_directive_line if
USE_CPPLIB.
* c-common.h: Add multiple include guard. Define RID values
for every keyword in C, C++, and Objective C. Put all the
modifiers first.
(struct c_fileinfo, get_fileinfo, dump_time_statistics): New.
* c-decl.c (c_decode_option): Handle -lang-objc here.
(print_lang_identifier): Handle C_IS_RESERVED_WORD case.
(grokdeclarator): Adjust for new RID scheme.
(extract_interface_info): New stub.
* c-lang.c: Don't declare yy_cur or parse_options.
(lang_init_options): Call cpp_init. Don't call
cpp_options_init.
(lang_init): Don't call check_newline if USE_CPPLIB.
* c-lex.c: Don't include c-parse.h. Do include timevar.h.
Elide lots of unnecessary code if USE_CPPLIB. Delete code
rendered unnecessary by new architecture. Move routines not
shared with C++ to c-parse.in. Maintain a local idea of the
line number. Handle C++ as well as C.
[USE_CPPLIB]: Declare and register callbacks for #ident and
for entering/leaving files.
(init_c_lex, c_lex): Are now the entry points to this file.
(check_newline): Break out directive handling to
process_directive.
(read_ucs, is_extended_char, utf8_extend_token): Moved here
from C++ front end.
(readescape, parse_float): Overhaul.
(lex_number, lex_string, lex_charconst): Break out of c_lex
(n'ee yylex).
(get_fileinfo, update_header_times, dump_one_header,
dump_time_statistics): New and/or moved here from C++.
Support per-file data needed by C++ and per-header timing
statistics (C++ only, at the moment).
* c-lex.h: Update prototypes. Add multiple include guard.
* c-tree.h (struct lang_identifier): Add rid_code field.
(C_IS_RESERVED_WORD, C_RID_CODE): New.
* c-parse.in: Include c-pragma.h. Remove unnecesary calls to
reinit_parse_for_function and/or position_after_white_space.
(save_filename, save_lineno): Look ahead before saving.
(label -> identifier ':'): Save file and line before shifting ':'.
(reservedwords): No need to call get_identifier.
(init_parse, finish_parse, yyerror, yylex, yyprint,
make_pointer_declarator): Are now here for C/ObjC.
(rid_to_yy): Conversion table from RID constants to Yacc codes.
* c-pragma.c: Rewrite parsing logic to fit with cpplib's
#pragma registry. Provide dummy implementation of that
interface if !USE_CPPLIB.
* c-pragma.h: Update to match.
* flags.h: Add multiple include guard.
(flag_detailed_statistics): Moved here from C++.
* toplev.c: Define flag_detailed_statistics.
* gcc.c (C specs): Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* timevar.def (TV_CPP, TV_LEX): New.
* timevar.h: Add multiple include guard.
* objc/lang-specs.h: Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* objc/objc-act.c: Don't mention yy_cur or parse_options.
Initialize cpplib properly. Force lineno to 0 after first
call to check_newline. Don't handle -lang-objc here.
Move forget_protocol_qualifiers and remember_protocol_qualifiers here.
cp:
* Make-lang.in, Makefile.in: Remove all references to input.c,
gxx.gperf, and hash.h. Add ../c-lex.o to C_OBJS.
* gxx.gperf, hash.h, input.c: Delete.
* lang-specs.h: Pass -lang-c++ to cc1plus so cpplib is
initialized properly.
* class.c (fixup_pending_inline): Take a tree, not a
struct pending_inline *. All callers changed.
(init_class_processing): Set RID_PUBLIC, RID_PRIVATE,
RID_PROTECTED entries in ridpointers[] array here.
* decl.c (duplicate_decls): Do not refer to struct
pending_inline.
(record_builtin_type, init_decl_processing): Use RID_MAX not
CP_RID_MAX.
(grokdeclarator): Use C_IS_RESERVED_WORD.
* decl2.c (lang_decode_option): Ignore -lang-c++ for sake of
cpplib.
(grok_x_components): Do not inspect pending_inlines chain.
* cp-tree.h (struct lang_identifier): Add rid_code entry.
(C_IS_RESERVED_WORD, C_RID_CODE, C_RID_YYCODE): New.
(flag_no_gnu_keywords, flag_operator_names, rid_to_yy): Declare.
(DEFARG_LENGTH, struct pending_inline, TIME_IDENTIFIER_TIME,
TIME_IDENTIFIER_FILEINFO): Kill.
Update prototypes.
* lex.h: Expunge cp_rid. Rewrite RIDBIT macros to use just a
single 32-bit word.
* parse.y: Call do_pending_inlines unconditionally.
reinit_parse_for_method is now snarf_method. fn.defpen is no
longer necessary. Remove unnecessary <itype> annotation on
SCOPE. Do not refer to end_of_file or struct pending_inline.
* semantics.c (begin_inline_definitions): Call
do_pending_inlines unconditionally.
* lex.c: Remove all code now shared with C front end.
Initialize cpplib properly if USE_CPPLIB. Put reserved words
into the get_identifier table. Rewrite pragma handling to
work with the registry. Move code to save tokens for later
processing to spew.c.
* spew.c: Rewrite everything in terms of token streams instead
of text. Move routines here from lex.c / input.c as
appropriate. GC-mark trees hanging off the pending inlines
chain.
testsuite:
* g++.old-deja/g++.benjamin/13478.C: Put meaningful tags on
ERROR markers.
* g++.old-deja/g++.brendan/crash8.C: Move ERROR marker up one line.
* gcc.dg/c99-array-nonobj-1.c: Don't expect func[] cases to fail.
* gcc.dg/wtr-label-1.c: Don't use unconstrained .* in error regexps.
* gcc.dg/wtr-suffix-1.c: Correct error regexps.
* gcc.dg/cpp/unc1.c, gcc.dg/cpp/unc2.c, gcc.dg/cpp/unc3.c:
Preprocess only.
* gcc.dg/cpp/unc4.c: Adjust line number in dg-error line.
* gcc.dg/noncompile/const-ll-1.c: Generalize error regexp.
From-SVN: r36216
2000-09-07 02:37:14 +02:00
|
|
|
|
{
|
2000-09-17 09:38:23 +02:00
|
|
|
|
tree decl = DECL_STMT_DECL (t);
|
2001-01-02 08:00:49 +01:00
|
|
|
|
|
2000-09-17 09:38:23 +02:00
|
|
|
|
/* Expand nested functions. */
|
|
|
|
|
if (TREE_CODE (decl) == FUNCTION_DECL
|
|
|
|
|
&& DECL_CONTEXT (decl) == current_function_decl
|
|
|
|
|
&& DECL_SAVED_TREE (decl))
|
2003-02-12 22:48:59 +01:00
|
|
|
|
c_expand_body_1 (decl, 1);
|
Integrated preprocessor.
top level:
* Makefile.in: Remove all references to c-parse.gperf,
c-gperf.h, and c-parse.h. Remove -d from yacc command line
generating c-parse.c. Update dependencies.
* c-parse.gperf, c-gperf.h: Delete.
* c-common.c: Don't define parse_options, cpp_token, yy_cur,
yy_lim, or yy_get_token. Don't define get_directive_line if
USE_CPPLIB.
* c-common.h: Add multiple include guard. Define RID values
for every keyword in C, C++, and Objective C. Put all the
modifiers first.
(struct c_fileinfo, get_fileinfo, dump_time_statistics): New.
* c-decl.c (c_decode_option): Handle -lang-objc here.
(print_lang_identifier): Handle C_IS_RESERVED_WORD case.
(grokdeclarator): Adjust for new RID scheme.
(extract_interface_info): New stub.
* c-lang.c: Don't declare yy_cur or parse_options.
(lang_init_options): Call cpp_init. Don't call
cpp_options_init.
(lang_init): Don't call check_newline if USE_CPPLIB.
* c-lex.c: Don't include c-parse.h. Do include timevar.h.
Elide lots of unnecessary code if USE_CPPLIB. Delete code
rendered unnecessary by new architecture. Move routines not
shared with C++ to c-parse.in. Maintain a local idea of the
line number. Handle C++ as well as C.
[USE_CPPLIB]: Declare and register callbacks for #ident and
for entering/leaving files.
(init_c_lex, c_lex): Are now the entry points to this file.
(check_newline): Break out directive handling to
process_directive.
(read_ucs, is_extended_char, utf8_extend_token): Moved here
from C++ front end.
(readescape, parse_float): Overhaul.
(lex_number, lex_string, lex_charconst): Break out of c_lex
(n'ee yylex).
(get_fileinfo, update_header_times, dump_one_header,
dump_time_statistics): New and/or moved here from C++.
Support per-file data needed by C++ and per-header timing
statistics (C++ only, at the moment).
* c-lex.h: Update prototypes. Add multiple include guard.
* c-tree.h (struct lang_identifier): Add rid_code field.
(C_IS_RESERVED_WORD, C_RID_CODE): New.
* c-parse.in: Include c-pragma.h. Remove unnecesary calls to
reinit_parse_for_function and/or position_after_white_space.
(save_filename, save_lineno): Look ahead before saving.
(label -> identifier ':'): Save file and line before shifting ':'.
(reservedwords): No need to call get_identifier.
(init_parse, finish_parse, yyerror, yylex, yyprint,
make_pointer_declarator): Are now here for C/ObjC.
(rid_to_yy): Conversion table from RID constants to Yacc codes.
* c-pragma.c: Rewrite parsing logic to fit with cpplib's
#pragma registry. Provide dummy implementation of that
interface if !USE_CPPLIB.
* c-pragma.h: Update to match.
* flags.h: Add multiple include guard.
(flag_detailed_statistics): Moved here from C++.
* toplev.c: Define flag_detailed_statistics.
* gcc.c (C specs): Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* timevar.def (TV_CPP, TV_LEX): New.
* timevar.h: Add multiple include guard.
* objc/lang-specs.h: Use %(trad_capable_cpp) for -E|-M|-MM case
#if USE_CPPLIB.
* objc/objc-act.c: Don't mention yy_cur or parse_options.
Initialize cpplib properly. Force lineno to 0 after first
call to check_newline. Don't handle -lang-objc here.
Move forget_protocol_qualifiers and remember_protocol_qualifiers here.
cp:
* Make-lang.in, Makefile.in: Remove all references to input.c,
gxx.gperf, and hash.h. Add ../c-lex.o to C_OBJS.
* gxx.gperf, hash.h, input.c: Delete.
* lang-specs.h: Pass -lang-c++ to cc1plus so cpplib is
initialized properly.
* class.c (fixup_pending_inline): Take a tree, not a
struct pending_inline *. All callers changed.
(init_class_processing): Set RID_PUBLIC, RID_PRIVATE,
RID_PROTECTED entries in ridpointers[] array here.
* decl.c (duplicate_decls): Do not refer to struct
pending_inline.
(record_builtin_type, init_decl_processing): Use RID_MAX not
CP_RID_MAX.
(grokdeclarator): Use C_IS_RESERVED_WORD.
* decl2.c (lang_decode_option): Ignore -lang-c++ for sake of
cpplib.
(grok_x_components): Do not inspect pending_inlines chain.
* cp-tree.h (struct lang_identifier): Add rid_code entry.
(C_IS_RESERVED_WORD, C_RID_CODE, C_RID_YYCODE): New.
(flag_no_gnu_keywords, flag_operator_names, rid_to_yy): Declare.
(DEFARG_LENGTH, struct pending_inline, TIME_IDENTIFIER_TIME,
TIME_IDENTIFIER_FILEINFO): Kill.
Update prototypes.
* lex.h: Expunge cp_rid. Rewrite RIDBIT macros to use just a
single 32-bit word.
* parse.y: Call do_pending_inlines unconditionally.
reinit_parse_for_method is now snarf_method. fn.defpen is no
longer necessary. Remove unnecessary <itype> annotation on
SCOPE. Do not refer to end_of_file or struct pending_inline.
* semantics.c (begin_inline_definitions): Call
do_pending_inlines unconditionally.
* lex.c: Remove all code now shared with C front end.
Initialize cpplib properly if USE_CPPLIB. Put reserved words
into the get_identifier table. Rewrite pragma handling to
work with the registry. Move code to save tokens for later
processing to spew.c.
* spew.c: Rewrite everything in terms of token streams instead
of text. Move routines here from lex.c / input.c as
appropriate. GC-mark trees hanging off the pending inlines
chain.
testsuite:
* g++.old-deja/g++.benjamin/13478.C: Put meaningful tags on
ERROR markers.
* g++.old-deja/g++.brendan/crash8.C: Move ERROR marker up one line.
* gcc.dg/c99-array-nonobj-1.c: Don't expect func[] cases to fail.
* gcc.dg/wtr-label-1.c: Don't use unconstrained .* in error regexps.
* gcc.dg/wtr-suffix-1.c: Correct error regexps.
* gcc.dg/cpp/unc1.c, gcc.dg/cpp/unc2.c, gcc.dg/cpp/unc3.c:
Preprocess only.
* gcc.dg/cpp/unc4.c: Adjust line number in dg-error line.
* gcc.dg/noncompile/const-ll-1.c: Generalize error regexp.
From-SVN: r36216
2000-09-07 02:37:14 +02:00
|
|
|
|
}
|
c-common.c: Include "defaults.h".
* c-common.c: Include "defaults.h".
(WINT_TYPE, INTMAX_TYPE, UINTMAX_TYPE): Define.
(c_common_nodes_and_builtins): Create string_type_node,
const_string_type_node, wint_type_node, intmax_type_node,
uintmax_type_node, default_function_type, ptrdiff_type_node and
unsigned_ptrdiff_type_node.
* c-common.h (identifier_global_value): Declare.
* c-decl.c (WINT_TYPE, INTMAX_TYPE, UINTMAX_TYPE): Don't define.
(init_decl_processing): Don't create string_type_node,
const_string_type_node, wint_type_node, intmax_type_node,
uintmax_type_node, default_function_type, ptrdiff_type_node and
unsigned_ptrdiff_type_node.
(identifier_global_value): New function.
cp:
* decl.c (WINT_TYPE, INTMAX_TYPE, UINTMAX_TYPE): Don't define.
(init_decl_processing): Don't create string_type_node,
const_string_type_node, wint_type_node, intmax_type_node,
uintmax_type_node, default_function_type, ptrdiff_type_node and
unsigned_ptrdiff_type_node. Adjust position of call to
c_common_nodes_and_builtins.
(identifier_global_value): New function.
From-SVN: r37931
2000-12-01 23:25:43 +01:00
|
|
|
|
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
/* Return the global value of T as a symbol. */
|
c-common.c: Include "defaults.h".
* c-common.c: Include "defaults.h".
(WINT_TYPE, INTMAX_TYPE, UINTMAX_TYPE): Define.
(c_common_nodes_and_builtins): Create string_type_node,
const_string_type_node, wint_type_node, intmax_type_node,
uintmax_type_node, default_function_type, ptrdiff_type_node and
unsigned_ptrdiff_type_node.
* c-common.h (identifier_global_value): Declare.
* c-decl.c (WINT_TYPE, INTMAX_TYPE, UINTMAX_TYPE): Don't define.
(init_decl_processing): Don't create string_type_node,
const_string_type_node, wint_type_node, intmax_type_node,
uintmax_type_node, default_function_type, ptrdiff_type_node and
unsigned_ptrdiff_type_node.
(identifier_global_value): New function.
cp:
* decl.c (WINT_TYPE, INTMAX_TYPE, UINTMAX_TYPE): Don't define.
(init_decl_processing): Don't create string_type_node,
const_string_type_node, wint_type_node, intmax_type_node,
uintmax_type_node, default_function_type, ptrdiff_type_node and
unsigned_ptrdiff_type_node. Adjust position of call to
c_common_nodes_and_builtins.
(identifier_global_value): New function.
From-SVN: r37931
2000-12-01 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
identifier_global_value (tree t)
|
c-common.c: Include "defaults.h".
* c-common.c: Include "defaults.h".
(WINT_TYPE, INTMAX_TYPE, UINTMAX_TYPE): Define.
(c_common_nodes_and_builtins): Create string_type_node,
const_string_type_node, wint_type_node, intmax_type_node,
uintmax_type_node, default_function_type, ptrdiff_type_node and
unsigned_ptrdiff_type_node.
* c-common.h (identifier_global_value): Declare.
* c-decl.c (WINT_TYPE, INTMAX_TYPE, UINTMAX_TYPE): Don't define.
(init_decl_processing): Don't create string_type_node,
const_string_type_node, wint_type_node, intmax_type_node,
uintmax_type_node, default_function_type, ptrdiff_type_node and
unsigned_ptrdiff_type_node.
(identifier_global_value): New function.
cp:
* decl.c (WINT_TYPE, INTMAX_TYPE, UINTMAX_TYPE): Don't define.
(init_decl_processing): Don't create string_type_node,
const_string_type_node, wint_type_node, intmax_type_node,
uintmax_type_node, default_function_type, ptrdiff_type_node and
unsigned_ptrdiff_type_node. Adjust position of call to
c_common_nodes_and_builtins.
(identifier_global_value): New function.
From-SVN: r37931
2000-12-01 23:25:43 +01:00
|
|
|
|
{
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
tree decl = IDENTIFIER_SYMBOL_VALUE (t);
|
2003-08-29 23:57:05 +02:00
|
|
|
|
if (decl == 0 || DECL_FILE_SCOPE_P (decl))
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
return decl;
|
|
|
|
|
|
|
|
|
|
/* Shadowed by something else; find the true global value. */
|
2003-07-24 18:59:32 +02:00
|
|
|
|
for (decl = global_scope->names; decl; decl = TREE_CHAIN (decl))
|
c-decl.c (struct binding_level): Add shadowed_tags and function_body...
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct binding_level): Add shadowed_tags and
function_body; remove this_block, tag_transparent, and
subblocks_tag_transparent; update comments.
(clear_binding_level, lookup_tag_reverse): Kill.
(make_binding_level): Use ggc_alloc_cleared or memset.
(lookup_tag): Remove struct binding_level* parameter. All
callers changed. Just look at IDENTIFIER_TAG_VALUE, and
current_binding_level->tags if asked for thislevel_only or if
we might have to diagnose "struct foo; union foo;"
(pushlevel): Ignore argument. Do not push another binding
level on the transition from the parameters to the top level
of the function body; just tweak the flags and proceed.
(poplevel): Overhaul. Clear IDENTIFIER_TAG_VALUEs; on exiting
a function body, separate the parameter list from the
top-level local variables.
(set_block): Do nothing.
(pushtag): Set IDENTIFIER_TAG_VALUE and add an entry to
shadowed_tags if necessary.
(warn_if_shadowing): Nuke the special case for local shadowing
parameter.
(pushdecl): Do not create a shadow entry if we are replacing
an older decl in the same binding level.
(pushdecl_function_level): Tweak for new way of indicating
function scope.
(shadow_tag_warned): Use TYPE_NAME, not lookup_tag_reverse.
(start_function): Don't set subblocks_tag_transparent.
(finish_function): Fix up the binding_level stack for totally
empty functions. Otherwise, don't call poplevel.
* c-common.c (shadow_warning): MANDATORY argument is no longer
necessary. Always use plain warning.
* c-common.h: Update to match.
* cfglayout.c (scope_to_insns_initialize): Clear block when we
hit the FUNCTION_DECL.
* function.c: Do not create cyclic tree structure.
2003-04-10 Zack Weinberg <zack@codesourcery.com>
* c-tree.h (struct lang_identifier): Replace global_value,
local_value members with symbol_value, tag_value. Kill
implicit_decl and limbo_value.
(IDENTIFIER_GLOBAL_VALUE, IDENTIFIER_LOCAL_VALUE,
IDENTIFIER_LIMBO_VALUE, IDENTIFIER_IMPLICIT_DECL,
C_MISSING_PROTOTYPE_WARNED): Kill.
(IDENTIFIER_SYMBOL_VALUE, IDENTIFIER_TAG_VALUE,
C_DECL_IMPLICIT, C_DECL_ISNT_PROTOTYPE): New.
(C_DECL_ANTICIPATED): Rename to C_DECL_INVISIBLE.
(implicit_decl_warning, lookup_name_current_level,
record_function_scope_shadow): Don't prototype.
(pushdecl_function_level): Prototype.
* c-decl.c (truly_local_externals): New variable.
(struct binding_level): Adjust commentary.
(get_function_binding_level, clear_limbo_values,
record_function_scope_shadow): Kill.
(lookup_name_current_level, implicit_decl_warning): Are now static.
(any_external_decl, record_external_decl): New static functions.
(clone_underlying type): Split out of pushdecl.
(c_print_identifier): Update to match changes to struct
lang_identifier.
(poplevel): Delete #if 0 block. Make externals invisible
instead of clearing their IDENTIFIER_SYMBOL_VALUEs. Don't
call clear_limbo_values. Refer to IDENTIFIER_SYMBOL_VALUE not
IDENTIFIER_GLOBAL_VALUE or IDENTIFIER_LOCAL_VALUE.
(duplicate-decls): For real parm decl after a forward decl,
set TREE_ASM_WRITTEN here. Allow void foo(...) followed by
foo(...) { } with only a warning. Say whether a previous
declaration was implicit.
(warn_if_shadowing): Now handles all shadowing, not just
local-over-local. Clarify comments.
(pushdecl): Rewritten. There is no longer a distinction
between global and local symbol values; they're all
IDENTIFIER_SYMBOL_VALUE. Call record_external_decl on all
DECL_EXTERNAL decls, and use any_external_decl to check
against previous externals. Kill #if 0 blocks. Don't
tolerate error_mark_node being NULL.
(pushdecl_top_level): Handle only those cases which
Objective C (the only user) needs.
(pushdecl_function_level): New function.
(implicitly_declare): Create ordinary decls with
C_DECL_IMPLICIT set. Recycle old decls, however they got
created.
(lookup_name): It's always IDENTIFIER_SYMBOL_VALUE. Return 0
for C_DECL_INVISIBLE symbols.
(lookup_name_current_level): Likewise. Use chain_member.
(c_make_fname_decl): Don't muck with DECL_CONTEXT.
Use pushdecl_function_level.
(builtin_function): Use C_DECL_INVISIBLE.
(start_function): Don't muck with IDENTIFIER_IMPLICIT_DECL.
Use C_DECL_ISNT_PROTOTYPE and C_DECL_IMPLICIT.
(store_parm_decls): It's IDENTIFIER_SYMBOL_VALUE now.
(identifier_global_value): Same. Must scan
global_binding_level in extremis.
* c-typeck.c (undeclared_variable): New static function, split
from build_external_ref.
(build_external_ref): Use DECL_CONTEXT, not
IDENTIFIER_LOCAL_VALUE, to decide whether a local hides
an instance variable. Restructure for clarity.
* objc/objc-act.c: Use identifier_global_value, not
IDENTIFIER_GLOBAL_VALUE.
cp:
* decl.c: Update all calls to shadow_warning.
testsuite:
* gcc.c-torture/execute/builtin-noret-2.c: New.
* gcc.c-torture/execute/builtin-noret-2.x: New.
XFAIL builtin-noret-2.c at -O1 and above.
* gcc.dg/redecl.c: New.
* gcc.dg/Wshadow-1.c: Update error regexps.
From-SVN: r65460
2003-04-11 06:26:55 +02:00
|
|
|
|
if (DECL_NAME (decl) == t)
|
|
|
|
|
return decl;
|
|
|
|
|
|
|
|
|
|
/* Only local values for this decl. */
|
|
|
|
|
return 0;
|
c-common.c: Include "defaults.h".
* c-common.c: Include "defaults.h".
(WINT_TYPE, INTMAX_TYPE, UINTMAX_TYPE): Define.
(c_common_nodes_and_builtins): Create string_type_node,
const_string_type_node, wint_type_node, intmax_type_node,
uintmax_type_node, default_function_type, ptrdiff_type_node and
unsigned_ptrdiff_type_node.
* c-common.h (identifier_global_value): Declare.
* c-decl.c (WINT_TYPE, INTMAX_TYPE, UINTMAX_TYPE): Don't define.
(init_decl_processing): Don't create string_type_node,
const_string_type_node, wint_type_node, intmax_type_node,
uintmax_type_node, default_function_type, ptrdiff_type_node and
unsigned_ptrdiff_type_node.
(identifier_global_value): New function.
cp:
* decl.c (WINT_TYPE, INTMAX_TYPE, UINTMAX_TYPE): Don't define.
(init_decl_processing): Don't create string_type_node,
const_string_type_node, wint_type_node, intmax_type_node,
uintmax_type_node, default_function_type, ptrdiff_type_node and
unsigned_ptrdiff_type_node. Adjust position of call to
c_common_nodes_and_builtins.
(identifier_global_value): New function.
From-SVN: r37931
2000-12-01 23:25:43 +01:00
|
|
|
|
}
|
c-common.c (SIZE_TYPE, WCHAR_TYPE): Define.
* c-common.c (SIZE_TYPE, WCHAR_TYPE): Define.
(flag_short_double, flag_short_wchar): Define.
(c_common_nodes_and_builtins): Create many tree nodes shared
between C and C++ here instead of in cp/decl.c and ...
* c-decl.c (init_decl_processing): ... here.
(SIZE_TYPE, WCHAR_TYPE): Don't define.
(flag_short_double, flag_short_wchar): Don't define.
(record_builtin_type): New function.
(build_void_list_node): New function.
* c-common.h (flag_short_double, flag_short_wchar,
record_builtin_type, build_void_list_node): Declare.
cp:
* decl.c (SIZE_TYPE, PTRDIFF_TYPE, WCHAR_TYPE): Don't define.
(record_builtin_type): Make non-static.
(flag_short_double): Don't declare.
(init_decl_processing): Remove the creation of many tree nodes now
in c_common_nodes_and_builtins.
(build_void_list_node): New function.
* decl2.c (flag_short_double, flag_short_wchar): Don't define.
* cp-tree.h (flag_short_wchar): Don't declare.
From-SVN: r38695
2001-01-05 00:53:54 +01:00
|
|
|
|
|
|
|
|
|
/* Record a builtin type for C. If NAME is non-NULL, it is the name used;
|
|
|
|
|
otherwise the name is found in ridpointers from RID_INDEX. */
|
|
|
|
|
|
|
|
|
|
void
|
2003-06-19 21:43:59 +02:00
|
|
|
|
record_builtin_type (enum rid rid_index, const char *name, tree type)
|
c-common.c (SIZE_TYPE, WCHAR_TYPE): Define.
* c-common.c (SIZE_TYPE, WCHAR_TYPE): Define.
(flag_short_double, flag_short_wchar): Define.
(c_common_nodes_and_builtins): Create many tree nodes shared
between C and C++ here instead of in cp/decl.c and ...
* c-decl.c (init_decl_processing): ... here.
(SIZE_TYPE, WCHAR_TYPE): Don't define.
(flag_short_double, flag_short_wchar): Don't define.
(record_builtin_type): New function.
(build_void_list_node): New function.
* c-common.h (flag_short_double, flag_short_wchar,
record_builtin_type, build_void_list_node): Declare.
cp:
* decl.c (SIZE_TYPE, PTRDIFF_TYPE, WCHAR_TYPE): Don't define.
(record_builtin_type): Make non-static.
(flag_short_double): Don't declare.
(init_decl_processing): Remove the creation of many tree nodes now
in c_common_nodes_and_builtins.
(build_void_list_node): New function.
* decl2.c (flag_short_double, flag_short_wchar): Don't define.
* cp-tree.h (flag_short_wchar): Don't declare.
From-SVN: r38695
2001-01-05 00:53:54 +01:00
|
|
|
|
{
|
|
|
|
|
tree id;
|
|
|
|
|
if (name == 0)
|
|
|
|
|
id = ridpointers[(int) rid_index];
|
|
|
|
|
else
|
|
|
|
|
id = get_identifier (name);
|
|
|
|
|
pushdecl (build_decl (TYPE_DECL, id, type));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Build the void_list_node (void_type_node having been created). */
|
|
|
|
|
tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
build_void_list_node (void)
|
c-common.c (SIZE_TYPE, WCHAR_TYPE): Define.
* c-common.c (SIZE_TYPE, WCHAR_TYPE): Define.
(flag_short_double, flag_short_wchar): Define.
(c_common_nodes_and_builtins): Create many tree nodes shared
between C and C++ here instead of in cp/decl.c and ...
* c-decl.c (init_decl_processing): ... here.
(SIZE_TYPE, WCHAR_TYPE): Don't define.
(flag_short_double, flag_short_wchar): Don't define.
(record_builtin_type): New function.
(build_void_list_node): New function.
* c-common.h (flag_short_double, flag_short_wchar,
record_builtin_type, build_void_list_node): Declare.
cp:
* decl.c (SIZE_TYPE, PTRDIFF_TYPE, WCHAR_TYPE): Don't define.
(record_builtin_type): Make non-static.
(flag_short_double): Don't declare.
(init_decl_processing): Remove the creation of many tree nodes now
in c_common_nodes_and_builtins.
(build_void_list_node): New function.
* decl2.c (flag_short_double, flag_short_wchar): Don't define.
* cp-tree.h (flag_short_wchar): Don't declare.
From-SVN: r38695
2001-01-05 00:53:54 +01:00
|
|
|
|
{
|
|
|
|
|
tree t = build_tree_list (NULL_TREE, void_type_node);
|
|
|
|
|
return t;
|
|
|
|
|
}
|
2002-05-26 00:01:55 +02:00
|
|
|
|
|
|
|
|
|
/* Return something to represent absolute declarators containing a *.
|
|
|
|
|
TARGET is the absolute declarator that the * contains.
|
|
|
|
|
TYPE_QUALS_ATTRS is a list of modifiers such as const or volatile
|
|
|
|
|
to apply to the pointer type, represented as identifiers, possible mixed
|
|
|
|
|
with attributes.
|
|
|
|
|
|
|
|
|
|
We return an INDIRECT_REF whose "contents" are TARGET (inside a TREE_LIST,
|
|
|
|
|
if attributes are present) and whose type is the modifier list. */
|
|
|
|
|
|
|
|
|
|
tree
|
2003-06-19 21:43:59 +02:00
|
|
|
|
make_pointer_declarator (tree type_quals_attrs, tree target)
|
2002-05-26 00:01:55 +02:00
|
|
|
|
{
|
|
|
|
|
tree quals, attrs;
|
|
|
|
|
tree itarget = target;
|
|
|
|
|
split_specs_attrs (type_quals_attrs, &quals, &attrs);
|
|
|
|
|
if (attrs != NULL_TREE)
|
|
|
|
|
itarget = tree_cons (attrs, target, NULL_TREE);
|
|
|
|
|
return build1 (INDIRECT_REF, quals, itarget);
|
|
|
|
|
}
|
2002-06-04 09:11:05 +02:00
|
|
|
|
|
2003-07-21 23:25:47 +02:00
|
|
|
|
/* A wrapper around lhd_set_decl_assembler_name that gives static
|
2003-07-24 18:59:32 +02:00
|
|
|
|
variables their C names if they are at file scope and only one
|
2003-07-21 23:25:47 +02:00
|
|
|
|
translation unit is being compiled, for backwards compatibility
|
2003-08-20 01:22:00 +02:00
|
|
|
|
with certain bizarre assembler hacks (like crtstuff.c). */
|
2003-07-21 23:25:47 +02:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
c_static_assembler_name (tree decl)
|
|
|
|
|
{
|
|
|
|
|
if (num_in_fnames == 1
|
2003-07-26 09:16:48 +02:00
|
|
|
|
&& !TREE_PUBLIC (decl) && DECL_CONTEXT (decl)
|
2003-07-21 23:25:47 +02:00
|
|
|
|
&& TREE_CODE (DECL_CONTEXT (decl)) == TRANSLATION_UNIT_DECL)
|
|
|
|
|
SET_DECL_ASSEMBLER_NAME (decl, DECL_NAME (decl));
|
|
|
|
|
else
|
|
|
|
|
lhd_set_decl_assembler_name (decl);
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-11 10:33:21 +02:00
|
|
|
|
/* Hash and equality functions for link_hash_table: key off
|
|
|
|
|
DECL_ASSEMBLER_NAME. */
|
|
|
|
|
|
|
|
|
|
static hashval_t
|
|
|
|
|
link_hash_hash (const void *x_p)
|
|
|
|
|
{
|
|
|
|
|
tree x = (tree)x_p;
|
2003-07-13 22:21:24 +02:00
|
|
|
|
return (hashval_t) (long)DECL_ASSEMBLER_NAME (x);
|
2003-07-11 10:33:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
link_hash_eq (const void *x1_p, const void *x2_p)
|
|
|
|
|
{
|
|
|
|
|
tree x1 = (tree)x1_p;
|
|
|
|
|
tree x2 = (tree)x2_p;
|
|
|
|
|
return DECL_ASSEMBLER_NAME (x1) == DECL_ASSEMBLER_NAME (x2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Propagate information between definitions and uses between multiple
|
|
|
|
|
translation units in TU_LIST based on linkage rules. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
merge_translation_unit_decls (void)
|
|
|
|
|
{
|
|
|
|
|
const tree tu_list = current_file_decl;
|
|
|
|
|
tree tu;
|
|
|
|
|
tree decl;
|
|
|
|
|
htab_t link_hash_table;
|
|
|
|
|
tree block;
|
|
|
|
|
|
|
|
|
|
/* Create the BLOCK that poplevel would have created, but don't
|
|
|
|
|
actually call poplevel since that's expensive. */
|
|
|
|
|
block = make_node (BLOCK);
|
2003-07-24 18:59:32 +02:00
|
|
|
|
BLOCK_VARS (block) = current_scope->names;
|
2003-07-11 10:33:21 +02:00
|
|
|
|
TREE_USED (block) = 1;
|
|
|
|
|
DECL_INITIAL (current_file_decl) = block;
|
|
|
|
|
|
|
|
|
|
/* If only one translation unit seen, no copying necessary. */
|
|
|
|
|
if (TREE_CHAIN (tu_list) == NULL_TREE)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
link_hash_table = htab_create (1021, link_hash_hash, link_hash_eq, NULL);
|
|
|
|
|
|
|
|
|
|
/* Enter any actual definitions into the hash table. */
|
|
|
|
|
for (tu = tu_list; tu; tu = TREE_CHAIN (tu))
|
|
|
|
|
for (decl = BLOCK_VARS (DECL_INITIAL (tu)); decl; decl = TREE_CHAIN (decl))
|
|
|
|
|
if (TREE_PUBLIC (decl) && ! DECL_EXTERNAL (decl))
|
|
|
|
|
{
|
|
|
|
|
PTR *slot;
|
|
|
|
|
slot = htab_find_slot (link_hash_table, decl, INSERT);
|
|
|
|
|
|
|
|
|
|
/* If we've already got a definition, work out which one is
|
|
|
|
|
the real one, put it into the hash table, and make the
|
|
|
|
|
other one DECL_EXTERNAL. This is important to avoid
|
|
|
|
|
putting out two definitions of the same symbol in the
|
|
|
|
|
assembly output. */
|
|
|
|
|
if (*slot != NULL)
|
|
|
|
|
{
|
|
|
|
|
tree old_decl = (tree) *slot;
|
|
|
|
|
|
|
|
|
|
/* If this is weak or common or whatever, suppress it
|
2003-08-19 23:09:36 +02:00
|
|
|
|
in favor of the other definition. */
|
2003-07-11 10:33:21 +02:00
|
|
|
|
if (DECL_WEAK (decl))
|
|
|
|
|
DECL_EXTERNAL (decl) = 1;
|
|
|
|
|
else if (DECL_WEAK (old_decl) && ! DECL_WEAK (decl))
|
|
|
|
|
DECL_EXTERNAL (old_decl) = 1;
|
|
|
|
|
else if (DECL_COMMON (decl) || DECL_ONE_ONLY (decl))
|
|
|
|
|
DECL_EXTERNAL (decl) = 1;
|
|
|
|
|
else if (DECL_COMMON (old_decl) || DECL_ONE_ONLY (old_decl))
|
|
|
|
|
DECL_EXTERNAL (old_decl) = 1;
|
|
|
|
|
|
|
|
|
|
if (DECL_EXTERNAL (decl))
|
|
|
|
|
{
|
|
|
|
|
DECL_INITIAL (decl) = NULL_TREE;
|
|
|
|
|
DECL_COMMON (decl) = 0;
|
|
|
|
|
DECL_ONE_ONLY (decl) = 0;
|
|
|
|
|
DECL_WEAK (decl) = 0;
|
|
|
|
|
}
|
|
|
|
|
else if (DECL_EXTERNAL (old_decl))
|
|
|
|
|
{
|
|
|
|
|
DECL_INITIAL (old_decl) = NULL_TREE;
|
|
|
|
|
DECL_COMMON (old_decl) = 0;
|
|
|
|
|
DECL_ONE_ONLY (old_decl) = 0;
|
|
|
|
|
DECL_WEAK (old_decl) = 0;
|
|
|
|
|
*slot = decl;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-07-19 12:19:19 +02:00
|
|
|
|
error ("%Hredefinition of global '%D'",
|
|
|
|
|
&DECL_SOURCE_LOCATION (decl), decl);
|
|
|
|
|
error ("%H'%D' previously defined here",
|
|
|
|
|
&DECL_SOURCE_LOCATION (old_decl), old_decl);
|
2003-07-11 10:33:21 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
*slot = decl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Now insert the desired information from all the definitions
|
|
|
|
|
into any plain declarations. */
|
|
|
|
|
for (tu = tu_list; tu; tu = TREE_CHAIN (tu))
|
|
|
|
|
for (decl = BLOCK_VARS (DECL_INITIAL (tu)); decl; decl = TREE_CHAIN (decl))
|
|
|
|
|
if (TREE_PUBLIC (decl) && DECL_EXTERNAL (decl))
|
|
|
|
|
{
|
|
|
|
|
tree global_decl;
|
2003-07-19 16:47:15 +02:00
|
|
|
|
global_decl = htab_find (link_hash_table, decl);
|
2003-07-11 10:33:21 +02:00
|
|
|
|
|
|
|
|
|
if (! global_decl)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* Print any appropriate error messages, and partially merge
|
|
|
|
|
the decls. */
|
|
|
|
|
(void) duplicate_decls (decl, global_decl, true, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
htab_delete (link_hash_table);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Perform final processing on file-scope data. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
c_write_global_declarations(void)
|
|
|
|
|
{
|
|
|
|
|
tree link;
|
|
|
|
|
|
|
|
|
|
for (link = current_file_decl; link; link = TREE_CHAIN (link))
|
|
|
|
|
{
|
|
|
|
|
tree globals = BLOCK_VARS (DECL_INITIAL (link));
|
|
|
|
|
int len = list_length (globals);
|
2003-07-19 16:47:15 +02:00
|
|
|
|
tree *vec = xmalloc (sizeof (tree) * len);
|
2003-07-11 10:33:21 +02:00
|
|
|
|
int i;
|
|
|
|
|
tree decl;
|
|
|
|
|
|
2003-08-01 20:41:40 +02:00
|
|
|
|
/* Process the decls in the order they were written. */
|
|
|
|
|
|
2003-07-11 10:33:21 +02:00
|
|
|
|
for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
|
2003-08-01 20:41:40 +02:00
|
|
|
|
vec[i] = decl;
|
2003-07-11 10:33:21 +02:00
|
|
|
|
|
|
|
|
|
wrapup_global_declarations (vec, len);
|
|
|
|
|
|
|
|
|
|
check_global_declarations (vec, len);
|
|
|
|
|
|
|
|
|
|
/* Clean up. */
|
|
|
|
|
free (vec);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Reset the parser's state in preparation for a new file. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
c_reset_state (void)
|
|
|
|
|
{
|
|
|
|
|
tree link;
|
|
|
|
|
tree file_scope_decl;
|
|
|
|
|
|
2003-07-24 18:59:32 +02:00
|
|
|
|
/* Pop the global scope. */
|
|
|
|
|
if (current_scope != global_scope)
|
|
|
|
|
current_scope = global_scope;
|
2003-07-11 10:33:21 +02:00
|
|
|
|
file_scope_decl = current_file_decl;
|
|
|
|
|
DECL_INITIAL (file_scope_decl) = poplevel (1, 0, 0);
|
2003-08-30 23:24:19 +02:00
|
|
|
|
BLOCK_SUPERCONTEXT (DECL_INITIAL (file_scope_decl)) = file_scope_decl;
|
2003-07-11 10:33:21 +02:00
|
|
|
|
truly_local_externals = NULL_TREE;
|
|
|
|
|
|
|
|
|
|
/* Start a new global binding level. */
|
|
|
|
|
pushlevel (0);
|
2003-07-24 18:59:32 +02:00
|
|
|
|
global_scope = current_scope;
|
2003-07-11 10:33:21 +02:00
|
|
|
|
current_file_decl = build_decl (TRANSLATION_UNIT_DECL, NULL, NULL);
|
|
|
|
|
TREE_CHAIN (current_file_decl) = file_scope_decl;
|
|
|
|
|
|
2003-08-07 05:12:09 +02:00
|
|
|
|
/* Reintroduce the builtin declarations. */
|
|
|
|
|
for (link = first_builtin_decl;
|
|
|
|
|
link != TREE_CHAIN (last_builtin_decl);
|
|
|
|
|
link = TREE_CHAIN (link))
|
2003-07-11 10:33:21 +02:00
|
|
|
|
pushdecl (copy_node (link));
|
|
|
|
|
}
|
|
|
|
|
|
2002-06-04 09:11:05 +02:00
|
|
|
|
#include "gt-c-decl.h"
|