Hi!

While working on the __builtin_source_location patch, I've noticed that
these two messages are weird:
spaceship-err3.C:11:12: error: ‘std::std::strong_ordering’ is not a type
spaceship-err3.C:11:12: note: forming type of ‘operator<=>’
spaceship-err3.C:13:14: error: 
‘std::partial_ordering::std::partial_ordering::equivalent()’ is not a static 
data member
spaceship-err3.C:13:14: note: determining value of ‘operator<=>’
Note the doubled std:: in the first case and std::partial_ordering:: in the
second case.  Most of the code that uses %<%T::%D%> elsewhere prints
DECL_NAME rather than the actual decl, but in this case when it is a decl,
there is no need to prefix it with anything.

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

2019-11-16  Jakub Jelinek  <ja...@redhat.com>

        * method.c (lookup_comparison_result): Use %qD instead of %<%T::%D%>
        to print the decl.
        (lookup_comparison_category): Use %qD instead of %<std::%D%> to print
        the decl.

        * g++.dg/cpp2a/spaceship-err3.C: New test.

--- gcc/cp/method.c.jj  2019-11-13 19:13:12.059100901 +0100
+++ gcc/cp/method.c     2019-11-16 00:07:56.080097451 +0100
@@ -924,7 +924,7 @@ lookup_comparison_result (tree type, con
          if (decl == error_mark_node || TREE_CODE (decl) == TREE_LIST)
            qualified_name_lookup_error (type, name, decl, input_location);
          else
-           error ("%<%T::%D%> is not a static data member", type, decl);
+           error ("%qD is not a static data member", decl);
          inform (input_location, "determining value of %qs", "operator<=>");
        }
       return error_mark_node;
@@ -951,7 +951,7 @@ lookup_comparison_category (comp_cat_tag
          if (decl == error_mark_node || TREE_CODE (decl) == TREE_LIST)
            qualified_name_lookup_error (std_node, name, decl, input_location);
          else
-           error ("%<std::%D%> is not a type", decl);
+           error ("%qD is not a type", decl);
          inform (input_location, "forming type of %qs", "operator<=>");
        }
       return error_mark_node;
--- gcc/testsuite/g++.dg/cpp2a/spaceship-err3.C.jj      2019-11-16 
00:11:19.105048135 +0100
+++ gcc/testsuite/g++.dg/cpp2a/spaceship-err3.C 2019-11-16 00:12:21.637108940 
+0100
@@ -0,0 +1,14 @@
+// { dg-do compile { target c++2a } }
+
+namespace std
+{
+  int strong_ordering;
+  struct partial_ordering {
+    static int equivalent ();
+  };
+}
+
+auto a = 1 <=> 2;      // { dg-error "'std::strong_ordering' is not a type" }
+                       // { dg-message "forming type of 'operator<=>'" "" { 
target *-*-* } .-1 }
+auto b = 3.0 <=> 4.0;  // { dg-error 
"'std::partial_ordering::equivalent\\(\\)' is not a static data member" }
+                       // { dg-message "determining value of 'operator<=>'" "" 
{ target *-*-* } .-1 }

        Jakub

Reply via email to