===================================================================
***************
+ /* A string to string mapping.
+
+ Copyright (C) 2011 Free Software Foundation, Inc.
+ Contributed by Lawrence Crowl <crowl@google.com> and
+ Diego Novillo <dnovillo@google.com>.
+
+ This file is part of GCC.
+
+ GCC 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, or (at your option)
+ any later version.
+
+ GCC 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/>. */
+
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+
+ #include "libiberty.h"
+ #include "hashtab.h"
+
+ #include "strstrmap.h"
+
+ /* The hash table slot type. */
+
+ typedef struct strstrhashslot_d
+ {
+ const char *key;
+ const char *val;
+ } strstrhashslot_t;
+
+ /* Returns a hash code for the slot v.
+ Function type is typedef hashval_t (*htab_hash) (const void *); */
+
+ static hashval_t
+ strstrhashslot_hash (const void *v)
+ {
+ const strstrhashslot_t *s = (const strstrhashslot_t *) v;
+ return htab_hash_string (s->key);
+ }
+
+ /* Compares two slots, V1 and V2, for equality.
+ Function type is typedef int (*htab_eq) (const void *, const void *); */
+
+ static int
+ strstrhashslot_eq (const void *v1, const void *v2)
+ {
+ const strstrhashslot_t *s1 = (const strstrhashslot_t *) v1;
+ const strstrhashslot_t *s2 = (const strstrhashslot_t *) v2;
+ return strcmp (s1->key, s2->key) == 0;
+ }
+
+ /* Free the slot V. */
+
+ static void
+ strstrhashslot_free (void *v)
+ {
+ strstrhashslot_t *s = (strstrhashslot_t *) v;
+ free (CONST_CAST (void *, (const void *) s->key));
+ free (CONST_CAST (void *, (const void *) s->val));
+ free (v);
+ }
+
+ /* The type for the hash table itself. */
+
+ struct strstrmap_d
+ {
+ htab_t tab;
+ };
+
+ /* Create a hash table. */
+
+ strstrmap_t*
+ strstrmap_create (void)
+ {
+ strstrmap_t *tbl;
+ htab_t tab;
+ tbl = XCNEW (strstrmap_t);
+ gcc_assert (tbl != NULL);
+ tab = htab_create (37, strstrhashslot_hash,
+ strstrhashslot_eq, strstrhashslot_free);
+ gcc_assert (tab != NULL);
+ tbl->tab = tab;
+ return tbl;
+ }
+
+ /* Destroy the hash table TBL. */
+
+ void
+ strstrmap_destroy (strstrmap_t *tbl)
+ {
+ htab_delete (tbl->tab);
+ free (tbl);
+ }
+
+ /* Insert a mapping from KEY to VAL into hash table TBL.
+ All parameters must not be NULL.
+ If the KEY is new, the insert returns NULL.
+ If the KEY is not new, the insert returns the old VAL,
+ which has been replaced.
+ The caller owns any storage that the return value points to. */
+
+ const char*
+ strstrmap_insert (strstrmap_t *tbl, const char *key, const char *val)
+ {
+ strstrhashslot_t query;
+ strstrhashslot_t **spot;
+ const char* result;
+
+ gcc_assert (tbl != NULL);
+ gcc_assert (key != NULL);
+ gcc_assert (val != NULL);
+
+ query.key = key;
+ query.val = val;
+ spot = (strstrhashslot_t **) htab_find_slot (tbl->tab, &query, INSERT);
+
+ if (*spot == NULL)
+ {
+ /* We found no instance of key in the table. */
+ strstrhashslot_t *entry
+ = (strstrhashslot_t *) xmalloc (sizeof (strstrhashslot_t));
+ entry->key = xstrdup (key);
+ entry->val = xstrdup (val);
+ *spot = entry;
+ result = NULL;
+ }
+ else
+ {
+ /* We found an instance of key already in the table. */
+ strstrhashslot_t *entry = (strstrhashslot_t *)*spot;
+ result = entry->val;
+ entry->val = xstrdup (val);
+ }
+
+ return result;
+ }
+
+ /* Lookup a mapping for KEY in hash table TBL.
+ All parameters must not be NULL.
+ If the KEY is new, the insert returns NULL.
+ If the KEY is not new, the insert returns the old VAL,
+ which has been replaced.
+ The caller does NOT owns any storage that the return value points to. */
+
+ const char*
+ strstrmap_lookup (strstrmap_t* tbl, const char* key)
+ {
+ strstrhashslot_t query;
+ strstrhashslot_t **spot;
+ const char* result;
+
+ gcc_assert (tbl != NULL);
+ gcc_assert (key != NULL);
+
+ query.key = key;
+ spot = (strstrhashslot_t **) htab_find_slot (tbl->tab, &query, NO_INSERT);
+
+ if (spot == NULL)
+ {
+ /* We found no instance of key in the table. */
+ result = NULL;
+ }
+ else
+ {
+ /* We found an instance of key in the table. */
+ strstrhashslot_t *entry = (strstrhashslot_t *)*spot;
+ gcc_assert (entry != NULL);
+ result = entry->val;
+ }
+
+ return result;
+ }
===================================================================
***************
+ /* A string to string mapping.
+
+ Copyright (C) 2011 Free Software Foundation, Inc.
+ Contributed by Lawrence Crowl <crowl@google.com> and
+ Diego Novillo <dnovillo@google.com>.
+
+ This file is part of GCC.
+
+ GCC 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, or (at your option)
+ any later version.
+
+ GCC 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/>. */
+
+ typedef struct strstrmap_d strstrmap_t;
+
+ extern strstrmap_t* strstrmap_create (void);
+ extern void strstrmap_destroy (strstrmap_t *tbl);
+ extern const char* strstrmap_insert (strstrmap_t *tbl, const char *key,
+ const char *val);
+ extern const char* strstrmap_lookup (strstrmap_t *tbl, const char *key);
===================================================================
*************** fpph
C++ Var(flag_pph)
-fpph Enable pre-parsed header (PPH) support
+ fpph-hdr=
+ C++ ObjC++ Joined MissingArgError(missing filename after %qs)
+ -fpph-hdr=<base-name> A mapping from <base-name>.h to <base-name>.pph
+
+ fpph-map=
+ C++ ObjC++ Joined MissingArgError(missing filename after %qs)
+ -fpph-map=<file-name> A file of mappings from #include to PPH file
+
fpph-debug=
C++ Joined RejectNegative UInteger Var(flag_pph_debug)
-fpph-debug=N Enable debugging output at level N from PPH support
===================================================================
*************** along with GCC; see the file COPYING3.
#include "mkdeps.h"
#include "target.h" /* For gcc_targetcm. */
#include "tm_p.h" /* For C_COMMON_OVERRIDE_OPTIONS. */
+ #include "strstrmap.h"
#ifndef DOLLARS_IN_IDENTIFIERS
# define DOLLARS_IN_IDENTIFIERS true
*************** static void c_finish_options (void);
#define STDC_0_IN_SYSTEM_HEADERS 0
#endif
+ /* Mappings from include directive to PPH file. */
+
+ strstrmap_t *include_pph_mapping;
+
+ /* Query if we have any map from INCLUDE to PPH file. */
+
+ bool
+ query_have_pph_map (void)
+ {
+ return include_pph_mapping != NULL;
+ }
+
+ /* Add mappings from include directive to PPH files found within file FILENAME.
+ The file is a sequence of lines.
+ Each line contains the directive, followed by a tab,
+ and finally followed by the filename. */
+
+ static void
+ add_pph_header_map (const char *basename)
+ {
+ int length;
+ const char* old_file;
+ char hdrbuf[MAXPATHLEN];
+ char pphbuf[MAXPATHLEN];
+
+ length = strlen (basename);
+ strcpy (hdrbuf, basename);
+ strcpy (hdrbuf+length, ".h");
+ strcpy (pphbuf, basename);
+ strcpy (pphbuf+length, ".pph");
+ old_file = strstrmap_insert (include_pph_mapping, hdrbuf, pphbuf);
+ if (old_file != NULL)
+ {
+ /* FIXME pph: free (CONST_CAST (void*, old_file)); */
+ fatal_error ("PPH include %s was remapped: ", pphbuf);
+ }
+ }
+
+ /* Add mappings from include directive to PPH files found within file FILENAME.
+ The file is a sequence of lines.
+ Each line contains the directive, followed by a tab,
+ and finally followed by the filename. */
+
+ static void
+ add_pph_include_maps (const char *filename)
+ {
+ FILE* stream;
+ char *line;
+ char linebuf[2*MAXPATHLEN];
+
+ if (include_pph_mapping == NULL)
+ include_pph_mapping = strstrmap_create ();
+
+ stream = fopen (filename, "r");
+ if (!stream)
+ fatal_error ("Cannot open %s for reading: %m", filename);
+
+ line = fgets (linebuf, sizeof linebuf, stream);
+ while (line != NULL)
+ {
+ char *eol, *tab;
+ const char *include, *pph_file, *old_file;
+ eol = strchr (line, '\n');
+ tab = strchr (line, '\t');
+ if (eol == NULL || tab == NULL)
+ fatal_error ("Ill-formed PPH mapping file %s: ", filename);
+ *eol = '\0';
+ *tab = '\0';
+ include = line;
+ pph_file = tab+1;
+ old_file = strstrmap_insert (include_pph_mapping, include, pph_file);
+ if (old_file != NULL)
+ {
+ /* FIXME pph: free (CONST_CAST (void*, old_file)); */
+ fatal_error ("PPH include %s was remapped: ", include);
+ }
+ line = fgets (linebuf, sizeof linebuf, stream);
+ }
+
+ fclose (stream);
+ }
+
+ /* Query for a mappings from an INCLUDE to a PPH file.
+ Return the filename, without ownership.
+ If there is no mapping, return null. */
+
+ const char *
+ query_pph_include_map (const char *include)
+ {
+ if (include_pph_mapping == NULL)
+ return NULL;
+ else
+ return strstrmap_lookup (include_pph_mapping, include);
+ }
+
/* Holds switches parsed by c_common_handle_option (), but whose
handling is deferred to c_common_post_options (). */
static void defer_opt (enum opt_code, const char *);
*************** c_common_handle_option (size_t scode, co
break;
case OPT__output_pch_:
! pch_file = arg;
break;
case OPT_A:
break;
case OPT__output_pch_:
! {
! char *dot = strrchr (arg, '.');
! if (dot != NULL && strcmp (dot, ".pph") == 0)
! pph_out_file = arg;
! else
! pch_file = arg;
! }
break;
case OPT_A:
*************** c_common_handle_option (size_t scode, co
set_struct_debug_option (&global_options, loc, arg);
break;
+ case OPT_fpph_hdr_:
+ add_pph_header_map (arg);
+ break;
+
+ case OPT_fpph_map_:
+ add_pph_include_maps (arg);
+ break;
+
case OPT_idirafter:
add_path (xstrdup (arg), AFTER, 0, true);
break;
===================================================================
*************** bool flag_pch_preprocess;
const char *pch_file;
+ /* The file name to which we should write a preparsed header, or
+ NULL if no header will be written in this compile. */
+
+ const char *pph_out_file;
+
/* Nonzero if an ISO standard was selected. It rejects macros in the
user's namespace. */
int flag_iso;
===================================================================
*************** extern bool flag_pch_preprocess;
extern const char *pch_file;
+ /* The file name to which we should write a preparsed header, or
+ NULL if no header will be written in this compile. */
+
+ extern const char *pph_out_file;
+
+ /* Query if we have any map from INCLUDE to PPH file. */
+
+ extern bool
+ query_have_pph_map (void);
+
+ /* Query for a mapping from an INCLUDE to a PPH file.
+ Return the filename, without ownership.
+ If there is no mapping, return null. */
+
+ extern const char *
+ query_pph_include_map (const char *include);
+
/* Nonzero if an ISO standard was selected. It rejects macros in the
user's namespace. */
===================================================================
***************
# <http://www.gnu.org/licenses/>.
# Contributed by Diego Novillo <dnovillo@google.com>
load_lib copy-file.exp
! proc dg-flags-pph { subdir test otherflags options suffix } {
global runtests dg-do-what-default
# If we're only testing specific files and this isn't one of them, skip it.
if ![runtest_file_p $runtests $test] {
return
}
set nshort "$subdir/[file tail $test]"
set bname "[file rootname [file tail $nshort]]"
! foreach flags $options {
! verbose "Testing $nshort, $otherflags $flags" 1
! set dg-do-what-default compile
! set have_errs [llength [grep $test "{\[ \t\]\+dg-error\[ \t\]\+.*\[ \t\]\+}"]]
! # Compile the file the first time to produce PPH/PTH images.
! dg-test -keep-output $test "$otherflags $flags -I." ""
!
! if { !$have_errs } {
! if { [ file_on_host exists "$bname.s" ] } {
! # Rename the .s file into .s-pph to compare it after the
! # second build.
! remote_upload host "$bname.s" "$bname.s-pph"
! remote_download host "$bname.s-pph"
!
! # Compile a second time to use the generated images.
! dg-test -keep-output $test "$otherflags $flags -I." ""
! remote_upload host "$bname.s"
!
! # Compare the two assembly files. They should be identical.
! set tmp [ diff "$bname.s" "$bname.s-pph" ]
! if { $tmp == 0 } {
! verbose -log "assembly file '$bname.s', '$bname.s-pph' comparison error"
! fail "$nshort $otherflags $flags assembly comparison"
! } elseif { $tmp == 1 } {
! pass "$nshort $otherflags $flags assembly comparison"
! } else {
! fail "$nshort $otherflags $flags assembly comparison"
! }
! file_on_host delete "$bname$suffix"
! file_on_host delete "$bname.s"
! file_on_host delete "$bname.s-pph"
! } else {
! verbose -log "assembly file '$bname.s' missing"
! fail "$nshort $flags assembly comparison"
! }
! }
!
! # Remove stale .pth files, if any.
! foreach pth_file [glob -nocomplain *.pth] {
! file_on_host delete $pth_file
! }
}
}
! proc dg-pph { subdir test options suffix } {
! return [dg-flags-pph $subdir $test "" $options $suffix]
}
# <http://www.gnu.org/licenses/>.
# Contributed by Diego Novillo <dnovillo@google.com>
+ # Adapted to new command-driven scheme by Lawrence Crowl <crowl@google.com>
load_lib copy-file.exp
! proc dg-pph-hdr { subdir test options mapflag suffix } {
!
global runtests dg-do-what-default
# If we're only testing specific files and this isn't one of them, skip it.
if ![runtest_file_p $runtests $test] {
return
}
+
set nshort "$subdir/[file tail $test]"
set bname "[file rootname [file tail $nshort]]"
+ verbose "Testing $nshort, $options" 1
+ set dg-do-what-default preparse
+ dg-test -keep-output $test "$options $mapflag -I." ""
! }
! proc dg-pph-neg { subdir test options mapflag suffix } {
! global runtests dg-do-what-default
!
! # If we're only testing specific files and this isn't one of them, skip it.
! if ![runtest_file_p $runtests $test] {
! return
}
+
+ set nshort "$subdir/[file tail $test]"
+ set bname "[file rootname [file tail $nshort]]"
+ verbose "Testing $nshort, $options" 1
+ set dg-do-what-default compile
+ dg-test -keep-output $test "$options $mapflag -I." ""
+ file_on_host delete "$bname.s"
}
! proc dg-pph-pos { subdir test options mapflag suffix } {
!
! global runtests dg-do-what-default
!
! # If we're only testing specific files and this isn't one of them, skip it.
! if ![runtest_file_p $runtests $test] {
! return
! }
!
! set nshort "$subdir/[file tail $test]"
! set bname "[file rootname [file tail $nshort]]"
! verbose "Testing $nshort, $options" 1
! set dg-do-what-default compile
!
! set have_errs [llength [grep $test "{\[ \t\]\+dg-error\[ \t\]\+.*\[ \t\]\+}"]]
! # Compile the file the first time for a base case.
! dg-test -keep-output $test "$options -I." ""
!
! if { $have_errs } {
! verbose -log "regular compilation failed"
! fail "$nshort $options, regular compilation failed"
! return
! }
!
! if { ! [ file_on_host exists "$bname.s" ] } {
! verbose -log "assembly file '$bname.s' missing"
! fail "$nshort $options, assembly comparison"
! return
! }
!
! # Rename the .s file into .s-pph to compare it after the second build.
! remote_upload host "$bname.s" "$bname.s-pph"
! remote_download host "$bname.s-pph"
!
! # Compile a second time using the pph files.
! dg-test -keep-output $test "$options $mapflag -I." ""
! remote_upload host "$bname.s"
!
! # Compare the two assembly files. They should be identical.
! set tmp [ diff "$bname.s" "$bname.s-pph" ]
! if { $tmp == 0 } {
! verbose -log "assembly file '$bname.s', '$bname.s-pph' comparison error"
! fail "$nshort $options assembly comparison"
! } elseif { $tmp == 1 } {
! pass "$nshort $options assembly comparison"
! } else {
! fail "$nshort $options assembly comparison"
! }
! file_on_host delete "$bname.s"
! file_on_host delete "$bname.s-pph"
!
}
===================================================================
*************** proc gcc-dg-test-1 { target_compile prog
set compile_type "precompiled_header"
set output_file "[file tail $prog].gch"
}
+ "preparse" {
+ set compile_type "preparsed_header"
+ set output_file "[file rootname [file tail $prog]].pph"
+ }
"link" {
set compile_type "executable"
set output_file "[file rootname [file tail $prog]].exe"
===================================================================
***************
+ #include "c1altinc2.h"
+ void foo (void)
+ {
+ int x = var1 + var2 - (int) f1;
+ }
===================================================================
***************
+ #ifndef X2NONTRIVINIT_H
+ #define X2NONTRIVINIT_H
+ int y = 0;
+ int x = y+1;
+ #endif
===================================================================
***************
+ #ifndef C1FUNCMAC_H
+ #define C1FUNCMAC_H
+ #define gnu_dev_major(dev) long dev
+ #define gnu_dev_minor(dev) short dev
+ #define major(dev) gnu_dev_major (dev)
+ #define minor(dev) gnu_dev_minor (dev)
+ #endif
===================================================================
***************
+ #include "x1globalref.h"
+ type x = 2;
+ type y = x;
+ type f() { return n+m+a[3]+x+y; }
===================================================================
***************
+ #include "c1struct.h"
+ thing var1;
+ thing var2 = { 3 };
===================================================================
***************
- namespace A {
- int x = 3;
- struct B;
- struct C {
- B* b;
- int method();
- int another()
- { return 1; }
- };
- int C::method()
- { return 1; }
- } // namespace A
- struct D : A::C {
- int method();
- int another()
- { return 1; }
- };
- int D::method()
- { return 1; }
- int main()
- { }
===================================================================
***************
- #ifndef SIMPLE2_H
- #define SIMPLE2_H
-
- #define assert(x) yellow(x)
- extern void yellow(int);
-
- #endif
===================================================================
***************
+ #ifndef X1STRUCT0_H
+ #define X1STRUCT0_H
+ typedef int type;
+ struct B {
+ };
+ typedef B thing;
+ #endif
===================================================================
***************
- class one {
- };
- typedef one type;
- class two {
- type fld;
- };
===================================================================
***************
+ #include "x1struct2.h"
+ type D::method()
+ { static int x = 2;
+ return fld + mbr + gbl; }
+ type D::mbr = 4;
+ typedef D D2;
+ D2 var1;
+ D2 var2 = var1;
===================================================================
***************
- #include <stdlib.h> // { dg-error "fatal" "invalid hunk" { xfail *-*-* } }
- #include <stdio.h>
- #include <math.h>
- #include <string.h>
-
- static unsigned long long MAX_ITEMS = 10000;
-
- static int
- cmpdouble (const void *p1, const void *p2)
- {
- double n1 = *((double *)p1);
- double n2 = *((double *)p2);
-
- if (n1 < n2)
- return -1;
- else if (n1 > n2)
- return 1;
- else
- return 0;
- }
-
-
- double
- compute_median (int n, double vec[])
- {
- qsort (vec, n, sizeof (double), cmpdouble);
-
- if (n % 2 == 0)
- return ((vec[n / 2] + vec[n / 2 - 1]) / 2.0);
- else
- return vec[n / 2];
- }
-
- double
- compute_stddev (int n, double avg, double vec[])
- {
- double sd, sum, s, x;
- int i;
-
- for (x = 0.0, sum = 0.0, i = 0; i < n; i++)
- {
- double d;
-
- x = x + vec[i];
- d = vec[i] - avg;
- sum += d * d;
- }
-
- s = sum / n;
- sd = sqrt (s);
-
- return sd;
- }
-
-
- int
- main (int argc, char *argv[])
- {
- double *vec;
- double x, sum, product, inverse_sum, arithmetic, geometric, harmonic;
- double min, max, median, variance, stddev;
- int count;
- int ret;
-
- sum = 0.0;
- product = 1.0;
- inverse_sum = 0.0;
- count = 0;
- min = 0.0;
- max = 0.0;
-
- vec = (double *) malloc (MAX_ITEMS * sizeof (double));
-
- while (1)
- {
- ret = scanf ("%lg", &x);
- if (ret == EOF)
- break;
-
- if (count == 0)
- min = max = x;
-
- if (x < min)
- min = x;
-
- if (x > max)
- max = x;
-
- sum += x;
- product *= x;
- inverse_sum += 1.0 / x;
- vec[count] = x;
-
- count++;
- if (count >= MAX_ITEMS)
- {
- MAX_ITEMS *= 3;
- vec = (double *) realloc (vec, MAX_ITEMS * sizeof (double));
- }
- }
-
- int do_min = (strstr (argv[0], "min") != NULL);
- int do_max = (strstr (argv[0], "max") != NULL);
- int do_avg = (strstr (argv[0], "avg") != NULL);
- int do_geo = (strstr (argv[0], "geoavg") != NULL);
- int do_harmonic = (strstr (argv[0], "harmonic") != NULL);
- int do_median = (strstr (argv[0], "median") != NULL);
- int do_variance = (strstr (argv[0], "variance") != NULL);
- int do_stdev = (strstr (argv[0], "stdev") != NULL);
- int do_all = (argc > 1 && strcmp (argv[1], "-a") == 0);
-
- if (count > 0)
- {
- arithmetic = sum / count;
- geometric = pow (product, (double) 1.0 / (double) count);
- harmonic = count / inverse_sum;
- median = compute_median (count, vec);
- stddev = compute_stddev (count, arithmetic, vec);
- variance = stddev * stddev;
-
- if (do_all)
- {
- printf ("# of items read --> %d\n", count);
- printf ("Min --------------> %lg\n", min);
- printf ("Max --------------> %lg\n", max);
- printf ("Arithmetic mean --> %lg\n", arithmetic);
- printf ("Geometric mean ---> %lg\n", geometric);
- printf ("Harmonic mean ----> %lg\n", harmonic);
- printf ("Median -----------> %lg\n", median);
- printf ("Variance ---------> %lg\n", variance);
- printf ("Standard dev -----> %lg\n", stddev);
- }
- else if (do_min)
- printf ("%lg\n", min);
- else if (do_max)
- printf ("%lg\n", max);
- else if (do_avg)
- printf ("%lg\n", arithmetic);
- else if (do_geo)
- printf ("%lg\n", geometric);
- else if (do_harmonic)
- printf ("%lg\n", harmonic);
- else if (do_median)
- printf ("%lg\n", median);
- else if (do_variance)
- printf ("%lg\n", variance);
- else if (do_stdev)
- printf ("%lg\n", stddev);
- else
- {
- fprintf (stderr, "ERROR: Unknown value '%s' to compute\n", argv[0]);
- return 1;
- }
- }
- else
- {
- fprintf (stderr, "ERROR: none of the input is positive\n");
- return 1;
- }
-
- return 0;
- }
- // { dg-error "excess errors" "" { xfail *-*-* } }
===================================================================
***************
+ #ifndef X1FUNCTIONS_H
+ #define X1FUNCTIONS_H
+ #include "c1functions.h"
+ inline int extern_inline(int i) // lazy body
+ { return extern_then_body(i); }
+ struct type {
+ int mbr_decl_only(int);
+ int mbr_decl_then_def(int);
+ inline int mbr_inl_then_def(int);
+ int mbr_decl_inline(int i) // lazy body
+ { return mbr_decl_only( i ); }
+ virtual int mbr_virtual_inline() // lazy body, but circular dependence
+ { return mbr_decl_only( 1 ); }
+ };
+ #endif
===================================================================
***************
- int y = 0;
- int x = y+1;
===================================================================
***************
- class base {
- virtual int method() {
- return 0;
- }
- int field;
- };
- void function() {
- base var1;
- base var2( var1 );
- var1 = var2;
- }
===================================================================
***************
- typedef int type;
- type val = 3;
-
- template< typename T >
- T identity(T arg)
- { return arg + val; }
-
- template<>
- int identity< type >(type arg)
- { return arg + val; }
-
- template
- short identity(short arg);
-
- int main() {
- return identity( 'a' );
- }
===================================================================
***************
- #define QUOTE(arg) #arg
- #define VALUE(arg) QUOTE(arg)
===================================================================
***************
+ #include "x1autometh.h"
+ void function() {
+ base var1;
+ base var2( var1 );
+ var1 = var2;
+ }
===================================================================
***************
+ #include "x1tmplfunc.h"
+ type val = 3;
+
+ template<>
+ int identity< type >(type arg)
+ { return arg + val; }
+
+ template
+ short identity(short arg);
+
+ int main() {
+ return identity( 'a' );
+ }
===================================================================
***************
+ #include "c2dupguard1.h"
+ #include "c2dupguard2.h"
+ // { dg-error "duplicate PPH guard header" "" { xfail *-*-* } }
+ int foo() { return x; }
===================================================================
***************
- int f() {
- static int x = 3;
- }
===================================================================
***************
+ #include <sys/types.h>
+ loff_t variable = 0;
===================================================================
***************
- #include "builtin1.h"
- #include "builtin2.h"
- #include "builtin3.h"
===================================================================
***************
+ // { dg-bogus "Cannot open PPH file for reading" "" { xfail *-*-* } }
+ #define NAME v
+ #define VALUE 1
+ #include "d1symnotinc.h"
+ // { dg-excess-errors "compilation terminated" { xfail *-*-* } }
===================================================================
***************
+ #ifndef X2OVERLOAD1_H
+ #define X2OVERLOAD1_H
+ int o(double x);
+ #endif
===================================================================
***************
- struct V { int a; static int b;};
- namespace N {
- int V;
- struct C { };
- int operator + (int i, C c);
- C O;
- int I(int arg)
- { return arg + V; }
- struct V w;
- int x = V::b;
- }
-
- int V;
- struct D { };
- D P;
- int operator + (int i, D d);
- int I(int arg)
- { return arg + V; }
-
- int F() {
- return I(N::V + N::O);
- }
-
- int G() {
- return I(::V + P);
- }
-
- struct V w;
- int x = V::b;
===================================================================
***************
- struct T NAME = { VALUE };
===================================================================
***************
- #include <sys/types.h> // { dg-error "fatal" "invalid hunk" { xfail *-*-* } }
- // { dg-error "excess errors" "" { xfail *-*-* } }
===================================================================
***************
- = { 1 };
===================================================================
***************
+ #ifndef C1ALTINC2
+ #define C1ALTINC2
+ extern void foo (void);
+ #define X 1
+ #if defined X
+ #include "c1altinc1.h"
+ extern int var1;
+ extern int var2;
+ #else
+ #include "c1altinc1.h"
+ #endif
+ #endif
===================================================================
***************
+ #ifndef X1VARIABLES_H
+ #define X1VARIABLES_H
+ #include "c1variables.h"
+ struct D {
+ static int mbr_init_plain;
+ static int mbr_uninit_plain;
+ static const int mbr_init_const;
+ static const int mbr_uninit_const;
+ static const int mbr_manifest = 3;
+ };
+ #endif
===================================================================
***************
- typedef int type;
- type gbl = 1;
- struct B {
- type fld;
- };
- struct D : B {
- type method();
- type another()
- { return fld + mbr + gbl; }
- type fld;
- static type mbr;
- };
- type D::method()
- { static int x = 2;
- return fld + mbr + gbl; }
- type D::mbr = 4;
- typedef D D2;
- D2 var1;
- D2 var2 = var1;
===================================================================
***************
+ #ifndef X1TEMPLATE_H
+ #define X1TEMPLATE_H
+ namespace A {
+ extern int x;
+ struct B;
+ template< typename T >
+ struct C {
+ T* b;
+ int method();
+ int another()
+ { return *b; }
+ };
+ template< typename T >
+ int C< T >::method()
+ { return x; }
+ } // namespace A
+ struct D : A::C< int > {
+ int method();
+ int another()
+ { return *b; }
+ };
+ #endif
===================================================================
***************
+ #include "x1special.h"
+ B b(1);
+
+ int H() {
+ F(b);
+ B a(3.2);
+ B c = b;
+ B d(b);
+ c = b;
+ d = 4;
+ G(d);
+ }
===================================================================
***************
+ #include "x2nontrivinit.h"
===================================================================
***************
# GCC testsuite for preparsed header interaction.
# Contributed by Diego Novillo <dnovillo@google.com>
+ # Adapted to new command-driven scheme by Lawrence Crowl <crowl@google.com>
# Load support procs.
load_lib "g++-dg.exp"
*************** load_lib dg-pph.exp
# Initialize `dg'.
dg-init
! set old_dg_do_what_default "${dg-do-what-default}"
! # Main loop.
! foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] {
! dg-pph $subdir $test [list "-fpth" ] ".pth"
! }
! set dg-do-what-default "$old_dg_do_what_default"
# All done.
dg-finish
# Initialize `dg'.
dg-init
! # FIXME set scenarios [list "" "-g" "-O"]
! set scenarios [list "" ]
! set hdr_tests [lsort [glob -nocomplain $srcdir/$subdir/\[cdx\]*.h]]
! set neg_tests [lsort [glob -nocomplain $srcdir/$subdir/\[dy\]*.cc]]
! set pos_tests [lsort [glob -nocomplain $srcdir/$subdir/\[cpx\]*.cc]]
! set mapflag -fpph-map=$srcdir/$subdir/pph.map
!
! foreach scenario $scenarios {
!
! set old_dg_do_what_default "${dg-do-what-default}"
!
! #system headers
! dg-pph-hdr $subdir /usr/include/math.h $scenario "" ".pph"
! dg-pph-hdr $subdir /usr/include/stdio.h $scenario "" ".pph"
! dg-pph-hdr $subdir /usr/include/stdlib.h $scenario "" ".pph"
! dg-pph-hdr $subdir /usr/include/string.h $scenario "" ".pph"
! dg-pph-hdr $subdir /usr/include/sys/types.h $scenario "" ".pph"
!
! # Header file loop.
! # Each pph header must include only pph headers
! # that are lexicographically earlier than itself.
! foreach test $hdr_tests {
! dg-pph-hdr $subdir $test $scenario $mapflag ".pph"
! }
!
! # Source file loop for negative tests.
! foreach test $neg_tests {
! dg-pph-neg $subdir $test $scenario $mapflag ".pph"
! }
!
! # Source file loop for positive tests.
! foreach test $pos_tests {
! dg-pph-pos $subdir $test $scenario $mapflag ".pph"
! }
!
! set dg-do-what-default "$old_dg_do_what_default"
! }
# All done.
dg-finish
===================================================================
***************
+ #ifndef C1SIMPLE1_H
+ #define C1SIMPLE1_H
+
+ #define assert(x) yellow(x)
+ extern void yellow(int);
+
+ #endif
===================================================================
***************
+ #ifndef C1CHAINED1_H
+ #define C1CHAINED1_H
+ #define ONE 1
+ #endif
===================================================================
***************
- template< typename T >
- struct wrapper {
- T value;
- static T cache;
- };
-
- template< typename T >
- T wrapper<T>::cache = 3;
-
- template<>
- struct wrapper<char> {
- int value;
- static int cache;
- };
-
- int wrapper<char>::cache = 2;
-
- template
- struct wrapper<short>;
-
- template
- long wrapper<long>::cache;
-
- int main() {
- wrapper<char> vc;
- wrapper<short> vs;
- wrapper<int> vi;
- return 0;
- }
===================================================================
***************
- int main()
- {
- }
===================================================================
***************
- namespace A {
- int x = 3;
- struct B;
- template< typename T >
- struct C {
- T* b;
- int method();
- int another()
- { return *b; }
- };
- template< typename T >
- int C< T >::method()
- { return x; }
- } // namespace A
- int y = 4;
- struct D : A::C< int > {
- int method();
- int another()
- { return *b; }
- };
- int D::method()
- { return y; }
- int main()
- { }
===================================================================
***************
+ /* comment */
+ #include "c1simple2.h"
+ int main()
+ {
+ return foo();
+ }
===================================================================
***************
+ #ifndef X1FUNCSTATIC_H
+ #define X1FUNCSTATIC_H
+ static int f() {
+ static int x = 3;
+ return x++;
+ }
+ #endif
===================================================================
***************
- #define ONE 1
===================================================================
***************
+ #ifndef C2BUILTIN1_H
+ #define C2BUILTIN1_H
+ #define QUOTE(arg) #arg
+ #define VALUE(arg) QUOTE(arg)
+ #endif
===================================================================
***************
+ #define QUOTE(arg) #arg
+ #define VALUE(arg) QUOTE(arg)
===================================================================
***************
+ c1altinc1.h c1altinc1.pph
+ c1altinc2.h c1altinc2.pph
+ c1chained1.h c1chained1.pph
+ c1chained2.h c1chained2.pph
+ c1empty.h c1empty.pph
+ c1field.h c1field.pph
+ c1funcmac.h c1funcmac.pph
+ c1functions.h c1functions.pph
+ c1guarded1.h c1guarded1.pph
+ c1guarded2.h c1guarded2.pph
+ c1guarded3.h c1guarded3.pph
+ c1multinc1.h c1multinc1.pph
+ c1multinc2.h c1multinc2.pph
+ c1simple1.h c1simple1.pph
+ c1simple2.h c1simple2.pph
+ c1struct.h c1struct.pph
+ c1typerefs.h c1typerefs.pph
+ c1variables.h c1variables.pph
+ c2builtin1.h c2builtin1.pph
+ c2builtin2.h c2builtin2.pph
+ c2builtin3.h c2builtin3.pph
+ c2dupguard1.h c2dupguard1.pph
+ c2dupguard2.h c2dupguard2.pph
+ c2paste.h c2paste.pph
+ d1symnotinc.h d1symnotinc.pph
+ math.h math.pph
+ stdio.h stdio.pph
+ stdlib.h stdlib.pph
+ string.h string.pph
+ sys/types.h types.pph
+ x1autometh.h x1autometh.pph
+ x1funcstatic.h x1funcstatic.pph
+ x1functions.h x1functions.pph
+ x1globalref.h x1globalref.pph
+ x1hardlookup.h x1hardlookup.pph
+ x1special.h x1special.pph
+ x1struct0.h x1struct0.pph
+ x1struct1.h x1struct1.pph
+ x1struct2.h x1struct2.pph
+ x1template.h x1template.pph
+ x1tmplclass.h x1tmplclass.pph
+ x1tmplfunc.h x1tmplfunc.pph
+ x1typerefs.h x1typerefs.pph
+ x1variables.h x1variables.pph
+ x2nontrivinit.h x2nontrivinit.pph
+ y2overload1.h y2overload1.pph
+ y2overload2.h y2overload2.pph
+ y2overload3.h y2overload3.pph
===================================================================
***************
+ #ifndef X1STRUCT1_H
+ #define X1STRUCT1_H
+ #include "x1struct0.h"
+ struct D : public thing {
+ type method();
+ type another()
+ { return fld + mbr; }
+ type fld;
+ static type mbr;
+ };
+ #endif
===================================================================
***************
- struct B {
- B( int );
- B( double );
- B( const B& );
- B& operator=( const B& );
- B& operator=( int );
- operator double();
- ~B();
- };
-
- struct D {
- D( const B& );
- };
-
- int F( D );
- int G( double );
-
- B b(1);
- //B q("hhh");
-
- int H() {
- F(b);
- B a(3.2);
- B c = b;
- B d(b);
- c = b;
- d = 4;
- //G(double(""));
- G(d);
- }
===================================================================
***************
+ #include <stdlib.h>
+ int f(const char* s)
+ {
+ return atoi(s);
+ }
===================================================================
***************
+ #ifndef C2BUILTIN5_H
+ #define C2BUILTIN5_H
+ #include "a2builtin4.h"
+ const char *file = VALUE(__FILE__);
+ const char *line = VALUE(__LINE__);
+ const char *vers = VALUE(__cplusplus);
+ const char *optm = VALUE(__OPTIMIZE__);
+ const char *func() { return __func__; }
+ #endif
===================================================================
***************
+ #ifndef C1GUARDED1_H
+ #define C1GUARDED1_H
+ typedef int type;
+ #endif
===================================================================
***************
+ #include "x1template.h"
+ namespace A {
+ int x = 3;
+ } // namespace A
+ int y = 4;
+ int D::method()
+ { return y; }
+ int main()
+ { }
===================================================================
***************
- const char *date = VALUE(__DATE__);
- const char *time = VALUE(__TIME__);
- const char *file = VALUE(__FILE__);
- const char *line = VALUE(__LINE__);
- const char *vers = VALUE(__cplusplus);
- const char *optm = VALUE(__OPTIMIZE__);
- const char *func() { return __func__; }
===================================================================
***************
- #include "chained1.h"
- #include "chained2.h"
- int x = TWO;
===================================================================
***************
- #include "usearray.h"
- const int x = 3;
- const int y = 10;
- float array[x + y];
- float foo (int i)
- {
- return array[i * 3];
- }
===================================================================
***************
- float foo(int);
===================================================================
***************
- typedef int type;
- class base {
- type fld;
- };
===================================================================
***************
- #ifndef GUARDED1_H
- #define GUARDED1_H
-
- typedef int type;
-
- #endif
===================================================================
***************
+ #include "c1guarded2.h"
+ #include "c1guarded3.h"
===================================================================
***************
+ #include "c2paste.h"
+ void foo_30_(int);
+ void bar(void)
+ {
+ M(30);
+ }
===================================================================
***************
+ // { dg-error "header lacks guard for PPH" "" { xfail *-*-* } }
===================================================================
***************
+ #ifndef X1TMPLFUNC_H
+ #define X1TMPLFUNC_H
+ typedef int type;
+ extern type val;
+
+ template< typename T >
+ T identity(T arg)
+ { return arg + val; }
+ #endif
===================================================================
***************
+ #include "c1field.h"
+ struct client {
+ program field;
+ };
+ client variable;
===================================================================
***************
+ #ifndef X2OVERLOAD2_H
+ #define X2OVERLOAD2_H
+ int o(float x);
+ #endif
===================================================================
***************
+ #ifndef C1STRUCT_H
+ #define C1STRUCT_H
+ typedef int type;
+ type gbl = 1;
+ struct B {
+ type fld;
+ };
+ typedef B thing;
+ #endif
===================================================================
***************
- #include "guarded2.h"
- #include "guarded3.h"
===================================================================
***************
+ #include "x1tmplclass.h"
+ int wrapper<char>::cache = 2;
+
+ template
+ struct wrapper<short>;
+
+ template
+ long wrapper<long>::cache;
+
+ int main() {
+ wrapper<char> vc;
+ wrapper<short> vs;
+ wrapper<int> vi;
+ return 0;
+ }
===================================================================
***************
+ #include "c2builtin1.h"
+ #include "c2builtin2.h"
+ #include "c2builtin3.h"
===================================================================
***************
- #define major "beef"
- #define M(major) foo##_##major##_(major)
-
- void foo_30_(int);
- void bar(void);
-
- void bar(void)
- {
- M(30);
- }
===================================================================
***************
+ #include "x1funcstatic.h"
+ int a = f();
===================================================================
***************
+ #ifndef X1TMPLCLASS_H
+ #define X1TMPLCLASS_H
+ template< typename T >
+ struct wrapper {
+ T value;
+ static T cache;
+ };
+
+ template< typename T >
+ T wrapper<T>::cache = 3;
+
+ template<>
+ struct wrapper<char> {
+ int value;
+ static int cache;
+ };
+ #endif
===================================================================
***************
+ #include "x1hardlookup.h"
+ D P;
+ int I(int arg)
+ { return arg + V; }
+
+ int F() {
+ return I(N::V + N::O);
+ }
+
+ int G() {
+ return I(::V + P);
+ }
+
+ struct V w;
+ int x = V::b;
===================================================================
***************
+ #include "c1empty.h"
===================================================================
***************
- typedef int language;
- struct program {
- language field;
- };
- struct client {
- program field;
- };
===================================================================
***************
- int one;
- int two;
===================================================================
***************
- extern float f1;
===================================================================
***************
+ #ifndef X1SPECIAL_H
+ #define X1SPECIAL_H
+
+ struct B {
+ B( int );
+ B( double );
+ B( const B& );
+ B& operator=( const B& );
+ B& operator=( int );
+ operator double();
+ ~B();
+ };
+
+ struct D {
+ D( const B& );
+ };
+
+ int F( D );
+ int G( double );
+
+ #endif
===================================================================
===================================================================
***************
+ #ifndef C1FUNCTIONS_H
+ #define C1FUNCTIONS_H
+ extern int extern_only(int); //
+ extern int extern_then_body(int); //
+ #endif
===================================================================
***************
- struct D {
- int method() { return mbr; }
- static int mbr;
- };
- int D::mbr = 4;
===================================================================
***************
- struct base {
- int field;
- };
- base function();
- int base_from_var() {
- base variable;
- }
- int base_from_func() {
- function();
- }
- struct derived : base {
- int method();
- };
- int derived::method() {
- return field;
- }
- struct vderived : virtual base {
- };
===================================================================
***************
+ #ifndef C1SIMPLE2_H
+ #define C1SIMPLE2_H
+
+ #include "c1simple1.h"
+
+ inline int foo()
+ {
+ assert(1);
+ }
+
+ #endif
===================================================================
***************
+ #ifndef C1CHAINED2_H
+ #define C1CHAINED2_H
+ #define TWO ONE
+ #endif
===================================================================
***************
- #include <stdlib.h> // { dg-error "fatal" "invalid hunk" { xfail *-*-* } }
- size_t X;
- // { dg-error "excess errors" "" { xfail *-*-* } }
===================================================================
***************
+ #ifndef D1SDYMNOTINC_H
+ #define D1SDYMNOTINC_H
+ struct T { int f; };
+ struct T NAME = { VALUE }; // { dg-error "was not declared in this scope" }
+ #endif
===================================================================
***************
+ #include "x1typerefs.h"
+ int derived::method() {
+ return field;
+ }
+ vderived variable;
===================================================================
***************
- #define TWO ONE
===================================================================
***************
+ #ifndef C2BUILTIN2_H
+ #define C2BUILTIN2_H
+ #include "c2builtin1.h"
+ const char *file = VALUE(__FILE__);
+ const char *line = VALUE(__LINE__);
+ const char *vers = VALUE(__cplusplus);
+ const char *optm = VALUE(__OPTIMIZE__);
+ const char *func() { return __func__; }
+ #endif
===================================================================
***************
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <math.h>
+ #include <string.h>
+
+ static unsigned long long MAX_ITEMS = 10000;
+
+ static int
+ cmpdouble (const void *p1, const void *p2)
+ {
+ double n1 = *((double *)p1);
+ double n2 = *((double *)p2);
+
+ if (n1 < n2)
+ return -1;
+ else if (n1 > n2)
+ return 1;
+ else
+ return 0;
+ }
+
+
+ double
+ compute_median (int n, double vec[])
+ {
+ qsort (vec, n, sizeof (double), cmpdouble);
+
+ if (n % 2 == 0)
+ return ((vec[n / 2] + vec[n / 2 - 1]) / 2.0);
+ else
+ return vec[n / 2];
+ }
+
+ double
+ compute_stddev (int n, double avg, double vec[])
+ {
+ double sd, sum, s, x;
+ int i;
+
+ for (x = 0.0, sum = 0.0, i = 0; i < n; i++)
+ {
+ double d;
+
+ x = x + vec[i];
+ d = vec[i] - avg;
+ sum += d * d;
+ }
+
+ s = sum / n;
+ sd = sqrt (s);
+
+ return sd;
+ }
+
+
+ int
+ main (int argc, char *argv[])
+ {
+ double *vec;
+ double x, sum, product, inverse_sum, arithmetic, geometric, harmonic;
+ double min, max, median, variance, stddev;
+ int count;
+ int ret;
+
+ sum = 0.0;
+ product = 1.0;
+ inverse_sum = 0.0;
+ count = 0;
+ min = 0.0;
+ max = 0.0;
+
+ vec = (double *) malloc (MAX_ITEMS * sizeof (double));
+
+ while (1)
+ {
+ ret = scanf ("%lg", &x);
+ if (ret == EOF)
+ break;
+
+ if (count == 0)
+ min = max = x;
+
+ if (x < min)
+ min = x;
+
+ if (x > max)
+ max = x;
+
+ sum += x;
+ product *= x;
+ inverse_sum += 1.0 / x;
+ vec[count] = x;
+
+ count++;
+ if (count >= MAX_ITEMS)
+ {
+ MAX_ITEMS *= 3;
+ vec = (double *) realloc (vec, MAX_ITEMS * sizeof (double));
+ }
+ }
+
+ int do_min = (strstr (argv[0], "min") != NULL);
+ int do_max = (strstr (argv[0], "max") != NULL);
+ int do_avg = (strstr (argv[0], "avg") != NULL);
+ int do_geo = (strstr (argv[0], "geoavg") != NULL);
+ int do_harmonic = (strstr (argv[0], "harmonic") != NULL);
+ int do_median = (strstr (argv[0], "median") != NULL);
+ int do_variance = (strstr (argv[0], "variance") != NULL);
+ int do_stdev = (strstr (argv[0], "stdev") != NULL);
+ int do_all = (argc > 1 && strcmp (argv[1], "-a") == 0);
+
+ if (count > 0)
+ {
+ arithmetic = sum / count;
+ geometric = pow (product, (double) 1.0 / (double) count);
+ harmonic = count / inverse_sum;
+ median = compute_median (count, vec);
+ stddev = compute_stddev (count, arithmetic, vec);
+ variance = stddev * stddev;
+
+ if (do_all)
+ {
+ printf ("# of items read --> %d\n", count);
+ printf ("Min --------------> %lg\n", min);
+ printf ("Max --------------> %lg\n", max);
+ printf ("Arithmetic mean --> %lg\n", arithmetic);
+ printf ("Geometric mean ---> %lg\n", geometric);
+ printf ("Harmonic mean ----> %lg\n", harmonic);
+ printf ("Median -----------> %lg\n", median);
+ printf ("Variance ---------> %lg\n", variance);
+ printf ("Standard dev -----> %lg\n", stddev);
+ }
+ else if (do_min)
+ printf ("%lg\n", min);
+ else if (do_max)
+ printf ("%lg\n", max);
+ else if (do_avg)
+ printf ("%lg\n", arithmetic);
+ else if (do_geo)
+ printf ("%lg\n", geometric);
+ else if (do_harmonic)
+ printf ("%lg\n", harmonic);
+ else if (do_median)
+ printf ("%lg\n", median);
+ else if (do_variance)
+ printf ("%lg\n", variance);
+ else if (do_stdev)
+ printf ("%lg\n", stddev);
+ else
+ {
+ fprintf (stderr, "ERROR: Unknown value '%s' to compute\n", argv[0]);
+ return 1;
+ }
+ }
+ else
+ {
+ fprintf (stderr, "ERROR: none of the input is positive\n");
+ return 1;
+ }
+
+ return 0;
+ }
===================================================================
***************
+ #ifndef X1STRUCT_H
+ #define X1STRUCT_H
+ #include "c1struct.h"
+ struct D : thing {
+ type method();
+ type another()
+ { return fld + mbr + gbl; }
+ type fld;
+ static type mbr;
+ };
+ #endif
===================================================================
***************
+ #ifndef C1MULTINC1_H
+ #define C1MULTINC1_H
+ extern float f1;
+ #endif
===================================================================
***************
+ #ifndef C2DUPGUARD_H
+ #define C2DUPGUARD_H
+ extern int x;
+ #endif
===================================================================
***************
+ #ifndef C2BUILTIN6_H
+ #define C2BUILTIN6_H
+ #include "a2builtin4.h"
+ const char *refile = VALUE(__FILE__);
+ const char *reline = VALUE(__LINE__);
+ #endif
===================================================================
***************
+ #ifndef C1GUARDED2_H
+ #define C1GUARDED2_H
+ #include "c1guarded1.h"
+ type variable2;
+ #endif
===================================================================
***************
+ #ifndef C1EMPTY_H
+ #define C1EMPTY_H
+ #endif
===================================================================
***************
- const char *refile = VALUE(__FILE__);
- const char *reline = VALUE(__LINE__);
===================================================================
***************
+ #include "c1functions.h"
+ int extern_then_body(int i) // need body, merge head to body
+ { return extern_only( i ); }
+ static int fwdref_static(int);
+ int fwdref_static(int i)
+ { return extern_then_body( i ); } // need body, merge head to body
===================================================================
***************
+ #ifndef C1VARIABLES_H
+ #define C1VARIABLES_H
+ extern int gbl_init_extern;
+ extern int gbl_uninit_extern;
+ int gbl_tentative;
+ extern const int gbl_extern_const;
+ #endif
===================================================================
***************
- #ifndef GUARDED2_H
- #define GUARDED2_H
-
- #include "guarded1.h"
-
- type variable2;
-
- #endif
===================================================================
***************
+ #include "c1multinc2.h"
+ void foo (void)
+ {
+ int x = var1 + var2 - (int) f1;
+ }
===================================================================
***************
+ #include "c1funcmac.h"
+ #define outer(major, minor) inner(major, minor)
+ void outer(long one, short two) { }
+ major(three);
+ minor(four);
===================================================================
***************
+ #ifndef X1AUTOMETH_H
+ #define X1AUTOMETH_H
+ class base {
+ virtual int method() {
+ return 0;
+ }
+ int field;
+ };
+ #endif
===================================================================
***************
+ #ifndef C2PASTE_H
+ #define C2PASTE_H
+ #define major "beef"
+ #define M(major) foo##_##major##_(major)
+ #endif
===================================================================
***************
+ #ifndef X1GLOBALREF_H
+ #define X1GLOBALREF_H
+ typedef int type;
+ const type n = 3;
+ const type m = 4;
+ type a[n+m];
+ #endif
===================================================================
***************
- extern int extern_only(int); //
- extern int extern_then_body(int); //
- inline int extern_inline(int i) // lazy body
- { return extern_then_body(i); }
- int extern_then_body(int i) // need body, merge head to body
- { return extern_only( i ); }
- static int fwdref_static(int);
- int fwdref_static(int i)
- { return extern_then_body( i ); } // need body, merge head to body
- struct type {
- int mbr_decl_only(int);
- int mbr_decl_then_def(int);
- inline int mbr_inl_then_def(int);
- int mbr_decl_inline(int i) // lazy body
- { return mbr_decl_only( i ); }
- virtual int mbr_virtual_inline() // lazy body, but circular dependence
- { return mbr_decl_only( 1 ); }
- };
- int type::mbr_decl_then_def(int i) // need body
- { return mbr_decl_inline( i ); }
- int type::mbr_inl_then_def(int i) // lazy body
- { return mbr_decl_then_def( i ); }
===================================================================
***************
+ #ifndef X2OVERLOAD3_H
+ #define X2OVERLOAD3_H
+ #include "x2overload1.h"
+ inline int f()
+ {
+ float x = 2.3f;
+ return o(x);
+ }
+ #endif
===================================================================
***************
- #include "cflow.h"
-
- void foo (void)
- {
- int x = var1 + var2 - (int) f1;
- }
===================================================================
***************
+ #ifndef X1TYPEREFS_H
+ #define X1TYPEREFS_H
+ #include "c1typerefs.h"
+ struct derived : base {
+ int method();
+ };
+ struct vderived : virtual base {
+ };
+ #endif
===================================================================
***************
+ #include "x1struct1.h"
+ type D::method()
+ { static int x = 2;
+ return fld + mbr; }
+ type D::mbr = 4;
+ typedef D D2;
+ D2 var1;
+ D2 var2 = var1;
===================================================================
***************
- struct T { int f; };
- struct T v
- #include "incsame.h"
- struct T w
- #include "incsame.h"
===================================================================
***************
+ #include "c1chained1.h"
+ #include "c1chained2.h"
+ // { dg-error "Preprocessor state inconsistent for PPH" "" { xfail *-*-* } }
+ int x = TWO;
===================================================================
***************
+ #ifndef X1HARDLOOKUP_H
+ #define X1HARDLOOKUP_H
+ struct V { int a; static int b;};
+ namespace N {
+ int V;
+ struct C { };
+ int operator + (int i, C c);
+ C O;
+ int I(int arg)
+ { return arg + V; }
+ struct V w;
+ int x = V::b;
+ }
+
+ int V;
+ struct D { };
+ int operator + (int i, D d);
+ #endif
===================================================================
***************
+ #include "x2overload1.h"
+ #include "x2overload2.h"
+ #include "x2overload3.h"
+ // { dg-error "inconsistent overload resolution" "" { xfail *-*-* } }
+
+ int g()
+ {
+ return f();
+ }
===================================================================
***************
+ #ifndef C1TYPEREFS_H
+ #define C1TYPEREFS_H
+ struct base {
+ int field;
+ };
+ base function();
+ #endif
===================================================================
***************
+ #include "c1variables.h"
+ int gbl_initial = 1;
+ const float gbl_init_const = 1.5;
+ const int gbl_manifest = 2;
===================================================================
***************
- extern int gbl_init_extern; // need body pass
- extern int gbl_uninit_extern; // head only pass
- int gbl_tentative; // need body pass
- int gbl_initial = 1; // need body pass
- extern const int gbl_extern_const; // head only pass
- const float gbl_init_const = 1.5; // need body pass
- const int gbl_manifest = 2; // lazy body merge head pass
- struct D {
- static int mbr_init_plain; // head only pass
- static int mbr_uninit_plain; // head only pass
- static const int mbr_init_const; // head only pass
- static const int mbr_uninit_const; // head only pass
- static const int mbr_manifest = 3; // lazy body merge head okay
- };
- int D::mbr_init_plain = 4; // need body merge body pass
- int D::mbr_uninit_plain; // need body merge body FAIL
- const int D::mbr_init_const = 5; // need body merge body FAIL
===================================================================
***************
- #ifndef __CFLOW_H
- #define __CFLOW_H
-
- extern void foo (void);
-
- #define X 1
- #if defined X
- #include "inif.h"
- extern int var1;
- extern int var2;
- #endif
- #include "inif.h"
- #endif
===================================================================
***************
- #ifndef SIMPLE1_H
- #define SIMPLE1_H
-
- #include "simple2.h"
-
- inline int foo()
- {
- assert(1);
- }
-
- #endif
===================================================================
***************
+ #include "a2builtin4.h"
+ #include "c2builtin5.h"
+ #include "c2builtin6.h"
===================================================================
***************
+ #ifndef C2BUILTIN3_H
+ #define C2BUILTIN3_H
+ #include "c2builtin1.h"
+ const char *refile = VALUE(__FILE__);
+ const char *reline = VALUE(__LINE__);
+ #endif
===================================================================
***************
+ #include "x1functions.h"
+ int type::mbr_decl_then_def(int i) // need body
+ { return mbr_decl_inline( i ); }
+ int type::mbr_inl_then_def(int i) // lazy body
+ { return mbr_decl_then_def( i ); }
===================================================================
***************
+ #ifndef C1MULTINC2
+ #define C1MULTINC2
+ #include "c1altinc1.h"
+ extern void foo (void);
+ extern int var1;
+ extern int var2;
+ #include "c1altinc1.h"
+ #endif
===================================================================
***************
- struct B {
- };
===================================================================
***************
+ #ifndef C2DUPGUARD_H
+ #define C2DUPGUARD_H
+ extern int x;
+ #endif
===================================================================
***************
+ #ifndef C1GUARDED3_H
+ #define C1GUARDED3_H
+ #include "c1guarded1.h"
+ type variable3;
+ #endif
===================================================================
***************
- int H( int a, int b) {
- }
-
- int I( int a, int b) {
- return a+b;
- }
-
- int F( int c, int d) {
- return H(c, d) + I(c, d);
- }
===================================================================
***************
- /* comment */
- #include "simple1.h"
-
- int main()
- {
- return foo();
- }
===================================================================
***************
- #include "invoke.h"
- #define outer(major, minor) inner(major, minor)
-
- void outer(long one, short two) { }
- major(three);
- minor(four);
===================================================================
***************
- # define gnu_dev_major(dev) long dev
- # define gnu_dev_minor(dev) short dev
- # define major(dev) gnu_dev_major (dev)
- # define minor(dev) gnu_dev_minor (dev)
===================================================================
***************
- typedef int type;
- type x = 2;
- type y = x;
- type f() { return x; }
- const type n = 3;
- const type m = 4;
- type a[n+m];
===================================================================
***************
- #ifndef GUARDED3_H
- #define GUARDED3_H
-
- #include "guarded1.h"
-
- type variable3;
-
- #endif
===================================================================
***************
+ #ifndef C1FIELD_H
+ #define C1FIELD_H
+ typedef int language;
+ struct program {
+ language field;
+ };
+ #endif
===================================================================
***************
- struct T { int f; };
- #define NAME v
- #define VALUE 1
- #include "incmod.h"
- #undef NAME
- #define NAME w
- #undef VALUE
- #define VALUE 2
- #include "incmod.h"
===================================================================
***************
+ #ifndef C1ALTINC1_H
+ #define C1ALTINC1_H
+ extern float f1;
+ #endif
===================================================================
***************
+ #include "x1variables.h"
+ int D::mbr_init_plain = 4;
+ int D::mbr_uninit_plain;
+ const int D::mbr_init_const = 5;
===================================================================
***************
+ #include "c1typerefs.h"
+ int base_from_var() {
+ base variable;
+ }
+ int base_from_func() {
+ function();
+ }
===================================================================
***************
- template< typename T >
- struct C {
- int* b;
- int method();
- int another()
- { return 1; }
- };
- template< typename T >
- int C< T >::method()
- { return 1; }
- C<int> v;
===================================================================
*************** pth_file_change (cpp_reader *reader, con
}
! /* Record a #include or #include_next. */
static void
pth_include_handler (cpp_reader *reader ATTRIBUTE_UNUSED,
}
! /* Write PPH output file. */
!
! static void
! write_pph_output (void)
! {
! FILE *stream;
!
! if (flag_pph_debug >= 1)
! fprintf (pph_logfile, "PPH: Writing %s\n", pph_out_file);
!
! stream = fopen (pph_out_file, "w");
! if (!stream)
! fatal_error ("Cannot open PPH file for writing: %s: %m", pph_out_file);
!
! fprintf (stream, "%s\n", pph_out_file);
! fclose (stream);
! }
!
! /* Read PPH file. */
!
! static void
! read_pph_file (const char* filename)
! {
! FILE *stream;
! char *line;
! char *eol;
! char linebuf[2*MAXPATHLEN];
!
! if (flag_pph_debug >= 1)
! fprintf (pph_logfile, "PPH: Reading %s\n", filename);
!
! stream = fopen (filename, "r");
! if (!stream)
! fatal_error ("Cannot open PPH file for reading: %s: %m", filename);
!
! line = fgets (linebuf, sizeof linebuf, stream);
! if (line == NULL)
! fatal_error ("No line in PPH file %s: ", filename);
!
! eol = strchr (line, '\n');
! *eol = '\0';
!
! if (strcmp (filename, line) != 0)
! fatal_error ("Wrong content in PPH file %s: ", filename);
!
! fclose (stream);
! }
!
! /* Record a #include or #include_next for PTH. */
static void
pth_include_handler (cpp_reader *reader ATTRIBUTE_UNUSED,
*************** pth_include_handler (cpp_reader *reader
state->new_iname = name;
}
+ /* Record a #include or #include_next for PPH. */
+
+ static void
+ pph_include_handler (cpp_reader *reader ATTRIBUTE_UNUSED,
+ location_t loc ATTRIBUTE_UNUSED,
+ const unsigned char *dname,
+ const char *name,
+ int angle_brackets,
+ const cpp_token **tok_p ATTRIBUTE_UNUSED)
+ {
+ const char *pph_file;
+
+ if (flag_pph_debug >= 1)
+ {
+ fprintf (pph_logfile, "PPH: #%s", dname);
+ fprintf (pph_logfile, " %c", angle_brackets ? '<' : '"');
+ fprintf (pph_logfile, "%s", name);
+ fprintf (pph_logfile, "%c\n", angle_brackets ? '>' : '"');
+ }
+
+ pph_file = query_pph_include_map (name);
+ if (pph_file != NULL)
+ read_pph_file (pph_file);
+ }
+
/* The initial order of the size of the lexical lookaside table,
which will accomodate as many as half of its slots in use. */
*************** pph_free_catcher_memory (void)
cp_token *
pph_start_exposed (cp_parser *parser)
{
! if (flag_pph_debug >= 1)
{
timevar_push (TV_PPH_MANAGE);
cp_token *
pph_start_exposed (cp_parser *parser)
{
! if (flag_pph_debug >= 2)
{
timevar_push (TV_PPH_MANAGE);
*************** pph_copy_decls_outof_cache (VEC(tree, he
void
pph_stop_exposed (cp_parser *parser, cp_token *first_token)
{
! if (flag_pph_debug >= 1 && !VEC_empty (tree, pph_tree_catcher))
{
cp_token *last_token;
void
pph_stop_exposed (cp_parser *parser, cp_token *first_token)
{
! if (flag_pph_debug >= 2 && !VEC_empty (tree, pph_tree_catcher))
{
cp_token *last_token;
*************** pph_print_stats (void)
void
pph_init (void)
{
+ cpp_callbacks *cb;
+
if (flag_pph_logfile)
{
pph_logfile = fopen (flag_pph_logfile, "w");
*************** pph_init (void)
}
else
pph_logfile = stdout;
+
+ if (flag_pph_debug >= 1)
+ fprintf (pph_logfile, "PPH: Initializing.\n");
+
+ cb = cpp_get_callbacks (parse_in);
+ cb->include = pph_include_handler;
}
*************** pph_init (void)
void
pph_finish (void)
{
+ if (pph_out_file != NULL)
+ write_pph_output ();
+
if (flag_pph_stats)
pph_print_stats ();
===================================================================
*************** cp_lexer_new_main (void)
pth_init (lexer);
cp_lexer_get_tokens (lexer);
}
+ else if (pph_out_file != NULL || query_have_pph_map ())
+ {
+ /* FIXME pph. PPH is incompatible with PCH, so do not read ahead to
+ the first token looking for a PCH pragma. This convoluted
+ initialization could be simplified if PCH was implemented in
+ terms of the incremental compiler. */
+ lexer = cp_lexer_alloc ();
+ pph_init ();
+ cp_lexer_get_tokens (lexer);
+ }
else
{
/* FIXME pph. Get rid of this duplicate and call cp_lexer_get_tokens
*************** c_parse_file (void)
}
already_called = true;
- pph_init ();
the_parser = cp_parser_new ();
push_deferring_access_checks (flag_access_control
? dk_no_deferred : dk_no_check);
===================================================================
*************** GCC_OBJS = gcc.o opts-common.o gcc-optio
# Language-specific object files shared by all C-family front ends.
C_COMMON_OBJS = c-family/c-common.o c-family/c-cppbuiltin.o c-family/c-dump.o \
c-family/c-format.o c-family/c-gimplify.o c-family/c-lex.o \
! c-family/c-omp.o c-family/c-opts.o c-family/c-pch.o \
c-family/c-ppoutput.o c-family/c-pragma.o c-family/c-pretty-print.o \
c-family/c-semantics.o c-family/c-ada-spec.o
# Language-specific object files shared by all C-family front ends.
C_COMMON_OBJS = c-family/c-common.o c-family/c-cppbuiltin.o c-family/c-dump.o \
c-family/c-format.o c-family/c-gimplify.o c-family/c-lex.o \
! c-family/c-omp.o strstrmap.o c-family/c-opts.o c-family/c-pch.o \
c-family/c-ppoutput.o c-family/c-pragma.o c-family/c-pretty-print.o \
c-family/c-semantics.o c-family/c-ada-spec.o
*************** c-family/c-omp.o : c-family/c-omp.c $(CO
c-family/c-opts.o : c-family/c-opts.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TREE_H) $(C_PRAGMA_H) $(FLAGS_H) toplev.h langhooks.h \
! $(DIAGNOSTIC_H) intl.h debug.h $(C_COMMON_H) \
$(OPTS_H) $(OPTIONS_H) $(MKDEPS_H) incpath.h cppdefault.h
$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) \
$< $(OUTPUT_OPTION) @TARGET_SYSTEM_ROOT_DEFINE@
c-family/c-opts.o : c-family/c-opts.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TREE_H) $(C_PRAGMA_H) $(FLAGS_H) toplev.h langhooks.h \
! $(DIAGNOSTIC_H) intl.h debug.h $(C_COMMON_H) strstrmap.h \
$(OPTS_H) $(OPTIONS_H) $(MKDEPS_H) incpath.h cppdefault.h
$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) \
$< $(OUTPUT_OPTION) @TARGET_SYSTEM_ROOT_DEFINE@
*************** s-bversion: BASE-VER
echo "#define BUILDING_GCC_VERSION (BUILDING_GCC_MAJOR * 1000 + BUILDING_GCC_MINOR)" >> bversion.h
$(STAMP) s-bversion
+ strstrmap.o: strstrmap.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
+ $(srcdir)/../include/libiberty.h $(srcdir)/../include/hashtab.h \
+ strstrmap.h
+
input.o : input.c $(CONFIG_H) $(SYSTEM_H) coretypes.h intl.h $(INPUT_H)
toplev.o : toplev.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \