// { dg-do run }
|
// { dg-do run }
|
// Copyright (C) 2000 Free Software Foundation, Inc.
|
// Copyright (C) 2000 Free Software Foundation, Inc.
|
// Contributed by Nathan Sidwell 3 Mar 2000
|
// Contributed by Nathan Sidwell 3 Mar 2000
|
|
|
// __PRETTY_FUNCTION__, __FUNCTION__ and __function__ should have the
|
// __PRETTY_FUNCTION__, __FUNCTION__ and __function__ should have the
|
// type char const [X], where X is the right value for that particular function
|
// type char const [X], where X is the right value for that particular function
|
|
|
static void const *strings[4];
|
static void const *strings[4];
|
static void const *tpls[4];
|
static void const *tpls[4];
|
static unsigned pos = 0;
|
static unsigned pos = 0;
|
static int fail;
|
static int fail;
|
static void const *ptr = 0;
|
static void const *ptr = 0;
|
|
|
void unover (char const (*)[5]) {}
|
void unover (char const (*)[5]) {}
|
void foo (char const (*)[5]) {}
|
void foo (char const (*)[5]) {}
|
void foo (void *) {fail = 1;}
|
void foo (void *) {fail = 1;}
|
void foo (void const *) {fail = 1;}
|
void foo (void const *) {fail = 1;}
|
void baz (char const (&)[5]) {}
|
void baz (char const (&)[5]) {}
|
|
|
template void PV (char const (&objRef)[I])
|
template void PV (char const (&objRef)[I])
|
{
|
{
|
strings[pos] = objRef;
|
strings[pos] = objRef;
|
tpls[pos] = __PRETTY_FUNCTION__;
|
tpls[pos] = __PRETTY_FUNCTION__;
|
pos++;
|
pos++;
|
}
|
}
|
|
|
void fn ()
|
void fn ()
|
{
|
{
|
PV (__FUNCTION__);
|
PV (__FUNCTION__);
|
PV (__func__);
|
PV (__func__);
|
PV (__PRETTY_FUNCTION__);
|
PV (__PRETTY_FUNCTION__);
|
PV ("wibble");
|
PV ("wibble");
|
}
|
}
|
|
|
void baz ()
|
void baz ()
|
{
|
{
|
ptr = __FUNCTION__;
|
ptr = __FUNCTION__;
|
// there should be no string const merging
|
// there should be no string const merging
|
if (ptr == "baz")
|
if (ptr == "baz")
|
fail = 1;
|
fail = 1;
|
// but all uses should be the same.
|
// but all uses should be the same.
|
if (ptr != __FUNCTION__)
|
if (ptr != __FUNCTION__)
|
fail = 1;
|
fail = 1;
|
}
|
}
|
int baz (int)
|
int baz (int)
|
{
|
{
|
return ptr == __FUNCTION__;
|
return ptr == __FUNCTION__;
|
}
|
}
|
|
|
int main ()
|
int main ()
|
{
|
{
|
// make sure we actually emit the VAR_DECL when needed, and things have the
|
// make sure we actually emit the VAR_DECL when needed, and things have the
|
// expected type.
|
// expected type.
|
foo (&__FUNCTION__);
|
foo (&__FUNCTION__);
|
baz (__FUNCTION__);
|
baz (__FUNCTION__);
|
unover (&__FUNCTION__);
|
unover (&__FUNCTION__);
|
if (fail)
|
if (fail)
|
return 1;
|
return 1;
|
|
|
// __FUNCTION__ should be unique across functions with the same base name
|
// __FUNCTION__ should be unique across functions with the same base name
|
// (it's a local static, _not_ a string).
|
// (it's a local static, _not_ a string).
|
baz ();
|
baz ();
|
if (fail)
|
if (fail)
|
return 1;
|
return 1;
|
if (baz (1))
|
if (baz (1))
|
return 1;
|
return 1;
|
fn ();
|
fn ();
|
|
|
// Check the names of fn. They should all be distinct strings (though two
|
// Check the names of fn. They should all be distinct strings (though two
|
// will have the same value).
|
// will have the same value).
|
if (strings[0] == strings[1])
|
if (strings[0] == strings[1])
|
return 1;
|
return 1;
|
if (strings[0] == strings[2])
|
if (strings[0] == strings[2])
|
return 1;
|
return 1;
|
if (strings[1] == strings[2])
|
if (strings[1] == strings[2])
|
return 1;
|
return 1;
|
|
|
// check the names of the template functions so invoked
|
// check the names of the template functions so invoked
|
if (tpls[0] != tpls[1])
|
if (tpls[0] != tpls[1])
|
return 1;
|
return 1;
|
if (tpls[0] == tpls[2])
|
if (tpls[0] == tpls[2])
|
return 1;
|
return 1;
|
|
|
return 0;
|
return 0;
|
}
|
}
|
|
|