public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Vineet Gupta <vgupta@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc] scripts: Add "|" operator support to glibcpp's parsing
Date: Wed, 30 Nov 2022 02:10:22 +0000 (GMT)	[thread overview]
Message-ID: <20221130021022.3E45C3858D28@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=987f8647e8d6206cebc613e5c162ff8b4d014d40

commit 987f8647e8d6206cebc613e5c162ff8b4d014d40
Author: Shahab Vahedi <shahab@synopsys.com>
Date:   Sun Nov 27 18:38:24 2022 +0100

    scripts: Add "|" operator support to glibcpp's parsing
    
    From the tests point of view, this is a necessary step for another
    patch [1] and allows parsing macros such as "#define A | B".  Without
    it, a few tests [2] choke when the other patch [1] is applied:
    
    /src/glibc/scripts/../elf/elf.h:4167: error: uninterpretable macro
    token sequence: ( EF_ARC_MACH_MSK | EF_ARC_OSABI_MSK )
    Traceback (most recent call last):
        File "/src/glibc/elf/tst-glibcelf.py", line 23, in <module>
          import glibcelf
        File "/src/glibc/scripts/glibcelf.py", line 226, in <module>
          _elf_h = _parse_elf_h()
                   ^^^^^^^^^^^^^^
        File "/src/glibc/scripts/glibcelf.py", line 223, in _parse_elf_h
          raise IOError('parse error in elf.h')
      OSError: parse error in elf.h
    
    [1] ARC: update definitions in elf/elf.h
    https://sourceware.org/pipermail/libc-alpha/2022-November/143503.html
    
    [2]
    tst-glibcelf, tst-relro-ldso, and tst-relro-libc
    
    Reviewed-by: Florian Weimer <fweimer@redhat.com>
    Signed-off-by: Shahab Vahedi <shahab@synopsys.com>

Diff:
---
 scripts/glibcpp.py     | 1 +
 support/tst-glibcpp.py | 1 +
 2 files changed, 2 insertions(+)

diff --git a/scripts/glibcpp.py b/scripts/glibcpp.py
index 455459a609..2f39979894 100644
--- a/scripts/glibcpp.py
+++ b/scripts/glibcpp.py
@@ -346,6 +346,7 @@ RE_SPLIT_INTEGER_SUFFIX = re.compile(r'([^ullULL]+)([ullULL]*)')
 BINARY_OPERATORS = {
     '+': operator.add,
     '<<': operator.lshift,
+    '|': operator.or_,
 }
 
 # Use the general-purpose dict type if it is order-preserving.
diff --git a/support/tst-glibcpp.py b/support/tst-glibcpp.py
index a2db1916cc..cca8bd6c44 100644
--- a/support/tst-glibcpp.py
+++ b/support/tst-glibcpp.py
@@ -131,6 +131,7 @@ check_macro_eval('#define A 1', {'A': 1})
 check_macro_eval('#define A (1)', {'A': 1})
 check_macro_eval('#define A (1 + 1)', {'A': 2})
 check_macro_eval('#define A (1U << 31)', {'A': 1 << 31})
+check_macro_eval('#define A (1 | 2)', {'A': 1 | 2})
 check_macro_eval('''\
 #define A (B + 1)
 #define B 10

                 reply	other threads:[~2022-11-30  2:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221130021022.3E45C3858D28@sourceware.org \
    --to=vgupta@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).