diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-14 04:41:43 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-14 04:41:43 +0000 |
commit | fa8ed26bf55154209a82c54ca4f3bbb7b65a280d (patch) | |
tree | 97ad70a23b265deb3ad4b09c18d9cf2bd1cd9038 | |
parent | 21ebcb6c628ff78fdae8d7b4132eeed62fca79b8 (diff) |
PR c++/50075
* name-lookup.c (local_bindings_p): New.
* name-lookup.h: Declare it.
* lex.c (unqualified_name_lookup_error): Use it.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@177743 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/lex.c | 2 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 9 | ||||
-rw-r--r-- | gcc/cp/name-lookup.h | 1 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/decltype32.C | 12 |
6 files changed, 31 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2f2b3069b78..c5ecf55fb61 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2011-08-13 Jason Merrill <jason@redhat.com> + PR c++/50075 + * name-lookup.c (local_bindings_p): New. + * name-lookup.h: Declare it. + * lex.c (unqualified_name_lookup_error): Use it. + PR c++/50059 * error.c (dump_expr): Handle MODIFY_EXPR properly. diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index 691a2ec1311..c11e3b31561 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -456,7 +456,7 @@ unqualified_name_lookup_error (tree name) } /* Prevent repeated error messages by creating a VAR_DECL with this NAME in the innermost block scope. */ - if (current_function_decl) + if (local_bindings_p ()) { tree decl; decl = build_decl (input_location, diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 1afd9edffec..64456b49699 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -1608,6 +1608,15 @@ namespace_bindings_p (void) return b->kind == sk_namespace; } +/* True if the innermost non-class scope is a block scope. */ + +bool +local_bindings_p (void) +{ + cp_binding_level *b = innermost_nonclass_level (); + return b->kind < sk_function_parms || b->kind == sk_omp; +} + /* True if the current level needs to have a BLOCK made. */ bool diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h index 5974dce3288..a37afdb9b33 100644 --- a/gcc/cp/name-lookup.h +++ b/gcc/cp/name-lookup.h @@ -292,6 +292,7 @@ extern bool kept_level_p (void); extern bool global_bindings_p (void); extern bool toplevel_bindings_p (void); extern bool namespace_bindings_p (void); +extern bool local_bindings_p (void); extern bool template_parm_scope_p (void); extern scope_kind innermost_scope_kind (void); extern cp_binding_level *begin_scope (scope_kind, tree); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6a13f664b11..a14be3d00d4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2011-08-13 Jason Merrill <jason@redhat.com> + PR c++/50075 + * g++.dg/cpp0x/decltype32.C: New. + PR c++/50059 * g++.dg/diagnostic/expr1.C: New. diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype32.C b/gcc/testsuite/g++.dg/cpp0x/decltype32.C new file mode 100644 index 00000000000..66731cc947d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype32.C @@ -0,0 +1,12 @@ +// PR c++/50075 +// { dg-options -std=c++0x } + +template <typename T> +auto make_array(const T& il) -> // { dg-error "not declared" } +decltype(make_array(il)) +{ } + +int main() +{ + int z = make_array(1); // { dg-error "no match" } +} |