public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/42056] ICE with invalid use of auto in template
       [not found] <bug-42056-4@http.gcc.gnu.org/bugzilla/>
@ 2011-05-26 16:23 ` paolo.carlini at oracle dot com
  2011-05-26 16:28 ` jason at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-05-26 16:23 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42056

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-05-26 16:14:51 UTC ---
To summarize, in current 4.6 and mainline at least, a C++0x warning is emitted
in C++03 mode and then both snippets are simply accepted. Errors are then
produced at instantiation time. Indeed, cp_parser_simple_type_specifier does
just:

    case RID_AUTO:
      maybe_warn_cpp0x (CPP0X_AUTO);
      type = make_auto ();
      break;

thus, by design, no chances for hard errors at parsing time. Jason, do we want
to improve this?


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/42056] ICE with invalid use of auto in template
       [not found] <bug-42056-4@http.gcc.gnu.org/bugzilla/>
  2011-05-26 16:23 ` [Bug c++/42056] ICE with invalid use of auto in template paolo.carlini at oracle dot com
@ 2011-05-26 16:28 ` jason at gcc dot gnu.org
  2011-05-26 17:01 ` paolo.carlini at oracle dot com
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2011-05-26 16:28 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42056

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.05.26 16:23:02
     Ever Confirmed|0                           |1

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2011-05-26 16:23:02 UTC ---
Sounds like build_functional_cast should check type_uses_auto.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/42056] ICE with invalid use of auto in template
       [not found] <bug-42056-4@http.gcc.gnu.org/bugzilla/>
  2011-05-26 16:23 ` [Bug c++/42056] ICE with invalid use of auto in template paolo.carlini at oracle dot com
  2011-05-26 16:28 ` jason at gcc dot gnu.org
@ 2011-05-26 17:01 ` paolo.carlini at oracle dot com
  2011-05-26 17:12 ` paolo.carlini at oracle dot com
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-05-26 17:01 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42056

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-05-26 16:48:01 UTC ---
Eh, I decided to ask when I saw your fix for 48599 involving type_uses_auto ;)
Anyway, the below indeed appears to work pretty well. Is the error message Ok
with you?


Index: typeck2.c
===================================================================
--- typeck2.c   (revision 174295)
+++ typeck2.c   (working copy)
@@ -1590,6 +1590,14 @@ build_functional_cast (tree exp, tree parms, tsubs
   else
     type = exp;

+  if (type_uses_auto (type))
+    {
+      if (complain & tf_error)
+       error ("expected an expression");
+      else
+       return error_mark_node;
+    }
+
   /* We need to check this explicitly, since value-initialization of
      arrays is allowed in other situations.  */
   if (TREE_CODE (type) == ARRAY_TYPE)


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/42056] ICE with invalid use of auto in template
       [not found] <bug-42056-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2011-05-26 17:01 ` paolo.carlini at oracle dot com
@ 2011-05-26 17:12 ` paolo.carlini at oracle dot com
  2011-05-26 18:03 ` paolo.carlini at oracle dot com
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-05-26 17:12 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42056

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|paolo.carlini at oracle dot |
                   |com                         |
         AssignedTo|unassigned at gcc dot       |paolo.carlini at oracle dot
                   |gnu.org                     |com


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/42056] ICE with invalid use of auto in template
       [not found] <bug-42056-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2011-05-26 17:12 ` paolo.carlini at oracle dot com
@ 2011-05-26 18:03 ` paolo.carlini at oracle dot com
  2011-05-26 18:28 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-05-26 18:03 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42056

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-05-26 18:01:42 UTC ---
Actually, I can do better.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/42056] ICE with invalid use of auto in template
       [not found] <bug-42056-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2011-05-26 18:03 ` paolo.carlini at oracle dot com
@ 2011-05-26 18:28 ` jason at gcc dot gnu.org
  2011-05-26 19:40 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2011-05-26 18:28 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42056

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> 2011-05-26 18:25:40 UTC ---
(In reply to comment #4)
> +       error ("expected an expression");

That sounds like a parse error, when the real issue is a semantic constraint
violation: it would make perfect sense to write auto(1) except that 7.1.6.4
says we can't.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/42056] ICE with invalid use of auto in template
       [not found] <bug-42056-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2011-05-26 18:28 ` jason at gcc dot gnu.org
@ 2011-05-26 19:40 ` paolo.carlini at oracle dot com
  2011-05-27 14:23 ` paolo at gcc dot gnu.org
  2011-05-27 14:32 ` paolo.carlini at oracle dot com
  8 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-05-26 19:40 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42056

--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-05-26 19:29:05 UTC ---
I see, agreed. Actual patch posted here:

  http://gcc.gnu.org/ml/gcc-patches/2011-05/msg02081.html


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/42056] ICE with invalid use of auto in template
       [not found] <bug-42056-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2011-05-26 19:40 ` paolo.carlini at oracle dot com
@ 2011-05-27 14:23 ` paolo at gcc dot gnu.org
  2011-05-27 14:32 ` paolo.carlini at oracle dot com
  8 siblings, 0 replies; 10+ messages in thread
From: paolo at gcc dot gnu.org @ 2011-05-27 14:23 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42056

--- Comment #8 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2011-05-27 14:21:39 UTC ---
Author: paolo
Date: Fri May 27 14:21:33 2011
New Revision: 174337

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174337
Log:
/cp
2011-05-27  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/42056
    * typeck2.c (build_functional_cast): Complain early for invalid uses
    of 'auto' and set type to error_mark_node.

/testsuite
2011-05-27  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/42056
    * testsuite/g++.dg/cpp0x/auto25.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/auto25.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/typeck2.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/42056] ICE with invalid use of auto in template
       [not found] <bug-42056-4@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2011-05-27 14:23 ` paolo at gcc dot gnu.org
@ 2011-05-27 14:32 ` paolo.carlini at oracle dot com
  8 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-05-27 14:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42056

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0

--- Comment #9 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-05-27 14:23:15 UTC ---
Fixed for 4.7.0.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/42056] ICE with invalid use of auto in template
  2009-11-15 21:23 [Bug c++/42056] New: " reichelt at gcc dot gnu dot org
@ 2010-05-04 16:32 ` paolo dot carlini at oracle dot com
  0 siblings, 0 replies; 10+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-05-04 16:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from paolo dot carlini at oracle dot com  2010-05-04 16:32 -------
Apparently now *both* snippets are wrongly accepted, at least in mainline.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42056


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-05-27 14:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-42056-4@http.gcc.gnu.org/bugzilla/>
2011-05-26 16:23 ` [Bug c++/42056] ICE with invalid use of auto in template paolo.carlini at oracle dot com
2011-05-26 16:28 ` jason at gcc dot gnu.org
2011-05-26 17:01 ` paolo.carlini at oracle dot com
2011-05-26 17:12 ` paolo.carlini at oracle dot com
2011-05-26 18:03 ` paolo.carlini at oracle dot com
2011-05-26 18:28 ` jason at gcc dot gnu.org
2011-05-26 19:40 ` paolo.carlini at oracle dot com
2011-05-27 14:23 ` paolo at gcc dot gnu.org
2011-05-27 14:32 ` paolo.carlini at oracle dot com
2009-11-15 21:23 [Bug c++/42056] New: " reichelt at gcc dot gnu dot org
2010-05-04 16:32 ` [Bug c++/42056] " paolo dot carlini at oracle dot com

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).