This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/12577] New: typeof does not qualify as unqualified-id in certain contexts


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]