public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51786] New: [c++0x] Invalid declaration with decltype accepted
@ 2012-01-07 16:16 reichelt at gcc dot gnu.org
2012-01-16 18:14 ` [Bug c++/51786] " paolo.carlini at oracle dot com
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: reichelt at gcc dot gnu.org @ 2012-01-07 16:16 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51786
Bug #: 51786
Summary: [c++0x] Invalid declaration with decltype accepted
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: reichelt@gcc.gnu.org
The error message "declaration does not declare anything" is not
triggered in certain cases when using decltype:
===================================
struct A {};
void foo() { decltype(A()); }
===================================
It *is* triggered if I write decltype(int) instead.
Another testcase is the following:
===================================
template<int> struct A
{
A() { decltype(this); }
};
A<0> a;
===================================
It *is* triggered if I make A a non-template class.
This bug is similar to PR21120 where the same problems occured with "typeof".
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/51786] [c++0x] Invalid declaration with decltype accepted
2012-01-07 16:16 [Bug c++/51786] New: [c++0x] Invalid declaration with decltype accepted reichelt at gcc dot gnu.org
@ 2012-01-16 18:14 ` paolo.carlini at oracle dot com
2012-01-31 16:25 ` paolo.carlini at oracle dot com
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-01-16 18:14 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51786
--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-01-16 18:10:46 UTC ---
I'm still not sure an error message should be triggered in the first place.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/51786] [c++0x] Invalid declaration with decltype accepted
2012-01-07 16:16 [Bug c++/51786] New: [c++0x] Invalid declaration with decltype accepted reichelt at gcc dot gnu.org
2012-01-16 18:14 ` [Bug c++/51786] " paolo.carlini at oracle dot com
@ 2012-01-31 16:25 ` paolo.carlini at oracle dot com
2012-01-31 22:09 ` daniel.kruegler at googlemail dot com
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-01-31 16:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51786
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |daniel.kruegler at
| |googlemail dot com,
| |paolo.carlini at oracle dot
| |com
--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-01-31 15:56:47 UTC ---
Hi Daniel, are you willing to help triaging this?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/51786] [c++0x] Invalid declaration with decltype accepted
2012-01-07 16:16 [Bug c++/51786] New: [c++0x] Invalid declaration with decltype accepted reichelt at gcc dot gnu.org
2012-01-16 18:14 ` [Bug c++/51786] " paolo.carlini at oracle dot com
2012-01-31 16:25 ` paolo.carlini at oracle dot com
@ 2012-01-31 22:09 ` daniel.kruegler at googlemail dot com
2012-01-31 22:24 ` paolo.carlini at oracle dot com
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2012-01-31 22:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51786
--- Comment #3 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-01-31 21:26:41 UTC ---
It seems to me that all these examples should be rejected (Thanks to Jens
Maurer for helping me here): At first it seems, that we can follow the grammar
chain starting from /declaration/ in 7 [dcl.dcl] via
simple-declaration => decl-specifier-seq_opt init-declarator-list_opt;
without the optional init-declarator-list reaching
decl-specifier => type-specifier => trailing-type-specifier =>
simple-type-specifier => decltype(expression).
But the show-stopper for this is 7 [dcl.dcl] p3:
"In a simple-declaration, the optional init-declarator-list can be omitted only
when declaring a class (Clause 9) or enumeration (7.2), that is, when the
decl-specifier-seq contains either a class-specifier, an elaborated-type-
specifier with a class-key (9.1), or an enum-specifier. [..]"
Neither of these three situations applies, so this is no valid
/simple-declaration/.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/51786] [c++0x] Invalid declaration with decltype accepted
2012-01-07 16:16 [Bug c++/51786] New: [c++0x] Invalid declaration with decltype accepted reichelt at gcc dot gnu.org
` (2 preceding siblings ...)
2012-01-31 22:09 ` daniel.kruegler at googlemail dot com
@ 2012-01-31 22:24 ` paolo.carlini at oracle dot com
2012-10-16 10:49 ` paolo.carlini at oracle dot com
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-01-31 22:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51786
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-01-31
CC|paolo.carlini at oracle dot |
|com |
Ever Confirmed|0 |1
--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-01-31 21:37:08 UTC ---
Ah, thanks a lot Daniel (and Jens). Let's confirm this.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/51786] [c++0x] Invalid declaration with decltype accepted
2012-01-07 16:16 [Bug c++/51786] New: [c++0x] Invalid declaration with decltype accepted reichelt at gcc dot gnu.org
` (3 preceding siblings ...)
2012-01-31 22:24 ` paolo.carlini at oracle dot com
@ 2012-10-16 10:49 ` paolo.carlini at oracle dot com
2013-07-06 22:49 ` paolo.carlini at oracle dot com
2013-07-07 13:59 ` paolo.carlini at oracle dot com
6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-16 10:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51786
--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-16 10:49:22 UTC ---
The problem is that by the time at the end of cp_parser_simple_declaration we
call check_tag_decl (via shadow_tag), which is supposed to check that the
simple declaration is valid, we already called finish_decltype_type thus it
doesn't see the decltype, it sees something like:
void foo() { struct A; }
a valid simple declaration.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/51786] [c++0x] Invalid declaration with decltype accepted
2012-01-07 16:16 [Bug c++/51786] New: [c++0x] Invalid declaration with decltype accepted reichelt at gcc dot gnu.org
` (4 preceding siblings ...)
2012-10-16 10:49 ` paolo.carlini at oracle dot com
@ 2013-07-06 22:49 ` paolo.carlini at oracle dot com
2013-07-07 13:59 ` paolo.carlini at oracle dot com
6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-07-06 22:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51786
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |0coming.soon at gmail dot com
--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> ---
*** Bug 57502 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/51786] [c++0x] Invalid declaration with decltype accepted
2012-01-07 16:16 [Bug c++/51786] New: [c++0x] Invalid declaration with decltype accepted reichelt at gcc dot gnu.org
` (5 preceding siblings ...)
2013-07-06 22:49 ` paolo.carlini at oracle dot com
@ 2013-07-07 13:59 ` paolo.carlini at oracle dot com
6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-07-07 13:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51786
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |paolo.carlini at oracle dot com
--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> ---
On it.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-07-07 13:59 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-07 16:16 [Bug c++/51786] New: [c++0x] Invalid declaration with decltype accepted reichelt at gcc dot gnu.org
2012-01-16 18:14 ` [Bug c++/51786] " paolo.carlini at oracle dot com
2012-01-31 16:25 ` paolo.carlini at oracle dot com
2012-01-31 22:09 ` daniel.kruegler at googlemail dot com
2012-01-31 22:24 ` paolo.carlini at oracle dot com
2012-10-16 10:49 ` paolo.carlini at oracle dot com
2013-07-06 22:49 ` paolo.carlini at oracle dot com
2013-07-07 13:59 ` paolo.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).