public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/12577] New: typeof does not qualify as unqualified-id in certain contexts
@ 2003-10-11 12:59 gabor dot greif at lucent dot com
2003-10-11 16:26 ` [Bug c++/12577] " pinskia at gcc dot gnu dot org
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: gabor dot greif at lucent dot com @ 2003-10-11 12:59 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3582 bytes --]
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12577
Summary: typeof does not qualify as unqualified-id in certain
contexts
Product: gcc
Version: 3.4
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gabor dot greif at lucent dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: *-*-*
GCC host triplet: *-*-*
GCC target triplet: *-*-*
Compile this snippet:
-----------------------------
struct bar
{
void setfoobar(int);
int getfoobar(void) const;
static int (bar::* const getter1)(void) const;
};
template <typename S, typename T>
struct foo
{
static void (S::* const setter)(T);
static T (S::* const getter)(void) const;
};
template <>
void (bar::* const foo<bar, int>::setter)(int)
= &bar::setfoobar;
template <typename T>
T* JustAPointer(void);
template <>
void (bar::* const foo<bar,
__typeof__(JustAPointer<bar>()->getfoobar())>::setter)(
__typeof__(JustAPointer<bar>()->getfoobar()))
= &bar::setfoobar;
__typeof__(JustAPointer<bar>()->getfoobar()) bar::getfoobar() const
{
return 42;
}
//int (bar::* const bar::getter1)(void) const = &bar::getfoobar;
//(__typeof__(JustAPointer<bar>()->getfoobar())) (bar::* const
bar::getter1)(void) const = &bar::getfoobar;
//typename __typeof__(JustAPointer<bar>()->getfoobar()) (bar::* const
bar::getter1)(void) const = &bar::getfoobar;
__typeof__(JustAPointer<bar>()->getfoobar()) (bar::* const bar::getter1)(void)
const = &bar::getfoobar;
template <>
//__typeof__(JustAPointer<bar>()->getfoobar()) (bar::* const foo<bar,
__typeof__(JustAPointer<bar>()->getfoobar())>::setter)(void)
typeof(JustAPointer<bar>()->getfoobar()) (bar::* const foo<bar,
__typeof__(JustAPointer<bar>()->getfoobar())>::setter)(void)
= &bar::getfoobar;
----------------------------------
You get numerous error. I go thru them one by one:
foobar.cpp:25: error: duplicate initialization of foo<bar, int>::setter
foobar.cpp:25: error: redefinition of `void (bar::*const foo<bar,
int>::setter)(int)'
----> this is expected, it shows that typeof works as template argument.
foobar.cpp:18: error: `void (bar::*const foo<bar, int>::setter)(int)' previously
declared here
----> dito
foobar.cpp:35: error: expected unqualified-id
----> I'd expect that G++ accepts this. Previous
versions certainly did. So this is a regression with
the new C++ parser.
foobar.cpp:35: error: expected primary-expression
foobar.cpp:35: error: `JustAPointer() [with T = bar]()->bar::getfoobar()
const()' cannot be used as a function
foobar.cpp:35: error: expected primary-expression
foobar.cpp:35: error: expected unqualified-id
foobar.cpp:35: error: expected `,' or `;'
-----> I guess this is further junk because of the above.
foobar.cpp:39: error: `JustAPointer() [with T = bar]()->bar::getfoobar()
const()' cannot be used as a function
foobar.cpp:39: error: expected unqualified-id
foobar.cpp:39: error: expected primary-expression
foobar.cpp:39: error: expected primary-expression
foobar.cpp:39: error: `JustAPointer() [with T = bar]()->bar::getfoobar()
const()' cannot be used as a function
foobar.cpp:39: error: expected primary-expression
foobar.cpp:40: error: expected unqualified-id
-----> similarly. This is the actual problem I encountered in
our cource code. Also, this is the most omportant one to fix! :-)
Thanks in advance,
Gabor
^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <bug-12577-4@http.gcc.gnu.org/bugzilla/>]
* [Bug c++/12577] typeof does not qualify as unqualified-id in certain contexts
[not found] <bug-12577-4@http.gcc.gnu.org/bugzilla/>
@ 2012-01-20 1:34 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-01-20 1:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12577
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |WONTFIX
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-01-20 01:29:24 UTC ---
t.cc:26:45: error: redefinition of ‘void (bar::* const foo<bar,
int>::setter)(int)’
t.cc:17:46: error: ‘void (bar::* const foo<bar, int>::setter)(int)’ previously
declared here
t.cc:37:52: error: expected unqualified-id before ‘*’ token
t.cc:37:54: error: expected primary-expression before ‘const’
t.cc:37:72: error: ‘JustAPointer<bar>()->bar::getfoobar()’ cannot be used as a
function
t.cc:37:74: error: expected primary-expression before ‘void’
t.cc:38:7: error: expected unqualified-id before ‘=’ token
t.cc:42:52: error: expected unqualified-id before ‘*’ token
t.cc:42:54: error: expected primary-expression before ‘const’
t.cc:42:68: error: expected primary-expression before ‘__typeof__’
t.cc:42:121: error: ‘JustAPointer<bar>()->bar::getfoobar()’ cannot be used as a
function
t.cc:42:123: error: expected primary-expression before ‘void’
t.cc:43:5: error: expected unqualified-id before ‘=’ token
--- CUT ---
If I use decltype instead of typeof we get:
t.cc:27:45: error: redefinition of ‘void (bar::* const foo<bar,
int>::setter)(int)’
t.cc:18:46: error: ‘void (bar::* const foo<bar, int>::setter)(int)’ previously
declared here
t.cc:43:127: error: conflicting declaration ‘int (bar::* const foo<bar,
int>::setter)()’
t.cc:18:46: error: ‘foo<bar, int>::setter’ has a previous declaration as ‘void
(bar::* const foo<bar, int>::setter)(int)’
Which looks correct so I am going to close as won't fix as decltype is the more
correct choice now.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-01-20 1:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-11 12:59 [Bug c++/12577] New: typeof does not qualify as unqualified-id in certain contexts gabor dot greif at lucent dot com
2003-10-11 16:26 ` [Bug c++/12577] " pinskia at gcc dot gnu dot org
2003-10-11 16:29 ` pinskia at gcc dot gnu dot org
2003-11-12 3:16 ` mmitchel at gcc dot gnu dot org
[not found] <bug-12577-4@http.gcc.gnu.org/bugzilla/>
2012-01-20 1:34 ` pinskia 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).