cpplib.h (cpp_callbacks): Add has_attribute.
libcpp: 2014-11-10 Edward Smith-Rowland <3dw4rd@verizon.net> * include/cpplib.h (cpp_callbacks): Add has_attribute. * internal.h (lexer_state): Add in__has_attribute__. * directives.c (lex_macro_node): Prevent use of __has_attribute__ as a macro. * expr.c (parse_has_attribute): New function; (eval_token): Look for __has_attribute__ and route to parse_has_attribute. * identifiers.c (_cpp_init_hashtable): Initialize n__has_attribute__. * pch.c (cpp_read_state): Initialize n__has_attribute__. * traditional.c (enum ls): Add ls_has_attribute, ls_has_attribute_close; (_cpp_scan_out_logical_line): Attend to __has_attribute__. gcc/c-family: 2014-11-10 Edward Smith-Rowland <3dw4rd@verizon.net> * c-cppbuiltin.c (__has_attribute, __has_cpp_attribute): New macros; (__cpp_rtti, __cpp_exceptions): New macros for C++98; (__cpp_range_based_for, __cpp_initializer_lists, __cpp_delegating_constructors, __cpp_nsdmi, __cpp_inheriting_constructors, __cpp_ref_qualifiers): New macros for C++11; (__cpp_attribute_deprecated): Remove in favor of __has_cpp_attribute. * c-lex.c (cb_has_attribute): New callback CPP function; (init_c_lex): Set has_attribute callback. gcc/testsuite: 2014-11-10 Edward Smith-Rowland <3dw4rd@verizon.net> * g++.dg/cpp1y/feat-cxx11.C: Test new feature macros for C++98 and C++11; Test existence of __has_cpp_attribute; Test C++11 attributes. * g++.dg/cpp1y/feat-cxx11-neg.C: Ditto. * g++.dg/cpp1y/feat-cxx14.C: Ditto and test for C++14 attributes. * g++.dg/cpp1y/feat-cxx98.C: Test new feature macros for C++98. * g++.dg/cpp1y/feat-cxx98-neg.C: Ditto. * g++.dg/cpp1y/feat-neg.C: Test that __cpp_rtti, _cpp_exceptions will be undefined for -fno-rtti -fno-exceptions. From-SVN: r217292
This commit is contained in:
parent
6d64f20c8d
commit
42fd12b1e7
18 changed files with 424 additions and 23 deletions
|
@ -65,6 +65,7 @@ static unsigned int interpret_int_suffix (cpp_reader *, const uchar *, size_t);
|
|||
static void check_promotion (cpp_reader *, const struct op *);
|
||||
|
||||
static cpp_num parse_has_include (cpp_reader *, enum include_type);
|
||||
static cpp_num parse_has_attribute (cpp_reader *);
|
||||
|
||||
/* Token type abuse to create unary plus and minus operators. */
|
||||
#define CPP_UPLUS ((enum cpp_ttype) (CPP_LAST_CPP_OP + 1))
|
||||
|
@ -1054,6 +1055,8 @@ eval_token (cpp_reader *pfile, const cpp_token *token,
|
|||
return parse_has_include (pfile, IT_INCLUDE);
|
||||
else if (token->val.node.node == pfile->spec_nodes.n__has_include_next__)
|
||||
return parse_has_include (pfile, IT_INCLUDE_NEXT);
|
||||
else if (token->val.node.node == pfile->spec_nodes.n__has_attribute__)
|
||||
return parse_has_attribute (pfile);
|
||||
else if (CPP_OPTION (pfile, cplusplus)
|
||||
&& (token->val.node.node == pfile->spec_nodes.n_true
|
||||
|| token->val.node.node == pfile->spec_nodes.n_false))
|
||||
|
@ -2147,3 +2150,21 @@ parse_has_include (cpp_reader *pfile, enum include_type type)
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Handle meeting "__has_attribute__" in a preprocessor expression. */
|
||||
static cpp_num
|
||||
parse_has_attribute (cpp_reader *pfile)
|
||||
{
|
||||
pfile->state.in__has_attribute__++;
|
||||
|
||||
cpp_num result;
|
||||
result.unsignedp = false;
|
||||
result.high = 0;
|
||||
result.overflow = false;
|
||||
|
||||
result.low = pfile->cb.has_attribute (pfile);
|
||||
|
||||
pfile->state.in__has_attribute__--;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue