public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/68847 (ICE with builtin in template)
@ 2016-01-15 15:52 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2016-01-15 15:52 UTC (permalink / raw)
  To: gcc-patches List

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

The delayed folding code for builtins needs to make sure that the 
expression is instantiated before we try to fold it, because we can get 
here while parsing a template.

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Attachment #2: 68847.patch --]
[-- Type: text/x-patch, Size: 1268 bytes --]

commit 6e41de9cec949bc7c09406b50105afee927a0ae3
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jan 14 17:25:27 2016 -0500

    	PR c++/68847
    	* call.c (build_cxx_call): Use fold_non_dependent_expr.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index c05170a..ce87be7 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -7755,7 +7755,7 @@ build_cxx_call (tree fn, int nargs, tree *argarray,
       /* We need to take care that values to BUILT_IN_NORMAL
          are reduced.  */
       for (i = 0; i < nargs; i++)
-	argarray[i] = maybe_constant_value (argarray[i]);
+	argarray[i] = fold_non_dependent_expr (argarray[i]);
 
       if (!check_builtin_function_arguments (fndecl, nargs, argarray))
 	return error_mark_node;
diff --git a/gcc/testsuite/g++.dg/delayedfold/builtin1.C b/gcc/testsuite/g++.dg/delayedfold/builtin1.C
new file mode 100644
index 0000000..32f4435
--- /dev/null
+++ b/gcc/testsuite/g++.dg/delayedfold/builtin1.C
@@ -0,0 +1,11 @@
+// PR c++/68847
+// { dg-do compile { target cas_int } }
+
+class RegionLock {
+  template <unsigned long> void m_fn1();
+  int spinlock;
+} acquire_zero;
+int acquire_one;
+template <unsigned long> void RegionLock::m_fn1() {
+  __atomic_compare_exchange(&spinlock, &acquire_zero, &acquire_one, false, 2, 2);
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-01-15 15:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-15 15:52 C++ PATCH for c++/68847 (ICE with builtin in template) 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).