diff mbox series

Allow #pragma GCC in headers in conformtest [committed] (was: Re: [PATCH v3] remove attribute access from regexec)

Message ID alpine.DEB.2.22.394.2108271748210.120578@digraph.polyomino.org.uk
State New
Headers show
Series Allow #pragma GCC in headers in conformtest [committed] (was: Re: [PATCH v3] remove attribute access from regexec) | expand

Commit Message

Joseph Myers Aug. 27, 2021, 5:50 p.m. UTC
No "#pragma GCC" pragma allows macro-expansion of its arguments, so no
namespace issues arise from use of such pragmas in installed headers.
Ignore them in conformtest tests of header namespace.

Tested for x86_64, in conjunction with Paul's patch
<https://sourceware.org/pipermail/libc-alpha/2021-August/130571.html>
adding use of such pragmas to installed headers shared with gnulib.

---

On Fri, 27 Aug 2021, Martin Sebor via Libc-alpha wrote:

> I'm guessing it's due to a limitation of the conformance test script
> that considers the GCC diagnostic pragmas unsafe to use because they
> are in the user-namespace (even though they're not subject to macro
> expansion).  I'm still not sure I understand why the #pragma is
> needed since -Wvla shouldn't trigger in a system header.

That conform test issue should be fixed by this (committed) patch (which 
makes sense independent of whether we actually add such pragmas to any 
installed headers, given that use of #pragma GCC there is indeed 
namespace-safe).
diff mbox series

Patch

diff --git a/conform/conformtest.py b/conform/conformtest.py
index f0405b7186..b0ec8e7ed1 100644
--- a/conform/conformtest.py
+++ b/conform/conformtest.py
@@ -624,6 +624,14 @@  class HeaderTests(object):
                     continue
                 if re.match(r'# [1-9]', line):
                     continue
+                if line.startswith('#pragma GCC '):
+                    # No GCC pragma uses macro expansion, so no
+                    # namespace issues arise from such pragmas.  (Some
+                    # pragmas not in the GCC namespace do macro-expand
+                    # their arguments and so could be affected by
+                    # macros defined by user code including the
+                    # header.)
+                    continue
                 match = re.match(r'#define (.*)', line)
                 if match:
                     self.check_token(bad_tokens, match.group(1))