mirror of git://gcc.gnu.org/git/gcc.git
re PR c++/64248 (Error: declarator-id missing; using reserved word ‘__FUNCTION__’)
PR c++/64248 Revert: * parser.c (cp_parser_unqualified_id): Handle __func__ here. (cp_parser_primary_expression): Not here. From-SVN: r218654
This commit is contained in:
parent
89631a4336
commit
8c7e9a616e
|
|
@ -1,5 +1,10 @@
|
||||||
2014-12-11 Jason Merrill <jason@redhat.com>
|
2014-12-11 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
|
PR c++/64248
|
||||||
|
Revert:
|
||||||
|
* parser.c (cp_parser_unqualified_id): Handle __func__ here.
|
||||||
|
(cp_parser_primary_expression): Not here.
|
||||||
|
|
||||||
PR c++/57510
|
PR c++/57510
|
||||||
* typeck2.c (split_nonconstant_init_1): Handle arrays here.
|
* typeck2.c (split_nonconstant_init_1): Handle arrays here.
|
||||||
(store_init_value): Not here.
|
(store_init_value): Not here.
|
||||||
|
|
|
||||||
|
|
@ -4503,9 +4503,39 @@ cp_parser_primary_expression (cp_parser *parser,
|
||||||
case RID_FUNCTION_NAME:
|
case RID_FUNCTION_NAME:
|
||||||
case RID_PRETTY_FUNCTION_NAME:
|
case RID_PRETTY_FUNCTION_NAME:
|
||||||
case RID_C99_FUNCTION_NAME:
|
case RID_C99_FUNCTION_NAME:
|
||||||
|
{
|
||||||
|
non_integral_constant name;
|
||||||
|
|
||||||
/* The symbols __FUNCTION__, __PRETTY_FUNCTION__, and
|
/* The symbols __FUNCTION__, __PRETTY_FUNCTION__, and
|
||||||
__func__ are the names of variables. */
|
__func__ are the names of variables -- but they are
|
||||||
goto id_expression;
|
treated specially. Therefore, they are handled here,
|
||||||
|
rather than relying on the generic id-expression logic
|
||||||
|
below. Grammatically, these names are id-expressions.
|
||||||
|
|
||||||
|
Consume the token. */
|
||||||
|
token = cp_lexer_consume_token (parser->lexer);
|
||||||
|
|
||||||
|
switch (token->keyword)
|
||||||
|
{
|
||||||
|
case RID_FUNCTION_NAME:
|
||||||
|
name = NIC_FUNC_NAME;
|
||||||
|
break;
|
||||||
|
case RID_PRETTY_FUNCTION_NAME:
|
||||||
|
name = NIC_PRETTY_FUNC;
|
||||||
|
break;
|
||||||
|
case RID_C99_FUNCTION_NAME:
|
||||||
|
name = NIC_C99_FUNC;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
gcc_unreachable ();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cp_parser_non_integral_constant_expression (parser, name))
|
||||||
|
return error_mark_node;
|
||||||
|
|
||||||
|
/* Look up the name. */
|
||||||
|
return finish_fname (token->u.value);
|
||||||
|
}
|
||||||
|
|
||||||
case RID_VA_ARG:
|
case RID_VA_ARG:
|
||||||
{
|
{
|
||||||
|
|
@ -4926,7 +4956,6 @@ cp_parser_unqualified_id (cp_parser* parser,
|
||||||
bool optional_p)
|
bool optional_p)
|
||||||
{
|
{
|
||||||
cp_token *token;
|
cp_token *token;
|
||||||
tree id;
|
|
||||||
|
|
||||||
/* Peek at the next token. */
|
/* Peek at the next token. */
|
||||||
token = cp_lexer_peek_token (parser->lexer);
|
token = cp_lexer_peek_token (parser->lexer);
|
||||||
|
|
@ -4935,6 +4964,8 @@ cp_parser_unqualified_id (cp_parser* parser,
|
||||||
{
|
{
|
||||||
case CPP_NAME:
|
case CPP_NAME:
|
||||||
{
|
{
|
||||||
|
tree id;
|
||||||
|
|
||||||
/* We don't know yet whether or not this will be a
|
/* We don't know yet whether or not this will be a
|
||||||
template-id. */
|
template-id. */
|
||||||
cp_parser_parse_tentatively (parser);
|
cp_parser_parse_tentatively (parser);
|
||||||
|
|
@ -5171,9 +5202,10 @@ cp_parser_unqualified_id (cp_parser* parser,
|
||||||
}
|
}
|
||||||
|
|
||||||
case CPP_KEYWORD:
|
case CPP_KEYWORD:
|
||||||
switch (token->keyword)
|
if (token->keyword == RID_OPERATOR)
|
||||||
{
|
{
|
||||||
case RID_OPERATOR:
|
tree id;
|
||||||
|
|
||||||
/* This could be a template-id, so we try that first. */
|
/* This could be a template-id, so we try that first. */
|
||||||
cp_parser_parse_tentatively (parser);
|
cp_parser_parse_tentatively (parser);
|
||||||
/* Try a template-id. */
|
/* Try a template-id. */
|
||||||
|
|
@ -5203,19 +5235,6 @@ cp_parser_unqualified_id (cp_parser* parser,
|
||||||
}
|
}
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
|
|
||||||
case RID_FUNCTION_NAME:
|
|
||||||
case RID_PRETTY_FUNCTION_NAME:
|
|
||||||
case RID_C99_FUNCTION_NAME:
|
|
||||||
cp_lexer_consume_token (parser->lexer);
|
|
||||||
/* Don't try to declare this while tentatively parsing a function
|
|
||||||
declarator, as cp_make_fname_decl will fail. */
|
|
||||||
if (current_binding_level->kind != sk_function_parms)
|
|
||||||
finish_fname (token->u.value);
|
|
||||||
return token->u.value;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
/* Fall through. */
|
/* Fall through. */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
// { dg-do compile { target c++11 } }
|
|
||||||
|
|
||||||
void f() {
|
|
||||||
typedef decltype(__func__) T;
|
|
||||||
T x = __func__; // { dg-error "array" }
|
|
||||||
}
|
|
||||||
|
|
@ -4,4 +4,3 @@
|
||||||
|
|
||||||
S () : str(__PRETTY_FUNCTION__) {} // { dg-error "forbids declaration" "decl" }
|
S () : str(__PRETTY_FUNCTION__) {} // { dg-error "forbids declaration" "decl" }
|
||||||
// { dg-error "only constructors" "constructor" { target *-*-* } 5 }
|
// { dg-error "only constructors" "constructor" { target *-*-* } 5 }
|
||||||
// { dg-prune-output "__PRETTY_FUNCTION__" }
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
// PR c++/64248
|
||||||
|
|
||||||
|
class A
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
A(const char* str) {};
|
||||||
|
};
|
||||||
|
|
||||||
|
class B
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
B(A a) {};
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
B b(A(__func__));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue