This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C11-atomic] Miscellaneous fixes 5/n


I've applied this small patch to C11-atomic branch to fix ICEs that
could occur with C_MAYBE_CONST_EXPR through lack of folding.

c:
2013-10-26  Joseph Myers  <joseph@codesourcery.com>

	* c-typeck.c (build_atomic_assign): Fold RHS if not already
	folded.

testsuite:
2013-10-26  Joseph Myers  <joseph@codesourcery.com>

	* gcc.dg/c11-atomic-1.c: Add more tests.

Index: gcc/testsuite/gcc.dg/c11-atomic-1.c
===================================================================
--- gcc/testsuite/gcc.dg/c11-atomic-1.c	(revision 204084)
+++ gcc/testsuite/gcc.dg/c11-atomic-1.c	(working copy)
@@ -255,3 +255,13 @@ fc4b (x)
 {
 }
 void fc4b (_Atomic int); /* { dg-warning "follows non-prototype" } */
+
+/* Test cases involving C_MAYBE_CONST_EXPR work.  */
+void
+func10 (_Atomic int *p)
+{
+  p[0 / 0] = 1; /* { dg-warning "division by zero" } */
+  p[0 / 0] += 1; /* { dg-warning "division by zero" } */
+  *p = 0 / 0; /* { dg-warning "division by zero" } */
+  *p += 0 / 0; /* { dg-warning "division by zero" } */
+}
Index: gcc/c/c-typeck.c
===================================================================
--- gcc/c/c-typeck.c	(revision 204084)
+++ gcc/c/c-typeck.c	(working copy)
@@ -11292,6 +11292,10 @@ build_atomic_assign (location_t loc, tree lhs, enu
      with a loop.  */
   compound_stmt = c_begin_compound_stmt (false);
 
+  /* Fold the RHS if it hasn't already been folded.  */
+  if (modifycode != NOP_EXPR)
+    rhs = c_fully_fold (rhs, false, NULL);
+
   /* Remove the qualifiers for the rest of the expressions and create
      the VAL temp variable to hold the RHS.  */
   nonatomic_lhs_type = build_qualified_type (lhs_type, TYPE_UNQUALIFIED);

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]