Patchwork =?UTF-8?Q?Fix=20PR=20objc++/47711=20("[4.5/4.6=20Regression]=20(even=20t?= =?UTF-8?Q?rivial)=20PCH=20fails=20for=20Objective-C++")?=

login
register
mail settings
Submitter Nicola Pero
Date Feb. 20, 2011, 2:50 p.m.
Message ID <1298213440.960720057@192.168.4.58>
Download mbox | patch
Permalink /patch/83743/
State New
Headers show

Comments

Nicola Pero - Feb. 20, 2011, 2:50 p.m.
This patch fixes PCH for ObjC++ (a regression since 4.4).  The fix (and ChangeLog entries)
is by me; the testcase by Iain.

Bootstrapped and tested on i686 gnu-linux.  The included PCH ObjC++ testcase would fail
without the patch, and succeeds with it.

Ok to commit ?

Thanks
Mike Stump - Feb. 20, 2011, 4:52 p.m.
On Feb 20, 2011, at 6:50 AM, Nicola Pero wrote:
> This patch fixes PCH for ObjC++ (a regression since 4.4).  The fix (and ChangeLog entries)
> is by me; the testcase by Iain.
> 
> Bootstrapped and tested on i686 gnu-linux.  The included PCH ObjC++ testcase would fail
> without the patch, and succeeds with it.
> 
> Ok to commit ?

Ok, thanks.
Nicola Pero - Feb. 20, 2011, 5:24 p.m.
>> This patch fixes PCH for ObjC++ (a regression since 4.4).  The fix (and ChangeLog entries)
>> is by me; the testcase by Iain.
>> 
>> Bootstrapped and tested on i686 gnu-linux.  The included PCH ObjC++ testcase would fail
>> without the patch, and succeeds with it.
>> 
>> Ok to commit ?
>
> Ok, thanks.

Thanks

I committed the fix, but not the testcase, as Iain may want to tidy that up
before commit.  I'll let him commit it as he sees fit.

Thanks

Patch

Index: testsuite/lib/obj-c++.exp
===================================================================
--- testsuite/lib/obj-c++.exp   (revision 170336)
+++ testsuite/lib/obj-c++.exp   (working copy)
@@ -362,6 +362,12 @@  proc obj-c++_target_compile { source dest type opt
        }
     }
 
+    if { $type == "precompiled_header" } {
+       # If we generating a precompiled header, we have say this is an
+       # objective-C header.
+       set source [concat "-x objective-c++-header" $source]
+    }
+
     lappend options "additional_flags=[libio_include_flags]"
     lappend options "compiler=$OBJCXX_UNDER_TEST";
     lappend options "timeout=[timeout_value]"
Index: testsuite/ChangeLog
===================================================================
--- testsuite/ChangeLog (revision 170336)
+++ testsuite/ChangeLog (working copy)
@@ -1,3 +1,12 @@ 
+2011-02-20  Iain Sandoe  <iains@gcc.gnu.org>
+
+       PR objc++/47711
+       * lib/obj-c++.exp: Updated to support pch test.
+       * obj-c++.dg/pch: New.
+       * obj-c++.dg/pch/pch.exp: New.
+       * obj-c++.dg/pch/interface-1.mm: New.
+       * obj-c++.dg/pch/interface-1.hs: New.
+       
 2011-02-20  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/44118
Index: testsuite/obj-c++.dg/pch/pch.exp
===================================================================
--- testsuite/obj-c++.dg/pch/pch.exp    (revision 0)
+++ testsuite/obj-c++.dg/pch/pch.exp    (revision 0)
@@ -0,0 +1,64 @@ 
+# Copyright (C) 1997, 2002, 2003, 2007, 2008, 2010
+# Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# GCC testsuite for precompiled header interaction,
+# that uses the `dg.exp' driver.
+
+# Load support procs.
+load_lib obj-c++-dg.exp
+load_lib dg-pch.exp
+load_lib torture-options.exp
+
+# Initialize `dg'.
+dg-init
+
+torture-init
+
+set-torture-options $DG_TORTURE_OPTIONS
+
+set old_dg_do_what_default "${dg-do-what-default}"
+
+global torture_without_loops
+
+# We don't try to use the loop-optimizing options, since they are highly
+# unlikely to make any difference to PCH.  However, we do want to
+# add -O0 -g, since users who want PCH usually want debugging and quick
+# compiles.
+
+set mytorture [concat [list {-O0 -g}] $torture_without_loops]
+
+set tests [lsort [glob -nocomplain $srcdir/$subdir/*.mm]]
+# Main loop.
+foreach test $tests {
+
+    dg-flags-pch $subdir $test "-fgnu-runtime" $mytorture ".h"
+}
+
+if [istarget "*-*-darwin*" ] {
+  foreach test $tests {
+    global torture_without_loops
+
+    # as above
+    dg-flags-pch $subdir $test "-fnext-runtime" $mytorture ".h"
+  }
+}
+
+set dg-do-what-default "$old_dg_do_what_default"
+
+# All done.
+torture-finish
+dg-finish
Index: testsuite/obj-c++.dg/pch/interface-1.mm
===================================================================
--- testsuite/obj-c++.dg/pch/interface-1.mm     (revision 0)
+++ testsuite/obj-c++.dg/pch/interface-1.mm     (revision 0)
@@ -0,0 +1,14 @@ 
+#include "interface-1.h"
+
+@implementation TestClass
++ (int) test
+{
+  return 0;
+}
+@end
+
+int main (void)
+{
+  return [TestClass test];
+}
+
Index: testsuite/obj-c++.dg/pch/interface-1.hs
===================================================================
--- testsuite/obj-c++.dg/pch/interface-1.hs     (revision 0)
+++ testsuite/obj-c++.dg/pch/interface-1.hs     (revision 0)
@@ -0,0 +1,4 @@ 
+@interface TestClass
++ (int) test;
+@end
+
Index: objcp/ChangeLog
===================================================================
--- objcp/ChangeLog     (revision 170336)
+++ objcp/ChangeLog     (working copy)
@@ -1,3 +1,8 @@ 
+2011-02-20  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       PR objc++/47711
+       * config-lang.in (gtfiles): Updated list.
+
 2011-02-17  Iain Sandoe  <iains@gcc.gnu.org>
 
        * Make-lang.in (START_HDRS): New.
Index: objcp/config-lang.in
===================================================================
--- objcp/config-lang.in        (revision 170336)
+++ objcp/config-lang.in        (working copy)
@@ -37,4 +37,5 @@  build_by_default="no"
 lang_requires="objc c++"
 subdir_requires="objc cp"

-gtfiles="\$(srcdir)/objc/objc-act.h \$(srcdir)/objc/objc-act.c \$(srcdir)/objc/objc-runtime-shared-support.c \$(srcdir)/objc/objc-gnu-runtime-abi-01.c \$(srcdir)/objc/objc-next-runtime-abi-01.c \$(srcdir)/objc/objc-next-runtime-abi-02.c \$(srcdir)/cp/call.c \$(srcdir)/cp/cp-tree.h \$(srcdir)/cp/decl.h \$(srcdir)/cp/decl.c \$(srcdir)/cp/decl2.c \$(srcdir)/cp/mangle.c \$(srcdir)/cp/method.c \$(srcdir)/cp/name-lookup.h \$(srcdir)/cp/name-lookup.c \$(srcdir)/cp/cp-objcp-common.c \$(srcdir)/cp/parser.c \$(srcdir)/cp/pt.c \$(srcdir)/cp/repo.c \$(srcdir)/cp/rtti.c \$(srcdir)/cp/semantics.c \$(srcdir)/cp/tree.c \$(srcdir)/cp/typeck2.c \$(srcdir)/c-family/c-common.c \$(srcdir)/c-family/c-common.h \$(srcdir)/c-family/c-objc.h \$(srcdir)/c-family/c-lex.c \$(srcdir)/c-family/c-cppbuiltin.c \$(srcdir)/c-family/c-pragma.h \$(srcdir)/c-family/c-pragma.c "
+gtfiles="\$(srcdir)/objc/objc-act.h \$(srcdir)/objc/objc-act.c \$(srcdir)/objc/objc-runtime-shared-support.c \$(srcdir)/objc/objc-gnu-runtime-abi-01.c \$(srcdir)/objc/objc-next-runtime-abi-01.c \$(srcdir)/objc/objc-next-runtime-abi-02.c \$(srcdir)/cp/call.c \$(srcdir)/cp/class.c \$(srcdir)/cp/cp-tree.h \$(srcdir)/cp/decl.c \$(srcdir)/cp/decl2.c \$(srcdir)/cp/mangle.c \$(srcdir)/cp/method.c \$(srcdir)/cp/name-lookup.h \$(srcdir)/cp/name-lookup.c \$(srcdir)/cp/cp-objcp-common.c \$(srcdir)/cp/parser.c \$(srcdir)/cp/pt.c \$(srcdir)/cp/repo.c \$(srcdir)/cp/rtti.c \$(srcdir)/cp/semantics.c \$(srcdir)/cp/tree.c \$(srcdir)/cp/typeck2.c \$(srcdir)/c-family/c-common.c \$(srcdir)/c-family/c-common.h \$(srcdir)/c-family/c-objc.h \$(srcdir)/c-family/c-lex.c \$(srcdir)/c-family/c-cppbuiltin.c \$(srcdir)/c-family/c-pragma.h \$(srcdir)/c-family/c-pragma.c "
+