OSDN Git Service

PR c++/47208
authordodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 18 Feb 2011 08:47:56 +0000 (08:47 +0000)
committerdodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 18 Feb 2011 08:47:56 +0000 (08:47 +0000)
gcc/cp/

PR c++/47208
* pt.c (do_auto_deduction): Do not mention error_mark_node in
diagnostics.
* semantics.c (finish_id_expression): Do not pass erroneous decl
to decl_constant_var_p.

gcc/testsuite/

PR c++/47208
* g++.dg/cpp0x/auto21.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170268 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/auto21.C [new file with mode: 0644]

index ae368a1..db9fa89 100644 (file)
@@ -1,3 +1,11 @@
+2011-02-18  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/47208
+       * pt.c (do_auto_deduction): Do not mention error_mark_node in
+       diagnostics.
+       * semantics.c (finish_id_expression): Do not pass erroneous decl
+       to decl_constant_var_p.
+
 2011-02-17  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/47783
index 02b8d15..4990636 100644 (file)
@@ -18926,7 +18926,11 @@ do_auto_deduction (tree type, tree init, tree auto_node)
                               DEDUCE_CALL, LOOKUP_NORMAL);
   if (val > 0)
     {
-      error ("unable to deduce %qT from %qE", type, init);
+      if (type && type != error_mark_node)
+       /* If type is error_mark_node a diagnostic must have been
+          emitted by now.  Also, having a mention to '<type error>'
+          in the diagnostic is not really useful to the user.  */
+       error ("unable to deduce %qT from %qE", type, init);
       return error_mark_node;
     }
 
index daa7280..1ad707b 100644 (file)
@@ -3148,7 +3148,8 @@ finish_id_expression (tree id_expression,
       /* Only certain kinds of names are allowed in constant
         expression.  Enumerators and template parameters have already
         been handled above.  */
-      if (integral_constant_expression_p
+      if (! error_operand_p (decl)
+         && integral_constant_expression_p
          && ! decl_constant_var_p (decl)
          && ! builtin_valid_in_constant_expr_p (decl))
        {
index 274da7e..2b4e1fa 100644 (file)
@@ -1,3 +1,8 @@
+2011-02-18  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/47208
+       * g++.dg/cpp0x/auto21.C: New test.
+
 2011-02-17  Iain Sandoe  <iains@gcc.gnu.org>
 
        * objc.dg/special/unclaimed-category-1.h: Updated for
diff --git a/gcc/testsuite/g++.dg/cpp0x/auto21.C b/gcc/testsuite/g++.dg/cpp0x/auto21.C
new file mode 100644 (file)
index 0000000..1cbcac5
--- /dev/null
@@ -0,0 +1,5 @@
+// Origin PR c++/47208
+// { dg-options "-std=c++0x" }
+
+constexpr auto list = { }; // { dg-error "deducing from brace-enclosed initializer list requires #include <initializer_list>" }
+static const int l = list.size();