summaryrefslogtreecommitdiff
path: root/libcpp/traditional.c
diff options
context:
space:
mode:
authoremsr <emsr@138bc75d-0d04-0410-961f-82ee72b054a4>2014-10-01 11:49:23 +0000
committeremsr <emsr@138bc75d-0d04-0410-961f-82ee72b054a4>2014-10-01 11:49:23 +0000
commitf6751ff23dad167a2c05930363ec640ed2b0a3a3 (patch)
tree0305f88949de10054e322e52911e9a53306c454d /libcpp/traditional.c
parent61bcd046b7d40b28fc3e140b32d29f170581737d (diff)
downloadgcc-f6751ff23dad167a2c05930363ec640ed2b0a3a3.tar.gz
2014-10-01 Edward Smith-Rowland <3dw4rd@verizon.net>
Implement SD-6: SG10 Feature Test Recommendations * internal.h (lexer_state, spec_nodes): Add in__has_include__. * directives.c: Support __has_include__ builtin. * expr.c (parse_has_include): New function to parse __has_include__ builtin; (eval_token()): Use it. * files.c (_cpp_has_header()): New funtion to look for header; (open_file_failed()): Not an error to not find a header file for __has_include__. * identifiers.c (_cpp_init_hashtable()): Add entry for __has_include__. * pch.c (cpp_read_state): Lookup __has_include__. * traditional.c (enum ls, _cpp_scan_out_logical_line()): Walk through __has_include__ statements. 2014-10-01 Edward Smith-Rowland <3dw4rd@verizon.net> Implement SD-6: SG10 Feature Test Recommendations * c-cppbuiltin.c (c_cpp_builtins()): Define language feature macros and the __has_header macro. 2014-10-01 Edward Smith-Rowland <3dw4rd@verizon.net> Implement SD-6: SG10 Feature Test Recommendations * include/bits/basic_string.h: Add __cpp_lib feature test macro. * include/bits/stl_algobase.h: Ditto. * include/bits/stl_function.h: Ditto. * include/bits/unique_ptr.h: Ditto. * include/std/chrono: Ditto. * include/std/complex: Ditto. * include/std/iomanip: Ditto. * include/std/shared_mutex: Ditto. * include/std/tuple: Ditto. * include/std/type_traits: Ditto. * include/std/utility: Ditto. * testsuite/experimental/feat-cxx14.cc: New. * testsuite/experimental/feat-lib-fund.cc: New. * testsuite/20_util/declval/requirements/1_neg.cc: Adjust. * testsuite/20_util/duration/literals/range.cc: Adjust. * testsuite/20_util/duration/requirements/typedefs_neg1.cc: Adjust. * testsuite/20_util/duration/requirements/typedefs_neg2.cc: Adjust. * testsuite/20_util/duration/requirements/typedefs_neg3.cc: Adjust. * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust. * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Adjust. * testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust. * testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc: Adjust. 2014-10-01 Edward Smith-Rowland <3dw4rd@verizon.net> Implement SD-6: SG10 Feature Test Recommendations * g++.dg/cpp1y/feat-cxx11-neg.C: New. * g++.dg/cpp1y/feat-cxx11.C: New. * g++.dg/cpp1y/feat-cxx14.C: New. * g++.dg/cpp1y/feat-cxx98.C: New. * g++.dg/cpp1y/feat-cxx98-neg.C: New. * g++.dg/cpp1y/phoobhar.h: New. * g++.dg/cpp1y/testinc/phoobhar.h: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@215752 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp/traditional.c')
-rw-r--r--libcpp/traditional.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/libcpp/traditional.c b/libcpp/traditional.c
index b770db7aba5..dfb53787a04 100644
--- a/libcpp/traditional.c
+++ b/libcpp/traditional.c
@@ -74,7 +74,9 @@ enum ls {ls_none = 0, /* Normal state. */
ls_defined_close, /* Looking for ')' of defined(). */
ls_hash, /* After # in preprocessor conditional. */
ls_predicate, /* After the predicate, maybe paren? */
- ls_answer}; /* In answer to predicate. */
+ ls_answer, /* In answer to predicate. */
+ ls_has_include, /* After __has_include__. */
+ ls_has_include_close}; /* Looking for ')' of __has_include__. */
/* Lexing TODO: Maybe handle space in escaped newlines. Stop lex.c
from recognizing comments and directives during its lexing pass. */
@@ -524,6 +526,13 @@ _cpp_scan_out_logical_line (cpp_reader *pfile, cpp_macro *macro)
lex_state = ls_defined;
continue;
}
+ else if (pfile->state.in_expression
+ && (node == pfile->spec_nodes.n__has_include__
+ || node == pfile->spec_nodes.n__has_include_next__))
+ {
+ lex_state = ls_has_include;
+ continue;
+ }
}
break;
@@ -547,6 +556,8 @@ _cpp_scan_out_logical_line (cpp_reader *pfile, cpp_macro *macro)
lex_state = ls_answer;
else if (lex_state == ls_defined)
lex_state = ls_defined_close;
+ else if (lex_state == ls_has_include)
+ lex_state = ls_has_include_close;
}
break;
@@ -584,7 +595,8 @@ _cpp_scan_out_logical_line (cpp_reader *pfile, cpp_macro *macro)
goto new_context;
}
}
- else if (lex_state == ls_answer || lex_state == ls_defined_close)
+ else if (lex_state == ls_answer || lex_state == ls_defined_close
+ || lex_state == ls_has_include_close)
lex_state = ls_none;
}
break;
@@ -665,7 +677,8 @@ _cpp_scan_out_logical_line (cpp_reader *pfile, cpp_macro *macro)
lex_state = ls_none;
else if (lex_state == ls_hash
|| lex_state == ls_predicate
- || lex_state == ls_defined)
+ || lex_state == ls_defined
+ || lex_state == ls_has_include)
lex_state = ls_none;
/* ls_answer and ls_defined_close keep going until ')'. */