diff options
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/decl.c | 34 |
2 files changed, 17 insertions, 21 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6e67244..29f3fd8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +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> PR c++/86981, Implement -Wpessimizing-move. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index f6dbd6b..82ec4af 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -70,7 +70,7 @@ static void push_local_name (tree); static tree grok_reference_init (tree, tree, tree, int); static tree grokvardecl (tree, tree, tree, const cp_decl_specifier_seq *, 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 tree builtin_function_1 (tree, tree, bool); static int member_function_or_else (tree, tree, enum overload_flags); @@ -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. Check to see that the definition is valid. Issue appropriate error - messages. Return 1 if the definition is particularly bad, or 0 - otherwise. */ + messages. */ -static int +static void check_static_variable_definition (tree decl, tree type) { /* Avoid redundant diagnostics on out-of-class definitions. */ if (!current_class_type || !TYPE_BEING_DEFINED (current_class_type)) - return 0; + ; /* Can't check yet if we don't know the type. */ - if (dependent_type_p (type)) - return 0; + else if (dependent_type_p (type)) + ; /* If DECL is declared constexpr, we'll do the appropriate checks in check_initializer. Similarly for inline static data members. */ - if (DECL_P (decl) + else if (DECL_P (decl) && (DECL_DECLARED_CONSTEXPR_P (decl) || undeduced_auto_decl (decl) || DECL_VAR_DECLARED_INLINE_P (decl))) - return 0; + ; else if (cxx_dialect >= cxx11 && !INTEGRAL_OR_ENUMERATION_TYPE_P (type)) { if (!COMPLETE_TYPE_P (type)) @@ -9564,23 +9563,18 @@ check_static_variable_definition (tree decl, tree type) error_at (DECL_SOURCE_LOCATION (decl), "in-class initialization of static data member %q#D of " "non-literal type", decl); - return 1; } - /* Motion 10 at San Diego: If a static const integral data member is initialized with an integral constant expression, the initializer may appear either in the declaration (within the class), or in the definition, but not both. If it appears in the class, the member is a member constant. The file-scope definition is always required. */ - if (!ARITHMETIC_TYPE_P (type) && TREE_CODE (type) != ENUMERAL_TYPE) - { - error_at (DECL_SOURCE_LOCATION (decl), - "invalid in-class initialization of static data member " - "of non-integral type %qT", - type); - return 1; - } + else if (!ARITHMETIC_TYPE_P (type) && TREE_CODE (type) != ENUMERAL_TYPE) + error_at (DECL_SOURCE_LOCATION (decl), + "invalid in-class initialization of static data member " + "of non-integral type %qT", + type); else if (!CP_TYPE_CONST_P (type)) error_at (DECL_SOURCE_LOCATION (decl), "ISO C++ forbids in-class initialization of non-const " @@ -9590,8 +9584,6 @@ check_static_variable_definition (tree decl, tree type) pedwarn (DECL_SOURCE_LOCATION (decl), OPT_Wpedantic, "ISO C++ forbids initialization of member constant " "%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 |