diff options
author | Bob Duff <duff@adacore.com> | 2019-07-08 08:13:16 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-07-08 08:13:16 +0000 |
commit | 23eb3cb2b4fb900398461410c6c31294fc77cfc6 (patch) | |
tree | a95bf7ce26a31e99deea051517dd5b83a6c3f3b9 /gcc/ada/doc/gnat_ugn | |
parent | f56e04e89e809dc34d3f7fd3137f7d35c26e8fee (diff) | |
download | gcc-23eb3cb2b4fb900398461410c6c31294fc77cfc6.zip gcc-23eb3cb2b4fb900398461410c6c31294fc77cfc6.tar.gz gcc-23eb3cb2b4fb900398461410c6c31294fc77cfc6.tar.bz2 |
[Ada] Document handling of preprocessor directives in GNATpp
2019-07-08 Bob Duff <duff@adacore.com>
gcc/ada/
* doc/gnat_ugn/gnat_utility_programs.rst: Document handling of
preprocessor directives in GNATpp.
From-SVN: r273203
Diffstat (limited to 'gcc/ada/doc/gnat_ugn')
-rw-r--r-- | gcc/ada/doc/gnat_ugn/gnat_utility_programs.rst | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/gcc/ada/doc/gnat_ugn/gnat_utility_programs.rst b/gcc/ada/doc/gnat_ugn/gnat_utility_programs.rst index 53904b1..b6a1d18 100644 --- a/gcc/ada/doc/gnat_ugn/gnat_utility_programs.rst +++ b/gcc/ada/doc/gnat_ugn/gnat_utility_programs.rst @@ -3933,6 +3933,67 @@ Alternatively, you may run the script using the following command line: Name2_NAME3_Name4 := Name4_NAME3_Name2 > NAME1; end Test; + .. _Preprocessor_directives: + + Preprocessor Directives + ^^^^^^^^^^^^^^^^^^^^^^^ + + ``gnatpp`` has some support for preprocessor directives. + You can use preprocessor symbols, as in ``$symbol``. + In addition, you can use conditional compilation, + so long as the program text is syntactically legal Ada code + after removing all the preprocessor directives (lines starting + with ``#``). For example, ``gnatpp`` can format the following: + + .. code-block:: ada + + package P is + #IF SOMETHING + X : constant Integer := 123; + #ELSE + X : constant Integer := 456; + #END IF; + end P; + + which will be formatted as if it were: + + .. code-block:: ada + + package P is + X : constant Integer := 123; + X : constant Integer := 456; + end P; + + except that the ``#`` lines will be preserved. + However, ``gnatpp`` cannot format the following: + + .. code-block:: ada + + procedure P is + begin + #IF SOMETHING + if X = 0 then + #ELSE + if X = 1 then + #END IF; + null; + end if; + end P; + + because removing the ``#`` lines gives: + + .. code-block:: ada + + procedure P is + begin + if X = 0 then + if X = 1 then + null; + end if; + end P; + + which is not syntactically legal. + Legacy Switches ^^^^^^^^^^^^^^^ |