From patchwork Thu Sep 11 18:37:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siva Chandra Reddy X-Patchwork-Id: 2771 Received: (qmail 19086 invoked by alias); 11 Sep 2014 18:37:04 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 19076 invoked by uid 89); 11 Sep 2014 18:37:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f172.google.com Received: from mail-ob0-f172.google.com (HELO mail-ob0-f172.google.com) (209.85.214.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 11 Sep 2014 18:37:03 +0000 Received: by mail-ob0-f172.google.com with SMTP id wp18so3722574obc.3 for ; Thu, 11 Sep 2014 11:37:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=kW0Y3IgqtFdVctoMWDNIVuCN1yiEJKdTBxJgaQwIp8M=; b=ZH+4+5u5sksFSQtGunCmUow3xd5Wr4tlNFWA7NytosA13FxIg5vOgnKmMJpwqkJG51 6namAJE+HDfiejSnCYtesph2jsziEAtHp6Y2h7wuGG2f4O64xtEMrWuvD/oGhNfqw802 0dHTdqW/l5alWF5SIVq1w8TmWgyogqZlMepsL/WbIF35bIMFTUi4oUF1RK4zlZUbbej+ Gk9Su14QxpeQHjas0Tl/flquLGQICZxG1x9334MdiafhgL+kFmmDExH8P7LYNzubZCwD Lxgf42dMfNvFfRnAdl+9GmRLxRjilFcDvrVgi+vJfIim51NNrdmKztbX4yU6yNsUIS+E ncBQ== X-Gm-Message-State: ALoCoQnF7Jav76zmUOwPOn4nxhvBZZWmC67wIL7VEuuUABxGwKjqERfx1dYFIBLcPlsuwuXK3I9U MIME-Version: 1.0 X-Received: by 10.182.20.242 with SMTP id q18mr3212272obe.52.1410460620535; Thu, 11 Sep 2014 11:37:00 -0700 (PDT) Received: by 10.202.225.135 with HTTP; Thu, 11 Sep 2014 11:37:00 -0700 (PDT) Date: Thu, 11 Sep 2014 11:37:00 -0700 Message-ID: Subject: [PATCH 2/4] PR c++/13403 and PR c++/15154: Fix gnuv3_pass_by_reference to lookup copy c-tors with qualified args From: Siva Chandra To: gdb-patches X-IsSubscribed: yes Before this, a copy constructor declared as in the following snippet was not being treated as a copy constructor. class A { public: A (A &); // OK. A (const A &); // Not being treated as a copy constructor because of the // 'const' qualifier. }; gdb/ChangeLog: 2014-09-11 Siva Chandra Reddy PR c++/13403 PR c++/15154 * gdbtypes.c (make_qualified_type): Make non-static. * gdbtypes.h (make_qualified_type): Declare. * gnu-v3-abi.c (gnuv3_pass_by_reference): Lookup copy constructors with qualified args diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 1326f85..0f5093d 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -568,7 +568,7 @@ address_space_int_to_name (struct gdbarch *gdbarch, int space_flag) If STORAGE is non-NULL, create the new type instance there. STORAGE must be in the same obstack as TYPE. */ -static struct type * +struct type * make_qualified_type (struct type *type, int new_flags, struct type *storage) { diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index bd1a0ab..80ed725 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1647,6 +1647,9 @@ extern int address_space_name_to_int (struct gdbarch *, char *); extern const char *address_space_int_to_name (struct gdbarch *, int); +extern struct type *make_qualified_type (struct type *type, int new_flags, + struct type *storage); + extern struct type *make_type_with_address_space (struct type *type, int space_identifier); diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index d5ed355..a79a6a9 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -1313,11 +1313,19 @@ gnuv3_pass_by_reference (struct type *type) /* If this method takes two arguments, and the second argument is a reference to this class, then it is a copy constructor. */ - if (TYPE_NFIELDS (fieldtype) == 2 - && TYPE_CODE (TYPE_FIELD_TYPE (fieldtype, 1)) == TYPE_CODE_REF - && check_typedef (TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (fieldtype, - 1))) == type) - return 1; + if (TYPE_NFIELDS (fieldtype) == 2) + { + struct type *arg_type = TYPE_FIELD_TYPE (fieldtype, 1); + struct type *arg_target_type; + int flags; + + arg_target_type = check_typedef (TYPE_TARGET_TYPE (arg_type)); + flags = TYPE_INSTANCE_FLAGS (arg_target_type); + + if (TYPE_CODE (arg_type) == TYPE_CODE_REF + && arg_target_type == make_qualified_type (type, flags, NULL)) + return 1; + } } /* Even if all the constructors and destructors were artificial, one