From patchwork Fri Oct 7 02:12:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 1799 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp81685wrs; Thu, 6 Oct 2022 19:14:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5DXc7BEPm+TrM9Jk0hOBBWbCZIRN9K54GwMDomxMF3Zib3UsAwF8I/2M0u9LhP/YemgbMq X-Received: by 2002:a17:906:5a4c:b0:78c:c893:74e6 with SMTP id my12-20020a1709065a4c00b0078cc89374e6mr2269623ejc.545.1665108875531; Thu, 06 Oct 2022 19:14:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665108875; cv=none; d=google.com; s=arc-20160816; b=q/sfrAs2PQoUHzLNT3qYqVk9LnE0U/0hXFRB4zs0+3nK9CHqu1TW25MvVQOF4DjZ2z IxZGELQ7JDOEkNl6ivCcGuyxBmPzllRVBFN4hl3uhPj2owPVY9T98jS99j8F91PWOQ8Q 6BSVi6biCJ3mr6Y2F2ntcH3HMRJE3Vu5mNWCVqj4TJWohBZ+Mkw9dSUS1nfjDIVacOyz wZXTT7XEntKd7pDsENuEKSowDVMMLJng21cld56HXgDKXjd0y57XO3EKxriQkiCTxOq7 lxWkUoQp2F8VBCqWtc5dl9D/Nt3dCFxJ3j4sYRdFc54pXsrk0tvo81vef65i+uSD0kfp OCyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-disposition:user-agent:in-reply-to:mime-version:references :message-id:subject:to:date:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=g9gC/Y2JJKP5j3HIdn3vnnP1L/ygonTK5hSTGOBt2mE=; b=tRmm/ZNc0fw648ChrHSRjEPVyM11BBCVCF9OsOzZTQn8+Xdj04SJ+bbMMFyjlxV4Te /49OLiqUQC1TPyWRz922wP53W66uobB0KCBvUej8f8SVIMQNTOgrPG919FBrfJAmQ3Ih xzXBE35KUC1X5HpHyOLVwVTksK93H2d1q0+Dw8K/dt3CBVqcpyvjwCIteHmi573F/i14 6jI6YPUpVmfNAgSRbFVWt6ORCMv218l2mm+9cA3PtbYULp2eVGiXP0HpYh+yoV0z95So XpfXpe6ZkQaA8AHm2Bhprtehcu0RJP6hGb+0SRUiqvtJ94p4+p8KVaCqtDCG79JUTImG GA9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=UldADsQ4; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id z20-20020a056402275400b00458ebd62c70si1097306edd.32.2022.10.06.19.14.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 19:14:35 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=UldADsQ4; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 34C37382F990 for ; Fri, 7 Oct 2022 02:14:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 34C37382F990 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665108874; bh=g9gC/Y2JJKP5j3HIdn3vnnP1L/ygonTK5hSTGOBt2mE=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=UldADsQ4CNoB0kfBtjCTnDpEgXjCQ7N3p8UefDAdmR+CHczsP+nOkwfbodqr5c+eA KmDjrwiollmfnehJWw1SctkX0163OnI241OklF6zAAE94AiHVsy1MdEsk67STNXryG nhNWpYSM6rkbpEIIIVu73y5JimWt8VmOSAhVzE6Y= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 9A41F3858C62 for ; Fri, 7 Oct 2022 02:12:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9A41F3858C62 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-53-ZGwErWl1M5W4dUF7BfonQg-1; Thu, 06 Oct 2022 22:12:51 -0400 X-MC-Unique: ZGwErWl1M5W4dUF7BfonQg-1 Received: by mail-qt1-f197.google.com with SMTP id gc10-20020a05622a59ca00b003951e095c04so1212158qtb.4 for ; Thu, 06 Oct 2022 19:12:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g9gC/Y2JJKP5j3HIdn3vnnP1L/ygonTK5hSTGOBt2mE=; b=of9+IQKWveJ7UoRx+cwDMiP8KpbkcQNmCMzzOq6ztnbYsdfcP75YmPdjDDzwhN48mu UJsM6rHN+tpvJY3JkVTrgsRoLjUqD+ZvG8OVER1fHy0/vS9OwyxsbYiUbXDusPQprXjm YQrR/i1y1cUw6WC4JSvWzh57uw92tMczhYewnh2D8TxaElY0jU59K5sHUQb7Tq5Jmc/Q ewZZwL1f+f0XSfQ9/JygM2C1PE8bNve/T8vM9umVWaDQm9kqkdy7IZzCVSY4EPPOFWNJ zU4bTHNCFPstJZSxHR4Jfshdohsyqc6gAgnCXPJUI39EYAzm5WjsKq2Kof1vRmLmOdml 1T9g== X-Gm-Message-State: ACrzQf1qXeKtk+jSh+CuHijIJN43LwhbQVlX8tdgsIDN7jnyu81FRV+j OJEuHFdu46uPBuJs8TL1Ven0punjDJRDT2rWWb8XAyh6E4u84s3YRVCni8WHwPHyDGWl4hnlRvN kiZycyCJsJWUneOoEpQ== X-Received: by 2002:a05:620a:2a09:b0:6cf:8fc6:e8d2 with SMTP id o9-20020a05620a2a0900b006cf8fc6e8d2mr2348535qkp.199.1665108770451; Thu, 06 Oct 2022 19:12:50 -0700 (PDT) X-Received: by 2002:a05:620a:2a09:b0:6cf:8fc6:e8d2 with SMTP id o9-20020a05620a2a0900b006cf8fc6e8d2mr2348520qkp.199.1665108769963; Thu, 06 Oct 2022 19:12:49 -0700 (PDT) Received: from redhat.com (2603-7000-9500-2e39-0000-0000-0000-1db4.res6.spectrum.com. [2603:7000:9500:2e39::1db4]) by smtp.gmail.com with ESMTPSA id u28-20020a05620a085c00b006ceafb1aa92sm736244qku.96.2022.10.06.19.12.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 19:12:49 -0700 (PDT) Date: Thu, 6 Oct 2022 22:12:47 -0400 To: Jason Merrill Subject: [PATCH v3] c-family: ICE with [[gnu::nocf_check]] [PR106937] Message-ID: References: <20220929224945.90798-1-polacek@redhat.com> <1c85a5bf-82dd-772c-a960-75a495ded832@redhat.com> <986ebf27-6897-c762-ff5a-d82c465e61a8@redhat.com> MIME-Version: 1.0 In-Reply-To: <986ebf27-6897-c762-ff5a-d82c465e61a8@redhat.com> User-Agent: Mutt/2.2.7 (2022-08-07) X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Marek Polacek via Gcc-patches From: Marek Polacek Reply-To: Marek Polacek Cc: GCC Patches , Joseph Myers Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1745346195308818410?= X-GMAIL-MSGID: =?utf-8?q?1745993204137414253?= On Thu, Oct 06, 2022 at 05:42:41PM -0400, Jason Merrill wrote: > On 10/4/22 19:06, Marek Polacek wrote: > > On Fri, Sep 30, 2022 at 09:12:24AM -0400, Jason Merrill wrote: > > > On 9/29/22 18:49, Marek Polacek wrote: > > > > When getting the name of an attribute, we ought to use > > > > get_attribute_name, which handles both [[ ]] and __attribute__(()) > > > > forms. Failure to do so may result in an ICE, like here. > > > > > > > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? > > > > > > How do we print the attributes with this patch? Don't we also want to print > > > the namespace, and use [[]] in the output? > > > > Good point, however: while the testcase indeed has an attribute > > in the [[]] form in the typedef, here we're printing its "aka": > > > > warning: initialization of 'FuncPointerWithNoCfCheck' {aka 'void (__attribute__((nocf_check)) *)(void)'} from incompatible pointer type 'FuncPointer' {aka 'void (*)(void)'} > > > > c-pretty-print.cc doesn't seem to know how to print an [[]] attribute. > > I could do that, but then we'd print > > > > aka 'void ([[nocf_check]] *)(void)' > > > > in the above, but that's invalid syntax! > > Indeed, it should be > > void (* [[gnu::nocf_check]])(void) Ok, let me fix that too, then. I've updated the description to show what we print with the patch, and what was printed before. And I also noticed another thing: type_hash_canon_hash hashes only get_attribute_name, so build_type_attribute_qual_variant will use the same function_type tree for these two pointers: __attribute__((nocf_check)) typedef void (*fp1)(); [[gnu::nocf_check]] typedef void (*fp2)(); so if gcc prints a diagnostic with fp2, it will show the GNU form of the attribute, because the already existing type of fp1 will be used! I'm not addressing it here, just an oddity I discovered. Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? -- >8 -- When getting the name of an attribute, we ought to use get_attribute_name, which handles both [[]] and __attribute__(()) forms. Failure to do so may result in an ICE, like here. pp_c_attributes_display wasn't able to print the [[]] form of attributes, so this patch teaches it to. When printing a pointer to function with an attribute, the attribute should be printed after the *, because that's what it appertains to. With this patch we print: aka 'void (*__attribute__((nocf_check)))()' aka 'void (*[[gnu::nocf_check]])()' rather than aka 'void (__attribute__((nocf_check)) *)() or crashing in the second case. pp_c_attributes has been unused since its introduction in r56273 so this patch removes it. PR c++/106937 gcc/c-family/ChangeLog: * c-pretty-print.cc (pp_c_specifier_qualifier_list): When printing a pointer to function with an attribute, print the attribute after the *. (pp_c_attributes): Remove. (pp_c_attributes_display): Print the [[]] form if appropriate. Use get_attribute_name. Don't print a trailing space. * c-pretty-print.h (pp_c_attributes): Remove. gcc/cp/ChangeLog: * error.cc (dump_type_prefix): When printing a pointer/reference to function with an attribute, print the attribute after the */&. gcc/testsuite/ChangeLog: * g++.dg/diagnostic/aka5a.C: Adjust. * g++.dg/diagnostic/aka5b.C: Likewise. * gcc.dg/diag-aka-5a.c: Likewise. * gcc.dg/diag-aka-5b.c: Likewise. * c-c++-common/pointer-to-fn1.c: New test. --- gcc/c-family/c-pretty-print.cc | 92 +++++++++++---------- gcc/c-family/c-pretty-print.h | 1 - gcc/cp/error.cc | 4 +- gcc/testsuite/c-c++-common/pointer-to-fn1.c | 18 ++++ gcc/testsuite/g++.dg/diagnostic/aka5a.C | 8 +- gcc/testsuite/g++.dg/diagnostic/aka5b.C | 9 +- gcc/testsuite/gcc.dg/diag-aka-5a.c | 8 +- gcc/testsuite/gcc.dg/diag-aka-5b.c | 8 +- 8 files changed, 84 insertions(+), 64 deletions(-) create mode 100644 gcc/testsuite/c-c++-common/pointer-to-fn1.c base-commit: 629d04d35d819bdc26c30d215bc4ea66a74af15b diff --git a/gcc/c-family/c-pretty-print.cc b/gcc/c-family/c-pretty-print.cc index efa1768f4d6..2523939cffb 100644 --- a/gcc/c-family/c-pretty-print.cc +++ b/gcc/c-family/c-pretty-print.cc @@ -466,11 +466,16 @@ pp_c_specifier_qualifier_list (c_pretty_printer *pp, tree t) { pp_c_whitespace (pp); pp_c_left_paren (pp); + pp_ptr_operator (pp, t); pp_c_attributes_display (pp, TYPE_ATTRIBUTES (pointee)); } - else if (!c_dialect_cxx ()) - pp_c_whitespace (pp); - pp_ptr_operator (pp, t); + else + { + /* Removing this WS inconsistency breaks too many tests. */ + if (!c_dialect_cxx ()) + pp_c_whitespace (pp); + pp_ptr_operator (pp, t); + } } break; @@ -850,32 +855,7 @@ c_pretty_printer::declaration (tree t) pp_c_init_declarator (this, t); } -/* Pretty-print ATTRIBUTES using GNU C extension syntax. */ - -void -pp_c_attributes (c_pretty_printer *pp, tree attributes) -{ - if (attributes == NULL_TREE) - return; - - pp_c_ws_string (pp, "__attribute__"); - pp_c_left_paren (pp); - pp_c_left_paren (pp); - for (; attributes != NULL_TREE; attributes = TREE_CHAIN (attributes)) - { - pp_tree_identifier (pp, TREE_PURPOSE (attributes)); - if (TREE_VALUE (attributes)) - pp_c_call_argument_list (pp, TREE_VALUE (attributes)); - - if (TREE_CHAIN (attributes)) - pp_separate_with (pp, ','); - } - pp_c_right_paren (pp); - pp_c_right_paren (pp); -} - -/* Pretty-print ATTRIBUTES using GNU C extension syntax for attributes - marked to be displayed on disgnostic. */ +/* Pretty-print ATTRIBUTES marked to be displayed on diagnostic. */ void pp_c_attributes_display (c_pretty_printer *pp, tree a) @@ -885,10 +865,12 @@ pp_c_attributes_display (c_pretty_printer *pp, tree a) if (a == NULL_TREE) return; + const bool std_p = cxx11_attribute_p (a); + for (; a != NULL_TREE; a = TREE_CHAIN (a)) { - const struct attribute_spec *as; - as = lookup_attribute_spec (TREE_PURPOSE (a)); + const struct attribute_spec *as + = lookup_attribute_spec (get_attribute_name (a)); if (!as || as->affects_type_identity == false) continue; if (c_dialect_cxx () @@ -896,26 +878,46 @@ pp_c_attributes_display (c_pretty_printer *pp, tree a) /* In C++ transaction_safe is printed at the end of the declarator. */ continue; if (is_first) - { - pp_c_ws_string (pp, "__attribute__"); - pp_c_left_paren (pp); - pp_c_left_paren (pp); - is_first = false; - } + { + if (std_p) + { + pp_c_left_bracket (pp); + pp_c_left_bracket (pp); + } + else + { + pp_c_ws_string (pp, "__attribute__"); + pp_c_left_paren (pp); + pp_c_left_paren (pp); + } + is_first = false; + } else - { - pp_separate_with (pp, ','); - } - pp_tree_identifier (pp, TREE_PURPOSE (a)); + pp_separate_with (pp, ','); + tree ns; + if (std_p && (ns = get_attribute_namespace (a))) + { + pp_tree_identifier (pp, ns); + pp_colon (pp); + pp_colon (pp); + } + pp_tree_identifier (pp, get_attribute_name (a)); if (TREE_VALUE (a)) - pp_c_call_argument_list (pp, TREE_VALUE (a)); + pp_c_call_argument_list (pp, TREE_VALUE (a)); } if (!is_first) { - pp_c_right_paren (pp); - pp_c_right_paren (pp); - pp_c_whitespace (pp); + if (std_p) + { + pp_c_right_bracket (pp); + pp_c_right_bracket (pp); + } + else + { + pp_c_right_paren (pp); + pp_c_right_paren (pp); + } } } diff --git a/gcc/c-family/c-pretty-print.h b/gcc/c-family/c-pretty-print.h index be86bed4fee..92674ab4d06 100644 --- a/gcc/c-family/c-pretty-print.h +++ b/gcc/c-family/c-pretty-print.h @@ -119,7 +119,6 @@ void pp_c_space_for_pointer_operator (c_pretty_printer *, tree); /* Declarations. */ void pp_c_tree_decl_identifier (c_pretty_printer *, tree); void pp_c_function_definition (c_pretty_printer *, tree); -void pp_c_attributes (c_pretty_printer *, tree); void pp_c_attributes_display (c_pretty_printer *, tree); void pp_c_cv_qualifiers (c_pretty_printer *pp, int qualifiers, bool func_type); void pp_c_type_qualifier_list (c_pretty_printer *, tree); diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc index 4514c8bbb44..4ce59157383 100644 --- a/gcc/cp/error.cc +++ b/gcc/cp/error.cc @@ -897,7 +897,6 @@ dump_type_prefix (cxx_pretty_printer *pp, tree t, int flags) { pp_cxx_whitespace (pp); pp_cxx_left_paren (pp); - pp_c_attributes_display (pp, TYPE_ATTRIBUTES (sub)); } if (TYPE_PTR_P (t)) pp_star (pp); @@ -908,6 +907,9 @@ dump_type_prefix (cxx_pretty_printer *pp, tree t, int flags) else pp_ampersand (pp); } + if (TREE_CODE (sub) == ARRAY_TYPE + || TREE_CODE (sub) == FUNCTION_TYPE) + pp_c_attributes_display (pp, TYPE_ATTRIBUTES (sub)); pp->padding = pp_before; pp_cxx_cv_qualifier_seq (pp, t); } diff --git a/gcc/testsuite/c-c++-common/pointer-to-fn1.c b/gcc/testsuite/c-c++-common/pointer-to-fn1.c new file mode 100644 index 00000000000..8b842e0774a --- /dev/null +++ b/gcc/testsuite/c-c++-common/pointer-to-fn1.c @@ -0,0 +1,18 @@ +/* PR c++/106937 */ +/* { dg-options "-fcf-protection" } */ +/* { dg-additional-options "-std=c++11 -fpermissive" { target c++ } } */ +/* Test printing a pointer to function with attribute. */ + +__attribute__((nocf_check)) typedef void (*FPA1)(); +[[gnu::nocf_check]] typedef void (*FPA2)(int); +typedef void (*FP1)(); +typedef void (*FP2)(int); + +void +g (FP1 f1, FP2 f2) +{ + FPA1 p1 = f1; // { dg-warning {aka .void \(\*__attribute__\(\(nocf_check\)\)\)\(\)} } + FPA2 p2 = f2; // { dg-warning {aka .void \(\*\[\[gnu::nocf_check\]\]\)\(int\)} } + FP1 p3 = p1; // { dg-warning {aka .void \(\*__attribute__\(\(nocf_check\)\)\)\(\)} } + FP2 p4 = p2; // { dg-warning {aka .void \(\*\[\[gnu::nocf_check\]\]\)\(int\)} } +} diff --git a/gcc/testsuite/g++.dg/diagnostic/aka5a.C b/gcc/testsuite/g++.dg/diagnostic/aka5a.C index e9d4c02f61d..94923c298dd 100644 --- a/gcc/testsuite/g++.dg/diagnostic/aka5a.C +++ b/gcc/testsuite/g++.dg/diagnostic/aka5a.C @@ -82,8 +82,8 @@ void f (s s1) ue_fn_ptr4 = &s1; // { dg-error {cannot convert 's\*' to 'user_enum_copy \(\*\)\(\)' {aka 'user_enum \(\*\)\(\)'} in assignment} } ue_fn_ptr5 = &s1; // { dg-error {cannot convert 's\*' to 'void \(\*\)\(user_enum_copy\)' {aka 'void \(\*\)\(user_enum\)'} in assignment} } ue_fn_ptr6 = &s1; // { dg-error {cannot convert 's\*' to 'void \(\*\)\(user_enum_copy, \.\.\.\)' {aka 'void \(\*\)\(user_enum, \.\.\.\)'} in assignment} } - unsafe_ue_fn_ptr1 = &s1; // { dg-error {cannot convert 's\*' to 'user_enum \(__attribute__\(\(transaction_unsafe\)\) \*\)\(\)' in assignment} } - unsafe_ue_fn_ptr2 = &s1; // { dg-error {cannot convert 's\*' to 'user_enum_copy \(__attribute__\(\(transaction_unsafe\)\) \*\)\(\)' {aka 'user_enum \(__attribute__\(\(transaction_unsafe\)\) \*\)\(\)'} in assignment} } + unsafe_ue_fn_ptr1 = &s1; // { dg-error {cannot convert 's\*' to 'user_enum \(\*__attribute__\(\(transaction_unsafe\)\)\)\(\)' in assignment} } + unsafe_ue_fn_ptr2 = &s1; // { dg-error {cannot convert 's\*' to 'user_enum_copy \(\*__attribute__\(\(transaction_unsafe\)\)\)\(\)' {aka 'user_enum \(\*__attribute__\(\(transaction_unsafe\)\)\)\(\)'} in assignment} } us1 = s1; // { dg-error {no match for 'operator=' in 'us1 = s1' \(operand types are 'user_struct' and 's'\)} } us2 = s1; // { dg-error {no match for 'operator=' in 'us2 = s1' \(operand types are 'user_struct_copy' {aka 'user_struct'} and 's'\)} } @@ -122,6 +122,6 @@ void f (s s1) ui_fn_ptr4 = &s1; // { dg-error {cannot convert 's\*' to 'user_int_copy \(\*\)\(\)' {aka 'int \(\*\)\(\)'} in assignment} } ui_fn_ptr5 = &s1; // { dg-error {cannot convert 's\*' to 'void \(\*\)\(user_int_copy\)' {aka 'void \(\*\)\(int\)'} in assignment} } ui_fn_ptr6 = &s1; // { dg-error {cannot convert 's\*' to 'void \(\*\)\(user_int_copy, \.\.\.\)' {aka 'void \(\*\)\(int, \.\.\.\)'} in assignment} } - unsafe_ui_fn_ptr1 = &s1; // { dg-error {cannot convert 's\*' to 'user_int \(__attribute__\(\(transaction_unsafe\)\) \*\)\(\)' {aka 'int \(__attribute__\(\(transaction_unsafe\)\) \*\)\(\)'} in assignment} } - unsafe_ui_fn_ptr2 = &s1; // { dg-error {cannot convert 's\*' to 'user_int_copy \(__attribute__\(\(transaction_unsafe\)\) \*\)\(\)' {aka 'int \(__attribute__\(\(transaction_unsafe\)\) \*\)\(\)'} in assignment} } + unsafe_ui_fn_ptr1 = &s1; // { dg-error {cannot convert 's\*' to 'user_int \(\*__attribute__\(\(transaction_unsafe\)\)\)\(\)' {aka 'int \(\*__attribute__\(\(transaction_unsafe\)\)\)\(\)'} in assignment} } + unsafe_ui_fn_ptr2 = &s1; // { dg-error {cannot convert 's\*' to 'user_int_copy \(\*__attribute__\(\(transaction_unsafe\)\)\)\(\)' {aka 'int \(\*__attribute__\(\(transaction_unsafe\)\)\)\(\)'} in assignment} } } diff --git a/gcc/testsuite/g++.dg/diagnostic/aka5b.C b/gcc/testsuite/g++.dg/diagnostic/aka5b.C index 6942be3eef1..45a0ce378f6 100644 --- a/gcc/testsuite/g++.dg/diagnostic/aka5b.C +++ b/gcc/testsuite/g++.dg/diagnostic/aka5b.C @@ -81,8 +81,8 @@ void f (s s1) ue_fn_ptr4 = &s1; // { dg-error {cannot convert 's\*' to 'user_enum_copy \(\*\)\(\)' {aka '__internal_enum \(\*\)\(\)'} in assignment} } ue_fn_ptr5 = &s1; // { dg-error {cannot convert 's\*' to 'void \(\*\)\(user_enum_copy\)' {aka 'void \(\*\)\(__internal_enum\)'} in assignment} } ue_fn_ptr6 = &s1; // { dg-error {cannot convert 's\*' to 'void \(\*\)\(user_enum_copy, \.\.\.\)' {aka 'void \(\*\)\(__internal_enum, \.\.\.\)'} in assignment} } - unsafe_ue_fn_ptr1 = &s1; // { dg-error {cannot convert 's\*' to 'user_enum \(__attribute__\(\(transaction_unsafe\)\) \*\)\(\)' {aka '__internal_enum \(__attribute__\(\(transaction_unsafe\)\) \*\)\(\)'} in assignment} } - unsafe_ue_fn_ptr2 = &s1; // { dg-error {cannot convert 's\*' to 'user_enum_copy \(__attribute__\(\(transaction_unsafe\)\) \*\)\(\)' {aka '__internal_enum \(__attribute__\(\(transaction_unsafe\)\) \*\)\(\)'} in assignment} } + unsafe_ue_fn_ptr1 = &s1; // { dg-error {cannot convert 's\*' to 'user_enum \(\*__attribute__\(\(transaction_unsafe\)\)\)\(\)' {aka '__internal_enum \(\*__attribute__\(\(transaction_unsafe\)\)\)\(\)'} in assignment} } + unsafe_ue_fn_ptr2 = &s1; // { dg-error {cannot convert 's\*' to 'user_enum_copy \(\*__attribute__\(\(transaction_unsafe\)\)\)\(\)' {aka '__internal_enum \(\*__attribute__\(\(transaction_unsafe\)\)\)\(\)'} in assignment} } us1 = s1; // { dg-error {no match for 'operator=' in 'us1 = s1' \(operand types are 'user_struct' {aka '__internal_struct'} and 's'\)} } us2 = s1; // { dg-error {no match for 'operator=' in 'us2 = s1' \(operand types are 'user_struct_copy' {aka '__internal_struct'} and 's'\)} } @@ -121,7 +121,6 @@ void f (s s1) ui_fn_ptr4 = &s1; // { dg-error {cannot convert 's\*' to 'user_int_copy \(\*\)\(\)' {aka 'int \(\*\)\(\)'} in assignment} } ui_fn_ptr5 = &s1; // { dg-error {cannot convert 's\*' to 'void \(\*\)\(user_int_copy\)' {aka 'void \(\*\)\(int\)'} in assignment} } ui_fn_ptr6 = &s1; // { dg-error {cannot convert 's\*' to 'void \(\*\)\(user_int_copy, \.\.\.\)' {aka 'void \(\*\)\(int, \.\.\.\)'} in assignment} } - unsafe_ui_fn_ptr1 = &s1; // { dg-error {cannot convert 's\*' to 'user_int \(__attribute__\(\(transaction_unsafe\)\) \*\)\(\)' {aka 'int \(__attribute__\(\(transaction_unsafe\)\) \*\)\(\)'} in assignment} } - unsafe_ui_fn_ptr2 = &s1; // { dg-error {cannot convert 's\*' to 'user_int_copy \(__attribute__\(\(transaction_unsafe\)\) \*\)\(\)' {aka 'int \(__attribute__\(\(transaction_unsafe\)\) \*\)\(\)'} in assignment} } + unsafe_ui_fn_ptr1 = &s1; // { dg-error {cannot convert 's\*' to 'user_int \(\*__attribute__\(\(transaction_unsafe\)\)\)\(\)' {aka 'int \(\*__attribute__\(\(transaction_unsafe\)\)\)\(\)'} in assignment} } + unsafe_ui_fn_ptr2 = &s1; // { dg-error {cannot convert 's\*' to 'user_int_copy \(\*__attribute__\(\(transaction_unsafe\)\)\)\(\)' {aka 'int \(\*__attribute__\(\(transaction_unsafe\)\)\)\(\)'} in assignment} } } - diff --git a/gcc/testsuite/gcc.dg/diag-aka-5a.c b/gcc/testsuite/gcc.dg/diag-aka-5a.c index 8768a79204a..227c01c16db 100644 --- a/gcc/testsuite/gcc.dg/diag-aka-5a.c +++ b/gcc/testsuite/gcc.dg/diag-aka-5a.c @@ -88,8 +88,8 @@ void f (struct s s) ue_fn_ptr4 = &s; /* { dg-error {assignment to 'user_enum_copy \(\*\)\(void\)' {aka 'user_enum \(\*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ ue_fn_ptr5 = &s; /* { dg-error {assignment to 'void \(\*\)\(user_enum_copy\)' {aka 'void \(\*\)\(user_enum\)'} from incompatible pointer type 'struct s \*'} } */ ue_fn_ptr6 = &s; /* { dg-error {assignment to 'void \(\*\)\(user_enum_copy, \.\.\.\)' {aka 'void \(\*\)\(user_enum, \.\.\.\)'} from incompatible pointer type 'struct s \*'} } */ - unsafe_ue_fn_ptr1 = &s; /* { dg-error {assignment to 'user_enum \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)' from incompatible pointer type 'struct s \*'} } */ - unsafe_ue_fn_ptr2 = &s; /* { dg-error {assignment to 'user_enum_copy \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)' {aka 'user_enum \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ + unsafe_ue_fn_ptr1 = &s; /* { dg-error {assignment to 'user_enum \(\*__attribute__\(\(transaction_unsafe\)\)\)\(void\)' from incompatible pointer type 'struct s \*'} } */ + unsafe_ue_fn_ptr2 = &s; /* { dg-error {assignment to 'user_enum_copy \(\*__attribute__\(\(transaction_unsafe\)\)\)\(void\)' {aka 'user_enum \(\*__attribute__\(\(transaction_unsafe\)\)\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ us1 = s; /* { dg-error {assigning to type 'user_struct' from type 'struct s'} } */ us2 = s; /* { dg-error {assigning to type 'user_struct_copy' {aka 'user_struct'} from type 'struct s'} } */ @@ -130,6 +130,6 @@ void f (struct s s) ui_fn_ptr4 = &s; /* { dg-error {assignment to 'user_int_copy \(\*\)\(void\)' {aka 'int \(\*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ ui_fn_ptr5 = &s; /* { dg-error {assignment to 'void \(\*\)\(user_int_copy\)' {aka 'void \(\*\)\(int\)'} from incompatible pointer type 'struct s \*'} } */ ui_fn_ptr6 = &s; /* { dg-error {assignment to 'void \(\*\)\(user_int_copy, \.\.\.\)' {aka 'void \(\*\)\(int, \.\.\.\)'} from incompatible pointer type 'struct s \*'} } */ - unsafe_ui_fn_ptr1 = &s; /* { dg-error {assignment to 'user_int \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)' {aka 'int \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ - unsafe_ui_fn_ptr2 = &s; /* { dg-error {assignment to 'user_int_copy \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)' {aka 'int \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ + unsafe_ui_fn_ptr1 = &s; /* { dg-error {assignment to 'user_int \(\*__attribute__\(\(transaction_unsafe\)\)\)\(void\)' {aka 'int \(\*__attribute__\(\(transaction_unsafe\)\)\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ + unsafe_ui_fn_ptr2 = &s; /* { dg-error {assignment to 'user_int_copy \(\*__attribute__\(\(transaction_unsafe\)\)\)\(void\)' {aka 'int \(\*__attribute__\(\(transaction_unsafe\)\)\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ } diff --git a/gcc/testsuite/gcc.dg/diag-aka-5b.c b/gcc/testsuite/gcc.dg/diag-aka-5b.c index e0ec7c816a2..848b1b76888 100644 --- a/gcc/testsuite/gcc.dg/diag-aka-5b.c +++ b/gcc/testsuite/gcc.dg/diag-aka-5b.c @@ -87,8 +87,8 @@ void f (struct s s) ue_fn_ptr4 = &s; /* { dg-error {assignment to 'user_enum_copy \(\*\)\(void\)' {aka 'enum __internal_enum \(\*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ ue_fn_ptr5 = &s; /* { dg-error {assignment to 'void \(\*\)\(user_enum_copy\)' {aka 'void \(\*\)\(enum __internal_enum\)'} from incompatible pointer type 'struct s \*'} } */ ue_fn_ptr6 = &s; /* { dg-error {assignment to 'void \(\*\)\(user_enum_copy, \.\.\.\)' {aka 'void \(\*\)\(enum __internal_enum, \.\.\.\)'} from incompatible pointer type 'struct s \*'} } */ - unsafe_ue_fn_ptr1 = &s; /* { dg-error {assignment to 'user_enum \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)' {aka 'enum __internal_enum \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ - unsafe_ue_fn_ptr2 = &s; /* { dg-error {assignment to 'user_enum_copy \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)' {aka 'enum __internal_enum \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ + unsafe_ue_fn_ptr1 = &s; /* { dg-error {assignment to 'user_enum \(\*__attribute__\(\(transaction_unsafe\)\)\)\(void\)' {aka 'enum __internal_enum \(\*__attribute__\(\(transaction_unsafe\)\)\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ + unsafe_ue_fn_ptr2 = &s; /* { dg-error {assignment to 'user_enum_copy \(\*__attribute__\(\(transaction_unsafe\)\)\)\(void\)' {aka 'enum __internal_enum \(\*__attribute__\(\(transaction_unsafe\)\)\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ us1 = s; /* { dg-error {assigning to type 'user_struct' {aka 'struct __internal_struct'} from type 'struct s'} } */ us2 = s; /* { dg-error {assigning to type 'user_struct_copy' {aka 'struct __internal_struct'} from type 'struct s'} } */ @@ -129,6 +129,6 @@ void f (struct s s) ui_fn_ptr4 = &s; /* { dg-error {assignment to 'user_int_copy \(\*\)\(void\)' {aka 'int \(\*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ ui_fn_ptr5 = &s; /* { dg-error {assignment to 'void \(\*\)\(user_int_copy\)' {aka 'void \(\*\)\(int\)'} from incompatible pointer type 'struct s \*'} } */ ui_fn_ptr6 = &s; /* { dg-error {assignment to 'void \(\*\)\(user_int_copy, \.\.\.\)' {aka 'void \(\*\)\(int, \.\.\.\)'} from incompatible pointer type 'struct s \*'} } */ - unsafe_ui_fn_ptr1 = &s; /* { dg-error {assignment to 'user_int \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)' {aka 'int \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ - unsafe_ui_fn_ptr2 = &s; /* { dg-error {assignment to 'user_int_copy \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)' {aka 'int \(__attribute__\(\(transaction_unsafe\)\) \*\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ + unsafe_ui_fn_ptr1 = &s; /* { dg-error {assignment to 'user_int \(\*__attribute__\(\(transaction_unsafe\)\)\)\(void\)' {aka 'int \(\*__attribute__\(\(transaction_unsafe\)\)\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ + unsafe_ui_fn_ptr2 = &s; /* { dg-error {assignment to 'user_int_copy \(\*__attribute__\(\(transaction_unsafe\)\)\)\(void\)' {aka 'int \(\*__attribute__\(\(transaction_unsafe\)\)\)\(void\)'} from incompatible pointer type 'struct s \*'} } */ }