public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ Patch] Prefer error + inform in four typeck.c places
@ 2019-10-24 14:07 Paolo Carlini
  2019-10-30  4:57 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Paolo Carlini @ 2019-10-24 14:07 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill

[-- Attachment #1: Type: text/plain, Size: 186 bytes --]

Hi,

some additional straightforward bits in typeck.c, which I noticed when I 
went through the cp_build_binary_op callers. Tested x86_64-linux.

Thanks, Paolo.

//////////////////////


[-- Attachment #2: CL_locs_57 --]
[-- Type: text/plain, Size: 403 bytes --]

/cp
2019-10-24  Paolo Carlini  <paolo.carlini@oracle.com>

	* typeck.c (cp_build_modify_expr): Prefer error + inform to
	error + error in one place.
	(get_delta_difference_1): Likewise.
	(get_delta_difference): Likewise, in two places.

/testsuite
2019-10-24  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/conversion/ptrmem2.C: Adjust for error + inform.
	* g++.dg/gomp/tpl-atomic-2.C: Likewise.

[-- Attachment #3: patch_locs_57 --]
[-- Type: text/plain, Size: 4560 bytes --]

Index: cp/typeck.c
===================================================================
--- cp/typeck.c	(revision 277366)
+++ cp/typeck.c	(working copy)
@@ -8358,8 +8358,8 @@ cp_build_modify_expr (location_t loc, tree lhs, en
 	  if (newrhs == error_mark_node)
 	    {
 	      if (complain & tf_error)
-		error ("  in evaluation of %<%Q(%#T, %#T)%>", modifycode,
-		       TREE_TYPE (lhs), TREE_TYPE (rhs));
+		inform (loc, "  in evaluation of %<%Q(%#T, %#T)%>",
+			modifycode, TREE_TYPE (lhs), TREE_TYPE (rhs));
 	      return error_mark_node;
 	    }
 
@@ -8594,7 +8594,7 @@ get_delta_difference_1 (tree from, tree to, bool c
       if (!(complain & tf_error))
 	return error_mark_node;
 
-      error ("   in pointer to member function conversion");
+      inform (input_location, "   in pointer to member function conversion");
       return size_zero_node;
     }
   else if (binfo)
@@ -8655,7 +8655,7 @@ get_delta_difference (tree from, tree to,
 	  return error_mark_node;
 
 	error_not_base_type (from, to);
-	error ("   in pointer to member conversion");
+	inform (input_location, "   in pointer to member conversion");
       	result = size_zero_node;
       }
     else
@@ -8674,7 +8674,7 @@ get_delta_difference (tree from, tree to,
 	      return error_mark_node;
 
 	    error_not_base_type (from, to);
-	    error ("   in pointer to member conversion");
+	    inform (input_location, "   in pointer to member conversion");
 	    result = size_zero_node;
 	  }
       }
Index: testsuite/g++.dg/conversion/ptrmem2.C
===================================================================
--- testsuite/g++.dg/conversion/ptrmem2.C	(revision 277366)
+++ testsuite/g++.dg/conversion/ptrmem2.C	(working copy)
@@ -15,16 +15,20 @@ int B::*p1 = static_cast<int B::*>(&D::x);
 int D::*p2 = static_cast<int D::*>(&B::x);
 
 // Virtual base class.
-int V::*p3 = static_cast<int V::*>(&D::x);  // { dg-error "" }
-int D::*p4 = static_cast<int D::*>(&V::x);  // { dg-error "" }
+int V::*p3 = static_cast<int V::*>(&D::x);  // { dg-error "virtual base" }
+int D::*p4 = static_cast<int D::*>(&V::x);  // { dg-error "virtual base" }
 
 // Inaccessible base class.
-int P::*p5 = static_cast<int P::*>(&D::x);  // { dg-error "" }
-int D::*p6 = static_cast<int D::*>(&P::x);  // { dg-error "" }
+int P::*p5 = static_cast<int P::*>(&D::x);  // { dg-error "inaccessible base" }
+// { dg-message "pointer to member function" "" { target *-*-* } .-1 }
+int D::*p6 = static_cast<int D::*>(&P::x);  // { dg-error "inaccessible base" }
+// { dg-message "pointer to member function" "" { target *-*-* } .-1 }
 
 // Ambiguous base class.
-int A::*p7 = static_cast<int A::*>(&D::x);  // { dg-error "" }
-int D::*p8 = static_cast<int D::*>(&A::x);  // { dg-error "" }
+int A::*p7 = static_cast<int A::*>(&D::x);  // { dg-error "ambiguous base" }
+// { dg-message "pointer to member function" "" { target *-*-* } .-1 }
+int D::*p8 = static_cast<int D::*>(&A::x);  // { dg-error "ambiguous base" }
+// { dg-message "pointer to member function" "" { target *-*-* } .-1 }
 
 // Valid conversions which increase cv-qualification.
 const int B::*p9 = static_cast<const int B::*>(&D::x);
@@ -35,5 +39,5 @@ int B::*p11 = static_cast<int B::*>(p10); // { dg-
 int D::*p12 = static_cast<int D::*>(p9);  // { dg-error "casts away qualifiers" }
 
 // Attempts to change member type.
-float B::*p13 = static_cast<float B::*>(&D::x); // { dg-error "" }
-float D::*p14 = static_cast<float D::*>(&B::x); // { dg-error "" }
+float B::*p13 = static_cast<float B::*>(&D::x); // { dg-error "invalid .static_cast." }
+float D::*p14 = static_cast<float D::*>(&B::x); // { dg-error "invalid .static_cast." }
Index: testsuite/g++.dg/gomp/tpl-atomic-2.C
===================================================================
--- testsuite/g++.dg/gomp/tpl-atomic-2.C	(revision 277374)
+++ testsuite/g++.dg/gomp/tpl-atomic-2.C	(working copy)
@@ -13,7 +13,7 @@ template<typename T> void f1()
 template<typename T> void f2(float *f)
 {
   #pragma omp atomic	// { dg-error "invalid" }
-  *f |= 1;		// { dg-error "evaluation" }
+  *f |= 1;             // { dg-message "evaluation" "" { target *-*-* } .-1 }
 }
 
 // Here the rhs is dependent, but not type dependent.
@@ -20,7 +20,7 @@ template<typename T> void f2(float *f)
 template<typename T> void f3(float *f)
 {
   #pragma omp atomic	// { dg-error "invalid" }
-  *f |= sizeof (T);	// { dg-error "evaluation" }
+  *f |= sizeof (T);    // { dg-message "evaluation" "" { target *-*-* } .-1 }
 }
 
 // And the converse, no error here because we're never fed a T.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [C++ Patch] Prefer error + inform in four typeck.c places
  2019-10-24 14:07 [C++ Patch] Prefer error + inform in four typeck.c places Paolo Carlini
@ 2019-10-30  4:57 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2019-10-30  4:57 UTC (permalink / raw)
  To: Paolo Carlini, gcc-patches

On 10/24/19 10:07 AM, Paolo Carlini wrote:
> Hi,
> 
> some additional straightforward bits in typeck.c, which I noticed when I 
> went through the cp_build_binary_op callers. Tested x86_64-linux.
> 
> Thanks, Paolo.
> 
> //////////////////////
> 
OK.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-10-30  3:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-24 14:07 [C++ Patch] Prefer error + inform in four typeck.c places Paolo Carlini
2019-10-30  4:57 ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).