Commit 55082d81 by Paolo Carlini Committed by Paolo Carlini

decl.c (check_static_variable_definition): Change to return void.

2018-08-21  Paolo Carlini  <paolo.carlini@oracle.com>

	* decl.c (check_static_variable_definition): Change to return void.

From-SVN: r263742
parent 79ca9c35
2018-08-21 Paolo Carlini <paolo.carlini@oracle.com>
* decl.c (check_static_variable_definition): Change to return void.
2018-08-21 Marek Polacek <polacek@redhat.com> 2018-08-21 Marek Polacek <polacek@redhat.com>
PR c++/86981, Implement -Wpessimizing-move. PR c++/86981, Implement -Wpessimizing-move.
......
...@@ -70,7 +70,7 @@ static void push_local_name (tree); ...@@ -70,7 +70,7 @@ static void push_local_name (tree);
static tree grok_reference_init (tree, tree, tree, int); static tree grok_reference_init (tree, tree, tree, int);
static tree grokvardecl (tree, tree, tree, const cp_decl_specifier_seq *, static tree grokvardecl (tree, tree, tree, const cp_decl_specifier_seq *,
int, int, int, bool, int, tree); int, int, int, bool, int, tree);
static int check_static_variable_definition (tree, tree); static void check_static_variable_definition (tree, tree);
static void record_unknown_type (tree, const char *); static void record_unknown_type (tree, const char *);
static tree builtin_function_1 (tree, tree, bool); static tree builtin_function_1 (tree, tree, bool);
static int member_function_or_else (tree, tree, enum overload_flags); static int member_function_or_else (tree, tree, enum overload_flags);
...@@ -9531,25 +9531,24 @@ build_ptrmem_type (tree class_type, tree member_type) ...@@ -9531,25 +9531,24 @@ build_ptrmem_type (tree class_type, tree member_type)
/* DECL is a VAR_DECL defined in-class, whose TYPE is also given. /* DECL is a VAR_DECL defined in-class, whose TYPE is also given.
Check to see that the definition is valid. Issue appropriate error Check to see that the definition is valid. Issue appropriate error
messages. Return 1 if the definition is particularly bad, or 0 messages. */
otherwise. */
static int static void
check_static_variable_definition (tree decl, tree type) check_static_variable_definition (tree decl, tree type)
{ {
/* Avoid redundant diagnostics on out-of-class definitions. */ /* Avoid redundant diagnostics on out-of-class definitions. */
if (!current_class_type || !TYPE_BEING_DEFINED (current_class_type)) if (!current_class_type || !TYPE_BEING_DEFINED (current_class_type))
return 0; ;
/* Can't check yet if we don't know the type. */ /* Can't check yet if we don't know the type. */
if (dependent_type_p (type)) else if (dependent_type_p (type))
return 0; ;
/* If DECL is declared constexpr, we'll do the appropriate checks /* If DECL is declared constexpr, we'll do the appropriate checks
in check_initializer. Similarly for inline static data members. */ in check_initializer. Similarly for inline static data members. */
if (DECL_P (decl) else if (DECL_P (decl)
&& (DECL_DECLARED_CONSTEXPR_P (decl) && (DECL_DECLARED_CONSTEXPR_P (decl)
|| undeduced_auto_decl (decl) || undeduced_auto_decl (decl)
|| DECL_VAR_DECLARED_INLINE_P (decl))) || DECL_VAR_DECLARED_INLINE_P (decl)))
return 0; ;
else if (cxx_dialect >= cxx11 && !INTEGRAL_OR_ENUMERATION_TYPE_P (type)) else if (cxx_dialect >= cxx11 && !INTEGRAL_OR_ENUMERATION_TYPE_P (type))
{ {
if (!COMPLETE_TYPE_P (type)) if (!COMPLETE_TYPE_P (type))
...@@ -9564,23 +9563,18 @@ check_static_variable_definition (tree decl, tree type) ...@@ -9564,23 +9563,18 @@ check_static_variable_definition (tree decl, tree type)
error_at (DECL_SOURCE_LOCATION (decl), error_at (DECL_SOURCE_LOCATION (decl),
"in-class initialization of static data member %q#D of " "in-class initialization of static data member %q#D of "
"non-literal type", decl); "non-literal type", decl);
return 1;
} }
/* Motion 10 at San Diego: If a static const integral data member is /* Motion 10 at San Diego: If a static const integral data member is
initialized with an integral constant expression, the initializer initialized with an integral constant expression, the initializer
may appear either in the declaration (within the class), or in may appear either in the declaration (within the class), or in
the definition, but not both. If it appears in the class, the the definition, but not both. If it appears in the class, the
member is a member constant. The file-scope definition is always member is a member constant. The file-scope definition is always
required. */ required. */
if (!ARITHMETIC_TYPE_P (type) && TREE_CODE (type) != ENUMERAL_TYPE) else if (!ARITHMETIC_TYPE_P (type) && TREE_CODE (type) != ENUMERAL_TYPE)
{ error_at (DECL_SOURCE_LOCATION (decl),
error_at (DECL_SOURCE_LOCATION (decl), "invalid in-class initialization of static data member "
"invalid in-class initialization of static data member " "of non-integral type %qT",
"of non-integral type %qT", type);
type);
return 1;
}
else if (!CP_TYPE_CONST_P (type)) else if (!CP_TYPE_CONST_P (type))
error_at (DECL_SOURCE_LOCATION (decl), error_at (DECL_SOURCE_LOCATION (decl),
"ISO C++ forbids in-class initialization of non-const " "ISO C++ forbids in-class initialization of non-const "
...@@ -9590,8 +9584,6 @@ check_static_variable_definition (tree decl, tree type) ...@@ -9590,8 +9584,6 @@ check_static_variable_definition (tree decl, tree type)
pedwarn (DECL_SOURCE_LOCATION (decl), OPT_Wpedantic, pedwarn (DECL_SOURCE_LOCATION (decl), OPT_Wpedantic,
"ISO C++ forbids initialization of member constant " "ISO C++ forbids initialization of member constant "
"%qD of non-integral type %qT", decl, type); "%qD of non-integral type %qT", decl, type);
return 0;
} }
/* *expr_p is part of the TYPE_SIZE of a variably-sized array. If any /* *expr_p is part of the TYPE_SIZE of a variably-sized array. If any
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment