public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51145] New: [C++11][DR1131] Alias template in elaborated-type-specifier accepted
@ 2011-11-15 19:50 daniel.kruegler at googlemail dot com
  2011-11-15 21:01 ` [Bug c++/51145] " jason at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-11-15 19:50 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51145
           Summary: [C++11][DR1131] Alias template in
                    elaborated-type-specifier accepted
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: daniel.kruegler@googlemail.com
                CC: jason@redhat.com


gcc 4.7.0 20111112 (experimental) in C++11 mode accepts the following code:

//---
struct A {};

template<class>
using X = A;

struct X<int>* px;

template<int>
using Y = A;

struct Y<0>* py;
//---

According to 7.1.6.3 [dcl.type.elab] p2 both elaborated-type-specifier usages
in the definition of px and py should be rejected:

"If the identifier resolves to a typedef-name or the simple-template-id
resolves to an alias template specialization, the elaborated-type-specifier is
ill-formed."

This sentence was added to honor NB comment US 41 via:

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1131


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

* [Bug c++/51145] [C++11][DR1131] Alias template in elaborated-type-specifier accepted
  2011-11-15 19:50 [Bug c++/51145] New: [C++11][DR1131] Alias template in elaborated-type-specifier accepted daniel.kruegler at googlemail dot com
@ 2011-11-15 21:01 ` jason at gcc dot gnu.org
  2011-11-17 21:37 ` [Bug c++/51145] [C++11][DR 1131] " dodji at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2011-11-15 21:01 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|jason at redhat dot com     |dodji at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org

--- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> 2011-11-15 20:30:38 UTC ---
Please add Dodji to CC for alias issues.


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

* [Bug c++/51145] [C++11][DR 1131] Alias template in elaborated-type-specifier accepted
  2011-11-15 19:50 [Bug c++/51145] New: [C++11][DR1131] Alias template in elaborated-type-specifier accepted daniel.kruegler at googlemail dot com
  2011-11-15 21:01 ` [Bug c++/51145] " jason at gcc dot gnu.org
@ 2011-11-17 21:37 ` dodji at gcc dot gnu.org
  2011-11-18  0:07 ` dodji at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dodji at gcc dot gnu.org @ 2011-11-17 21:37 UTC (permalink / raw)
  To: gcc-bugs

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

Dodji Seketeli <dodji at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2011-11-17
         AssignedTo|unassigned at gcc dot       |dodji at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1


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

* [Bug c++/51145] [C++11][DR 1131] Alias template in elaborated-type-specifier accepted
  2011-11-15 19:50 [Bug c++/51145] New: [C++11][DR1131] Alias template in elaborated-type-specifier accepted daniel.kruegler at googlemail dot com
  2011-11-15 21:01 ` [Bug c++/51145] " jason at gcc dot gnu.org
  2011-11-17 21:37 ` [Bug c++/51145] [C++11][DR 1131] " dodji at gcc dot gnu.org
@ 2011-11-18  0:07 ` dodji at gcc dot gnu.org
  2011-11-18 13:25 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dodji at gcc dot gnu.org @ 2011-11-18  0:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Dodji Seketeli <dodji at gcc dot gnu.org> 2011-11-18 00:03:04 UTC ---
Created attachment 25849
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25849
Candidate patch

I am currently testing the attached patch.  Note that the hunk of pt.c should
be committed separately as a fix for PR c++/51191; I am including it here so
that this patch can be tested in isolation.

On the example provided, I am getting the following output with the patch
applied:

$ cat -n test.cc
     1    struct A {};
     2    
     3    template<class>
     4    using X = A;
     5    
     6    struct X<int>* px;
     7    
     8    template<int>
     9    using Y = A;
    10    
    11    struct Y<0>* py;

$ ./cc1plus -quiet -std=c++0x test.cc
test.cc:6:8: error: using alias template specialization ‘X<int> {aka A}’ after
‘struct’
test.cc:6:18: error: invalid type in declaration before ‘;’ token
test.cc:11:8: error: using alias template specialization ‘Y<0> {aka A}’ after
‘struct’
test.cc:11:16: error: invalid type in declaration before ‘;’ token
$


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

* [Bug c++/51145] [C++11][DR 1131] Alias template in elaborated-type-specifier accepted
  2011-11-15 19:50 [Bug c++/51145] New: [C++11][DR1131] Alias template in elaborated-type-specifier accepted daniel.kruegler at googlemail dot com
                   ` (2 preceding siblings ...)
  2011-11-18  0:07 ` dodji at gcc dot gnu.org
@ 2011-11-18 13:25 ` jason at gcc dot gnu.org
  2011-11-18 19:35 ` dodji at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2011-11-18 13:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2011-11-18 13:11:48 UTC ---
(In reply to comment #2)
> -      error ("using typedef-name %qD after %qs", decl, tag_name (tag_code));
> -      error ("%q+D has a previous declaration here", decl);
> +      if (alias_template_specialization_p (type))
> +	error ("using alias template specialization %qT after %qs",
> +	       type, tag_name (tag_code));
> +      else
> +	{
> +	  error ("using typedef-name %qD after %qs", decl, tag_name (tag_code));
> +	  error ("%q+D has a previous declaration here", decl);
> +	}

Let's share the "previous declaration" message between the two cases, and
change it to inform.


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

* [Bug c++/51145] [C++11][DR 1131] Alias template in elaborated-type-specifier accepted
  2011-11-15 19:50 [Bug c++/51145] New: [C++11][DR1131] Alias template in elaborated-type-specifier accepted daniel.kruegler at googlemail dot com
                   ` (3 preceding siblings ...)
  2011-11-18 13:25 ` jason at gcc dot gnu.org
@ 2011-11-18 19:35 ` dodji at gcc dot gnu.org
  2011-11-23  9:22 ` dodji at gcc dot gnu.org
  2011-11-23  9:27 ` dodji at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: dodji at gcc dot gnu.org @ 2011-11-18 19:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Dodji Seketeli <dodji at gcc dot gnu.org> 2011-11-18 19:16:52 UTC ---
A candidate fix has been posted to
http://gcc.gnu.org/ml/gcc-patches/2011-11/msg01945.html


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

* [Bug c++/51145] [C++11][DR 1131] Alias template in elaborated-type-specifier accepted
  2011-11-15 19:50 [Bug c++/51145] New: [C++11][DR1131] Alias template in elaborated-type-specifier accepted daniel.kruegler at googlemail dot com
                   ` (4 preceding siblings ...)
  2011-11-18 19:35 ` dodji at gcc dot gnu.org
@ 2011-11-23  9:22 ` dodji at gcc dot gnu.org
  2011-11-23  9:27 ` dodji at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: dodji at gcc dot gnu.org @ 2011-11-23  9:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Dodji Seketeli <dodji at gcc dot gnu.org> 2011-11-23 08:24:08 UTC ---
Author: dodji
Date: Wed Nov 23 08:23:59 2011
New Revision: 181653

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181653
Log:
PR c++/51145 - Alias template in elaborated-type-specifier accepted

gcc/cp/

    PR c++/51145
    * decl.c (check_elaborated_type_specifier): Gracefully handle
    error_mark_node.  Accept bound template template parameters.
    Update diagnostics for alias template specializations.  Update
    comment.
    * parser.c (cp_parser_elaborated_type_specifier): Use
    check_elaborated_type_specifier for simple-template-ids as well.

gcc/testsuite/

    PR c++/51145
    * g++.dg/cpp0x/alias-decl-14.C: New test.
    * g++.dg/cpp0x/alias-decl-2.C: Adjust for tests that were wrongly
    passing before.
    * g++.dg/cpp0x/alias-decl-10.C: Likewise and adjust for diagnostic
    change.
    * g++.dg/ext/attrib27.C: Adjust for diagnostic change.
    * g++.dg/lookup/struct1.C: Likewise.
    * g++.dg/parse/elab1.C: Likewise.
    * g++.dg/parse/elab2.C: Likewise.
    * g++.dg/parse/int-as-enum1.C: Likewise.
    * g++.dg/parse/typedef1.C: Likewise.
    * g++.dg/parse/typedef3.C: Likewise.
    * g++.dg/parse/typedef4.C: Likewise.
    * g++.dg/parse/typedef5.C: Likewise.
    * g++.dg/template/crash26.C: Likewise.
    * g++.dg/template/nontype4.C: Likewise.
    * g++.old-deja/g++.benjamin/typedef01.C: Likewise.
    * g++.old-deja/g++.brendan/line1.C: Likewise.
    * g++.old-deja/g++.other/elab1.C: Likewise.
    * g++.old-deja/g++.other/syntax4.C: Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/alias-decl-14.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/cpp0x/alias-decl-10.C
    trunk/gcc/testsuite/g++.dg/cpp0x/alias-decl-2.C
    trunk/gcc/testsuite/g++.dg/ext/attrib27.C
    trunk/gcc/testsuite/g++.dg/lookup/struct1.C
    trunk/gcc/testsuite/g++.dg/parse/elab1.C
    trunk/gcc/testsuite/g++.dg/parse/elab2.C
    trunk/gcc/testsuite/g++.dg/parse/int-as-enum1.C
    trunk/gcc/testsuite/g++.dg/parse/typedef1.C
    trunk/gcc/testsuite/g++.dg/parse/typedef3.C
    trunk/gcc/testsuite/g++.dg/parse/typedef4.C
    trunk/gcc/testsuite/g++.dg/parse/typedef5.C
    trunk/gcc/testsuite/g++.dg/template/crash26.C
    trunk/gcc/testsuite/g++.dg/template/nontype4.C
    trunk/gcc/testsuite/g++.old-deja/g++.benjamin/typedef01.C
    trunk/gcc/testsuite/g++.old-deja/g++.brendan/line1.C
    trunk/gcc/testsuite/g++.old-deja/g++.other/elab1.C
    trunk/gcc/testsuite/g++.old-deja/g++.other/syntax4.C


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

* [Bug c++/51145] [C++11][DR 1131] Alias template in elaborated-type-specifier accepted
  2011-11-15 19:50 [Bug c++/51145] New: [C++11][DR1131] Alias template in elaborated-type-specifier accepted daniel.kruegler at googlemail dot com
                   ` (5 preceding siblings ...)
  2011-11-23  9:22 ` dodji at gcc dot gnu.org
@ 2011-11-23  9:27 ` dodji at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: dodji at gcc dot gnu.org @ 2011-11-23  9:27 UTC (permalink / raw)
  To: gcc-bugs

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

Dodji Seketeli <dodji at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #6 from Dodji Seketeli <dodji at gcc dot gnu.org> 2011-11-23 08:25:58 UTC ---
Should be fixed in trunk (4.7) now.


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

end of thread, other threads:[~2011-11-23  8:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-15 19:50 [Bug c++/51145] New: [C++11][DR1131] Alias template in elaborated-type-specifier accepted daniel.kruegler at googlemail dot com
2011-11-15 21:01 ` [Bug c++/51145] " jason at gcc dot gnu.org
2011-11-17 21:37 ` [Bug c++/51145] [C++11][DR 1131] " dodji at gcc dot gnu.org
2011-11-18  0:07 ` dodji at gcc dot gnu.org
2011-11-18 13:25 ` jason at gcc dot gnu.org
2011-11-18 19:35 ` dodji at gcc dot gnu.org
2011-11-23  9:22 ` dodji at gcc dot gnu.org
2011-11-23  9:27 ` dodji at gcc dot gnu.org

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