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]

RFA: PATCH to operand_equal_p for c++/40138 (ICE after error with __builtin_va_arg)


Straightforward error-recovery patch.

Tested x86_64-pc-linux-gnu. OK for 4.5?
commit 855e19d24578c9028ec0e25d6e8a44d4b8ca41c9
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Feb 3 13:36:43 2010 -0500

    	PR c++/40138
    	* fold-const.c (operand_equal_p): Handle erroneous types.

diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index e7a4b8c..292b89f 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -3165,7 +3165,9 @@ int
 operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags)
 {
   /* If either is ERROR_MARK, they aren't equal.  */
-  if (TREE_CODE (arg0) == ERROR_MARK || TREE_CODE (arg1) == ERROR_MARK)
+  if (TREE_CODE (arg0) == ERROR_MARK || TREE_CODE (arg1) == ERROR_MARK
+      || TREE_TYPE (arg0) == error_mark_node
+      || TREE_TYPE (arg1) == error_mark_node)
     return 0;
 
   /* Check equality of integer constants before bailing out due to
diff --git a/gcc/testsuite/g++.dg/ext/builtin11.C b/gcc/testsuite/g++.dg/ext/builtin11.C
new file mode 100644
index 0000000..2749671
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/builtin11.C
@@ -0,0 +1,9 @@
+// PR c++/40138
+// { dg-options "-Wall" }
+
+void foo(int i, ...)
+{
+  V v;				// { dg-error "not declared|expected" }
+  __builtin_va_start(v, i);	// { dg-error "not declared" }
+  i = __builtin_va_arg(v, int);
+}

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