summaryrefslogtreecommitdiffstats
path: root/contrib/gcclibs
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2013-12-15 03:47:31 +0000
committerpfg <pfg@FreeBSD.org>2013-12-15 03:47:31 +0000
commit81b52978780f8e031af44e70e553b7b8c7146659 (patch)
treeac6cf6b38fa03b3fe833b7fed287d281e90a822e /contrib/gcclibs
parent452ca0b4a4cc660ea49c3719436eebd4fe78b787 (diff)
downloadFreeBSD-src-81b52978780f8e031af44e70e553b7b8c7146659.zip
FreeBSD-src-81b52978780f8e031af44e70e553b7b8c7146659.tar.gz
MFC rr258501, r258507;
gcc: Bring updates from Google's enhanced gcc-4.2.1. Google released and enhanced version of gcc-4.2.1 plus their local patches for Android[1]. The patches are owned by Google and the license hasn't been changed from the original GPLv2. We are only bringing a subset of the available patches that may be helpful in FreeBSD, in other words, changes specific to android are not included. From the README.google file[1]. Patches applied to google_vendor_src_branch/gcc/gcc-4.2.1: gcc/Makefile.in gcc/c-common.c gcc/c-common.h gcc/c-opts.c gcc/c-typeck.c gcc/cp/typeck.c gcc/doc/invoke.texi gcc/flags.h gcc/opts.c gcc/tree-flow.h gcc/tree-ssa-alias-warnings.c gcc/tree-ssa-alias.c Backport of -Wstrict-aliasing from mainline. Silvius Rus <rus@google.com> gcc/coverage.c: Patch coverage_checksum_string for PR 25351. Seongbae Park <spark@google.com> Not yet submitted to FSF. gcc/c-opts.c gcc/c-ppoutput.c gcc/c.opt gcc/doc/cppopts.texi libcpp/Makefile.in libcpp/directives-only.c libcpp/directives.c libcpp/files.c libcpp/include/cpplib.h libcpp/init.c libcpp/internal.h libcpp/macro.c Support for -fdirectives-only. Ollie Wild <aaw@google.com>. Submitted to FSF but not yet approved. libstdc++-v3/include/ext/hashtable.h http://b/742065 http://b/629994 Reduce min size of hashtable for hash_map, hash_set from 53 to 5 libstdc++-v3/include/ext/hashtable.h http://b/629994 Do not iterate over buckets if hashtable is empty. gcc/common.opt gcc/doc/invoke.texi gcc/flags.h gcc/gimplify.c gcc/opts.c Add Saito's patch for -finstrument-functions-exclude-* options. gcc/common.opt gcc/doc/invoke.texi gcc/final.c gcc/flags.h gcc/opts.c gcc/testsuite/gcc.dg/Wframe-larger-than.c Add a new flag -Wframe-larger-than- which enables a new warning when a frame size of a function is larger than specified. This patch hasn't been integrated into gcc mainline yet. gcc/tree-vrp.c Add a hack to avoid using ivopts information for pointers starting at constant values. Reference: [1] https://android.googlesource.com/toolchain/gcc/+/master/gcc-4.2.1/ Obtained from: Google Inc.
Diffstat (limited to 'contrib/gcclibs')
-rw-r--r--contrib/gcclibs/libcpp/Makefile.in12
-rw-r--r--contrib/gcclibs/libcpp/directives-only.c229
-rw-r--r--contrib/gcclibs/libcpp/directives.c7
-rw-r--r--contrib/gcclibs/libcpp/files.c3
-rw-r--r--contrib/gcclibs/libcpp/include/cpplib.h7
-rw-r--r--contrib/gcclibs/libcpp/init.c27
-rw-r--r--contrib/gcclibs/libcpp/internal.h11
-rw-r--r--contrib/gcclibs/libcpp/macro.c3
8 files changed, 282 insertions, 17 deletions
diff --git a/contrib/gcclibs/libcpp/Makefile.in b/contrib/gcclibs/libcpp/Makefile.in
index 7a0b74f..697318d 100644
--- a/contrib/gcclibs/libcpp/Makefile.in
+++ b/contrib/gcclibs/libcpp/Makefile.in
@@ -69,14 +69,14 @@ INCLUDES = -I$(srcdir) -I. -I$(srcdir)/../include @INCINTL@ \
ALL_CFLAGS = $(CFLAGS) $(WARN_CFLAGS) $(INCLUDES) $(CPPFLAGS)
-libcpp_a_OBJS = charset.o directives.o errors.o expr.o files.o \
- identifiers.o init.o lex.o line-map.o macro.o mkdeps.o \
- pch.o symtab.o traditional.o
+libcpp_a_OBJS = charset.o directives.o directives-only.o errors.o \
+ expr.o files.o identifiers.o init.o lex.o line-map.o macro.o \
+ mkdeps.o pch.o symtab.o traditional.o
makedepend_OBJS = makedepend.o
-libcpp_a_SOURCES = charset.c directives.c errors.c expr.c files.c \
- identifiers.c init.c lex.c line-map.c macro.c mkdeps.c \
- pch.c symtab.c traditional.c
+libcpp_a_SOURCES = charset.c directives.c directives-only.c errors.c \
+ expr.c files.c identifiers.c init.c lex.c line-map.c macro.c \
+ mkdeps.c pch.c symtab.c traditional.c
all: libcpp.a makedepend$(EXEEXT) $(USED_CATALOGS)
diff --git a/contrib/gcclibs/libcpp/directives-only.c b/contrib/gcclibs/libcpp/directives-only.c
new file mode 100644
index 0000000..5990fbf
--- /dev/null
+++ b/contrib/gcclibs/libcpp/directives-only.c
@@ -0,0 +1,229 @@
+/* CPP Library - directive only preprocessing for distributed compilation.
+ Copyright (C) 2007
+ Free Software Foundation, Inc.
+ Contributed by Ollie Wild <aaw@google.com>.
+
+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 2, 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 this program; if not, write to the Free Software
+Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#include "config.h"
+#include "system.h"
+#include "cpplib.h"
+#include "internal.h"
+
+/* DO (Directive only) flags. */
+#define DO_BOL (1 << 0) /* At the beginning of a logical line. */
+#define DO_STRING (1 << 1) /* In a string constant. */
+#define DO_CHAR (1 << 2) /* In a character constant. */
+#define DO_BLOCK_COMMENT (1 << 3) /* In a block comment. */
+#define DO_LINE_COMMENT (1 << 4) /* In a single line "//-style" comment. */
+
+#define DO_LINE_SPECIAL (DO_STRING | DO_CHAR | DO_LINE_COMMENT)
+#define DO_SPECIAL (DO_LINE_SPECIAL | DO_BLOCK_COMMENT)
+
+/* Writes out the preprocessed file, handling spacing and paste
+ avoidance issues. */
+void
+_cpp_preprocess_dir_only (cpp_reader *pfile,
+ const struct _cpp_dir_only_callbacks *cb)
+{
+ struct cpp_buffer *buffer;
+ const unsigned char *cur, *base, *next_line, *rlimit;
+ cppchar_t c, last_c;
+ unsigned flags;
+ int lines, col;
+ source_location loc;
+
+ restart:
+ /* Buffer initialization ala _cpp_clean_line(). */
+ buffer = pfile->buffer;
+ buffer->cur_note = buffer->notes_used = 0;
+ buffer->cur = buffer->line_base = buffer->next_line;
+ buffer->need_line = false;
+
+ /* This isn't really needed. It prevents a compiler warning, though. */
+ loc = pfile->line_table->highest_line;
+
+ /* Scan initialization. */
+ next_line = cur = base = buffer->cur;
+ rlimit = buffer->rlimit;
+ flags = DO_BOL;
+ lines = 0;
+ col = 1;
+
+ for (last_c = '\n', c = *cur; cur < rlimit; last_c = c, c = *++cur, ++col)
+ {
+ /* Skip over escaped newlines. */
+ if (__builtin_expect (c == '\\', false))
+ {
+ const unsigned char *tmp = cur + 1;
+
+ while (is_nvspace (*tmp) && tmp < rlimit)
+ tmp++;
+ if (*tmp == '\r')
+ tmp++;
+ if (*tmp == '\n' && tmp < rlimit)
+ {
+ CPP_INCREMENT_LINE (pfile, 0);
+ lines++;
+ col = 0;
+ cur = tmp;
+ c = last_c;
+ continue;
+ }
+ }
+
+ if (__builtin_expect (last_c == '#', false) && !(flags & DO_SPECIAL))
+ {
+ if (c != '#' && (flags & DO_BOL))
+ {
+ struct line_maps *line_table;
+
+ if (!pfile->state.skipping && next_line != base)
+ cb->print_lines (lines, base, next_line - base);
+
+ /* Prep things for directive handling. */
+ buffer->next_line = cur;
+ buffer->need_line = true;
+ _cpp_get_fresh_line (pfile);
+
+ /* Ensure proper column numbering for generated error messages. */
+ buffer->line_base -= col - 1;
+
+ _cpp_handle_directive (pfile, 0 /* ignore indented */);
+
+ /* Sanitize the line settings. Duplicate #include's can mess
+ things up. */
+ line_table = pfile->line_table;
+ line_table->highest_location = line_table->highest_line;
+
+ /* The if block prevents us from outputing line information when
+ the file ends with a directive and no newline. Note that we
+ must use pfile->buffer, not buffer. */
+ if (pfile->buffer->cur != pfile->buffer->rlimit)
+ cb->maybe_print_line (pfile->line_table->highest_line);
+
+ goto restart;
+ }
+
+ flags &= ~DO_BOL;
+ pfile->mi_valid = false;
+ }
+ else if (__builtin_expect (last_c == '/', false) \
+ && !(flags & DO_SPECIAL) && c != '*' && c != '/')
+ {
+ /* If a previous slash is not starting a block comment, clear the
+ DO_BOL flag. */
+ flags &= ~DO_BOL;
+ pfile->mi_valid = false;
+ }
+
+ switch (c)
+ {
+ case '/':
+ if ((flags & DO_BLOCK_COMMENT) && last_c == '*')
+ {
+ flags &= ~DO_BLOCK_COMMENT;
+ c = 0;
+ }
+ else if (!(flags & DO_SPECIAL) && last_c == '/')
+ flags |= DO_LINE_COMMENT;
+ else if (!(flags & DO_SPECIAL))
+ /* Mark the position for possible error reporting. */
+ LINEMAP_POSITION_FOR_COLUMN (loc, pfile->line_table, col);
+
+ break;
+
+ case '*':
+ if (!(flags & DO_SPECIAL))
+ {
+ if (last_c == '/')
+ flags |= DO_BLOCK_COMMENT;
+ else
+ {
+ flags &= ~DO_BOL;
+ pfile->mi_valid = false;
+ }
+ }
+
+ break;
+
+ case '\'':
+ case '"':
+ {
+ unsigned state = (c == '"') ? DO_STRING : DO_CHAR;
+
+ if (!(flags & DO_SPECIAL))
+ {
+ flags |= state;
+ flags &= ~DO_BOL;
+ pfile->mi_valid = false;
+ }
+ else if ((flags & state) && last_c != '\\')
+ flags &= ~state;
+
+ break;
+ }
+
+ case '\\':
+ {
+ if ((flags & (DO_STRING | DO_CHAR)) && last_c == '\\')
+ c = 0;
+
+ if (!(flags & DO_SPECIAL))
+ {
+ flags &= ~DO_BOL;
+ pfile->mi_valid = false;
+ }
+
+ break;
+ }
+
+ case '\n':
+ CPP_INCREMENT_LINE (pfile, 0);
+ lines++;
+ col = 0;
+ flags &= ~DO_LINE_SPECIAL;
+ if (!(flags & DO_SPECIAL))
+ flags |= DO_BOL;
+ break;
+
+ case '#':
+ next_line = cur;
+ /* Don't update DO_BOL yet. */
+ break;
+
+ case ' ': case '\t': case '\f': case '\v': case '\0':
+ break;
+
+ default:
+ if (!(flags & DO_SPECIAL))
+ {
+ flags &= ~DO_BOL;
+ pfile->mi_valid = false;
+ }
+ break;
+ }
+ }
+
+ if (flags & DO_BLOCK_COMMENT)
+ cpp_error_with_line (pfile, CPP_DL_ERROR, loc, 0, "unterminated comment");
+
+ if (!pfile->state.skipping && cur != base)
+ cb->print_lines (lines, base, cur - base);
+
+ _cpp_pop_buffer (pfile);
+ if (pfile->buffer)
+ goto restart;
+}
diff --git a/contrib/gcclibs/libcpp/directives.c b/contrib/gcclibs/libcpp/directives.c
index 7fb142e..7011842 100644
--- a/contrib/gcclibs/libcpp/directives.c
+++ b/contrib/gcclibs/libcpp/directives.c
@@ -423,8 +423,13 @@ _cpp_handle_directive (cpp_reader *pfile, int indented)
does not cause '#define foo bar' to get executed when
compiled with -save-temps, we recognize directives in
-fpreprocessed mode only if the # is in column 1. macro.c
- puts a space in front of any '#' at the start of a macro. */
+ puts a space in front of any '#' at the start of a macro.
+
+ We exclude the -fdirectives-only case because macro expansion
+ has not been performed yet, and block comments can cause spaces
+ to preceed the directive. */
if (CPP_OPTION (pfile, preprocessed)
+ && !CPP_OPTION (pfile, directives_only)
&& (indented || !(dir->flags & IN_I)))
{
skip = 0;
diff --git a/contrib/gcclibs/libcpp/files.c b/contrib/gcclibs/libcpp/files.c
index 3751184d..0e9f977 100644
--- a/contrib/gcclibs/libcpp/files.c
+++ b/contrib/gcclibs/libcpp/files.c
@@ -775,7 +775,8 @@ _cpp_stack_file (cpp_reader *pfile, _cpp_file *file, bool import)
/* Stack the buffer. */
buffer = cpp_push_buffer (pfile, file->buffer, file->st.st_size,
- CPP_OPTION (pfile, preprocessed));
+ CPP_OPTION (pfile, preprocessed)
+ && !CPP_OPTION (pfile, directives_only));
buffer->file = file;
buffer->sysp = sysp;
diff --git a/contrib/gcclibs/libcpp/include/cpplib.h b/contrib/gcclibs/libcpp/include/cpplib.h
index 7fd73b8..5acef41 100644
--- a/contrib/gcclibs/libcpp/include/cpplib.h
+++ b/contrib/gcclibs/libcpp/include/cpplib.h
@@ -440,6 +440,9 @@ struct cpp_options
/* True means error callback should be used for diagnostics. */
bool client_diagnostic;
+
+ /* True disables tokenization outside of preprocessing directives. */
+ bool directives_only;
};
/* Callback for header lookup for HEADER, which is the name of a
@@ -644,6 +647,10 @@ extern struct deps *cpp_get_deps (cpp_reader *);
too. If there was an error opening the file, it returns NULL. */
extern const char *cpp_read_main_file (cpp_reader *, const char *);
+/* Set up built-ins with special behavior. Use cpp_init_builtins()
+ instead unless your know what you are doing. */
+extern void cpp_init_special_builtins (cpp_reader *);
+
/* Set up built-ins like __FILE__. */
extern void cpp_init_builtins (cpp_reader *, int);
diff --git a/contrib/gcclibs/libcpp/init.c b/contrib/gcclibs/libcpp/init.c
index 8280f2f..248d84f 100644
--- a/contrib/gcclibs/libcpp/init.c
+++ b/contrib/gcclibs/libcpp/init.c
@@ -348,11 +348,8 @@ mark_named_operators (cpp_reader *pfile)
}
}
-/* Read the builtins table above and enter them, and language-specific
- macros, into the hash table. HOSTED is true if this is a hosted
- environment. */
void
-cpp_init_builtins (cpp_reader *pfile, int hosted)
+cpp_init_special_builtins (cpp_reader *pfile)
{
const struct builtin *b;
size_t n = ARRAY_SIZE (builtin_array);
@@ -361,10 +358,7 @@ cpp_init_builtins (cpp_reader *pfile, int hosted)
n -= 2;
else if (! CPP_OPTION (pfile, stdc_0_in_system_headers)
|| CPP_OPTION (pfile, std))
- {
- n--;
- _cpp_define_builtin (pfile, "__STDC__ 1");
- }
+ n--;
for (b = builtin_array; b < builtin_array + n; b++)
{
@@ -373,6 +367,20 @@ cpp_init_builtins (cpp_reader *pfile, int hosted)
hp->flags |= NODE_BUILTIN | NODE_WARN;
hp->value.builtin = (enum builtin_type) b->value;
}
+}
+
+/* Read the builtins table above and enter them, and language-specific
+ macros, into the hash table. HOSTED is true if this is a hosted
+ environment. */
+void
+cpp_init_builtins (cpp_reader *pfile, int hosted)
+{
+ cpp_init_special_builtins (pfile);
+
+ if (!CPP_OPTION (pfile, traditional)
+ && (! CPP_OPTION (pfile, stdc_0_in_system_headers)
+ || CPP_OPTION (pfile, std)))
+ _cpp_define_builtin (pfile, "__STDC__ 1");
if (CPP_OPTION (pfile, cplusplus))
_cpp_define_builtin (pfile, "__cplusplus 1");
@@ -620,7 +628,8 @@ post_options (cpp_reader *pfile)
preprocessed text. Read preprocesed source in ISO mode. */
if (CPP_OPTION (pfile, preprocessed))
{
- pfile->state.prevent_expansion = 1;
+ if (!CPP_OPTION (pfile, directives_only))
+ pfile->state.prevent_expansion = 1;
CPP_OPTION (pfile, traditional) = 0;
}
diff --git a/contrib/gcclibs/libcpp/internal.h b/contrib/gcclibs/libcpp/internal.h
index 1661f7a..ebc2ca9 100644
--- a/contrib/gcclibs/libcpp/internal.h
+++ b/contrib/gcclibs/libcpp/internal.h
@@ -567,6 +567,17 @@ extern void _cpp_do_file_change (cpp_reader *, enum lc_reason, const char *,
unsigned int, unsigned int);
extern void _cpp_pop_buffer (cpp_reader *);
+/* In directives.c */
+struct _cpp_dir_only_callbacks
+{
+ /* Called to print a block of lines. */
+ void (*print_lines) (int, const void *, size_t);
+ void (*maybe_print_line) (source_location);
+};
+
+extern void _cpp_preprocess_dir_only (cpp_reader *,
+ const struct _cpp_dir_only_callbacks *);
+
/* In traditional.c. */
extern bool _cpp_scan_out_logical_line (cpp_reader *, cpp_macro *);
extern bool _cpp_read_logical_line_trad (cpp_reader *);
diff --git a/contrib/gcclibs/libcpp/macro.c b/contrib/gcclibs/libcpp/macro.c
index 1eec578..d294f04 100644
--- a/contrib/gcclibs/libcpp/macro.c
+++ b/contrib/gcclibs/libcpp/macro.c
@@ -264,6 +264,9 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node)
break;
case BT_COUNTER:
+ if (CPP_OPTION (pfile, directives_only) && pfile->state.in_directive)
+ cpp_error (pfile, CPP_DL_ERROR,
+ "__COUNTER__ expanded inside directive with -fdirectives-only");
number = pfile->nextcounter++;
break;
}
OpenPOWER on IntegriCloud