public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Paolo Carlini <paolo.carlini@oracle.com>
To: Jason Merrill <jason@redhat.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [C++ Patch] PR 44625
Date: Thu, 23 Jun 2011 16:53:00 -0000	[thread overview]
Message-ID: <4E036EAE.5010507@oracle.com> (raw)
In-Reply-To: <4E036459.2090903@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 438 bytes --]

On 06/23/2011 06:05 PM, Jason Merrill wrote:
> So we should be able to just reject nested anonymous aggregates and 
> not worry about how to make them work.
The below appears to work pretty well, regtests fine. I had to tweak the 
existing error17.C, we don't emit anymore the warning about no members 
in the nested anonymous struct, because we bail out early. Doesn't seem 
a serious issue to me...

Ok?

Paolo.

//////////////////////

[-- Attachment #2: CL_44625_2 --]
[-- Type: text/plain, Size: 325 bytes --]

/cp
2011-06-23  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/44625
	* decl2.c (build_anon_union_vars): Early return error_mark_node
	for a nested anonymous struct.

/testsuite
2011-06-23  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/44625
	* g++.dg/template/crash107.C: New.
	* g++.dg/template/error17.C: Adjust.

[-- Attachment #3: patch_44625_2 --]
[-- Type: text/plain, Size: 1974 bytes --]

Index: testsuite/g++.dg/template/error17.C
===================================================================
--- testsuite/g++.dg/template/error17.C	(revision 175330)
+++ testsuite/g++.dg/template/error17.C	(working copy)
@@ -6,5 +6,4 @@ foo()
 {
   union { struct { }; }; // { dg-error "prohibits anonymous struct" "anon" }
   // { dg-error "not inside" "not inside" { target *-*-* } 7 }
-  // { dg-warning "no members" "no members" { target *-*-* } 7 }
 }
Index: testsuite/g++.dg/template/crash107.C
===================================================================
--- testsuite/g++.dg/template/crash107.C	(revision 0)
+++ testsuite/g++.dg/template/crash107.C	(revision 0)
@@ -0,0 +1,20 @@
+// PR c++/44625
+// { dg-do compile }
+// { dg-options "" }
+
+template<typename FP_> struct Vec { // { dg-message "note" }
+    Vec& operator^=(Vec& rhs)     {
+        union {
+            struct {FP_ x,y,z;};
+        }; // { dg-error "anonymous struct" }
+        X = y*rhs.z() - z*rhs.y(); // { dg-error "not declared|no member" }
+    }
+    Vec& operator^(Vec& rhs) {
+        return Vec(*this)^=rhs; // { dg-message "required" }
+    }
+};
+Vec<double> v(3,4,12); // { dg-error "no matching" }
+// { dg-message "note" { target *-*-* } 16 }
+Vec<double> V(12,4,3);  // { dg-error "no matching" }
+// { dg-message "note" { target *-*-* } 18 }
+Vec<double> c = v^V;   // { dg-message "required" }
Index: cp/decl2.c
===================================================================
--- cp/decl2.c	(revision 175335)
+++ cp/decl2.c	(working copy)
@@ -1327,7 +1327,10 @@ build_anon_union_vars (tree type, tree object)
   /* Rather than write the code to handle the non-union case,
      just give an error.  */
   if (TREE_CODE (type) != UNION_TYPE)
-    error ("anonymous struct not inside named type");
+    {
+      error ("anonymous struct not inside named type");
+      return error_mark_node;
+    }
 
   for (field = TYPE_FIELDS (type);
        field != NULL_TREE;

  parent reply	other threads:[~2011-06-23 16:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-23 11:56 Paolo Carlini
2011-06-23 15:17 ` Jason Merrill
2011-06-23 15:47   ` Paolo Carlini
2011-06-23 16:01     ` Jason Merrill
2011-06-23 16:06       ` Paolo Carlini
2011-06-23 16:06         ` Jason Merrill
2011-06-23 16:06           ` Jason Merrill
2011-06-23 16:13             ` Paolo Carlini
2011-06-23 16:19               ` Paolo Carlini
2011-06-23 16:53             ` Paolo Carlini [this message]
2011-06-23 16:54               ` Jason Merrill
2011-06-23 16:11           ` Paolo Carlini
  -- strict thread matches above, loose matches on Subject: below --
2010-07-05 11:52 Paolo Carlini
2010-07-05 13:10 ` Jason Merrill
2010-07-05 13:13   ` Paolo Carlini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E036EAE.5010507@oracle.com \
    --to=paolo.carlini@oracle.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).