re PR c++/50075 ([C++0x] ICE related to parameter deduction and initializer_list)
authorJason Merrill <jason@redhat.com>
Sun, 14 Aug 2011 04:41:43 +0000 (00:41 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sun, 14 Aug 2011 04:41:43 +0000 (00:41 -0400)
PR c++/50075
* name-lookup.c (local_bindings_p): New.
* name-lookup.h: Declare it.
* lex.c (unqualified_name_lookup_error): Use it.

From-SVN: r177743

gcc/cp/ChangeLog
gcc/cp/lex.c
gcc/cp/name-lookup.c
gcc/cp/name-lookup.h
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/decltype32.C [new file with mode: 0644]

index 2f2b3069b7801ec21ba6c23df95ba65efe2bbef7..c5ecf55fb615794a26d49918758ceb370d4f6ddd 100644 (file)
@@ -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.
 
index 691a2ec1311b854912abbe4be90d0046cf65588c..c11e3b315610ee67c15f58d9dbfc19e08cade7aa 100644 (file)
@@ -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,
index 1afd9edffec795dd2248a742fc53fd3cabfde38b..64456b496998d15910d33f0f1fa23c8e6e7f7cb5 100644 (file)
@@ -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
index 5974dce328813c6bda77225330718944adb6d837..a37afdb9b33b252e09f6896568021e7517852d70 100644 (file)
@@ -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);
index 6a13f664b11518d9da7433a3d30b5f195c320a41..a14be3d00d48ba61c80e7eafd7efc51a0a3fcfce 100644 (file)
@@ -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 (file)
index 0000000..66731cc
--- /dev/null
@@ -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" }
+}