]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/cp/decl.c
Merge from trunk.
[thirdparty/gcc.git] / gcc / cp / decl.c
index 81a35004730b404c6f8e842e088c6e5660a43bd8..babfc8893b850e9fb32805225e97d75694bf765c 100644 (file)
@@ -31,6 +31,11 @@ along with GCC; see the file COPYING3.  If not see
 #include "coretypes.h"
 #include "tm.h"
 #include "tree.h"
+#include "stringpool.h"
+#include "stor-layout.h"
+#include "varasm.h"
+#include "attribs.h"
+#include "calls.h"
 #include "flags.h"
 #include "cp-tree.h"
 #include "tree-iterator.h"
@@ -1217,10 +1222,12 @@ validate_constexpr_redeclaration (tree old_decl, tree new_decl)
       if (! DECL_TEMPLATE_SPECIALIZATION (old_decl)
          && DECL_TEMPLATE_SPECIALIZATION (new_decl))
        return true;
+
+      error ("redeclaration %qD differs in %<constexpr%>", new_decl);
+      error ("from previous declaration %q+D", old_decl);
+      return false;
     }
-  error ("redeclaration %qD differs in %<constexpr%>", new_decl);
-  error ("from previous declaration %q+D", old_decl);
-  return false;
+  return true;
 }
 
 #define GNU_INLINE_P(fn) (DECL_DECLARED_INLINE_P (fn)                  \
@@ -4805,8 +4812,7 @@ check_array_designated_initializer (constructor_elt *ce,
       if (TREE_CODE (ce->index) == INTEGER_CST)
        {
          /* A C99 designator is OK if it matches the current index.  */
-         if (tree_fits_uhwi_p (ce->index) 
-             && tree_to_uhwi (ce->index) == index)
+         if (wi::eq_p (ce->index, index))
            return true;
          else
            sorry ("non-trivial designated initializers not supported");
@@ -5684,6 +5690,7 @@ check_initializer (tree decl, tree init, int flags, vec<tree, va_gc> **cleanups)
          && !(init && BRACE_ENCLOSED_INITIALIZER_P (init)
               && CP_AGGREGATE_TYPE_P (type)
               && (CLASS_TYPE_P (type)
+                  || !TYPE_NEEDS_CONSTRUCTING (type)
                   || type_has_extended_temps (type))))
        {
          init_code = build_aggr_init_full_exprs (decl, init, flags);
@@ -10031,7 +10038,7 @@ grokdeclarator (const cp_declarator *declarator,
     {
       error ("size of array %qs is too large", name);
       /* If we proceed with the array type as it is, we'll eventually
-        crash in tree_to_uhwi ().  */
+        crash in tree_to_[su]hwi().  */
       type = error_mark_node;
     }
 
@@ -10381,33 +10388,11 @@ grokdeclarator (const cp_declarator *declarator,
 
       if (type_uses_auto (type))
        {
-         if (template_parm_flag)
-           {
-             error ("template parameter declared %<auto%>");
-             type = error_mark_node;
-           }
-         else if (decl_context == CATCHPARM)
-           {
-             error ("catch parameter declared %<auto%>");
-             type = error_mark_node;
-           }
-         else if (current_class_type && LAMBDA_TYPE_P (current_class_type))
-           {
-             if (cxx_dialect < cxx1y)
-               pedwarn (location_of (type), 0,
-                        "use of %<auto%> in lambda parameter declaration "
-                        "only available with "
-                        "-std=c++1y or -std=gnu++1y");
-           }
-         else if (cxx_dialect < cxx1y)
-           pedwarn (location_of (type), 0,
-                    "use of %<auto%> in parameter declaration "
-                    "only available with "
-                    "-std=c++1y or -std=gnu++1y");
+         if (cxx_dialect >= cxx1y)
+           error ("%<auto%> parameter not permitted in this context");
          else
-           pedwarn (location_of (type), OPT_Wpedantic,
-                    "ISO C++ forbids use of %<auto%> in parameter "
-                    "declaration");
+           error ("parameter declared %<auto%>");
+         type = error_mark_node;
        }
 
       /* A parameter declared as an array of T is really a pointer to T.