public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Preprocessor symbols in non-C languages
@ 2004-08-14 13:56 Waldek Hebisch
  2004-08-14 15:15 ` Joseph S. Myers
  0 siblings, 1 reply; 2+ messages in thread
From: Waldek Hebisch @ 2004-08-14 13:56 UTC (permalink / raw)
  To: gcc

What is current policy concerning use of predefined preprocessors
symbols in non-C languages? Currently GNU Pascal contains a preprocessor
which used to predefine all symbols which C preprocessor predefine
(via CPP_PREDEFINES). For 3.3 backend and above I am trying to use 
TARGET_CPU_CPP_BUILTINS and TARGET_OS_CPP_BUILTINS. But the new macros
despite beeing defined in language independent header tend to hook 
more and more into C frontend. ATM GNU Pascal to work around the problem
provides stubs for missing C symbols, but I am asking for long-term 
solution.

If TARGET_CPU_CPP_BUILTINS and TARGET_OS_CPP_BUILTINS are deemed C
specific, then how is a frontend supposed to collect target information
needed by user programs? Will patches to remove C dependency in
TARGET_CPU_CPP_BUILTINS and TARGET_OS_CPP_BUILTINS be accepted?

Note that lack of target predefines was the main regression in 
GNU Pascal when using 3.3 and newer backends.

-- 
                              Waldek Hebisch
hebisch@math.uni.wroc.pl 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Preprocessor symbols in non-C languages
  2004-08-14 13:56 Preprocessor symbols in non-C languages Waldek Hebisch
@ 2004-08-14 15:15 ` Joseph S. Myers
  0 siblings, 0 replies; 2+ messages in thread
From: Joseph S. Myers @ 2004-08-14 15:15 UTC (permalink / raw)
  To: Waldek Hebisch; +Cc: gcc

On Sat, 14 Aug 2004, Waldek Hebisch wrote:

> What is current policy concerning use of predefined preprocessors
> symbols in non-C languages? Currently GNU Pascal contains a preprocessor
> which used to predefine all symbols which C preprocessor predefine
> (via CPP_PREDEFINES). For 3.3 backend and above I am trying to use 
> TARGET_CPU_CPP_BUILTINS and TARGET_OS_CPP_BUILTINS. But the new macros
> despite beeing defined in language independent header tend to hook 
> more and more into C frontend. ATM GNU Pascal to work around the problem
> provides stubs for missing C symbols, but I am asking for long-term 
> solution.

The documentation of these macros lists the interface as three main 
functions (or macros) they may call, builtin_define, builtin_define_std 
and builtin_assert, along with

c_language
clk_c (which includes assembler)
clk_cplusplus
clk_objective_c
preprocessing_asm_p
flag_iso
preprocessing_trad_p

which you can define appropriately for GNU Pascal.  Note that 
c-cppbuiltin.c defines some of these names as macros to call cpplib 
functions; there is no direct target dependence on cpplib, the interface 
allows for non-C and non-cpplib front ends.

  /* A straightforward target hook doesn't work, because of problems
     linking that hook's body when part of non-C front ends.  */
# define preprocessing_asm_p() (cpp_get_options (pfile)->lang == CLK_ASM)
# define preprocessing_trad_p() (cpp_get_options (pfile)->traditional)
# define builtin_define(TXT) cpp_define (pfile, TXT)
# define builtin_assert(TXT) cpp_assert (pfile, TXT)
  TARGET_CPU_CPP_BUILTINS ();
  TARGET_OS_CPP_BUILTINS ();
  TARGET_OBJFMT_CPP_BUILTINS ();

(While builtin_define_std is a real function.)

Now, it seems the documentation is out of date and the headers now use 
c_dialect_cxx and c_dialect_objc, which means the documentation needs 
updating; you can just define those function-like macros to false for GNU 
Pascal.  mips/iris6.h also uses flag_isoc99, which is not in the 
documented interface; this would be another bug in the documentation, and 
you can define flag_isoc99 for your front end as well.  In general, this 
is meant to be a documented interface, and the problems with the 
documentation should be fixable.

The rationale for this approach replacing specs is that when predefines 
depended on command-line options, and were meant to express some part of 
the internal state of the compiler, there were two different 
implementations of the logic for arriving at that state, one in the specs 
and one that parsed the command line options in the internal compiler 
executables such as cc1, and keeping these in sync was very error-prone. 
The transition is as yet incomplete: there are still macros defined in 
specs that should migrate to the new system.

As for C dependencies accidentally entering target headers, I must urge 
again the inclusion of GNU Pascal in GCC CVS as the best way of ensuring 
that it is not accidentally broken by changes to GCC.  Compiler testing 
uses those included front ends that are enabled by default, and global 
cleanups take account of those features that are being used in GCC CVS; 
features are not kept in the tree for the sake of front ends (or target 
CPU architectures) that are not in CVS.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-08-14 14:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-14 13:56 Preprocessor symbols in non-C languages Waldek Hebisch
2004-08-14 15:15 ` Joseph S. Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).