diff mbox series

c++: Fix spelling of non-static

Message ID 20200319154857.2703391-1-polacek@redhat.com
State New
Headers show
Series c++: Fix spelling of non-static | expand

Commit Message

Li, Pan2 via Gcc-patches March 19, 2020, 3:48 p.m. UTC
I was looking at DR 296 and noticed that we say "nonstatic" instead of
"non-static", which is the version the standard uses.  So this patch
fixes the spelling throughout the front end.  Did not check e.g.
non-dependent or any other.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

	* decl.c (grok_op_properties): Fix spelling of non-static.
	* typeck.c (build_class_member_access_expr): Likewise.

	* g++.dg/other/operator1.C: Adjust expected message.
	* g++.dg/overload/operator2.C: Likewise.
	* g++.dg/template/error30.C: Likewise.
	* g++.old-deja/g++.jason/operator.C: Likewise.
---
 gcc/cp/call.c                                   |  2 +-
 gcc/cp/class.c                                  |  8 ++++----
 gcc/cp/cxx-pretty-print.c                       |  2 +-
 gcc/cp/decl.c                                   |  2 +-
 gcc/cp/init.c                                   | 10 +++++-----
 gcc/cp/search.c                                 |  6 +++---
 gcc/cp/typeck.c                                 |  2 +-
 gcc/testsuite/g++.dg/other/operator1.C          |  2 +-
 gcc/testsuite/g++.dg/overload/operator2.C       |  4 ++--
 gcc/testsuite/g++.dg/template/error30.C         |  2 +-
 gcc/testsuite/g++.old-deja/g++.jason/operator.C |  4 ++--
 11 files changed, 22 insertions(+), 22 deletions(-)


base-commit: 02f7334ac93f53ed06d881beb611e88be36dc56a

Comments

Li, Pan2 via Gcc-patches March 19, 2020, 4:26 p.m. UTC | #1
On 3/19/20 11:48 AM, Marek Polacek wrote:
> I was looking at DR 296 and noticed that we say "nonstatic" instead of
> "non-static", which is the version the standard uses.  So this patch
> fixes the spelling throughout the front end.  Did not check e.g.
> non-dependent or any other.
> 
> Bootstrapped/regtested on x86_64-linux, ok for trunk?

OK for stage 1; at this point I'd prefer not to make unnecessary changes 
to diagnostic messages that will break translations in gcc/po/*

> 	* decl.c (grok_op_properties): Fix spelling of non-static.
> 	* typeck.c (build_class_member_access_expr): Likewise.
> 
> 	* g++.dg/other/operator1.C: Adjust expected message.
> 	* g++.dg/overload/operator2.C: Likewise.
> 	* g++.dg/template/error30.C: Likewise.
> 	* g++.old-deja/g++.jason/operator.C: Likewise.
> ---
>   gcc/cp/call.c                                   |  2 +-
>   gcc/cp/class.c                                  |  8 ++++----
>   gcc/cp/cxx-pretty-print.c                       |  2 +-
>   gcc/cp/decl.c                                   |  2 +-
>   gcc/cp/init.c                                   | 10 +++++-----
>   gcc/cp/search.c                                 |  6 +++---
>   gcc/cp/typeck.c                                 |  2 +-
>   gcc/testsuite/g++.dg/other/operator1.C          |  2 +-
>   gcc/testsuite/g++.dg/overload/operator2.C       |  4 ++--
>   gcc/testsuite/g++.dg/template/error30.C         |  2 +-
>   gcc/testsuite/g++.old-deja/g++.jason/operator.C |  4 ++--
>   11 files changed, 22 insertions(+), 22 deletions(-)
> 
> diff --git a/gcc/cp/call.c b/gcc/cp/call.c
> index 1715acc0ec3..db396f428a4 100644
> --- a/gcc/cp/call.c
> +++ b/gcc/cp/call.c
> @@ -8671,7 +8671,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
>   	      (DECL_CONTEXT (fn), BINFO_TYPE (cand->conversion_path))))
>   	flags |= LOOKUP_NONVIRTUAL;
>   
> -      /* [class.mfct.nonstatic]: If a nonstatic member function of a class
> +      /* [class.mfct.non-static]: If a non-static member function of a class
>   	 X is called for an object that is not of type X, or of a type
>   	 derived from X, the behavior is undefined.
>   
> diff --git a/gcc/cp/class.c b/gcc/cp/class.c
> index 5340799fdd3..fb2ef202629 100644
> --- a/gcc/cp/class.c
> +++ b/gcc/cp/class.c
> @@ -3661,7 +3661,7 @@ check_field_decls (tree t, tree *access_decls,
>   	    {
>   	      /* ARM $12.6.2: [A member initializer list] (or, for an
>   		 aggregate, initialization by a brace-enclosed list) is the
> -		 only way to initialize nonstatic const and reference
> +		 only way to initialize non-static const and reference
>   		 members.  */
>   	      TYPE_HAS_COMPLEX_COPY_ASSIGN (t) = 1;
>   	      TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) = 1;
> @@ -3784,7 +3784,7 @@ check_field_decls (tree t, tree *access_decls,
>   	    {
>   	      /* ARM $12.6.2: [A member initializer list] (or, for an
>   		 aggregate, initialization by a brace-enclosed list) is the
> -		 only way to initialize nonstatic const and reference
> +		 only way to initialize non-static const and reference
>   		 members.  */
>   	      TYPE_HAS_COMPLEX_COPY_ASSIGN (t) = 1;
>   	      TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) = 1;
> @@ -3799,7 +3799,7 @@ check_field_decls (tree t, tree *access_decls,
>   	    | CLASSTYPE_READONLY_FIELDS_NEED_INIT (type));
>   	}
>   
> -      /* Core issue 80: A nonstatic data member is required to have a
> +      /* Core issue 80: A non-static data member is required to have a
>   	 different name from the class iff the class has a
>   	 user-declared constructor.  */
>         if (constructor_name_p (DECL_NAME (field), t)
> @@ -8104,7 +8104,7 @@ resolve_address_of_overloaded_function (tree target_type,
>          member functions match targets of type "pointer-to-member
>          function;" the function type of the pointer to member is used to
>          select the member function from the set of overloaded member
> -       functions.  If a nonstatic member function is selected, the
> +       functions.  If a non-static member function is selected, the
>          reference to the overloaded function name is required to have the
>          form of a pointer to member as described in 5.3.1.
>   
> diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c
> index 100154e400f..05c56775adc 100644
> --- a/gcc/cp/cxx-pretty-print.c
> +++ b/gcc/cp/cxx-pretty-print.c
> @@ -1532,7 +1532,7 @@ pp_cxx_parameter_declaration_clause (cxx_pretty_printer *pp, tree t)
>       }
>     bool first = true;
>   
> -  /* Skip artificial parameter for nonstatic member functions.  */
> +  /* Skip artificial parameter for non-static member functions.  */
>     if (TREE_CODE (t) == METHOD_TYPE)
>       types = TREE_CHAIN (types);
>   
> diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
> index 319b7ee5c1c..31025cd5edc 100644
> --- a/gcc/cp/decl.c
> +++ b/gcc/cp/decl.c
> @@ -14388,7 +14388,7 @@ grok_op_properties (tree decl, bool complain)
>   	  || operator_code == ARRAY_REF
>   	  || operator_code == NOP_EXPR)
>   	{
> -	  error_at (loc, "%qD must be a nonstatic member function", decl);
> +	  error_at (loc, "%qD must be a non-static member function", decl);
>   	  return false;
>   	}
>   
> diff --git a/gcc/cp/init.c b/gcc/cp/init.c
> index 27623cf4db1..ac661e06d20 100644
> --- a/gcc/cp/init.c
> +++ b/gcc/cp/init.c
> @@ -160,7 +160,7 @@ build_zero_init_1 (tree type, tree nelts, bool static_storage_p,
>        -- if T is a scalar type, the storage is set to the value of zero
>   	converted to T.
>   
> -     -- if T is a non-union class type, the storage for each nonstatic
> +     -- if T is a non-union class type, the storage for each non-static
>   	data member and each base-class subobject is zero-initialized.
>   
>        -- if T is a union type, the storage for its first data member is
> @@ -2219,8 +2219,8 @@ build_offset_ref (tree type, tree member, bool address_p,
>         /* If MEMBER is non-static, then the program has fallen afoul of
>   	 [expr.prim]:
>   
> -	   An id-expression that denotes a nonstatic data member or
> -	   nonstatic member function of a class can only be used:
> +	   An id-expression that denotes a non-static data member or
> +	   non-static member function of a class can only be used:
>   
>   	   -- as part of a class member access (_expr.ref_) in which the
>   	   object-expression refers to the member's class or a class
> @@ -2228,8 +2228,8 @@ build_offset_ref (tree type, tree member, bool address_p,
>   
>   	   -- to form a pointer to member (_expr.unary.op_), or
>   
> -	   -- in the body of a nonstatic member function of that class or
> -	   of a class derived from that class (_class.mfct.nonstatic_), or
> +	   -- in the body of a non-static member function of that class or
> +	   of a class derived from that class (_class.mfct.non-static_), or
>   
>   	   -- in a mem-initializer for a constructor for that class or for
>   	   a class derived from that class (_class.base.init_).  */
> diff --git a/gcc/cp/search.c b/gcc/cp/search.c
> index 6eada2d3788..d9a2d748428 100644
> --- a/gcc/cp/search.c
> +++ b/gcc/cp/search.c
> @@ -631,7 +631,7 @@ protected_accessible_p (tree decl, tree derived, tree type, tree otype)
>     /* [class.protected]
>   
>        When a friend or a member function of a derived class references
> -     a protected nonstatic member of a base class, an access check
> +     a protected non-static member of a base class, an access check
>        applies in addition to those described earlier in clause
>        _class.access_) Except when forming a pointer to member
>        (_expr.unary.op_), the access must be through a pointer to,
> @@ -921,11 +921,11 @@ struct lookup_field_info {
>      of that class.
>   
>      [class.member.lookup]:If the resulting set of declarations are not all
> -   from sub-objects of the same type, or the set has a  nonstatic  member
> +   from sub-objects of the same type, or the set has a non-static member
>      and  includes members from distinct sub-objects, there is an ambiguity
>      and the program is ill-formed.
>   
> -   This function checks that T contains no nonstatic members.  */
> +   This function checks that T contains no non-static members.  */
>   
>   int
>   shared_member_p (tree t)
> diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
> index 8e3188a415d..99d76e18eab 100644
> --- a/gcc/cp/typeck.c
> +++ b/gcc/cp/typeck.c
> @@ -2512,7 +2512,7 @@ build_class_member_access_expr (cp_expr object, tree member,
>         if (complain & tf_error)
>   	{
>   	  if (TREE_CODE (member) == FIELD_DECL)
> -	    error ("invalid use of nonstatic data member %qE", member);
> +	    error ("invalid use of non-static data member %qE", member);
>   	  else
>   	    error ("%qD is not a member of %qT", member, object_type);
>   	}
> diff --git a/gcc/testsuite/g++.dg/other/operator1.C b/gcc/testsuite/g++.dg/other/operator1.C
> index d0b0cb25f8c..121c106ad18 100644
> --- a/gcc/testsuite/g++.dg/other/operator1.C
> +++ b/gcc/testsuite/g++.dg/other/operator1.C
> @@ -1,7 +1,7 @@
>   // PR c++/27547
>   // { dg-do compile }
>   
> -int operator=(int);  // { dg-error "5:.int operator=\\(int\\). must be a nonstatic member function" }
> +int operator=(int);  // { dg-error "5:.int operator=\\(int\\). must be a non-static member function" }
>   
>   void foo()
>   {
> diff --git a/gcc/testsuite/g++.dg/overload/operator2.C b/gcc/testsuite/g++.dg/overload/operator2.C
> index b60c629744e..64640b6cfe0 100644
> --- a/gcc/testsuite/g++.dg/overload/operator2.C
> +++ b/gcc/testsuite/g++.dg/overload/operator2.C
> @@ -3,7 +3,7 @@
>   
>   struct A
>   {
> -  static operator int(); // { dg-error "10:.static A::operator int\\(\\). must be a nonstatic member function" }
> +  static operator int(); // { dg-error "10:.static A::operator int\\(\\). must be a non-static member function" }
>   };
>   
>   struct B
> @@ -11,4 +11,4 @@ struct B
>     static int operator*(); // { dg-error "14:.static int B::operator\\*\\(\\). must be either a non-static member function or a non-member function" }
>   };
>   
> -static operator int(); // { dg-error "8:.operator int\\(\\). must be a nonstatic member function" }
> +static operator int(); // { dg-error "8:.operator int\\(\\). must be a non-static member function" }
> diff --git a/gcc/testsuite/g++.dg/template/error30.C b/gcc/testsuite/g++.dg/template/error30.C
> index e1706af0b7a..3a87872d526 100644
> --- a/gcc/testsuite/g++.dg/template/error30.C
> +++ b/gcc/testsuite/g++.dg/template/error30.C
> @@ -2,4 +2,4 @@
>   
>   template<int> struct A;
>   
> -template<template<typename> class B> A<B<int>::x> operator() (); // { dg-error "51:.A<B<int>::x> operator\\(\\)\\(\\). must be a nonstatic member function" }
> +template<template<typename> class B> A<B<int>::x> operator() (); // { dg-error "51:.A<B<int>::x> operator\\(\\)\\(\\). must be a non-static member function" }
> diff --git a/gcc/testsuite/g++.old-deja/g++.jason/operator.C b/gcc/testsuite/g++.old-deja/g++.jason/operator.C
> index 69a41cf2448..79c1932a353 100644
> --- a/gcc/testsuite/g++.old-deja/g++.jason/operator.C
> +++ b/gcc/testsuite/g++.old-deja/g++.jason/operator.C
> @@ -6,7 +6,7 @@ typedef __SIZE_TYPE__ size_t;
>   
>   struct A {
>     int operator?:(int a, int b);	   // { dg-error "prohibits overloading" }
> -  static int operator()(int a);	   // { dg-error "14:.static int A::operator\\(\\)\\(int\\). must be a nonstatic member function" }
> +  static int operator()(int a);	   // { dg-error "14:.static int A::operator\\(\\)\\(int\\). must be a non-static member function" }
>     static int operator+(A,A);	   // { dg-error "14:.static int A::operator\\+\\(A, A\\). must be either a non-static member function or a non-member function" }
>     int operator+(int a, int b = 1); // { dg-error "7:.int A::operator\\+\\(int, int\\). must have either zero or one argument" }
>     int operator++(char);		   // { dg-error "7:postfix .int A::operator\\+\\+\\(char\\). must have .int. as its argument" }
> @@ -29,4 +29,4 @@ void * operator new (A a);	// { dg-error ".operator new. takes type .size_t." }
>   void operator delete (A a);	// { dg-error ".operator delete. takes type .void\\*. as first parameter" }
>   
>   char * operator char * (int);	// { dg-error "return type" "ret" }
> -// { dg-error "8:.operator char\\*\\*\\(int\\). must be a nonstatic member function" "mem" { target *-*-* } .-1 }
> +// { dg-error "8:.operator char\\*\\*\\(int\\). must be a non-static member function" "mem" { target *-*-* } .-1 }
> 
> base-commit: 02f7334ac93f53ed06d881beb611e88be36dc56a
>
Li, Pan2 via Gcc-patches March 19, 2020, 4:45 p.m. UTC | #2
On 3/19/20 9:48 AM, Marek Polacek via Gcc-patches wrote:
> I was looking at DR 296 and noticed that we say "nonstatic" instead of
> "non-static", which is the version the standard uses.  So this patch
> fixes the spelling throughout the front end.  Did not check e.g.
> non-dependent or any other.
> 
> Bootstrapped/regtested on x86_64-linux, ok for trunk?

If this is the spelling we want to standardize on, would you mind
adding a check to -Wformat-diag as well so these misspellings get
diagnosed in diagnostic messages?  We might also want to add
a mention of it to the Spelling section of the GCC Coding
Conventions.

Alternatively, please try to remember to CC me when you commit
the patch in stage1 and I'll add that myself.

Thanks
Martin

PS The hyphenated form makes sense to me when applied to keywords
or standard terms like non-inline or non-static.  I'm not sure it's
necessary or even widespread in other already established terms
like nonnegative, and it's even explicitly discouraged in the GCC
Coding Conventions for nonzero.

> 
> 	* decl.c (grok_op_properties): Fix spelling of non-static.
> 	* typeck.c (build_class_member_access_expr): Likewise.
> 
> 	* g++.dg/other/operator1.C: Adjust expected message.
> 	* g++.dg/overload/operator2.C: Likewise.
> 	* g++.dg/template/error30.C: Likewise.
> 	* g++.old-deja/g++.jason/operator.C: Likewise.
> ---
>   gcc/cp/call.c                                   |  2 +-
>   gcc/cp/class.c                                  |  8 ++++----
>   gcc/cp/cxx-pretty-print.c                       |  2 +-
>   gcc/cp/decl.c                                   |  2 +-
>   gcc/cp/init.c                                   | 10 +++++-----
>   gcc/cp/search.c                                 |  6 +++---
>   gcc/cp/typeck.c                                 |  2 +-
>   gcc/testsuite/g++.dg/other/operator1.C          |  2 +-
>   gcc/testsuite/g++.dg/overload/operator2.C       |  4 ++--
>   gcc/testsuite/g++.dg/template/error30.C         |  2 +-
>   gcc/testsuite/g++.old-deja/g++.jason/operator.C |  4 ++--
>   11 files changed, 22 insertions(+), 22 deletions(-)
> 
> diff --git a/gcc/cp/call.c b/gcc/cp/call.c
> index 1715acc0ec3..db396f428a4 100644
> --- a/gcc/cp/call.c
> +++ b/gcc/cp/call.c
> @@ -8671,7 +8671,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
>   	      (DECL_CONTEXT (fn), BINFO_TYPE (cand->conversion_path))))
>   	flags |= LOOKUP_NONVIRTUAL;
>   
> -      /* [class.mfct.nonstatic]: If a nonstatic member function of a class
> +      /* [class.mfct.non-static]: If a non-static member function of a class
>   	 X is called for an object that is not of type X, or of a type
>   	 derived from X, the behavior is undefined.
>   
> diff --git a/gcc/cp/class.c b/gcc/cp/class.c
> index 5340799fdd3..fb2ef202629 100644
> --- a/gcc/cp/class.c
> +++ b/gcc/cp/class.c
> @@ -3661,7 +3661,7 @@ check_field_decls (tree t, tree *access_decls,
>   	    {
>   	      /* ARM $12.6.2: [A member initializer list] (or, for an
>   		 aggregate, initialization by a brace-enclosed list) is the
> -		 only way to initialize nonstatic const and reference
> +		 only way to initialize non-static const and reference
>   		 members.  */
>   	      TYPE_HAS_COMPLEX_COPY_ASSIGN (t) = 1;
>   	      TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) = 1;
> @@ -3784,7 +3784,7 @@ check_field_decls (tree t, tree *access_decls,
>   	    {
>   	      /* ARM $12.6.2: [A member initializer list] (or, for an
>   		 aggregate, initialization by a brace-enclosed list) is the
> -		 only way to initialize nonstatic const and reference
> +		 only way to initialize non-static const and reference
>   		 members.  */
>   	      TYPE_HAS_COMPLEX_COPY_ASSIGN (t) = 1;
>   	      TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) = 1;
> @@ -3799,7 +3799,7 @@ check_field_decls (tree t, tree *access_decls,
>   	    | CLASSTYPE_READONLY_FIELDS_NEED_INIT (type));
>   	}
>   
> -      /* Core issue 80: A nonstatic data member is required to have a
> +      /* Core issue 80: A non-static data member is required to have a
>   	 different name from the class iff the class has a
>   	 user-declared constructor.  */
>         if (constructor_name_p (DECL_NAME (field), t)
> @@ -8104,7 +8104,7 @@ resolve_address_of_overloaded_function (tree target_type,
>          member functions match targets of type "pointer-to-member
>          function;" the function type of the pointer to member is used to
>          select the member function from the set of overloaded member
> -       functions.  If a nonstatic member function is selected, the
> +       functions.  If a non-static member function is selected, the
>          reference to the overloaded function name is required to have the
>          form of a pointer to member as described in 5.3.1.
>   
> diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c
> index 100154e400f..05c56775adc 100644
> --- a/gcc/cp/cxx-pretty-print.c
> +++ b/gcc/cp/cxx-pretty-print.c
> @@ -1532,7 +1532,7 @@ pp_cxx_parameter_declaration_clause (cxx_pretty_printer *pp, tree t)
>       }
>     bool first = true;
>   
> -  /* Skip artificial parameter for nonstatic member functions.  */
> +  /* Skip artificial parameter for non-static member functions.  */
>     if (TREE_CODE (t) == METHOD_TYPE)
>       types = TREE_CHAIN (types);
>   
> diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
> index 319b7ee5c1c..31025cd5edc 100644
> --- a/gcc/cp/decl.c
> +++ b/gcc/cp/decl.c
> @@ -14388,7 +14388,7 @@ grok_op_properties (tree decl, bool complain)
>   	  || operator_code == ARRAY_REF
>   	  || operator_code == NOP_EXPR)
>   	{
> -	  error_at (loc, "%qD must be a nonstatic member function", decl);
> +	  error_at (loc, "%qD must be a non-static member function", decl);
>   	  return false;
>   	}
>   
> diff --git a/gcc/cp/init.c b/gcc/cp/init.c
> index 27623cf4db1..ac661e06d20 100644
> --- a/gcc/cp/init.c
> +++ b/gcc/cp/init.c
> @@ -160,7 +160,7 @@ build_zero_init_1 (tree type, tree nelts, bool static_storage_p,
>        -- if T is a scalar type, the storage is set to the value of zero
>   	converted to T.
>   
> -     -- if T is a non-union class type, the storage for each nonstatic
> +     -- if T is a non-union class type, the storage for each non-static
>   	data member and each base-class subobject is zero-initialized.
>   
>        -- if T is a union type, the storage for its first data member is
> @@ -2219,8 +2219,8 @@ build_offset_ref (tree type, tree member, bool address_p,
>         /* If MEMBER is non-static, then the program has fallen afoul of
>   	 [expr.prim]:
>   
> -	   An id-expression that denotes a nonstatic data member or
> -	   nonstatic member function of a class can only be used:
> +	   An id-expression that denotes a non-static data member or
> +	   non-static member function of a class can only be used:
>   
>   	   -- as part of a class member access (_expr.ref_) in which the
>   	   object-expression refers to the member's class or a class
> @@ -2228,8 +2228,8 @@ build_offset_ref (tree type, tree member, bool address_p,
>   
>   	   -- to form a pointer to member (_expr.unary.op_), or
>   
> -	   -- in the body of a nonstatic member function of that class or
> -	   of a class derived from that class (_class.mfct.nonstatic_), or
> +	   -- in the body of a non-static member function of that class or
> +	   of a class derived from that class (_class.mfct.non-static_), or
>   
>   	   -- in a mem-initializer for a constructor for that class or for
>   	   a class derived from that class (_class.base.init_).  */
> diff --git a/gcc/cp/search.c b/gcc/cp/search.c
> index 6eada2d3788..d9a2d748428 100644
> --- a/gcc/cp/search.c
> +++ b/gcc/cp/search.c
> @@ -631,7 +631,7 @@ protected_accessible_p (tree decl, tree derived, tree type, tree otype)
>     /* [class.protected]
>   
>        When a friend or a member function of a derived class references
> -     a protected nonstatic member of a base class, an access check
> +     a protected non-static member of a base class, an access check
>        applies in addition to those described earlier in clause
>        _class.access_) Except when forming a pointer to member
>        (_expr.unary.op_), the access must be through a pointer to,
> @@ -921,11 +921,11 @@ struct lookup_field_info {
>      of that class.
>   
>      [class.member.lookup]:If the resulting set of declarations are not all
> -   from sub-objects of the same type, or the set has a  nonstatic  member
> +   from sub-objects of the same type, or the set has a non-static member
>      and  includes members from distinct sub-objects, there is an ambiguity
>      and the program is ill-formed.
>   
> -   This function checks that T contains no nonstatic members.  */
> +   This function checks that T contains no non-static members.  */
>   
>   int
>   shared_member_p (tree t)
> diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
> index 8e3188a415d..99d76e18eab 100644
> --- a/gcc/cp/typeck.c
> +++ b/gcc/cp/typeck.c
> @@ -2512,7 +2512,7 @@ build_class_member_access_expr (cp_expr object, tree member,
>         if (complain & tf_error)
>   	{
>   	  if (TREE_CODE (member) == FIELD_DECL)
> -	    error ("invalid use of nonstatic data member %qE", member);
> +	    error ("invalid use of non-static data member %qE", member);
>   	  else
>   	    error ("%qD is not a member of %qT", member, object_type);
>   	}
> diff --git a/gcc/testsuite/g++.dg/other/operator1.C b/gcc/testsuite/g++.dg/other/operator1.C
> index d0b0cb25f8c..121c106ad18 100644
> --- a/gcc/testsuite/g++.dg/other/operator1.C
> +++ b/gcc/testsuite/g++.dg/other/operator1.C
> @@ -1,7 +1,7 @@
>   // PR c++/27547
>   // { dg-do compile }
>   
> -int operator=(int);  // { dg-error "5:.int operator=\\(int\\). must be a nonstatic member function" }
> +int operator=(int);  // { dg-error "5:.int operator=\\(int\\). must be a non-static member function" }
>   
>   void foo()
>   {
> diff --git a/gcc/testsuite/g++.dg/overload/operator2.C b/gcc/testsuite/g++.dg/overload/operator2.C
> index b60c629744e..64640b6cfe0 100644
> --- a/gcc/testsuite/g++.dg/overload/operator2.C
> +++ b/gcc/testsuite/g++.dg/overload/operator2.C
> @@ -3,7 +3,7 @@
>   
>   struct A
>   {
> -  static operator int(); // { dg-error "10:.static A::operator int\\(\\). must be a nonstatic member function" }
> +  static operator int(); // { dg-error "10:.static A::operator int\\(\\). must be a non-static member function" }
>   };
>   
>   struct B
> @@ -11,4 +11,4 @@ struct B
>     static int operator*(); // { dg-error "14:.static int B::operator\\*\\(\\). must be either a non-static member function or a non-member function" }
>   };
>   
> -static operator int(); // { dg-error "8:.operator int\\(\\). must be a nonstatic member function" }
> +static operator int(); // { dg-error "8:.operator int\\(\\). must be a non-static member function" }
> diff --git a/gcc/testsuite/g++.dg/template/error30.C b/gcc/testsuite/g++.dg/template/error30.C
> index e1706af0b7a..3a87872d526 100644
> --- a/gcc/testsuite/g++.dg/template/error30.C
> +++ b/gcc/testsuite/g++.dg/template/error30.C
> @@ -2,4 +2,4 @@
>   
>   template<int> struct A;
>   
> -template<template<typename> class B> A<B<int>::x> operator() (); // { dg-error "51:.A<B<int>::x> operator\\(\\)\\(\\). must be a nonstatic member function" }
> +template<template<typename> class B> A<B<int>::x> operator() (); // { dg-error "51:.A<B<int>::x> operator\\(\\)\\(\\). must be a non-static member function" }
> diff --git a/gcc/testsuite/g++.old-deja/g++.jason/operator.C b/gcc/testsuite/g++.old-deja/g++.jason/operator.C
> index 69a41cf2448..79c1932a353 100644
> --- a/gcc/testsuite/g++.old-deja/g++.jason/operator.C
> +++ b/gcc/testsuite/g++.old-deja/g++.jason/operator.C
> @@ -6,7 +6,7 @@ typedef __SIZE_TYPE__ size_t;
>   
>   struct A {
>     int operator?:(int a, int b);	   // { dg-error "prohibits overloading" }
> -  static int operator()(int a);	   // { dg-error "14:.static int A::operator\\(\\)\\(int\\). must be a nonstatic member function" }
> +  static int operator()(int a);	   // { dg-error "14:.static int A::operator\\(\\)\\(int\\). must be a non-static member function" }
>     static int operator+(A,A);	   // { dg-error "14:.static int A::operator\\+\\(A, A\\). must be either a non-static member function or a non-member function" }
>     int operator+(int a, int b = 1); // { dg-error "7:.int A::operator\\+\\(int, int\\). must have either zero or one argument" }
>     int operator++(char);		   // { dg-error "7:postfix .int A::operator\\+\\+\\(char\\). must have .int. as its argument" }
> @@ -29,4 +29,4 @@ void * operator new (A a);	// { dg-error ".operator new. takes type .size_t." }
>   void operator delete (A a);	// { dg-error ".operator delete. takes type .void\\*. as first parameter" }
>   
>   char * operator char * (int);	// { dg-error "return type" "ret" }
> -// { dg-error "8:.operator char\\*\\*\\(int\\). must be a nonstatic member function" "mem" { target *-*-* } .-1 }
> +// { dg-error "8:.operator char\\*\\*\\(int\\). must be a non-static member function" "mem" { target *-*-* } .-1 }
> 
> base-commit: 02f7334ac93f53ed06d881beb611e88be36dc56a
>
Li, Pan2 via Gcc-patches March 19, 2020, 4:51 p.m. UTC | #3
On Thu, Mar 19, 2020 at 10:45:01AM -0600, Martin Sebor via Gcc-patches wrote:
> On 3/19/20 9:48 AM, Marek Polacek via Gcc-patches wrote:
> > I was looking at DR 296 and noticed that we say "nonstatic" instead of
> > "non-static", which is the version the standard uses.  So this patch
> > fixes the spelling throughout the front end.  Did not check e.g.
> > non-dependent or any other.
> > 
> > Bootstrapped/regtested on x86_64-linux, ok for trunk?
> 
> If this is the spelling we want to standardize on, would you mind
> adding a check to -Wformat-diag as well so these misspellings get
> diagnosed in diagnostic messages?  We might also want to add
> a mention of it to the Spelling section of the GCC Coding
> Conventions.

Good point, I can definitely add it.  For now I'm putting this aside though.

> Alternatively, please try to remember to CC me when you commit
> the patch in stage1 and I'll add that myself.
> 
> Thanks
> Martin
> 
> PS The hyphenated form makes sense to me when applied to keywords
> or standard terms like non-inline or non-static.  I'm not sure it's
> necessary or even widespread in other already established terms
> like nonnegative, and it's even explicitly discouraged in the GCC
> Coding Conventions for nonzero.
> 
> > 
> > 	* decl.c (grok_op_properties): Fix spelling of non-static.
> > 	* typeck.c (build_class_member_access_expr): Likewise.
> > 
> > 	* g++.dg/other/operator1.C: Adjust expected message.
> > 	* g++.dg/overload/operator2.C: Likewise.
> > 	* g++.dg/template/error30.C: Likewise.
> > 	* g++.old-deja/g++.jason/operator.C: Likewise.
> > ---
> >   gcc/cp/call.c                                   |  2 +-
> >   gcc/cp/class.c                                  |  8 ++++----
> >   gcc/cp/cxx-pretty-print.c                       |  2 +-
> >   gcc/cp/decl.c                                   |  2 +-
> >   gcc/cp/init.c                                   | 10 +++++-----
> >   gcc/cp/search.c                                 |  6 +++---
> >   gcc/cp/typeck.c                                 |  2 +-
> >   gcc/testsuite/g++.dg/other/operator1.C          |  2 +-
> >   gcc/testsuite/g++.dg/overload/operator2.C       |  4 ++--
> >   gcc/testsuite/g++.dg/template/error30.C         |  2 +-
> >   gcc/testsuite/g++.old-deja/g++.jason/operator.C |  4 ++--
> >   11 files changed, 22 insertions(+), 22 deletions(-)
> > 
> > diff --git a/gcc/cp/call.c b/gcc/cp/call.c
> > index 1715acc0ec3..db396f428a4 100644
> > --- a/gcc/cp/call.c
> > +++ b/gcc/cp/call.c
> > @@ -8671,7 +8671,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
> >   	      (DECL_CONTEXT (fn), BINFO_TYPE (cand->conversion_path))))
> >   	flags |= LOOKUP_NONVIRTUAL;
> > -      /* [class.mfct.nonstatic]: If a nonstatic member function of a class
> > +      /* [class.mfct.non-static]: If a non-static member function of a class
> >   	 X is called for an object that is not of type X, or of a type
> >   	 derived from X, the behavior is undefined.
> > diff --git a/gcc/cp/class.c b/gcc/cp/class.c
> > index 5340799fdd3..fb2ef202629 100644
> > --- a/gcc/cp/class.c
> > +++ b/gcc/cp/class.c
> > @@ -3661,7 +3661,7 @@ check_field_decls (tree t, tree *access_decls,
> >   	    {
> >   	      /* ARM $12.6.2: [A member initializer list] (or, for an
> >   		 aggregate, initialization by a brace-enclosed list) is the
> > -		 only way to initialize nonstatic const and reference
> > +		 only way to initialize non-static const and reference
> >   		 members.  */
> >   	      TYPE_HAS_COMPLEX_COPY_ASSIGN (t) = 1;
> >   	      TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) = 1;
> > @@ -3784,7 +3784,7 @@ check_field_decls (tree t, tree *access_decls,
> >   	    {
> >   	      /* ARM $12.6.2: [A member initializer list] (or, for an
> >   		 aggregate, initialization by a brace-enclosed list) is the
> > -		 only way to initialize nonstatic const and reference
> > +		 only way to initialize non-static const and reference
> >   		 members.  */
> >   	      TYPE_HAS_COMPLEX_COPY_ASSIGN (t) = 1;
> >   	      TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) = 1;
> > @@ -3799,7 +3799,7 @@ check_field_decls (tree t, tree *access_decls,
> >   	    | CLASSTYPE_READONLY_FIELDS_NEED_INIT (type));
> >   	}
> > -      /* Core issue 80: A nonstatic data member is required to have a
> > +      /* Core issue 80: A non-static data member is required to have a
> >   	 different name from the class iff the class has a
> >   	 user-declared constructor.  */
> >         if (constructor_name_p (DECL_NAME (field), t)
> > @@ -8104,7 +8104,7 @@ resolve_address_of_overloaded_function (tree target_type,
> >          member functions match targets of type "pointer-to-member
> >          function;" the function type of the pointer to member is used to
> >          select the member function from the set of overloaded member
> > -       functions.  If a nonstatic member function is selected, the
> > +       functions.  If a non-static member function is selected, the
> >          reference to the overloaded function name is required to have the
> >          form of a pointer to member as described in 5.3.1.
> > diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c
> > index 100154e400f..05c56775adc 100644
> > --- a/gcc/cp/cxx-pretty-print.c
> > +++ b/gcc/cp/cxx-pretty-print.c
> > @@ -1532,7 +1532,7 @@ pp_cxx_parameter_declaration_clause (cxx_pretty_printer *pp, tree t)
> >       }
> >     bool first = true;
> > -  /* Skip artificial parameter for nonstatic member functions.  */
> > +  /* Skip artificial parameter for non-static member functions.  */
> >     if (TREE_CODE (t) == METHOD_TYPE)
> >       types = TREE_CHAIN (types);
> > diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
> > index 319b7ee5c1c..31025cd5edc 100644
> > --- a/gcc/cp/decl.c
> > +++ b/gcc/cp/decl.c
> > @@ -14388,7 +14388,7 @@ grok_op_properties (tree decl, bool complain)
> >   	  || operator_code == ARRAY_REF
> >   	  || operator_code == NOP_EXPR)
> >   	{
> > -	  error_at (loc, "%qD must be a nonstatic member function", decl);
> > +	  error_at (loc, "%qD must be a non-static member function", decl);
> >   	  return false;
> >   	}
> > diff --git a/gcc/cp/init.c b/gcc/cp/init.c
> > index 27623cf4db1..ac661e06d20 100644
> > --- a/gcc/cp/init.c
> > +++ b/gcc/cp/init.c
> > @@ -160,7 +160,7 @@ build_zero_init_1 (tree type, tree nelts, bool static_storage_p,
> >        -- if T is a scalar type, the storage is set to the value of zero
> >   	converted to T.
> > -     -- if T is a non-union class type, the storage for each nonstatic
> > +     -- if T is a non-union class type, the storage for each non-static
> >   	data member and each base-class subobject is zero-initialized.
> >        -- if T is a union type, the storage for its first data member is
> > @@ -2219,8 +2219,8 @@ build_offset_ref (tree type, tree member, bool address_p,
> >         /* If MEMBER is non-static, then the program has fallen afoul of
> >   	 [expr.prim]:
> > -	   An id-expression that denotes a nonstatic data member or
> > -	   nonstatic member function of a class can only be used:
> > +	   An id-expression that denotes a non-static data member or
> > +	   non-static member function of a class can only be used:
> >   	   -- as part of a class member access (_expr.ref_) in which the
> >   	   object-expression refers to the member's class or a class
> > @@ -2228,8 +2228,8 @@ build_offset_ref (tree type, tree member, bool address_p,
> >   	   -- to form a pointer to member (_expr.unary.op_), or
> > -	   -- in the body of a nonstatic member function of that class or
> > -	   of a class derived from that class (_class.mfct.nonstatic_), or
> > +	   -- in the body of a non-static member function of that class or
> > +	   of a class derived from that class (_class.mfct.non-static_), or
> >   	   -- in a mem-initializer for a constructor for that class or for
> >   	   a class derived from that class (_class.base.init_).  */
> > diff --git a/gcc/cp/search.c b/gcc/cp/search.c
> > index 6eada2d3788..d9a2d748428 100644
> > --- a/gcc/cp/search.c
> > +++ b/gcc/cp/search.c
> > @@ -631,7 +631,7 @@ protected_accessible_p (tree decl, tree derived, tree type, tree otype)
> >     /* [class.protected]
> >        When a friend or a member function of a derived class references
> > -     a protected nonstatic member of a base class, an access check
> > +     a protected non-static member of a base class, an access check
> >        applies in addition to those described earlier in clause
> >        _class.access_) Except when forming a pointer to member
> >        (_expr.unary.op_), the access must be through a pointer to,
> > @@ -921,11 +921,11 @@ struct lookup_field_info {
> >      of that class.
> >      [class.member.lookup]:If the resulting set of declarations are not all
> > -   from sub-objects of the same type, or the set has a  nonstatic  member
> > +   from sub-objects of the same type, or the set has a non-static member
> >      and  includes members from distinct sub-objects, there is an ambiguity
> >      and the program is ill-formed.
> > -   This function checks that T contains no nonstatic members.  */
> > +   This function checks that T contains no non-static members.  */
> >   int
> >   shared_member_p (tree t)
> > diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
> > index 8e3188a415d..99d76e18eab 100644
> > --- a/gcc/cp/typeck.c
> > +++ b/gcc/cp/typeck.c
> > @@ -2512,7 +2512,7 @@ build_class_member_access_expr (cp_expr object, tree member,
> >         if (complain & tf_error)
> >   	{
> >   	  if (TREE_CODE (member) == FIELD_DECL)
> > -	    error ("invalid use of nonstatic data member %qE", member);
> > +	    error ("invalid use of non-static data member %qE", member);
> >   	  else
> >   	    error ("%qD is not a member of %qT", member, object_type);
> >   	}
> > diff --git a/gcc/testsuite/g++.dg/other/operator1.C b/gcc/testsuite/g++.dg/other/operator1.C
> > index d0b0cb25f8c..121c106ad18 100644
> > --- a/gcc/testsuite/g++.dg/other/operator1.C
> > +++ b/gcc/testsuite/g++.dg/other/operator1.C
> > @@ -1,7 +1,7 @@
> >   // PR c++/27547
> >   // { dg-do compile }
> > -int operator=(int);  // { dg-error "5:.int operator=\\(int\\). must be a nonstatic member function" }
> > +int operator=(int);  // { dg-error "5:.int operator=\\(int\\). must be a non-static member function" }
> >   void foo()
> >   {
> > diff --git a/gcc/testsuite/g++.dg/overload/operator2.C b/gcc/testsuite/g++.dg/overload/operator2.C
> > index b60c629744e..64640b6cfe0 100644
> > --- a/gcc/testsuite/g++.dg/overload/operator2.C
> > +++ b/gcc/testsuite/g++.dg/overload/operator2.C
> > @@ -3,7 +3,7 @@
> >   struct A
> >   {
> > -  static operator int(); // { dg-error "10:.static A::operator int\\(\\). must be a nonstatic member function" }
> > +  static operator int(); // { dg-error "10:.static A::operator int\\(\\). must be a non-static member function" }
> >   };
> >   struct B
> > @@ -11,4 +11,4 @@ struct B
> >     static int operator*(); // { dg-error "14:.static int B::operator\\*\\(\\). must be either a non-static member function or a non-member function" }
> >   };
> > -static operator int(); // { dg-error "8:.operator int\\(\\). must be a nonstatic member function" }
> > +static operator int(); // { dg-error "8:.operator int\\(\\). must be a non-static member function" }
> > diff --git a/gcc/testsuite/g++.dg/template/error30.C b/gcc/testsuite/g++.dg/template/error30.C
> > index e1706af0b7a..3a87872d526 100644
> > --- a/gcc/testsuite/g++.dg/template/error30.C
> > +++ b/gcc/testsuite/g++.dg/template/error30.C
> > @@ -2,4 +2,4 @@
> >   template<int> struct A;
> > -template<template<typename> class B> A<B<int>::x> operator() (); // { dg-error "51:.A<B<int>::x> operator\\(\\)\\(\\). must be a nonstatic member function" }
> > +template<template<typename> class B> A<B<int>::x> operator() (); // { dg-error "51:.A<B<int>::x> operator\\(\\)\\(\\). must be a non-static member function" }
> > diff --git a/gcc/testsuite/g++.old-deja/g++.jason/operator.C b/gcc/testsuite/g++.old-deja/g++.jason/operator.C
> > index 69a41cf2448..79c1932a353 100644
> > --- a/gcc/testsuite/g++.old-deja/g++.jason/operator.C
> > +++ b/gcc/testsuite/g++.old-deja/g++.jason/operator.C
> > @@ -6,7 +6,7 @@ typedef __SIZE_TYPE__ size_t;
> >   struct A {
> >     int operator?:(int a, int b);	   // { dg-error "prohibits overloading" }
> > -  static int operator()(int a);	   // { dg-error "14:.static int A::operator\\(\\)\\(int\\). must be a nonstatic member function" }
> > +  static int operator()(int a);	   // { dg-error "14:.static int A::operator\\(\\)\\(int\\). must be a non-static member function" }
> >     static int operator+(A,A);	   // { dg-error "14:.static int A::operator\\+\\(A, A\\). must be either a non-static member function or a non-member function" }
> >     int operator+(int a, int b = 1); // { dg-error "7:.int A::operator\\+\\(int, int\\). must have either zero or one argument" }
> >     int operator++(char);		   // { dg-error "7:postfix .int A::operator\\+\\+\\(char\\). must have .int. as its argument" }
> > @@ -29,4 +29,4 @@ void * operator new (A a);	// { dg-error ".operator new. takes type .size_t." }
> >   void operator delete (A a);	// { dg-error ".operator delete. takes type .void\\*. as first parameter" }
> >   char * operator char * (int);	// { dg-error "return type" "ret" }
> > -// { dg-error "8:.operator char\\*\\*\\(int\\). must be a nonstatic member function" "mem" { target *-*-* } .-1 }
> > +// { dg-error "8:.operator char\\*\\*\\(int\\). must be a non-static member function" "mem" { target *-*-* } .-1 }
> > 
> > base-commit: 02f7334ac93f53ed06d881beb611e88be36dc56a
> > 
> 

Marek
Marek Polacek May 7, 2020, 5:24 p.m. UTC | #4
On Thu, Mar 19, 2020 at 12:51:42PM -0400, Marek Polacek via Gcc-patches wrote:
> On Thu, Mar 19, 2020 at 10:45:01AM -0600, Martin Sebor via Gcc-patches wrote:
> > On 3/19/20 9:48 AM, Marek Polacek via Gcc-patches wrote:
> > > I was looking at DR 296 and noticed that we say "nonstatic" instead of
> > > "non-static", which is the version the standard uses.  So this patch
> > > fixes the spelling throughout the front end.  Did not check e.g.
> > > non-dependent or any other.
> > > 
> > > Bootstrapped/regtested on x86_64-linux, ok for trunk?
> > 
> > If this is the spelling we want to standardize on, would you mind
> > adding a check to -Wformat-diag as well so these misspellings get
> > diagnosed in diagnostic messages?  We might also want to add
> > a mention of it to the Spelling section of the GCC Coding
> > Conventions.
> 
> Good point, I can definitely add it.  For now I'm putting this aside though.

Actually, I wasn't sure where to add such a diagnostic, check_plain doesn't seem
to already check for similar typos, so I'll just go ahead with my patch as-is.

> > Alternatively, please try to remember to CC me when you commit
> > the patch in stage1 and I'll add that myself.
> > 
> > Thanks
> > Martin
> > 
> > PS The hyphenated form makes sense to me when applied to keywords
> > or standard terms like non-inline or non-static.  I'm not sure it's
> > necessary or even widespread in other already established terms
> > like nonnegative, and it's even explicitly discouraged in the GCC
> > Coding Conventions for nonzero.
> > 
> > > 
> > > 	* decl.c (grok_op_properties): Fix spelling of non-static.
> > > 	* typeck.c (build_class_member_access_expr): Likewise.
> > > 
> > > 	* g++.dg/other/operator1.C: Adjust expected message.
> > > 	* g++.dg/overload/operator2.C: Likewise.
> > > 	* g++.dg/template/error30.C: Likewise.
> > > 	* g++.old-deja/g++.jason/operator.C: Likewise.
> > > ---
> > >   gcc/cp/call.c                                   |  2 +-
> > >   gcc/cp/class.c                                  |  8 ++++----
> > >   gcc/cp/cxx-pretty-print.c                       |  2 +-
> > >   gcc/cp/decl.c                                   |  2 +-
> > >   gcc/cp/init.c                                   | 10 +++++-----
> > >   gcc/cp/search.c                                 |  6 +++---
> > >   gcc/cp/typeck.c                                 |  2 +-
> > >   gcc/testsuite/g++.dg/other/operator1.C          |  2 +-
> > >   gcc/testsuite/g++.dg/overload/operator2.C       |  4 ++--
> > >   gcc/testsuite/g++.dg/template/error30.C         |  2 +-
> > >   gcc/testsuite/g++.old-deja/g++.jason/operator.C |  4 ++--
> > >   11 files changed, 22 insertions(+), 22 deletions(-)
> > > 
> > > diff --git a/gcc/cp/call.c b/gcc/cp/call.c
> > > index 1715acc0ec3..db396f428a4 100644
> > > --- a/gcc/cp/call.c
> > > +++ b/gcc/cp/call.c
> > > @@ -8671,7 +8671,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
> > >   	      (DECL_CONTEXT (fn), BINFO_TYPE (cand->conversion_path))))
> > >   	flags |= LOOKUP_NONVIRTUAL;
> > > -      /* [class.mfct.nonstatic]: If a nonstatic member function of a class
> > > +      /* [class.mfct.non-static]: If a non-static member function of a class
> > >   	 X is called for an object that is not of type X, or of a type
> > >   	 derived from X, the behavior is undefined.
> > > diff --git a/gcc/cp/class.c b/gcc/cp/class.c
> > > index 5340799fdd3..fb2ef202629 100644
> > > --- a/gcc/cp/class.c
> > > +++ b/gcc/cp/class.c
> > > @@ -3661,7 +3661,7 @@ check_field_decls (tree t, tree *access_decls,
> > >   	    {
> > >   	      /* ARM $12.6.2: [A member initializer list] (or, for an
> > >   		 aggregate, initialization by a brace-enclosed list) is the
> > > -		 only way to initialize nonstatic const and reference
> > > +		 only way to initialize non-static const and reference
> > >   		 members.  */
> > >   	      TYPE_HAS_COMPLEX_COPY_ASSIGN (t) = 1;
> > >   	      TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) = 1;
> > > @@ -3784,7 +3784,7 @@ check_field_decls (tree t, tree *access_decls,
> > >   	    {
> > >   	      /* ARM $12.6.2: [A member initializer list] (or, for an
> > >   		 aggregate, initialization by a brace-enclosed list) is the
> > > -		 only way to initialize nonstatic const and reference
> > > +		 only way to initialize non-static const and reference
> > >   		 members.  */
> > >   	      TYPE_HAS_COMPLEX_COPY_ASSIGN (t) = 1;
> > >   	      TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) = 1;
> > > @@ -3799,7 +3799,7 @@ check_field_decls (tree t, tree *access_decls,
> > >   	    | CLASSTYPE_READONLY_FIELDS_NEED_INIT (type));
> > >   	}
> > > -      /* Core issue 80: A nonstatic data member is required to have a
> > > +      /* Core issue 80: A non-static data member is required to have a
> > >   	 different name from the class iff the class has a
> > >   	 user-declared constructor.  */
> > >         if (constructor_name_p (DECL_NAME (field), t)
> > > @@ -8104,7 +8104,7 @@ resolve_address_of_overloaded_function (tree target_type,
> > >          member functions match targets of type "pointer-to-member
> > >          function;" the function type of the pointer to member is used to
> > >          select the member function from the set of overloaded member
> > > -       functions.  If a nonstatic member function is selected, the
> > > +       functions.  If a non-static member function is selected, the
> > >          reference to the overloaded function name is required to have the
> > >          form of a pointer to member as described in 5.3.1.
> > > diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c
> > > index 100154e400f..05c56775adc 100644
> > > --- a/gcc/cp/cxx-pretty-print.c
> > > +++ b/gcc/cp/cxx-pretty-print.c
> > > @@ -1532,7 +1532,7 @@ pp_cxx_parameter_declaration_clause (cxx_pretty_printer *pp, tree t)
> > >       }
> > >     bool first = true;
> > > -  /* Skip artificial parameter for nonstatic member functions.  */
> > > +  /* Skip artificial parameter for non-static member functions.  */
> > >     if (TREE_CODE (t) == METHOD_TYPE)
> > >       types = TREE_CHAIN (types);
> > > diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
> > > index 319b7ee5c1c..31025cd5edc 100644
> > > --- a/gcc/cp/decl.c
> > > +++ b/gcc/cp/decl.c
> > > @@ -14388,7 +14388,7 @@ grok_op_properties (tree decl, bool complain)
> > >   	  || operator_code == ARRAY_REF
> > >   	  || operator_code == NOP_EXPR)
> > >   	{
> > > -	  error_at (loc, "%qD must be a nonstatic member function", decl);
> > > +	  error_at (loc, "%qD must be a non-static member function", decl);
> > >   	  return false;
> > >   	}
> > > diff --git a/gcc/cp/init.c b/gcc/cp/init.c
> > > index 27623cf4db1..ac661e06d20 100644
> > > --- a/gcc/cp/init.c
> > > +++ b/gcc/cp/init.c
> > > @@ -160,7 +160,7 @@ build_zero_init_1 (tree type, tree nelts, bool static_storage_p,
> > >        -- if T is a scalar type, the storage is set to the value of zero
> > >   	converted to T.
> > > -     -- if T is a non-union class type, the storage for each nonstatic
> > > +     -- if T is a non-union class type, the storage for each non-static
> > >   	data member and each base-class subobject is zero-initialized.
> > >        -- if T is a union type, the storage for its first data member is
> > > @@ -2219,8 +2219,8 @@ build_offset_ref (tree type, tree member, bool address_p,
> > >         /* If MEMBER is non-static, then the program has fallen afoul of
> > >   	 [expr.prim]:
> > > -	   An id-expression that denotes a nonstatic data member or
> > > -	   nonstatic member function of a class can only be used:
> > > +	   An id-expression that denotes a non-static data member or
> > > +	   non-static member function of a class can only be used:
> > >   	   -- as part of a class member access (_expr.ref_) in which the
> > >   	   object-expression refers to the member's class or a class
> > > @@ -2228,8 +2228,8 @@ build_offset_ref (tree type, tree member, bool address_p,
> > >   	   -- to form a pointer to member (_expr.unary.op_), or
> > > -	   -- in the body of a nonstatic member function of that class or
> > > -	   of a class derived from that class (_class.mfct.nonstatic_), or
> > > +	   -- in the body of a non-static member function of that class or
> > > +	   of a class derived from that class (_class.mfct.non-static_), or
> > >   	   -- in a mem-initializer for a constructor for that class or for
> > >   	   a class derived from that class (_class.base.init_).  */
> > > diff --git a/gcc/cp/search.c b/gcc/cp/search.c
> > > index 6eada2d3788..d9a2d748428 100644
> > > --- a/gcc/cp/search.c
> > > +++ b/gcc/cp/search.c
> > > @@ -631,7 +631,7 @@ protected_accessible_p (tree decl, tree derived, tree type, tree otype)
> > >     /* [class.protected]
> > >        When a friend or a member function of a derived class references
> > > -     a protected nonstatic member of a base class, an access check
> > > +     a protected non-static member of a base class, an access check
> > >        applies in addition to those described earlier in clause
> > >        _class.access_) Except when forming a pointer to member
> > >        (_expr.unary.op_), the access must be through a pointer to,
> > > @@ -921,11 +921,11 @@ struct lookup_field_info {
> > >      of that class.
> > >      [class.member.lookup]:If the resulting set of declarations are not all
> > > -   from sub-objects of the same type, or the set has a  nonstatic  member
> > > +   from sub-objects of the same type, or the set has a non-static member
> > >      and  includes members from distinct sub-objects, there is an ambiguity
> > >      and the program is ill-formed.
> > > -   This function checks that T contains no nonstatic members.  */
> > > +   This function checks that T contains no non-static members.  */
> > >   int
> > >   shared_member_p (tree t)
> > > diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
> > > index 8e3188a415d..99d76e18eab 100644
> > > --- a/gcc/cp/typeck.c
> > > +++ b/gcc/cp/typeck.c
> > > @@ -2512,7 +2512,7 @@ build_class_member_access_expr (cp_expr object, tree member,
> > >         if (complain & tf_error)
> > >   	{
> > >   	  if (TREE_CODE (member) == FIELD_DECL)
> > > -	    error ("invalid use of nonstatic data member %qE", member);
> > > +	    error ("invalid use of non-static data member %qE", member);
> > >   	  else
> > >   	    error ("%qD is not a member of %qT", member, object_type);
> > >   	}
> > > diff --git a/gcc/testsuite/g++.dg/other/operator1.C b/gcc/testsuite/g++.dg/other/operator1.C
> > > index d0b0cb25f8c..121c106ad18 100644
> > > --- a/gcc/testsuite/g++.dg/other/operator1.C
> > > +++ b/gcc/testsuite/g++.dg/other/operator1.C
> > > @@ -1,7 +1,7 @@
> > >   // PR c++/27547
> > >   // { dg-do compile }
> > > -int operator=(int);  // { dg-error "5:.int operator=\\(int\\). must be a nonstatic member function" }
> > > +int operator=(int);  // { dg-error "5:.int operator=\\(int\\). must be a non-static member function" }
> > >   void foo()
> > >   {
> > > diff --git a/gcc/testsuite/g++.dg/overload/operator2.C b/gcc/testsuite/g++.dg/overload/operator2.C
> > > index b60c629744e..64640b6cfe0 100644
> > > --- a/gcc/testsuite/g++.dg/overload/operator2.C
> > > +++ b/gcc/testsuite/g++.dg/overload/operator2.C
> > > @@ -3,7 +3,7 @@
> > >   struct A
> > >   {
> > > -  static operator int(); // { dg-error "10:.static A::operator int\\(\\). must be a nonstatic member function" }
> > > +  static operator int(); // { dg-error "10:.static A::operator int\\(\\). must be a non-static member function" }
> > >   };
> > >   struct B
> > > @@ -11,4 +11,4 @@ struct B
> > >     static int operator*(); // { dg-error "14:.static int B::operator\\*\\(\\). must be either a non-static member function or a non-member function" }
> > >   };
> > > -static operator int(); // { dg-error "8:.operator int\\(\\). must be a nonstatic member function" }
> > > +static operator int(); // { dg-error "8:.operator int\\(\\). must be a non-static member function" }
> > > diff --git a/gcc/testsuite/g++.dg/template/error30.C b/gcc/testsuite/g++.dg/template/error30.C
> > > index e1706af0b7a..3a87872d526 100644
> > > --- a/gcc/testsuite/g++.dg/template/error30.C
> > > +++ b/gcc/testsuite/g++.dg/template/error30.C
> > > @@ -2,4 +2,4 @@
> > >   template<int> struct A;
> > > -template<template<typename> class B> A<B<int>::x> operator() (); // { dg-error "51:.A<B<int>::x> operator\\(\\)\\(\\). must be a nonstatic member function" }
> > > +template<template<typename> class B> A<B<int>::x> operator() (); // { dg-error "51:.A<B<int>::x> operator\\(\\)\\(\\). must be a non-static member function" }
> > > diff --git a/gcc/testsuite/g++.old-deja/g++.jason/operator.C b/gcc/testsuite/g++.old-deja/g++.jason/operator.C
> > > index 69a41cf2448..79c1932a353 100644
> > > --- a/gcc/testsuite/g++.old-deja/g++.jason/operator.C
> > > +++ b/gcc/testsuite/g++.old-deja/g++.jason/operator.C
> > > @@ -6,7 +6,7 @@ typedef __SIZE_TYPE__ size_t;
> > >   struct A {
> > >     int operator?:(int a, int b);	   // { dg-error "prohibits overloading" }
> > > -  static int operator()(int a);	   // { dg-error "14:.static int A::operator\\(\\)\\(int\\). must be a nonstatic member function" }
> > > +  static int operator()(int a);	   // { dg-error "14:.static int A::operator\\(\\)\\(int\\). must be a non-static member function" }
> > >     static int operator+(A,A);	   // { dg-error "14:.static int A::operator\\+\\(A, A\\). must be either a non-static member function or a non-member function" }
> > >     int operator+(int a, int b = 1); // { dg-error "7:.int A::operator\\+\\(int, int\\). must have either zero or one argument" }
> > >     int operator++(char);		   // { dg-error "7:postfix .int A::operator\\+\\+\\(char\\). must have .int. as its argument" }
> > > @@ -29,4 +29,4 @@ void * operator new (A a);	// { dg-error ".operator new. takes type .size_t." }
> > >   void operator delete (A a);	// { dg-error ".operator delete. takes type .void\\*. as first parameter" }
> > >   char * operator char * (int);	// { dg-error "return type" "ret" }
> > > -// { dg-error "8:.operator char\\*\\*\\(int\\). must be a nonstatic member function" "mem" { target *-*-* } .-1 }
> > > +// { dg-error "8:.operator char\\*\\*\\(int\\). must be a non-static member function" "mem" { target *-*-* } .-1 }
> > > 
> > > base-commit: 02f7334ac93f53ed06d881beb611e88be36dc56a
> > > 
> > 
> 
> Marek
>
Martin Sebor May 7, 2020, 6:34 p.m. UTC | #5
On 5/7/20 11:24 AM, Marek Polacek wrote:
> On Thu, Mar 19, 2020 at 12:51:42PM -0400, Marek Polacek via Gcc-patches wrote:
>> On Thu, Mar 19, 2020 at 10:45:01AM -0600, Martin Sebor via Gcc-patches wrote:
>>> On 3/19/20 9:48 AM, Marek Polacek via Gcc-patches wrote:
>>>> I was looking at DR 296 and noticed that we say "nonstatic" instead of
>>>> "non-static", which is the version the standard uses.  So this patch
>>>> fixes the spelling throughout the front end.  Did not check e.g.
>>>> non-dependent or any other.
>>>>
>>>> Bootstrapped/regtested on x86_64-linux, ok for trunk?
>>>
>>> If this is the spelling we want to standardize on, would you mind
>>> adding a check to -Wformat-diag as well so these misspellings get
>>> diagnosed in diagnostic messages?  We might also want to add
>>> a mention of it to the Spelling section of the GCC Coding
>>> Conventions.
>>
>> Good point, I can definitely add it.  For now I'm putting this aside though.
> 
> Actually, I wasn't sure where to add such a diagnostic, check_plain doesn't seem
> to already check for similar typos, so I'll just go ahead with my patch as-is.

Thanks for remembering this!  I think the word should be added to
the badwords array (above "non-static").  But I can do that if you
prefer.  Looks like I'll be doing some work in this space anyway.

Martin

> 
>>> Alternatively, please try to remember to CC me when you commit
>>> the patch in stage1 and I'll add that myself.
>>>
>>> Thanks
>>> Martin
>>>
>>> PS The hyphenated form makes sense to me when applied to keywords
>>> or standard terms like non-inline or non-static.  I'm not sure it's
>>> necessary or even widespread in other already established terms
>>> like nonnegative, and it's even explicitly discouraged in the GCC
>>> Coding Conventions for nonzero.
>>>
>>>>
>>>> 	* decl.c (grok_op_properties): Fix spelling of non-static.
>>>> 	* typeck.c (build_class_member_access_expr): Likewise.
>>>>
>>>> 	* g++.dg/other/operator1.C: Adjust expected message.
>>>> 	* g++.dg/overload/operator2.C: Likewise.
>>>> 	* g++.dg/template/error30.C: Likewise.
>>>> 	* g++.old-deja/g++.jason/operator.C: Likewise.
>>>> ---
>>>>    gcc/cp/call.c                                   |  2 +-
>>>>    gcc/cp/class.c                                  |  8 ++++----
>>>>    gcc/cp/cxx-pretty-print.c                       |  2 +-
>>>>    gcc/cp/decl.c                                   |  2 +-
>>>>    gcc/cp/init.c                                   | 10 +++++-----
>>>>    gcc/cp/search.c                                 |  6 +++---
>>>>    gcc/cp/typeck.c                                 |  2 +-
>>>>    gcc/testsuite/g++.dg/other/operator1.C          |  2 +-
>>>>    gcc/testsuite/g++.dg/overload/operator2.C       |  4 ++--
>>>>    gcc/testsuite/g++.dg/template/error30.C         |  2 +-
>>>>    gcc/testsuite/g++.old-deja/g++.jason/operator.C |  4 ++--
>>>>    11 files changed, 22 insertions(+), 22 deletions(-)
>>>>
>>>> diff --git a/gcc/cp/call.c b/gcc/cp/call.c
>>>> index 1715acc0ec3..db396f428a4 100644
>>>> --- a/gcc/cp/call.c
>>>> +++ b/gcc/cp/call.c
>>>> @@ -8671,7 +8671,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
>>>>    	      (DECL_CONTEXT (fn), BINFO_TYPE (cand->conversion_path))))
>>>>    	flags |= LOOKUP_NONVIRTUAL;
>>>> -      /* [class.mfct.nonstatic]: If a nonstatic member function of a class
>>>> +      /* [class.mfct.non-static]: If a non-static member function of a class
>>>>    	 X is called for an object that is not of type X, or of a type
>>>>    	 derived from X, the behavior is undefined.
>>>> diff --git a/gcc/cp/class.c b/gcc/cp/class.c
>>>> index 5340799fdd3..fb2ef202629 100644
>>>> --- a/gcc/cp/class.c
>>>> +++ b/gcc/cp/class.c
>>>> @@ -3661,7 +3661,7 @@ check_field_decls (tree t, tree *access_decls,
>>>>    	    {
>>>>    	      /* ARM $12.6.2: [A member initializer list] (or, for an
>>>>    		 aggregate, initialization by a brace-enclosed list) is the
>>>> -		 only way to initialize nonstatic const and reference
>>>> +		 only way to initialize non-static const and reference
>>>>    		 members.  */
>>>>    	      TYPE_HAS_COMPLEX_COPY_ASSIGN (t) = 1;
>>>>    	      TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) = 1;
>>>> @@ -3784,7 +3784,7 @@ check_field_decls (tree t, tree *access_decls,
>>>>    	    {
>>>>    	      /* ARM $12.6.2: [A member initializer list] (or, for an
>>>>    		 aggregate, initialization by a brace-enclosed list) is the
>>>> -		 only way to initialize nonstatic const and reference
>>>> +		 only way to initialize non-static const and reference
>>>>    		 members.  */
>>>>    	      TYPE_HAS_COMPLEX_COPY_ASSIGN (t) = 1;
>>>>    	      TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) = 1;
>>>> @@ -3799,7 +3799,7 @@ check_field_decls (tree t, tree *access_decls,
>>>>    	    | CLASSTYPE_READONLY_FIELDS_NEED_INIT (type));
>>>>    	}
>>>> -      /* Core issue 80: A nonstatic data member is required to have a
>>>> +      /* Core issue 80: A non-static data member is required to have a
>>>>    	 different name from the class iff the class has a
>>>>    	 user-declared constructor.  */
>>>>          if (constructor_name_p (DECL_NAME (field), t)
>>>> @@ -8104,7 +8104,7 @@ resolve_address_of_overloaded_function (tree target_type,
>>>>           member functions match targets of type "pointer-to-member
>>>>           function;" the function type of the pointer to member is used to
>>>>           select the member function from the set of overloaded member
>>>> -       functions.  If a nonstatic member function is selected, the
>>>> +       functions.  If a non-static member function is selected, the
>>>>           reference to the overloaded function name is required to have the
>>>>           form of a pointer to member as described in 5.3.1.
>>>> diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c
>>>> index 100154e400f..05c56775adc 100644
>>>> --- a/gcc/cp/cxx-pretty-print.c
>>>> +++ b/gcc/cp/cxx-pretty-print.c
>>>> @@ -1532,7 +1532,7 @@ pp_cxx_parameter_declaration_clause (cxx_pretty_printer *pp, tree t)
>>>>        }
>>>>      bool first = true;
>>>> -  /* Skip artificial parameter for nonstatic member functions.  */
>>>> +  /* Skip artificial parameter for non-static member functions.  */
>>>>      if (TREE_CODE (t) == METHOD_TYPE)
>>>>        types = TREE_CHAIN (types);
>>>> diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
>>>> index 319b7ee5c1c..31025cd5edc 100644
>>>> --- a/gcc/cp/decl.c
>>>> +++ b/gcc/cp/decl.c
>>>> @@ -14388,7 +14388,7 @@ grok_op_properties (tree decl, bool complain)
>>>>    	  || operator_code == ARRAY_REF
>>>>    	  || operator_code == NOP_EXPR)
>>>>    	{
>>>> -	  error_at (loc, "%qD must be a nonstatic member function", decl);
>>>> +	  error_at (loc, "%qD must be a non-static member function", decl);
>>>>    	  return false;
>>>>    	}
>>>> diff --git a/gcc/cp/init.c b/gcc/cp/init.c
>>>> index 27623cf4db1..ac661e06d20 100644
>>>> --- a/gcc/cp/init.c
>>>> +++ b/gcc/cp/init.c
>>>> @@ -160,7 +160,7 @@ build_zero_init_1 (tree type, tree nelts, bool static_storage_p,
>>>>         -- if T is a scalar type, the storage is set to the value of zero
>>>>    	converted to T.
>>>> -     -- if T is a non-union class type, the storage for each nonstatic
>>>> +     -- if T is a non-union class type, the storage for each non-static
>>>>    	data member and each base-class subobject is zero-initialized.
>>>>         -- if T is a union type, the storage for its first data member is
>>>> @@ -2219,8 +2219,8 @@ build_offset_ref (tree type, tree member, bool address_p,
>>>>          /* If MEMBER is non-static, then the program has fallen afoul of
>>>>    	 [expr.prim]:
>>>> -	   An id-expression that denotes a nonstatic data member or
>>>> -	   nonstatic member function of a class can only be used:
>>>> +	   An id-expression that denotes a non-static data member or
>>>> +	   non-static member function of a class can only be used:
>>>>    	   -- as part of a class member access (_expr.ref_) in which the
>>>>    	   object-expression refers to the member's class or a class
>>>> @@ -2228,8 +2228,8 @@ build_offset_ref (tree type, tree member, bool address_p,
>>>>    	   -- to form a pointer to member (_expr.unary.op_), or
>>>> -	   -- in the body of a nonstatic member function of that class or
>>>> -	   of a class derived from that class (_class.mfct.nonstatic_), or
>>>> +	   -- in the body of a non-static member function of that class or
>>>> +	   of a class derived from that class (_class.mfct.non-static_), or
>>>>    	   -- in a mem-initializer for a constructor for that class or for
>>>>    	   a class derived from that class (_class.base.init_).  */
>>>> diff --git a/gcc/cp/search.c b/gcc/cp/search.c
>>>> index 6eada2d3788..d9a2d748428 100644
>>>> --- a/gcc/cp/search.c
>>>> +++ b/gcc/cp/search.c
>>>> @@ -631,7 +631,7 @@ protected_accessible_p (tree decl, tree derived, tree type, tree otype)
>>>>      /* [class.protected]
>>>>         When a friend or a member function of a derived class references
>>>> -     a protected nonstatic member of a base class, an access check
>>>> +     a protected non-static member of a base class, an access check
>>>>         applies in addition to those described earlier in clause
>>>>         _class.access_) Except when forming a pointer to member
>>>>         (_expr.unary.op_), the access must be through a pointer to,
>>>> @@ -921,11 +921,11 @@ struct lookup_field_info {
>>>>       of that class.
>>>>       [class.member.lookup]:If the resulting set of declarations are not all
>>>> -   from sub-objects of the same type, or the set has a  nonstatic  member
>>>> +   from sub-objects of the same type, or the set has a non-static member
>>>>       and  includes members from distinct sub-objects, there is an ambiguity
>>>>       and the program is ill-formed.
>>>> -   This function checks that T contains no nonstatic members.  */
>>>> +   This function checks that T contains no non-static members.  */
>>>>    int
>>>>    shared_member_p (tree t)
>>>> diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
>>>> index 8e3188a415d..99d76e18eab 100644
>>>> --- a/gcc/cp/typeck.c
>>>> +++ b/gcc/cp/typeck.c
>>>> @@ -2512,7 +2512,7 @@ build_class_member_access_expr (cp_expr object, tree member,
>>>>          if (complain & tf_error)
>>>>    	{
>>>>    	  if (TREE_CODE (member) == FIELD_DECL)
>>>> -	    error ("invalid use of nonstatic data member %qE", member);
>>>> +	    error ("invalid use of non-static data member %qE", member);
>>>>    	  else
>>>>    	    error ("%qD is not a member of %qT", member, object_type);
>>>>    	}
>>>> diff --git a/gcc/testsuite/g++.dg/other/operator1.C b/gcc/testsuite/g++.dg/other/operator1.C
>>>> index d0b0cb25f8c..121c106ad18 100644
>>>> --- a/gcc/testsuite/g++.dg/other/operator1.C
>>>> +++ b/gcc/testsuite/g++.dg/other/operator1.C
>>>> @@ -1,7 +1,7 @@
>>>>    // PR c++/27547
>>>>    // { dg-do compile }
>>>> -int operator=(int);  // { dg-error "5:.int operator=\\(int\\). must be a nonstatic member function" }
>>>> +int operator=(int);  // { dg-error "5:.int operator=\\(int\\). must be a non-static member function" }
>>>>    void foo()
>>>>    {
>>>> diff --git a/gcc/testsuite/g++.dg/overload/operator2.C b/gcc/testsuite/g++.dg/overload/operator2.C
>>>> index b60c629744e..64640b6cfe0 100644
>>>> --- a/gcc/testsuite/g++.dg/overload/operator2.C
>>>> +++ b/gcc/testsuite/g++.dg/overload/operator2.C
>>>> @@ -3,7 +3,7 @@
>>>>    struct A
>>>>    {
>>>> -  static operator int(); // { dg-error "10:.static A::operator int\\(\\). must be a nonstatic member function" }
>>>> +  static operator int(); // { dg-error "10:.static A::operator int\\(\\). must be a non-static member function" }
>>>>    };
>>>>    struct B
>>>> @@ -11,4 +11,4 @@ struct B
>>>>      static int operator*(); // { dg-error "14:.static int B::operator\\*\\(\\). must be either a non-static member function or a non-member function" }
>>>>    };
>>>> -static operator int(); // { dg-error "8:.operator int\\(\\). must be a nonstatic member function" }
>>>> +static operator int(); // { dg-error "8:.operator int\\(\\). must be a non-static member function" }
>>>> diff --git a/gcc/testsuite/g++.dg/template/error30.C b/gcc/testsuite/g++.dg/template/error30.C
>>>> index e1706af0b7a..3a87872d526 100644
>>>> --- a/gcc/testsuite/g++.dg/template/error30.C
>>>> +++ b/gcc/testsuite/g++.dg/template/error30.C
>>>> @@ -2,4 +2,4 @@
>>>>    template<int> struct A;
>>>> -template<template<typename> class B> A<B<int>::x> operator() (); // { dg-error "51:.A<B<int>::x> operator\\(\\)\\(\\). must be a nonstatic member function" }
>>>> +template<template<typename> class B> A<B<int>::x> operator() (); // { dg-error "51:.A<B<int>::x> operator\\(\\)\\(\\). must be a non-static member function" }
>>>> diff --git a/gcc/testsuite/g++.old-deja/g++.jason/operator.C b/gcc/testsuite/g++.old-deja/g++.jason/operator.C
>>>> index 69a41cf2448..79c1932a353 100644
>>>> --- a/gcc/testsuite/g++.old-deja/g++.jason/operator.C
>>>> +++ b/gcc/testsuite/g++.old-deja/g++.jason/operator.C
>>>> @@ -6,7 +6,7 @@ typedef __SIZE_TYPE__ size_t;
>>>>    struct A {
>>>>      int operator?:(int a, int b);	   // { dg-error "prohibits overloading" }
>>>> -  static int operator()(int a);	   // { dg-error "14:.static int A::operator\\(\\)\\(int\\). must be a nonstatic member function" }
>>>> +  static int operator()(int a);	   // { dg-error "14:.static int A::operator\\(\\)\\(int\\). must be a non-static member function" }
>>>>      static int operator+(A,A);	   // { dg-error "14:.static int A::operator\\+\\(A, A\\). must be either a non-static member function or a non-member function" }
>>>>      int operator+(int a, int b = 1); // { dg-error "7:.int A::operator\\+\\(int, int\\). must have either zero or one argument" }
>>>>      int operator++(char);		   // { dg-error "7:postfix .int A::operator\\+\\+\\(char\\). must have .int. as its argument" }
>>>> @@ -29,4 +29,4 @@ void * operator new (A a);	// { dg-error ".operator new. takes type .size_t." }
>>>>    void operator delete (A a);	// { dg-error ".operator delete. takes type .void\\*. as first parameter" }
>>>>    char * operator char * (int);	// { dg-error "return type" "ret" }
>>>> -// { dg-error "8:.operator char\\*\\*\\(int\\). must be a nonstatic member function" "mem" { target *-*-* } .-1 }
>>>> +// { dg-error "8:.operator char\\*\\*\\(int\\). must be a non-static member function" "mem" { target *-*-* } .-1 }
>>>>
>>>> base-commit: 02f7334ac93f53ed06d881beb611e88be36dc56a
>>>>
>>>
>>
>> Marek
>>
>
Marek Polacek May 7, 2020, 6:44 p.m. UTC | #6
On Thu, May 07, 2020 at 12:34:44PM -0600, Martin Sebor wrote:
> On 5/7/20 11:24 AM, Marek Polacek wrote:
> > On Thu, Mar 19, 2020 at 12:51:42PM -0400, Marek Polacek via Gcc-patches wrote:
> > > On Thu, Mar 19, 2020 at 10:45:01AM -0600, Martin Sebor via Gcc-patches wrote:
> > > > On 3/19/20 9:48 AM, Marek Polacek via Gcc-patches wrote:
> > > > > I was looking at DR 296 and noticed that we say "nonstatic" instead of
> > > > > "non-static", which is the version the standard uses.  So this patch
> > > > > fixes the spelling throughout the front end.  Did not check e.g.
> > > > > non-dependent or any other.
> > > > > 
> > > > > Bootstrapped/regtested on x86_64-linux, ok for trunk?
> > > > 
> > > > If this is the spelling we want to standardize on, would you mind
> > > > adding a check to -Wformat-diag as well so these misspellings get
> > > > diagnosed in diagnostic messages?  We might also want to add
> > > > a mention of it to the Spelling section of the GCC Coding
> > > > Conventions.
> > > 
> > > Good point, I can definitely add it.  For now I'm putting this aside though.
> > 
> > Actually, I wasn't sure where to add such a diagnostic, check_plain doesn't seem
> > to already check for similar typos, so I'll just go ahead with my patch as-is.
> 
> Thanks for remembering this!  I think the word should be added to
> the badwords array (above "non-static").  But I can do that if you
> prefer.  Looks like I'll be doing some work in this space anyway.

Oof, how did I miss that?  Does this patch look OK to you then?
Not sure if it deserves a test, I would think not.

	* c-format.c (badwords): Add "nonstatic".
---
 gcc/c-family/c-format.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c
index 33a5b6d3965..77d24ad94e4 100644
--- a/gcc/c-family/c-format.c
+++ b/gcc/c-family/c-format.c
@@ -2997,6 +2997,7 @@ static const struct
    NAME ("decl", "declaration"),
    NAME ("enumeral", "enumerated"),
    NAME ("floating point", "floating-point"),
+   NAME ("nonstatic", "non-static"),
    NAME ("non-zero", "nonzero"),
    NAME ("reg", "register"),
    NAME ("stmt", "statement"),

base-commit: 5d5dcc65aae1024da31e0e9cae6a8966461037e8
Martin Sebor May 7, 2020, 6:49 p.m. UTC | #7
On 5/7/20 12:44 PM, Marek Polacek wrote:
> On Thu, May 07, 2020 at 12:34:44PM -0600, Martin Sebor wrote:
>> On 5/7/20 11:24 AM, Marek Polacek wrote:
>>> On Thu, Mar 19, 2020 at 12:51:42PM -0400, Marek Polacek via Gcc-patches wrote:
>>>> On Thu, Mar 19, 2020 at 10:45:01AM -0600, Martin Sebor via Gcc-patches wrote:
>>>>> On 3/19/20 9:48 AM, Marek Polacek via Gcc-patches wrote:
>>>>>> I was looking at DR 296 and noticed that we say "nonstatic" instead of
>>>>>> "non-static", which is the version the standard uses.  So this patch
>>>>>> fixes the spelling throughout the front end.  Did not check e.g.
>>>>>> non-dependent or any other.
>>>>>>
>>>>>> Bootstrapped/regtested on x86_64-linux, ok for trunk?
>>>>>
>>>>> If this is the spelling we want to standardize on, would you mind
>>>>> adding a check to -Wformat-diag as well so these misspellings get
>>>>> diagnosed in diagnostic messages?  We might also want to add
>>>>> a mention of it to the Spelling section of the GCC Coding
>>>>> Conventions.
>>>>
>>>> Good point, I can definitely add it.  For now I'm putting this aside though.
>>>
>>> Actually, I wasn't sure where to add such a diagnostic, check_plain doesn't seem
>>> to already check for similar typos, so I'll just go ahead with my patch as-is.
>>
>> Thanks for remembering this!  I think the word should be added to
>> the badwords array (above "non-static").  But I can do that if you
>> prefer.  Looks like I'll be doing some work in this space anyway.
> 
> Oof, how did I miss that?  Does this patch look OK to you then?
> Not sure if it deserves a test, I would think not.

Looks good to me. (Despite the contrast with nonzero ;)

Thanks again!

Martin

> 
> 	* c-format.c (badwords): Add "nonstatic".
> ---
>   gcc/c-family/c-format.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c
> index 33a5b6d3965..77d24ad94e4 100644
> --- a/gcc/c-family/c-format.c
> +++ b/gcc/c-family/c-format.c
> @@ -2997,6 +2997,7 @@ static const struct
>      NAME ("decl", "declaration"),
>      NAME ("enumeral", "enumerated"),
>      NAME ("floating point", "floating-point"),
> +   NAME ("nonstatic", "non-static"),
>      NAME ("non-zero", "nonzero"),
>      NAME ("reg", "register"),
>      NAME ("stmt", "statement"),
> 
> base-commit: 5d5dcc65aae1024da31e0e9cae6a8966461037e8
>
diff mbox series

Patch

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 1715acc0ec3..db396f428a4 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -8671,7 +8671,7 @@  build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
 	      (DECL_CONTEXT (fn), BINFO_TYPE (cand->conversion_path)))) 
 	flags |= LOOKUP_NONVIRTUAL;
 
-      /* [class.mfct.nonstatic]: If a nonstatic member function of a class
+      /* [class.mfct.non-static]: If a non-static member function of a class
 	 X is called for an object that is not of type X, or of a type
 	 derived from X, the behavior is undefined.
 
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 5340799fdd3..fb2ef202629 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -3661,7 +3661,7 @@  check_field_decls (tree t, tree *access_decls,
 	    {
 	      /* ARM $12.6.2: [A member initializer list] (or, for an
 		 aggregate, initialization by a brace-enclosed list) is the
-		 only way to initialize nonstatic const and reference
+		 only way to initialize non-static const and reference
 		 members.  */
 	      TYPE_HAS_COMPLEX_COPY_ASSIGN (t) = 1;
 	      TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) = 1;
@@ -3784,7 +3784,7 @@  check_field_decls (tree t, tree *access_decls,
 	    {
 	      /* ARM $12.6.2: [A member initializer list] (or, for an
 		 aggregate, initialization by a brace-enclosed list) is the
-		 only way to initialize nonstatic const and reference
+		 only way to initialize non-static const and reference
 		 members.  */
 	      TYPE_HAS_COMPLEX_COPY_ASSIGN (t) = 1;
 	      TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) = 1;
@@ -3799,7 +3799,7 @@  check_field_decls (tree t, tree *access_decls,
 	    | CLASSTYPE_READONLY_FIELDS_NEED_INIT (type));
 	}
 
-      /* Core issue 80: A nonstatic data member is required to have a
+      /* Core issue 80: A non-static data member is required to have a
 	 different name from the class iff the class has a
 	 user-declared constructor.  */
       if (constructor_name_p (DECL_NAME (field), t)
@@ -8104,7 +8104,7 @@  resolve_address_of_overloaded_function (tree target_type,
        member functions match targets of type "pointer-to-member
        function;" the function type of the pointer to member is used to
        select the member function from the set of overloaded member
-       functions.  If a nonstatic member function is selected, the
+       functions.  If a non-static member function is selected, the
        reference to the overloaded function name is required to have the
        form of a pointer to member as described in 5.3.1.
 
diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c
index 100154e400f..05c56775adc 100644
--- a/gcc/cp/cxx-pretty-print.c
+++ b/gcc/cp/cxx-pretty-print.c
@@ -1532,7 +1532,7 @@  pp_cxx_parameter_declaration_clause (cxx_pretty_printer *pp, tree t)
     }
   bool first = true;
 
-  /* Skip artificial parameter for nonstatic member functions.  */
+  /* Skip artificial parameter for non-static member functions.  */
   if (TREE_CODE (t) == METHOD_TYPE)
     types = TREE_CHAIN (types);
 
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 319b7ee5c1c..31025cd5edc 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -14388,7 +14388,7 @@  grok_op_properties (tree decl, bool complain)
 	  || operator_code == ARRAY_REF
 	  || operator_code == NOP_EXPR)
 	{
-	  error_at (loc, "%qD must be a nonstatic member function", decl);
+	  error_at (loc, "%qD must be a non-static member function", decl);
 	  return false;
 	}
 
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 27623cf4db1..ac661e06d20 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -160,7 +160,7 @@  build_zero_init_1 (tree type, tree nelts, bool static_storage_p,
      -- if T is a scalar type, the storage is set to the value of zero
 	converted to T.
 
-     -- if T is a non-union class type, the storage for each nonstatic
+     -- if T is a non-union class type, the storage for each non-static
 	data member and each base-class subobject is zero-initialized.
 
      -- if T is a union type, the storage for its first data member is
@@ -2219,8 +2219,8 @@  build_offset_ref (tree type, tree member, bool address_p,
       /* If MEMBER is non-static, then the program has fallen afoul of
 	 [expr.prim]:
 
-	   An id-expression that denotes a nonstatic data member or
-	   nonstatic member function of a class can only be used:
+	   An id-expression that denotes a non-static data member or
+	   non-static member function of a class can only be used:
 
 	   -- as part of a class member access (_expr.ref_) in which the
 	   object-expression refers to the member's class or a class
@@ -2228,8 +2228,8 @@  build_offset_ref (tree type, tree member, bool address_p,
 
 	   -- to form a pointer to member (_expr.unary.op_), or
 
-	   -- in the body of a nonstatic member function of that class or
-	   of a class derived from that class (_class.mfct.nonstatic_), or
+	   -- in the body of a non-static member function of that class or
+	   of a class derived from that class (_class.mfct.non-static_), or
 
 	   -- in a mem-initializer for a constructor for that class or for
 	   a class derived from that class (_class.base.init_).  */
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index 6eada2d3788..d9a2d748428 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -631,7 +631,7 @@  protected_accessible_p (tree decl, tree derived, tree type, tree otype)
   /* [class.protected]
 
      When a friend or a member function of a derived class references
-     a protected nonstatic member of a base class, an access check
+     a protected non-static member of a base class, an access check
      applies in addition to those described earlier in clause
      _class.access_) Except when forming a pointer to member
      (_expr.unary.op_), the access must be through a pointer to,
@@ -921,11 +921,11 @@  struct lookup_field_info {
    of that class.
 
    [class.member.lookup]:If the resulting set of declarations are not all
-   from sub-objects of the same type, or the set has a  nonstatic  member
+   from sub-objects of the same type, or the set has a non-static member
    and  includes members from distinct sub-objects, there is an ambiguity
    and the program is ill-formed.
 
-   This function checks that T contains no nonstatic members.  */
+   This function checks that T contains no non-static members.  */
 
 int
 shared_member_p (tree t)
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 8e3188a415d..99d76e18eab 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -2512,7 +2512,7 @@  build_class_member_access_expr (cp_expr object, tree member,
       if (complain & tf_error)
 	{
 	  if (TREE_CODE (member) == FIELD_DECL)
-	    error ("invalid use of nonstatic data member %qE", member);
+	    error ("invalid use of non-static data member %qE", member);
 	  else
 	    error ("%qD is not a member of %qT", member, object_type);
 	}
diff --git a/gcc/testsuite/g++.dg/other/operator1.C b/gcc/testsuite/g++.dg/other/operator1.C
index d0b0cb25f8c..121c106ad18 100644
--- a/gcc/testsuite/g++.dg/other/operator1.C
+++ b/gcc/testsuite/g++.dg/other/operator1.C
@@ -1,7 +1,7 @@ 
 // PR c++/27547
 // { dg-do compile }
 
-int operator=(int);  // { dg-error "5:.int operator=\\(int\\). must be a nonstatic member function" }
+int operator=(int);  // { dg-error "5:.int operator=\\(int\\). must be a non-static member function" }
 
 void foo()
 {
diff --git a/gcc/testsuite/g++.dg/overload/operator2.C b/gcc/testsuite/g++.dg/overload/operator2.C
index b60c629744e..64640b6cfe0 100644
--- a/gcc/testsuite/g++.dg/overload/operator2.C
+++ b/gcc/testsuite/g++.dg/overload/operator2.C
@@ -3,7 +3,7 @@ 
 
 struct A
 {
-  static operator int(); // { dg-error "10:.static A::operator int\\(\\). must be a nonstatic member function" }
+  static operator int(); // { dg-error "10:.static A::operator int\\(\\). must be a non-static member function" }
 };
 
 struct B
@@ -11,4 +11,4 @@  struct B
   static int operator*(); // { dg-error "14:.static int B::operator\\*\\(\\). must be either a non-static member function or a non-member function" }
 };
 
-static operator int(); // { dg-error "8:.operator int\\(\\). must be a nonstatic member function" }
+static operator int(); // { dg-error "8:.operator int\\(\\). must be a non-static member function" }
diff --git a/gcc/testsuite/g++.dg/template/error30.C b/gcc/testsuite/g++.dg/template/error30.C
index e1706af0b7a..3a87872d526 100644
--- a/gcc/testsuite/g++.dg/template/error30.C
+++ b/gcc/testsuite/g++.dg/template/error30.C
@@ -2,4 +2,4 @@ 
 
 template<int> struct A;
 
-template<template<typename> class B> A<B<int>::x> operator() (); // { dg-error "51:.A<B<int>::x> operator\\(\\)\\(\\). must be a nonstatic member function" }
+template<template<typename> class B> A<B<int>::x> operator() (); // { dg-error "51:.A<B<int>::x> operator\\(\\)\\(\\). must be a non-static member function" }
diff --git a/gcc/testsuite/g++.old-deja/g++.jason/operator.C b/gcc/testsuite/g++.old-deja/g++.jason/operator.C
index 69a41cf2448..79c1932a353 100644
--- a/gcc/testsuite/g++.old-deja/g++.jason/operator.C
+++ b/gcc/testsuite/g++.old-deja/g++.jason/operator.C
@@ -6,7 +6,7 @@  typedef __SIZE_TYPE__ size_t;
 
 struct A {
   int operator?:(int a, int b);	   // { dg-error "prohibits overloading" } 
-  static int operator()(int a);	   // { dg-error "14:.static int A::operator\\(\\)\\(int\\). must be a nonstatic member function" }
+  static int operator()(int a);	   // { dg-error "14:.static int A::operator\\(\\)\\(int\\). must be a non-static member function" }
   static int operator+(A,A);	   // { dg-error "14:.static int A::operator\\+\\(A, A\\). must be either a non-static member function or a non-member function" } 
   int operator+(int a, int b = 1); // { dg-error "7:.int A::operator\\+\\(int, int\\). must have either zero or one argument" }
   int operator++(char);		   // { dg-error "7:postfix .int A::operator\\+\\+\\(char\\). must have .int. as its argument" }
@@ -29,4 +29,4 @@  void * operator new (A a);	// { dg-error ".operator new. takes type .size_t." }
 void operator delete (A a);	// { dg-error ".operator delete. takes type .void\\*. as first parameter" }
 
 char * operator char * (int);	// { dg-error "return type" "ret" }
-// { dg-error "8:.operator char\\*\\*\\(int\\). must be a nonstatic member function" "mem" { target *-*-* } .-1 }
+// { dg-error "8:.operator char\\*\\*\\(int\\). must be a non-static member function" "mem" { target *-*-* } .-1 }