diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2013-07-06 08:54:56 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2013-07-06 08:54:56 +0000 |
commit | 5504e5d864f7b9c83727669847396c639abdf77b (patch) | |
tree | 0b0bbcb0102dac83bf4b9a61a67885dcc67f3b9a /gcc | |
parent | 90b0f444fa56c5282c8543a7191095eabd79529a (diff) | |
download | gcc-5504e5d864f7b9c83727669847396c639abdf77b.zip gcc-5504e5d864f7b9c83727669847396c639abdf77b.tar.gz gcc-5504e5d864f7b9c83727669847396c639abdf77b.tar.bz2 |
re PR c++/28262 (Inconsistent "default arguments are only permitted for function parameters".)
/cp
2013-07-06 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/28262
* parser.c (cp_parser_init_declarator): If we are parsing a typedef
set parser->default_arg_ok_p to false before cp_parser_declarator.
/testsuite
2013-07-06 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/28262
* g++.dg/parse/defarg16.C: New.
From-SVN: r200730
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/parser.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/defarg16.C | 4 |
4 files changed, 22 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c45c8be..333249a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2013-07-06 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/28262 + * parser.c (cp_parser_init_declarator): If we are parsing a typedef + set parser->default_arg_ok_p to false before cp_parser_declarator. + 2013-07-05 Paolo Carlini <paolo.carlini@oracle.com> PR c++/14263 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 46a8deb..05643e4 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -16182,6 +16182,7 @@ cp_parser_init_declarator (cp_parser* parser, bool friend_p; tree pushed_scope = NULL_TREE; bool range_for_decl_p = false; + bool saved_default_arg_ok_p = parser->default_arg_ok_p; /* Gather the attributes that were provided with the decl-specifiers. */ @@ -16192,6 +16193,10 @@ cp_parser_init_declarator (cp_parser* parser, if (function_definition_p) *function_definition_p = false; + /* Default arguments are only permitted for function parameters. */ + if (decl_spec_seq_has_spec_p (decl_specifiers, ds_typedef)) + parser->default_arg_ok_p = false; + /* Defer access checks while parsing the declarator; we cannot know what names are accessible until we know what is being declared. */ @@ -16207,6 +16212,8 @@ cp_parser_init_declarator (cp_parser* parser, /* Gather up the deferred checks. */ stop_deferring_access_checks (); + parser->default_arg_ok_p = saved_default_arg_ok_p; + /* If the DECLARATOR was erroneous, there's no need to go further. */ if (declarator == cp_error_declarator) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b84de4b..7161536 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-07-06 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/28262 + * g++.dg/parse/defarg16.C: New. + 2013-07-05 Vladimir Makarov <vmakarov@redhat.com> PR rtl-optimization/55342 diff --git a/gcc/testsuite/g++.dg/parse/defarg16.C b/gcc/testsuite/g++.dg/parse/defarg16.C new file mode 100644 index 0000000..8eb0014 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/defarg16.C @@ -0,0 +1,4 @@ +// PR c++/28262 + +typedef void (funcptrhack) (int = 10); // { dg-error "default arguments" } +typedef funcptrhack * funcptr; |