11.2.1-3
This commit is contained in:
parent
ba0a2baa86
commit
892f8cf6be
1
.gitignore
vendored
1
.gitignore
vendored
@ -49,3 +49,4 @@
|
||||
/gcc-11.1.1-20210623.tar.xz
|
||||
/gcc-11.1.1-20210726.tar.xz
|
||||
/gcc-11.2.1-20210728.tar.xz
|
||||
/gcc-11.2.1-20210823.tar.xz
|
||||
|
40
gcc.spec
40
gcc.spec
@ -1,10 +1,10 @@
|
||||
%global DATE 20210728
|
||||
%global gitrev 134ab8155c937122663513b76afa8e64ad61fe99
|
||||
%global DATE 20210823
|
||||
%global gitrev b558c8e931f0c36cda40bd60f5cdeb92452e91b5
|
||||
%global gcc_version 11.2.1
|
||||
%global gcc_major 11
|
||||
# Note, gcc_release must be integer, if you want to add suffixes to
|
||||
# %%{release}, append them after %%{gcc_release} on Release: line.
|
||||
%global gcc_release 2
|
||||
%global gcc_release 3
|
||||
%global nvptx_tools_gitrev 5f6f343a302d620b0868edab376c00b15741e39e
|
||||
%global newlib_cygwin_gitrev 50e2a63b04bdd018484605fbb954fd1bd5147fa0
|
||||
%global _unpackaged_files_terminate_build 0
|
||||
@ -250,6 +250,8 @@ Obsoletes: gcc-gnat < %{version}-%{release}
|
||||
Obsoletes: gcc-java < %{version}-%{release}
|
||||
AutoReq: true
|
||||
Provides: bundled(libiberty)
|
||||
Provides: bundled(libbacktrace)
|
||||
Provides: bundled(libffi)
|
||||
Provides: gcc(major) = %{gcc_major}
|
||||
|
||||
Patch0: gcc11-hack.patch
|
||||
@ -265,6 +267,9 @@ Patch10: gcc11-Wno-format-security.patch
|
||||
Patch11: gcc11-rh1574936.patch
|
||||
Patch12: gcc11-d-shared-libphobos.patch
|
||||
Patch13: gcc11-pr99341-revert.patch
|
||||
Patch14: gcc11-libgcc-link.patch
|
||||
Patch15: gcc11-pr101786.patch
|
||||
Patch16: gcc11-stringify-__VA_OPT__.patch
|
||||
|
||||
Patch100: gcc11-fortran-fdec-duplicates.patch
|
||||
Patch101: gcc11-fortran-flogical-as-integer.patch
|
||||
@ -788,6 +793,9 @@ to NVidia PTX capable devices if available.
|
||||
%endif
|
||||
%patch12 -p0 -b .d-shared-libphobos~
|
||||
%patch13 -p0 -b .pr99341-revert~
|
||||
%patch14 -p0 -b .libgcc-link~
|
||||
%patch15 -p0 -b .pr101786~
|
||||
%patch16 -p0 -b .stringify-__VA_OPT__~
|
||||
|
||||
%if 0%{?rhel} >= 9
|
||||
%patch100 -p1 -b .fortran-fdec-duplicates~
|
||||
@ -1092,9 +1100,9 @@ CC="$CC" CXX="$CXX" CFLAGS="$OPT_FLAGS" \
|
||||
$CONFIGURE_OPTS
|
||||
|
||||
%ifarch sparc sparcv9 sparc64
|
||||
make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS" bootstrap
|
||||
make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS" LDFLAGS_FOR_TARGET=-Wl,-z,relro,-z,now bootstrap
|
||||
%else
|
||||
make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS" profiledbootstrap
|
||||
make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS" LDFLAGS_FOR_TARGET=-Wl,-z,relro,-z,now profiledbootstrap
|
||||
%endif
|
||||
|
||||
CC="`%{gcc_target_platform}/libstdc++-v3/scripts/testsuite_flags --build-cc`"
|
||||
@ -2091,7 +2099,7 @@ end
|
||||
|
||||
%ldconfig_scriptlets -n libgccjit
|
||||
|
||||
%ldconfig_scriptlets -n libgquadmath
|
||||
%ldconfig_scriptlets -n libquadmath
|
||||
|
||||
%ldconfig_scriptlets -n libitm
|
||||
|
||||
@ -3133,6 +3141,26 @@ end
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Mon Aug 23 2021 Jakub Jelinek <jakub@redhat.com> 11.2.1-3
|
||||
- update from releases/gcc-11-branch
|
||||
- PRs c++/100828, c++/101663, c++/101725, c++/101759, c/100150, c/101512,
|
||||
d/96435, d/101127, d/101441, d/101490, d/101619, d/101640, d/101664,
|
||||
debug/101905, fortran/99351, fortran/101084, fortran/101514,
|
||||
fortran/101536, fortran/101564, gcov-profile/89961,
|
||||
gcov-profile/100788, ipa/100600, ipa/101261, ipa/101726,
|
||||
libstdc++/100139, libstdc++/101056, libstdc++/101258,
|
||||
libstdc++/101510, libstdc++/101866, middle-end/101624,
|
||||
preprocessor/101638, sanitizer/101749, target/94780, target/100952,
|
||||
target/101132, target/101531, target/101723, testsuite/101969,
|
||||
tree-optimization/101373, tree-optimization/101505,
|
||||
tree-optimization/101868
|
||||
- add bundled(libbacktrace) and bundled(libffi) provides
|
||||
- build target shared libraries with -Wl,-z,relro,-z,now
|
||||
- improve generated code with extern thread_local constinit vars
|
||||
with trivial dtors
|
||||
- add support for C++20 #__VA_OPT__
|
||||
- fix up %%ldconfig_scriptlets
|
||||
|
||||
* Fri Jul 30 2021 Jakub Jelinek <jakub@redhat.com> 11.2.1-2
|
||||
- enable LTO profiledbootstrap on all arches, and also for RHEL9+
|
||||
|
||||
|
57
gcc11-libgcc-link.patch
Normal file
57
gcc11-libgcc-link.patch
Normal file
@ -0,0 +1,57 @@
|
||||
libgcc: Honor LDFLAGS_FOR_TARGET when linking libgcc_s
|
||||
|
||||
When building gcc with some specific LDFLAGS_FOR_TARGET, e.g.
|
||||
LDFLAGS_FOR_TARGET=-Wl,-z,relro,-z,now
|
||||
those flags propagate info linking of target shared libraries,
|
||||
e.g. lib{ubsan,tsan,stdc++,quadmath,objc,lsan,itm,gphobos,gdruntime,gomp,go,gfortran,atomic,asan}.so.*
|
||||
but there is one important exception, libgcc_s.so.* linking ignores it.
|
||||
|
||||
The following patch fixes that.
|
||||
|
||||
Bootstrapped/regtested on x86_64-linux with LDFLAGS_FOR_TARGET=-Wl,-z,relro,-z,now
|
||||
and verified that libgcc_s.so.* is BIND_NOW when it previously wasn't, and
|
||||
without any LDFLAGS_FOR_TARGET on x86_64-linux and i686-linux.
|
||||
There on x86_64-linux I've verified that the libgcc_s.so.1 linking command
|
||||
line for -m64 is identical except for whitespace to one without the patch,
|
||||
and for -m32 multilib $(LDFLAGS) actually do supply there an extra -m32
|
||||
that also repeats later in the @multilib_flags@, which should be harmless.
|
||||
|
||||
2021-08-04 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* config/t-slibgcc (SHLIB_LINK): Add $(LDFLAGS).
|
||||
* config/t-slibgcc-darwin (SHLIB_LINK): Likewise.
|
||||
* config/t-slibgcc-vms (SHLIB_LINK): Likewise.
|
||||
|
||||
--- libgcc/config/t-slibgcc
|
||||
+++ libgcc/config/t-slibgcc
|
||||
@@ -32,7 +32,7 @@ SHLIB_INSTALL_SOLINK = $(LN_S) $(SHLIB_SONAME) \
|
||||
$(DESTDIR)$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK)
|
||||
|
||||
SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \
|
||||
- $(SHLIB_LDFLAGS) \
|
||||
+ $(SHLIB_LDFLAGS) $(LDFLAGS) \
|
||||
-o $(SHLIB_DIR)/$(SHLIB_SONAME).tmp @multilib_flags@ \
|
||||
$(SHLIB_OBJS) $(SHLIB_LC) && \
|
||||
rm -f $(SHLIB_DIR)/$(SHLIB_SOLINK) && \
|
||||
--- libgcc/config/t-slibgcc-darwin
|
||||
+++ libgcc/config/t-slibgcc-darwin
|
||||
@@ -15,7 +15,7 @@ SHLIB_LC = -lc
|
||||
# Note that this version is used for the loader, not the linker; the linker
|
||||
# uses the stub versions named by the versioned members of $(INSTALL_FILES).
|
||||
|
||||
-SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) -dynamiclib -nodefaultlibs \
|
||||
+SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) $(LDFLAGS) -dynamiclib -nodefaultlibs \
|
||||
-install_name @shlib_slibdir@/$(SHLIB_INSTALL_NAME) \
|
||||
-single_module -o $(SHLIB_DIR)/$(SHLIB_SONAME) \
|
||||
-Wl,-exported_symbols_list,$(SHLIB_MAP) \
|
||||
--- libgcc/config/t-slibgcc-vms
|
||||
+++ libgcc/config/t-slibgcc-vms
|
||||
@@ -22,7 +22,7 @@ SHLIB_LINK = \
|
||||
objdump --syms $(SHLIB_OBJS) | \
|
||||
$(SHLIB_SYMVEC) >> SYMVEC_$$$$.opt ; \
|
||||
echo "case_sensitive=NO" >> SYMVEC_$$$$.opt; \
|
||||
- $(CC) $(LIBGCC2_CFLAGS) -nodefaultlibs \
|
||||
+ $(CC) $(LIBGCC2_CFLAGS) $(LDFLAGS) -nodefaultlibs \
|
||||
-shared --for-linker=/noinform -o $(SHLIB_NAME) $(SHLIB_OBJS) \
|
||||
--for-linker=SYMVEC_$$$$.opt \
|
||||
--for-linker=gsmatch=equal,$(shlib_version)
|
66
gcc11-pr101786.patch
Normal file
66
gcc11-pr101786.patch
Normal file
@ -0,0 +1,66 @@
|
||||
c++: Optimize constinit thread_local vars [PR101786]
|
||||
|
||||
The paper that introduced constinit mentioned in rationale that constinit
|
||||
can be used on externs as well and that it can be used to avoid the
|
||||
thread_local initialization wrappers, because the standard requires that
|
||||
if constinit is present on any declaration, it is also present on the
|
||||
initialization declaration, even if it is in some other TU etc.
|
||||
|
||||
There is a small problem though, we use the tls wrappers not just if
|
||||
the thread_local variable needs dynamic initialization, but also when
|
||||
it has static initialization, but non-trivial destructor, as the
|
||||
"dynamic initialization" in that case needs to register the destructor.
|
||||
|
||||
So, the following patch optimizes constinit thread_local vars only
|
||||
if we can prove they will not have non-trivial destructors. That includes
|
||||
the case where we have incomplete type where we don't know and need to
|
||||
conservatively assume the type will have non-trivial destructor at the
|
||||
initializing declaration side.
|
||||
|
||||
2021-08-11 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/101786
|
||||
* decl2.c (var_defined_without_dynamic_init): Return true for
|
||||
DECL_DECLARED_CONSTINIT_P with complete type and trivial destructor.
|
||||
|
||||
* g++.dg/cpp2a/constinit16.C: New test.
|
||||
|
||||
--- gcc/cp/decl2.c
|
||||
+++ gcc/cp/decl2.c
|
||||
@@ -3447,6 +3447,12 @@ set_guard (tree guard)
|
||||
static bool
|
||||
var_defined_without_dynamic_init (tree var)
|
||||
{
|
||||
+ /* constinit vars are guaranteed to not have dynamic initializer,
|
||||
+ but still registering the destructor counts as dynamic initialization. */
|
||||
+ if (DECL_DECLARED_CONSTINIT_P (var)
|
||||
+ && COMPLETE_TYPE_P (TREE_TYPE (var))
|
||||
+ && !TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (var)))
|
||||
+ return true;
|
||||
/* If it's defined in another TU, we can't tell. */
|
||||
if (DECL_EXTERNAL (var))
|
||||
return false;
|
||||
--- gcc/testsuite/g++.dg/cpp2a/constinit16.C
|
||||
+++ gcc/testsuite/g++.dg/cpp2a/constinit16.C
|
||||
@@ -0,0 +1,21 @@
|
||||
+// PR c++/101786
|
||||
+// { dg-do compile { target c++20 } }
|
||||
+// { dg-add-options tls }
|
||||
+// { dg-require-alias "" }
|
||||
+// { dg-require-effective-target tls_runtime }
|
||||
+// { dg-final { scan-assembler-not "_ZTH17mythreadlocalvar1" } }
|
||||
+// { dg-final { scan-assembler "_ZTH17mythreadlocalvar2" } }
|
||||
+// { dg-final { scan-assembler-not "_ZTH17mythreadlocalvar3" } }
|
||||
+// { dg-final { scan-assembler "_ZTH17mythreadlocalvar4" } }
|
||||
+
|
||||
+extern thread_local constinit int mythreadlocalvar1;
|
||||
+struct S;
|
||||
+extern thread_local constinit S mythreadlocalvar2;
|
||||
+struct T { int t; };
|
||||
+extern thread_local constinit T mythreadlocalvar3;
|
||||
+struct U { int u; ~U (); };
|
||||
+extern thread_local constinit U mythreadlocalvar4;
|
||||
+int foo () { return mythreadlocalvar1; }
|
||||
+S *bar () { return &mythreadlocalvar2; }
|
||||
+T *baz () { return &mythreadlocalvar3; }
|
||||
+U *qux () { return &mythreadlocalvar4; }
|
308
gcc11-stringify-__VA_OPT__.patch
Normal file
308
gcc11-stringify-__VA_OPT__.patch
Normal file
@ -0,0 +1,308 @@
|
||||
c++: Add C++20 #__VA_OPT__ support
|
||||
|
||||
The following patch implements C++20 # __VA_OPT__ (...) support.
|
||||
Testcases cover what I came up with myself and what LLVM has for #__VA_OPT__
|
||||
in its testsuite and the string literals are identical between the two
|
||||
compilers on the va-opt-5.c testcase.
|
||||
|
||||
2021-08-17 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
libcpp/
|
||||
* macro.c (vaopt_state): Add m_stringify member.
|
||||
(vaopt_state::vaopt_state): Initialize it.
|
||||
(vaopt_state::update): Overwrite it.
|
||||
(vaopt_state::stringify): New method.
|
||||
(stringify_arg): Replace arg argument with first, count arguments
|
||||
and add va_opt argument. Use first instead of arg->first and
|
||||
count instead of arg->count, for va_opt add paste_tokens handling.
|
||||
(paste_tokens): Fix up len calculation. Don't spell rhs twice,
|
||||
instead use %.*s to supply lhs and rhs spelling lengths. Don't call
|
||||
_cpp_backup_tokens here.
|
||||
(paste_all_tokens): Call it here instead.
|
||||
(replace_args): Adjust stringify_arg caller. For vaopt_state::END
|
||||
if stringify is true handle __VA_OPT__ stringification.
|
||||
(create_iso_definition): Handle # __VA_OPT__ similarly to # macro_arg.
|
||||
gcc/testsuite/
|
||||
* c-c++-common/cpp/va-opt-5.c: New test.
|
||||
* c-c++-common/cpp/va-opt-6.c: New test.
|
||||
|
||||
--- libcpp/macro.c
|
||||
+++ libcpp/macro.c
|
||||
@@ -118,6 +118,7 @@ class vaopt_state {
|
||||
m_arg (arg),
|
||||
m_variadic (is_variadic),
|
||||
m_last_was_paste (false),
|
||||
+ m_stringify (false),
|
||||
m_state (0),
|
||||
m_paste_location (0),
|
||||
m_location (0),
|
||||
@@ -145,6 +146,7 @@ class vaopt_state {
|
||||
}
|
||||
++m_state;
|
||||
m_location = token->src_loc;
|
||||
+ m_stringify = (token->flags & STRINGIFY_ARG) != 0;
|
||||
return BEGIN;
|
||||
}
|
||||
else if (m_state == 1)
|
||||
@@ -234,6 +236,12 @@ class vaopt_state {
|
||||
return m_state == 0;
|
||||
}
|
||||
|
||||
+ /* Return true for # __VA_OPT__. */
|
||||
+ bool stringify () const
|
||||
+ {
|
||||
+ return m_stringify;
|
||||
+ }
|
||||
+
|
||||
private:
|
||||
|
||||
/* The cpp_reader. */
|
||||
@@ -247,6 +255,8 @@ class vaopt_state {
|
||||
/* If true, the previous token was ##. This is used to detect when
|
||||
a paste occurs at the end of the sequence. */
|
||||
bool m_last_was_paste;
|
||||
+ /* True for #__VA_OPT__. */
|
||||
+ bool m_stringify;
|
||||
|
||||
/* The state variable:
|
||||
0 means not parsing
|
||||
@@ -284,7 +294,8 @@ static _cpp_buff *collect_args (cpp_reader *, const cpp_hashnode *,
|
||||
static cpp_context *next_context (cpp_reader *);
|
||||
static const cpp_token *padding_token (cpp_reader *, const cpp_token *);
|
||||
static const cpp_token *new_string_token (cpp_reader *, uchar *, unsigned int);
|
||||
-static const cpp_token *stringify_arg (cpp_reader *, macro_arg *);
|
||||
+static const cpp_token *stringify_arg (cpp_reader *, const cpp_token **,
|
||||
+ unsigned int, bool);
|
||||
static void paste_all_tokens (cpp_reader *, const cpp_token *);
|
||||
static bool paste_tokens (cpp_reader *, location_t,
|
||||
const cpp_token **, const cpp_token *);
|
||||
@@ -818,10 +829,11 @@ cpp_quote_string (uchar *dest, const uchar *src, unsigned int len)
|
||||
return dest;
|
||||
}
|
||||
|
||||
-/* Convert a token sequence ARG to a single string token according to
|
||||
- the rules of the ISO C #-operator. */
|
||||
+/* Convert a token sequence FIRST to FIRST+COUNT-1 to a single string token
|
||||
+ according to the rules of the ISO C #-operator. */
|
||||
static const cpp_token *
|
||||
-stringify_arg (cpp_reader *pfile, macro_arg *arg)
|
||||
+stringify_arg (cpp_reader *pfile, const cpp_token **first, unsigned int count,
|
||||
+ bool va_opt)
|
||||
{
|
||||
unsigned char *dest;
|
||||
unsigned int i, escape_it, backslash_count = 0;
|
||||
@@ -834,9 +846,27 @@ stringify_arg (cpp_reader *pfile, macro_arg *arg)
|
||||
*dest++ = '"';
|
||||
|
||||
/* Loop, reading in the argument's tokens. */
|
||||
- for (i = 0; i < arg->count; i++)
|
||||
+ for (i = 0; i < count; i++)
|
||||
{
|
||||
- const cpp_token *token = arg->first[i];
|
||||
+ const cpp_token *token = first[i];
|
||||
+
|
||||
+ if (va_opt && (token->flags & PASTE_LEFT))
|
||||
+ {
|
||||
+ location_t virt_loc = pfile->invocation_location;
|
||||
+ const cpp_token *rhs;
|
||||
+ do
|
||||
+ {
|
||||
+ if (i == count)
|
||||
+ abort ();
|
||||
+ rhs = first[++i];
|
||||
+ if (!paste_tokens (pfile, virt_loc, &token, rhs))
|
||||
+ {
|
||||
+ --i;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ while (rhs->flags & PASTE_LEFT);
|
||||
+ }
|
||||
|
||||
if (token->type == CPP_PADDING)
|
||||
{
|
||||
@@ -923,7 +953,7 @@ paste_tokens (cpp_reader *pfile, location_t location,
|
||||
cpp_token *lhs;
|
||||
unsigned int len;
|
||||
|
||||
- len = cpp_token_len (*plhs) + cpp_token_len (rhs) + 1;
|
||||
+ len = cpp_token_len (*plhs) + cpp_token_len (rhs) + 2;
|
||||
buf = (unsigned char *) alloca (len);
|
||||
end = lhsend = cpp_spell_token (pfile, *plhs, buf, true);
|
||||
|
||||
@@ -949,8 +979,10 @@ paste_tokens (cpp_reader *pfile, location_t location,
|
||||
location_t saved_loc = lhs->src_loc;
|
||||
|
||||
_cpp_pop_buffer (pfile);
|
||||
- _cpp_backup_tokens (pfile, 1);
|
||||
- *lhsend = '\0';
|
||||
+
|
||||
+ unsigned char *rhsstart = lhsend;
|
||||
+ if ((*plhs)->type == CPP_DIV && rhs->type != CPP_EQ)
|
||||
+ rhsstart++;
|
||||
|
||||
/* We have to remove the PASTE_LEFT flag from the old lhs, but
|
||||
we want to keep the new location. */
|
||||
@@ -962,8 +994,10 @@ paste_tokens (cpp_reader *pfile, location_t location,
|
||||
/* Mandatory error for all apart from assembler. */
|
||||
if (CPP_OPTION (pfile, lang) != CLK_ASM)
|
||||
cpp_error_with_line (pfile, CPP_DL_ERROR, location, 0,
|
||||
- "pasting \"%s\" and \"%s\" does not give a valid preprocessing token",
|
||||
- buf, cpp_token_as_text (pfile, rhs));
|
||||
+ "pasting \"%.*s\" and \"%.*s\" does not give "
|
||||
+ "a valid preprocessing token",
|
||||
+ (int) (lhsend - buf), buf,
|
||||
+ (int) (end - rhsstart), rhsstart);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1039,7 +1073,10 @@ paste_all_tokens (cpp_reader *pfile, const cpp_token *lhs)
|
||||
abort ();
|
||||
}
|
||||
if (!paste_tokens (pfile, virt_loc, &lhs, rhs))
|
||||
- break;
|
||||
+ {
|
||||
+ _cpp_backup_tokens (pfile, 1);
|
||||
+ break;
|
||||
+ }
|
||||
}
|
||||
while (rhs->flags & PASTE_LEFT);
|
||||
|
||||
@@ -1906,7 +1943,8 @@ replace_args (cpp_reader *pfile, cpp_hashnode *node, cpp_macro *macro,
|
||||
if (src->flags & STRINGIFY_ARG)
|
||||
{
|
||||
if (!arg->stringified)
|
||||
- arg->stringified = stringify_arg (pfile, arg);
|
||||
+ arg->stringified = stringify_arg (pfile, arg->first, arg->count,
|
||||
+ false);
|
||||
}
|
||||
else if ((src->flags & PASTE_LEFT)
|
||||
|| (src != macro->exp.tokens && (src[-1].flags & PASTE_LEFT)))
|
||||
@@ -2029,7 +2067,24 @@ replace_args (cpp_reader *pfile, cpp_hashnode *node, cpp_macro *macro,
|
||||
paste_flag = tokens_buff_last_token_ptr (buff);
|
||||
}
|
||||
|
||||
- if (src->flags & PASTE_LEFT)
|
||||
+ if (vaopt_tracker.stringify ())
|
||||
+ {
|
||||
+ unsigned int count
|
||||
+ = start ? paste_flag - start : tokens_buff_count (buff);
|
||||
+ const cpp_token *t
|
||||
+ = stringify_arg (pfile,
|
||||
+ start ? start + 1
|
||||
+ : (const cpp_token **) (buff->base),
|
||||
+ count, true);
|
||||
+ while (count--)
|
||||
+ tokens_buff_remove_last_token (buff);
|
||||
+ if (src->flags & PASTE_LEFT)
|
||||
+ copy_paste_flag (pfile, &t, src);
|
||||
+ tokens_buff_add_token (buff, virt_locs,
|
||||
+ t, t->src_loc, t->src_loc,
|
||||
+ NULL, 0);
|
||||
+ }
|
||||
+ else if (src->flags & PASTE_LEFT)
|
||||
{
|
||||
/* With a non-empty __VA_OPT__ on the LHS of ##, the last
|
||||
token should be flagged PASTE_LEFT. */
|
||||
@@ -3585,7 +3640,10 @@ create_iso_definition (cpp_reader *pfile)
|
||||
function-like macros when lexing the subsequent token. */
|
||||
if (macro->count > 1 && token[-1].type == CPP_HASH && macro->fun_like)
|
||||
{
|
||||
- if (token->type == CPP_MACRO_ARG)
|
||||
+ if (token->type == CPP_MACRO_ARG
|
||||
+ || (macro->variadic
|
||||
+ && token->type == CPP_NAME
|
||||
+ && token->val.node.node == pfile->spec_nodes.n__VA_OPT__))
|
||||
{
|
||||
if (token->flags & PREV_WHITE)
|
||||
token->flags |= SP_PREV_WHITE;
|
||||
--- gcc/testsuite/c-c++-common/cpp/va-opt-5.c
|
||||
+++ gcc/testsuite/c-c++-common/cpp/va-opt-5.c
|
||||
@@ -0,0 +1,67 @@
|
||||
+/* { dg-do run } */
|
||||
+/* { dg-options "-std=gnu99" { target c } } */
|
||||
+/* { dg-options "-std=c++20" { target c++ } } */
|
||||
+
|
||||
+#define lparen (
|
||||
+#define a0 fooa0
|
||||
+#define a1 fooa1 a0
|
||||
+#define a2 fooa2 a1
|
||||
+#define a3 fooa3 a2
|
||||
+#define a() b lparen )
|
||||
+#define b() c lparen )
|
||||
+#define c() d lparen )
|
||||
+#define g h
|
||||
+#define i(j) j
|
||||
+#define f(...) #__VA_OPT__(g i(0))
|
||||
+#define k(x,...) # __VA_OPT__(x) #x #__VA_OPT__(__VA_ARGS__)
|
||||
+#define l(x,...) #__VA_OPT__(a1 x)
|
||||
+#define m(x,...) "a()" #__VA_OPT__(a3 __VA_ARGS__ x ## __VA_ARGS__ ## x ## c a3) "a()"
|
||||
+#define n(x,...) = #__VA_OPT__(a3 __VA_ARGS__ x ## __VA_ARGS__ ## x ## c a3) #x #__VA_OPT__(a0 __VA_ARGS__ x ## __VA_ARGS__ ## x ## c a0) ;
|
||||
+#define o(x, ...) #__VA_OPT__(x##x x##x)
|
||||
+#define p(x, ...) #__VA_OPT__(_Pragma ("foobar"))
|
||||
+#define q(...) #__VA_OPT__(/* foo */x/* bar */)
|
||||
+const char *v1 = f();
|
||||
+const char *v2 = f(123);
|
||||
+const char *v3 = k(1);
|
||||
+const char *v4 = k(1, 2, 3 );
|
||||
+const char *v5 = l(a());
|
||||
+const char *v6 = l(a1 a(), 1);
|
||||
+const char *v7 = m();
|
||||
+const char *v8 = m(,);
|
||||
+const char *v9 = m(,a3);
|
||||
+const char *v10 = m(a3,a(),a0);
|
||||
+const char *v11 n()
|
||||
+const char *v12 n(,)
|
||||
+const char *v13 n(,a0)
|
||||
+const char *v14 n(a0, a(),a0)
|
||||
+const char *v15 = o(, 0);
|
||||
+const char *v16 = p(0);
|
||||
+const char *v17 = p(0, 1);
|
||||
+const char *v18 = q();
|
||||
+const char *v19 = q(1);
|
||||
+
|
||||
+int
|
||||
+main ()
|
||||
+{
|
||||
+ if (__builtin_strcmp (v1, "")
|
||||
+ || __builtin_strcmp (v2, "g i(0)")
|
||||
+ || __builtin_strcmp (v3, "1")
|
||||
+ || __builtin_strcmp (v4, "112, 3")
|
||||
+ || __builtin_strcmp (v5, "")
|
||||
+ || __builtin_strcmp (v6, "a1 fooa1 fooa0 b ( )")
|
||||
+ || __builtin_strcmp (v7, "a()a()")
|
||||
+ || __builtin_strcmp (v8, "a()a()")
|
||||
+ || __builtin_strcmp (v9, "a()a3 fooa3 fooa2 fooa1 fooa0 a3c a3a()")
|
||||
+ || __builtin_strcmp (v10, "a()a3 b ( ),fooa0 a3a(),a0a3c a3a()")
|
||||
+ || __builtin_strcmp (v11, "")
|
||||
+ || __builtin_strcmp (v12, "")
|
||||
+ || __builtin_strcmp (v13, "a3 fooa0 a0c a3a0 fooa0 a0c a0")
|
||||
+ || __builtin_strcmp (v14, "a3 b ( ),fooa0 a0a(),a0a0c a3a0a0 b ( ),fooa0 a0a(),a0a0c a0")
|
||||
+ || __builtin_strcmp (v15, "")
|
||||
+ || __builtin_strcmp (v16, "")
|
||||
+ || __builtin_strcmp (v17, "_Pragma (\"foobar\")")
|
||||
+ || __builtin_strcmp (v18, "")
|
||||
+ || __builtin_strcmp (v19, "x"))
|
||||
+ __builtin_abort ();
|
||||
+ return 0;
|
||||
+}
|
||||
--- gcc/testsuite/c-c++-common/cpp/va-opt-6.c
|
||||
+++ gcc/testsuite/c-c++-common/cpp/va-opt-6.c
|
||||
@@ -0,0 +1,17 @@
|
||||
+/* { dg-do preprocess } */
|
||||
+/* { dg-options "-std=gnu99" { target c } } */
|
||||
+/* { dg-options "-std=c++20" { target c++ } } */
|
||||
+
|
||||
+#define a ""
|
||||
+#define b(...) a ## #__VA_OPT__(1) /* { dg-error "pasting \"a\" and \"\"\"\" does not give a valid preprocessing token" } */
|
||||
+#define c(...) a ## #__VA_OPT__(1) /* { dg-error "pasting \"a\" and \"\"1\"\" does not give a valid preprocessing token" } */
|
||||
+#define d(...) #__VA_OPT__(1) ## !
|
||||
+#define e(...) #__VA_OPT__(1) ## !
|
||||
+#define f(...) #__VA_OPT__(. ## !)
|
||||
+#define g(...) #__VA_OPT__(. ## !)
|
||||
+b()
|
||||
+c(1)
|
||||
+d( ) /* { dg-error "pasting \"\"\"\" and \"!\" does not give a valid preprocessing token" } */
|
||||
+e( 1 ) /* { dg-error "pasting \"\"1\"\" and \"!\" does not give a valid preprocessing token" } */
|
||||
+f()
|
||||
+g(0) /* { dg-error "pasting \".\" and \"!\" does not give a valid preprocessing token" } */
|
2
sources
2
sources
@ -1,4 +1,4 @@
|
||||
SHA512 (gcc-11.2.1-20210728.tar.xz) = 2234298652f882151aead486bb22481ba8181df69b9c7c5d73b8aa505ace58462fcd0b482680f466e2d21dc47e869651c7dbf224b65791ca47204dab01e89e7c
|
||||
SHA512 (gcc-11.2.1-20210823.tar.xz) = 1ef37ca5f54c437cc01402ff9ba9599ae5e4db25f93efdf627a353596f88f9b377f1bb7b2b8406f6a09bcc1da310ccc58f88767d59efcd54cf1d46a7134ebf4f
|
||||
SHA512 (isl-0.18.tar.bz2) = 85d0b40f4dbf14cb99d17aa07048cdcab2dc3eb527d2fbb1e84c41b2de5f351025370e57448b63b2b8a8cf8a0843a089c3263f9baee1542d5c2e1cb37ed39d94
|
||||
SHA512 (newlib-cygwin-50e2a63b04bdd018484605fbb954fd1bd5147fa0.tar.xz) = 002a48a7b689a81abbf16161bcaec001a842e67dfbe372e9e109092703bfc666675f16198f60ca429370e8850d564547dc505df81bc3aaca4ce6defbc014ad6c
|
||||
SHA512 (nvptx-tools-5f6f343a302d620b0868edab376c00b15741e39e.tar.xz) = f6d10db94fa1570ae0f94df073fa3c73c8e5ee16d59070b53d94f7db0de8a031bc44d7f3f1852533da04b625ce758e022263855ed43cfc6867e0708d001e53c7
|
||||
|
Loading…
Reference in New Issue
Block a user