re PR pch/54117 (FAIL: ./decl-3.h -O0 -g (internal compiler error))
authorJakub Jelinek <jakub@redhat.com>
Mon, 18 Feb 2013 19:42:56 +0000 (20:42 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 18 Feb 2013 19:42:56 +0000 (20:42 +0100)
PR pch/54117
* c-opts.c (c_common_post_options): If debug info is enabled
and non-dwarf*, refuse to load PCH files and when writing PCH
file warn.

* lib/dg-pch.exp (pch-init, pch-finish,
check_effective_target_pch_supported_debug): New procs.
(dg-flags-pch): If $pch_unsupported, make tests UNSUPPORTED.
Likewise if $pch_unsupported_debug and $flags include -g.
Skip FAILs about missing *.gch file if $pch_unsupported_debug
and dg-require-effective-target pch_unsupported_debug.
* g++.dg/pch/pch.exp: Call pch-init and pch-finish.
* objc.dg/pch/pch.exp: Likewise.
* gcc.dg/pch/pch.exp: Likewise.
* gcc.dg/pch/valid-1.c: Add dg-require-effective-target
pch_unsupported_debug.
* gcc.dg/pch/valid-1.hs: Likewise.
* gcc.dg/pch/valid-1b.c: Likewise.
* gcc.dg/pch/valid-1b.hs: Likewise.

Co-Authored-By: Steven Bosscher <steven@gcc.gnu.org>
From-SVN: r196124

gcc/c-family/ChangeLog
gcc/c-family/c-opts.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/pch/pch.exp
gcc/testsuite/gcc.dg/pch/pch.exp
gcc/testsuite/gcc.dg/pch/valid-1.c
gcc/testsuite/gcc.dg/pch/valid-1.hs
gcc/testsuite/gcc.dg/pch/valid-1b.c
gcc/testsuite/gcc.dg/pch/valid-1b.hs
gcc/testsuite/lib/dg-pch.exp
gcc/testsuite/objc.dg/pch/pch.exp

index 16ef84a36345b41fd0b733e719489f2f9d8af118..40b6e5569560f98f3687a4bb90c89a03d8517265 100644 (file)
@@ -1,3 +1,11 @@
+2013-02-18  Jakub Jelinek  <jakub@redhat.com>
+           Steven Bosscher  <steven@gcc.gnu.org>
+
+       PR pch/54117
+       * c-opts.c (c_common_post_options): If debug info is enabled
+       and non-dwarf*, refuse to load PCH files and when writing PCH
+       file warn.
+
 2013-02-05  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/56167
index 1a922a81c35fb43c1ce89132fefa24eb0ef3db53..4b6990a60c19b727c7b377423d81a0cae2b2cdbd 100644 (file)
@@ -945,6 +945,16 @@ c_common_post_options (const char **pfilename)
         because the default address space slot then can't be used
         for the output PCH file.  */
       if (pch_file)
+       {
+         c_common_no_more_pch ();
+         /* Only -g0 and -gdwarf* are supported with PCH, for other
+            debug formats we warn here and refuse to load any PCH files.  */
+         if (write_symbols != NO_DEBUG && write_symbols != DWARF2_DEBUG)
+           warning (OPT_Wdeprecated,
+                    "the \"%s\" debug format cannot be used with "
+                    "pre-compiled headers", debug_type_names[write_symbols]);
+       }
+      else if (write_symbols != NO_DEBUG && write_symbols != DWARF2_DEBUG)
        c_common_no_more_pch ();
 
       /* Yuk.  WTF is this?  I do know ObjC relies on it somewhere.  */
index fe995e8e0eab807e20d988fdb341e76c94ebeeff..8458cce659e428419edcf08ed98ff4a55412929f 100644 (file)
@@ -1,3 +1,21 @@
+2013-02-18  Jakub Jelinek  <jakub@redhat.com>
+
+       PR pch/54117
+       * lib/dg-pch.exp (pch-init, pch-finish,
+       check_effective_target_pch_supported_debug): New procs.
+       (dg-flags-pch): If $pch_unsupported, make tests UNSUPPORTED.
+       Likewise if $pch_unsupported_debug and $flags include -g.
+       Skip FAILs about missing *.gch file if $pch_unsupported_debug
+       and dg-require-effective-target pch_unsupported_debug.
+       * g++.dg/pch/pch.exp: Call pch-init and pch-finish.
+       * objc.dg/pch/pch.exp: Likewise.
+       * gcc.dg/pch/pch.exp: Likewise.
+       * gcc.dg/pch/valid-1.c: Add dg-require-effective-target
+       pch_unsupported_debug.
+       * gcc.dg/pch/valid-1.hs: Likewise.
+       * gcc.dg/pch/valid-1b.c: Likewise.
+       * gcc.dg/pch/valid-1b.hs: Likewise.
+
 2013-02-18  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/56366
index 0c5e13319ee1c5f6b8472c4bb0d7679fe19f4352..db67c24f5b9dd385767439f92773646e0b426173 100644 (file)
@@ -23,6 +23,7 @@ load_lib dg-pch.exp
 
 # Initialize `dg'.
 dg-init
+pch-init
 
 set old_dg_do_what_default "${dg-do-what-default}"
 
@@ -36,4 +37,5 @@ foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.C]] {
 set dg-do-what-default "$old_dg_do_what_default"
 
 # All done.
+pch-finish
 dg-finish
index 4144243a7a1fe177edd42658bb1c1418218c98fb..7bf64df172c7a669ef745b5f13ea49f4e33d8c42 100644 (file)
@@ -26,6 +26,7 @@ load_lib torture-options.exp
 dg-init
 torture-init
 set-torture-options $DG_TORTURE_OPTIONS
+pch-init
 
 set old_dg_do_what_default "${dg-do-what-default}"
 
@@ -59,5 +60,6 @@ file delete $testh
 set dg-do-what-default "$old_dg_do_what_default"
 
 # All done.
+pch-finish
 torture-finish
 dg-finish
index b7f22d0dc17a12cd32a69cafc046809b7a487394..d445c47d6f3c3c7df3b2e1d7b39d9cb4774d5ef1 100644 (file)
@@ -1,3 +1,4 @@
+/* { dg-require-effective-target pch_supported_debug } */
 /* { dg-options "-I. -Winvalid-pch -g" } */
 
 #include "valid-1.h"/* { dg-warning "created with -gnone, but used with -g" } */
index e1ed11df4cc81b1524bb4f0e3582fedf2eacdb38..20d9f65dd72ecf34b1a6b9c6ec9d3e8716ec5fc8 100644 (file)
@@ -1,3 +1,4 @@
+/* { dg-require-effective-target pch_supported_debug } */
 /* { dg-options "-I. -Winvalid-pch -g0" } */
 
 extern int x;
index a2709967c0728a04603fc02ebf710aa6830eb727..3113d0f744de6235c802aaef373d34a71bcd4b4c 100644 (file)
@@ -1,3 +1,4 @@
+/* { dg-require-effective-target pch_supported_debug } */
 /* { dg-options "-I. -Winvalid-pch -g0" } */
 
 #include "valid-1b.h"
index 6dc358735a7a552e351a5c43f737688d53c8cf9a..93b2256e3555dcc065ec2017db6c716bdbf7b022 100644 (file)
@@ -1,3 +1,4 @@
+/* { dg-require-effective-target pch_supported_debug } */
 /* { dg-options "-I. -Winvalid-pch -g" } */
 
 extern int x;
index d6a55d89e12a85b67da9702b3c911ec547a9eb87..1b3591a7506a142447e79ea511def68f4fd2672e 100644 (file)
 
 load_lib copy-file.exp
 
+proc pch-init { args } {
+    global pch_unsupported_debug pch_unsupported
+
+    if [info exists pch_unsupported_debug] {
+       error "pch-init: pch_unsupported_debug is not empty as expected"
+    }
+    if [info exists pch_unsupported] {
+       error "pch-init: pch_unsupported is not empty as expected"
+    }
+
+    set result [check_compile pchtest object "int i;" "-g -x c-header"]
+    set pch_unsupported_debug \
+       [regexp "debug format cannot be used with pre-compiled headers" \
+               [lindex $result 0]]
+
+    set pch_unsupported 0
+    if { $pch_unsupported_debug } {
+       verbose -log "pch is unsupported with the debug info format"
+
+       set result [check_compile pchtest object "int i;" "-x c-header"]
+           set pch_unsupported \
+               [regexp "debug format cannot be used with pre-compiled headers" \
+                       [lindex $result 0]]
+    }
+}
+
+proc pch-finish { args } {
+    global pch_unsupported_debug pch_unsupported
+    unset pch_unsupported_debug
+    unset pch_unsupported
+}
+
+proc check_effective_target_pch_supported_debug { } {
+    global pch_unsupported_debug
+    if { $pch_unsupported_debug } {
+       return 0
+    }
+    return 1
+}
+
 proc dg-flags-pch { subdir test otherflags options suffix } {
     global runtests dg-do-what-default
+    global pch_unsupported_debug pch_unsupported
 
     # If we're only testing specific files and this isn't one of them, skip it.
     if ![runtest_file_p $runtests $test] {
@@ -35,6 +76,13 @@ proc dg-flags-pch { subdir test otherflags options suffix } {
     foreach flags $options {
        verbose "Testing $nshort, $otherflags $flags" 1
 
+       if { $pch_unsupported != 0 \
+            || ( $pch_unsupported_debug != 0 && [regexp " -g" " $flags"] ) } {
+           verbose -log "$nshort unsupported because debug format conflicts with PCH"
+           unsupported "$nshort $flags"
+           continue
+       }
+
        # For the header files, the default is to precompile.
        set dg-do-what-default precompile
        catch { file_on_host delete "$bname$suffix" }
@@ -78,7 +126,8 @@ proc dg-flags-pch { subdir test otherflags options suffix } {
                    fail "$nshort $flags assembly comparison"
                }
            }
-       } else {
+       } elseif { $pch_unsupported_debug == 0 \
+                  || [llength [grep $test "{\[ \t\]\+dg-require-effective-target\[ \t\]\+pch_supported_debug\[ \t\]\+.*\[ \t\]\+}"]] > 0 } {
            verbose -log "pch file '$bname$suffix.gch' missing"
            fail "$nshort $flags"
            if { !$have_errs } {
index 90b5b17d2a9ffc26354d14318c17b6c2aace6ab3..e380390bba6220a8c464a8d9b80e3bc6df298959 100644 (file)
@@ -24,8 +24,8 @@ load_lib torture-options.exp
 
 # Initialize `dg'.
 dg-init
-
 torture-init
+pch-init
 
 set-torture-options $DG_TORTURE_OPTIONS
 
@@ -59,5 +59,6 @@ if [istarget "*-*-darwin*" ] {
 set dg-do-what-default "$old_dg_do_what_default"
 
 # All done.
+pch-finish
 torture-finish
 dg-finish