[PATCH] Fix PR43379

H.J. Lu hjl.tools@gmail.com
Tue Mar 16 19:39:00 GMT 2010


On Tue, Mar 16, 2010 at 10:56 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, Mar 16, 2010 at 5:29 AM, Richard Guenther <rguenther@suse.de> wrote:
>>
>> This fixes PR43379, for VOPs we need to merge
>> SSA_NAME_OCCURS_IN_ABNORMAL_PHI when propagating single-argument
>> PHIs.
>>
>> Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
>>
>> Richard.
>>
>> 2010-03-16  Richard Guenther  <rguenther@suse.de>
>>
>>        PR middle-end/43379
>>        * tree-cfg.c (gimple_merge_blocks): When propagating virtual
>>        PHI operands make sure to merge SSA_NAME_OCCURS_IN_ABNORMAL_PHI
>>        properly.
>>
>>        * gcc.dg/pr43379.c: New testcase.
>
> I got
>
> FAIL: gcc.dg/pr43379.c (test for excess errors)
>
> on Linux/ia32.
>

We are warning return of label as local variable. This patch fixes it,.



-- 
H.J.
-------------- next part --------------
gcc/

2010-03-16  H.J. Lu  <hongjiu.lu@intel.com>

	* c-typeck.c (c_finish_return): Don't warn return of label.

gcc/cp/

2010-03-16  H.J. Lu  <hongjiu.lu@intel.com>

	* typeck.c (maybe_warn_about_returning_address_of_local): Don't
	warn return of label.

gcc/testsuite/

2010-03-16  H.J. Lu  <hongjiu.lu@intel.com>
 
	* gcc.dg/pr43379.c: Moved to ...
	* c-c++-common/pr43379.c: Here.

diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 81c18ac..05126cd 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -8389,6 +8389,7 @@ c_finish_return (location_t loc, tree retval, tree origtype)
 		inner = TREE_OPERAND (inner, 0);
 
 	      if (DECL_P (inner)
+		  && TREE_CODE (inner) != LABEL_DECL
 		  && !DECL_EXTERNAL (inner)
 		  && !TREE_STATIC (inner)
 		  && DECL_CONTEXT (inner) == current_function_decl)
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index b9ef78f..ea22adf 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -7277,6 +7277,7 @@ maybe_warn_about_returning_address_of_local (tree retval)
     whats_returned = TREE_OPERAND (whats_returned, 0);
 
   if (DECL_P (whats_returned)
+      && TREE_CODE (whats_returned) != LABEL_DECL
       && DECL_NAME (whats_returned)
       && DECL_FUNCTION_SCOPE_P (whats_returned)
       && !(TREE_STATIC (whats_returned)
diff --git a/gcc/testsuite/c-c++-common/pr43379.c b/gcc/testsuite/c-c++-common/pr43379.c
new file mode 100644
index 0000000..de9bf66
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr43379.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftracer" } */
+
+void *foo(int i, int *p)
+{
+lab:
+  if (p) *p = i;
+  goto *p;
+  return &&lab;
+}
+
diff --git a/gcc/testsuite/gcc.dg/pr43379.c b/gcc/testsuite/gcc.dg/pr43379.c
deleted file mode 100644
index de9bf66..0000000
--- a/gcc/testsuite/gcc.dg/pr43379.c
+++ /dev/null
@@ -1,11 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-O2 -ftracer" } */
-
-void *foo(int i, int *p)
-{
-lab:
-  if (p) *p = i;
-  goto *p;
-  return &&lab;
-}
-


More information about the Gcc-patches mailing list