]> gcc.gnu.org Git - gcc.git/commitdiff
c++: make cxx_incomplete_type_diagnostic return bool
authorJason Merrill <jason@redhat.com>
Thu, 13 Apr 2023 06:11:22 +0000 (02:11 -0400)
committerJason Merrill <jason@redhat.com>
Thu, 13 Apr 2023 18:59:31 +0000 (14:59 -0400)
Like other diagnostic functions that might be silenced by options, it should
return whether or not it actually emitted a diagnostic.

gcc/cp/ChangeLog:

* typeck2.cc (cxx_incomplete_type_diagnostic): Return bool.
* cp-tree.h (cxx_incomplete_type_diagnostic): Adjust.

gcc/cp/cp-tree.h
gcc/cp/typeck2.cc

index 622752ae4e6e9d5967f844f3c79e7cbbc5856d9c..a14eb8d0b9a538e49c3c53220a3df0bc6557091b 100644 (file)
@@ -8155,7 +8155,7 @@ extern void maybe_warn_pessimizing_move        (tree, tree, bool);
 
 /* in typeck2.cc */
 extern void require_complete_eh_spec_types     (tree, tree);
-extern void cxx_incomplete_type_diagnostic     (location_t, const_tree,
+extern bool cxx_incomplete_type_diagnostic     (location_t, const_tree,
                                                 const_tree, diagnostic_t);
 inline location_t
 loc_or_input_loc (location_t loc)
@@ -8178,12 +8178,12 @@ cp_expr_loc_or_input_loc (const_tree t)
   return cp_expr_loc_or_loc (t, input_location);
 }
 
-inline void
+inline bool
 cxx_incomplete_type_diagnostic (const_tree value, const_tree type,
                                diagnostic_t diag_kind)
 {
-  cxx_incomplete_type_diagnostic (cp_expr_loc_or_input_loc (value),
-                                 value, type, diag_kind);
+  return cxx_incomplete_type_diagnostic (cp_expr_loc_or_input_loc (value),
+                                        value, type, diag_kind);
 }
 
 extern void cxx_incomplete_type_error          (location_t, const_tree,
index c56b69164e2b84551dadf32c39b36a08507e129d..76a7a7f6b984d2fdc76b9e8c11d0e84bd2dc536d 100644 (file)
@@ -292,7 +292,7 @@ cxx_incomplete_type_inform (const_tree type)
    and TYPE is the type that was invalid.  DIAG_KIND indicates the
    type of diagnostic (see diagnostic.def).  */
 
-void
+bool
 cxx_incomplete_type_diagnostic (location_t loc, const_tree value,
                                const_tree type, diagnostic_t diag_kind)
 {
@@ -304,7 +304,7 @@ cxx_incomplete_type_diagnostic (location_t loc, const_tree value,
 
   /* Avoid duplicate error message.  */
   if (TREE_CODE (type) == ERROR_MARK)
-    return;
+    return false;
 
   if (value)
     {
@@ -336,7 +336,7 @@ cxx_incomplete_type_diagnostic (location_t loc, const_tree value,
       break;
 
     case VOID_TYPE:
-      emit_diagnostic (diag_kind, loc, 0,
+      complained = emit_diagnostic (diag_kind, loc, 0,
                       "invalid use of %qT", type);
       break;
 
@@ -346,7 +346,7 @@ cxx_incomplete_type_diagnostic (location_t loc, const_tree value,
          type = TREE_TYPE (type);
          goto retry;
        }
-      emit_diagnostic (diag_kind, loc, 0,
+      complained = emit_diagnostic (diag_kind, loc, 0,
                       "invalid use of array with unspecified bounds");
       break;
 
@@ -365,12 +365,12 @@ cxx_incomplete_type_diagnostic (location_t loc, const_tree value,
               add a fix-it hint.  */
            if (type_num_arguments (TREE_TYPE (member)) == 1)
              richloc.add_fixit_insert_after ("()");
-           emit_diagnostic (diag_kind, &richloc, 0,
+           complained = emit_diagnostic (diag_kind, &richloc, 0,
                             "invalid use of member function %qD "
                             "(did you forget the %<()%> ?)", member);
          }
        else
-         emit_diagnostic (diag_kind, loc, 0,
+         complained = emit_diagnostic (diag_kind, loc, 0,
                           "invalid use of member %qD "
                           "(did you forget the %<&%> ?)", member);
       }
@@ -380,38 +380,38 @@ cxx_incomplete_type_diagnostic (location_t loc, const_tree value,
       if (is_auto (type))
        {
          if (CLASS_PLACEHOLDER_TEMPLATE (type))
-           emit_diagnostic (diag_kind, loc, 0,
+           complained = emit_diagnostic (diag_kind, loc, 0,
                             "invalid use of placeholder %qT", type);
          else
-           emit_diagnostic (diag_kind, loc, 0,
+           complained = emit_diagnostic (diag_kind, loc, 0,
                             "invalid use of %qT", type);
        }
       else
-       emit_diagnostic (diag_kind, loc, 0,
+       complained = emit_diagnostic (diag_kind, loc, 0,
                         "invalid use of template type parameter %qT", type);
       break;
 
     case BOUND_TEMPLATE_TEMPLATE_PARM:
-      emit_diagnostic (diag_kind, loc, 0,
+      complained = emit_diagnostic (diag_kind, loc, 0,
                       "invalid use of template template parameter %qT",
                       TYPE_NAME (type));
       break;
 
     case TYPE_PACK_EXPANSION:
-      emit_diagnostic (diag_kind, loc, 0,
+      complained = emit_diagnostic (diag_kind, loc, 0,
                       "invalid use of pack expansion %qT", type);
       break;
 
     case TYPENAME_TYPE:
     case DECLTYPE_TYPE:
-      emit_diagnostic (diag_kind, loc, 0,
+      complained = emit_diagnostic (diag_kind, loc, 0,
                       "invalid use of dependent type %qT", type);
       break;
 
     case LANG_TYPE:
       if (type == init_list_type_node)
        {
-         emit_diagnostic (diag_kind, loc, 0,
+         complained = emit_diagnostic (diag_kind, loc, 0,
                           "invalid use of brace-enclosed initializer list");
          break;
        }
@@ -419,20 +419,22 @@ cxx_incomplete_type_diagnostic (location_t loc, const_tree value,
       if (value && TREE_CODE (value) == COMPONENT_REF)
        goto bad_member;
       else if (value && TREE_CODE (value) == ADDR_EXPR)
-       emit_diagnostic (diag_kind, loc, 0,
+       complained = emit_diagnostic (diag_kind, loc, 0,
                         "address of overloaded function with no contextual "
                         "type information");
       else if (value && TREE_CODE (value) == OVERLOAD)
-       emit_diagnostic (diag_kind, loc, 0,
+       complained = emit_diagnostic (diag_kind, loc, 0,
                         "overloaded function with no contextual type information");
       else
-       emit_diagnostic (diag_kind, loc, 0,
+       complained = emit_diagnostic (diag_kind, loc, 0,
                         "insufficient contextual information to determine type");
       break;
 
     default:
       gcc_unreachable ();
     }
+
+  return complained;
 }
 
 /* Print an error message for invalid use of an incomplete type.
This page took 0.067384 seconds and 5 git commands to generate.