From d62d5686f41bb4ea50b8de640fac51decd24199a Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Mon, 15 May 2023 23:17:48 +0000 Subject: c: Ignore _Atomic on function return type for C2x For C2x it was decided that _Atomic would be completely ignored on function return types (just as was done for qualifiers in C11 DR#423), to eliminate the potential for an rvalue returned by a function having _Atomic-qualified type when an rvalue resulting from lvalue-to-rvalue conversion could not have such a type. Implement this for GCC. Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc/c/ * c-decl.cc (grokdeclarator): Ignore _Atomic on function return type for C2x. gcc/testsuite/ * gcc.dg/qual-return-9.c, gcc.dg/qual-return-10.c: New tests. --- gcc/c/c-decl.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index 1b53f2d..90d7cd2 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -7412,9 +7412,12 @@ grokdeclarator (const struct c_declarator *declarator, them for noreturn functions. The resolution of C11 DR#423 means qualifiers (other than _Atomic) are actually removed from the return type when - determining the function type. */ + determining the function type. For C2X, _Atomic is + removed as well. */ int quals_used = type_quals; - if (flag_isoc11) + if (flag_isoc2x) + quals_used = 0; + else if (flag_isoc11) quals_used &= TYPE_QUAL_ATOMIC; if (quals_used && VOID_TYPE_P (type) && really_funcdef) pedwarn (specs_loc, 0, -- cgit v1.1