aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/cp-name-hint.h1
-rw-r--r--gcc/cp/decl.cc10
-rw-r--r--gcc/cp/name-lookup.cc2
4 files changed, 21 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 7230564..280e373 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2023-06-23 David Malcolm <dmalcolm@redhat.com>
+
+ PR c++/110164
+ * cp-name-hint.h (maybe_suggest_missing_header): New decl.
+ * decl.cc: Define INCLUDE_MEMORY. Add include of
+ "cp/cp-name-hint.h".
+ (start_decl_1): Call maybe_suggest_missing_header.
+ * name-lookup.cc (maybe_suggest_missing_header): Remove "static".
+
2023-06-16 Alex Coplan <alex.coplan@arm.com>
* parser.cc (cp_parser_enum_specifier): Don't reject
diff --git a/gcc/cp/cp-name-hint.h b/gcc/cp/cp-name-hint.h
index bfa7c53..7693980 100644
--- a/gcc/cp/cp-name-hint.h
+++ b/gcc/cp/cp-name-hint.h
@@ -32,6 +32,7 @@ along with GCC; see the file COPYING3. If not see
extern name_hint suggest_alternatives_for (location_t, tree, bool);
extern name_hint suggest_alternatives_in_other_namespaces (location_t, tree);
+extern name_hint maybe_suggest_missing_header (location_t, tree, tree);
extern name_hint suggest_alternative_in_explicit_scope (location_t, tree, tree);
extern name_hint suggest_alternative_in_scoped_enum (tree, tree);
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index c07a4a8..60f107d 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see
line numbers. For example, the CONST_DECLs for enum values. */
#include "config.h"
+#define INCLUDE_MEMORY
#include "system.h"
#include "coretypes.h"
#include "target.h"
@@ -46,6 +47,7 @@ along with GCC; see the file COPYING3. If not see
#include "c-family/c-objc.h"
#include "c-family/c-pragma.h"
#include "c-family/c-ubsan.h"
+#include "cp/cp-name-hint.h"
#include "debug.h"
#include "plugin.h"
#include "builtins.h"
@@ -5995,7 +5997,11 @@ start_decl_1 (tree decl, bool initialized)
; /* An auto type is ok. */
else if (TREE_CODE (type) != ARRAY_TYPE)
{
+ auto_diagnostic_group d;
error ("variable %q#D has initializer but incomplete type", decl);
+ maybe_suggest_missing_header (input_location,
+ TYPE_IDENTIFIER (type),
+ CP_TYPE_CONTEXT (type));
type = TREE_TYPE (decl) = error_mark_node;
}
else if (!COMPLETE_TYPE_P (complete_type (TREE_TYPE (type))))
@@ -6011,8 +6017,12 @@ start_decl_1 (tree decl, bool initialized)
gcc_assert (CLASS_PLACEHOLDER_TEMPLATE (type));
else
{
+ auto_diagnostic_group d;
error ("aggregate %q#D has incomplete type and cannot be defined",
decl);
+ maybe_suggest_missing_header (input_location,
+ TYPE_IDENTIFIER (type),
+ CP_TYPE_CONTEXT (type));
/* Change the type so that assemble_variable will give
DECL an rtl we can live with: (mem (const_int 0)). */
type = TREE_TYPE (decl) = error_mark_node;
diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
index 53b6870..7456518 100644
--- a/gcc/cp/name-lookup.cc
+++ b/gcc/cp/name-lookup.cc
@@ -6796,7 +6796,7 @@ maybe_suggest_missing_std_header (location_t location, tree name)
for NAME within SCOPE at LOCATION, or an empty name_hint if this isn't
applicable. */
-static name_hint
+name_hint
maybe_suggest_missing_header (location_t location, tree name, tree scope)
{
if (scope == NULL_TREE)