From: Georg-Johann Lay Date: Wed, 20 Jul 2016 13:07:43 +0000 (+0000) Subject: target.def (addr_space): Add new diagnose_usage to hook vector. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ffc2284012c94620bdbffb5276a264bd7fcf7d91;p=gcc.git target.def (addr_space): Add new diagnose_usage to hook vector. gcc/ * target.def (addr_space): Add new diagnose_usage to hook vector. * targhooks.c (default_addr_space_diagnose_usage): Add default implementation and... * targhooks.h (default_addr_space_diagnose_usage): ... its prototype. * c/c-parser.c (c_lex_one_token) [CPP_NAME]: If the token is some address space, call targetm.addr_space.diagnose_usage. * doc/tm.texi.in (Named Address Spaces): Add anchor for TARGET_ADDR_SPACE_DIAGNOSE_USAGE documentation. * doc/tm.texi: Regenerate. From-SVN: r238514 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 32e90ce66cd..8cafd56b5b2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2016-07-20 Georg-Johann Lay + + * target.def (addr_space): Add new diagnose_usage to hook vector. + * targhooks.c (default_addr_space_diagnose_usage): Add default + implementation and... + * targhooks.h (default_addr_space_diagnose_usage): ... its prototype. + * c/c-parser.c (c_lex_one_token) [CPP_NAME]: If the token + is some address space, call targetm.addr_space.diagnose_usage. + * doc/tm.texi.in (Named Address Spaces): Add anchor for + TARGET_ADDR_SPACE_DIAGNOSE_USAGE documentation. + * doc/tm.texi: Regenerate. + 2016-07-20 Martin Liska PR middle-end/71898 diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index ef585fb9990..45e32ba49d4 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -301,6 +301,9 @@ c_lex_one_token (c_parser *parser, c_token *token) else if (rid_code >= RID_FIRST_ADDR_SPACE && rid_code <= RID_LAST_ADDR_SPACE) { + addr_space_t as; + as = (addr_space_t) (rid_code - RID_FIRST_ADDR_SPACE); + targetm.addr_space.diagnose_usage (as, token->location); token->id_kind = C_ID_ADDRSPACE; token->keyword = rid_code; break; diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index b318615b7b3..160ced1d284 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -10431,6 +10431,17 @@ Define this to define how the address space is encoded in dwarf. The result is the value to be used with @code{DW_AT_address_class}. @end deftypefn +@deftypefn {Target Hook} void TARGET_ADDR_SPACE_DIAGNOSE_USAGE (addr_space_t @var{as}, location_t @var{loc}) +Define this hook if the availability of an address space depends on +command line options and some diagnostics should be printed when the +address space is used. This hook is called during parsing and allows +to emit a better diagnostic compared to the case where the address space +was not registered with @code{c_register_addr_space}. @var{as} is +the address space as registered with @code{c_register_addr_space}. +@var{loc} is the location of the address space qualifier token. +The default implementation does nothing. +@end deftypefn + @node Misc @section Miscellaneous Parameters @cindex parameters, miscellaneous diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 1e8423cb4e2..6a114961e27 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -7486,6 +7486,8 @@ c_register_addr_space ("__ea", ADDR_SPACE_EA); @hook TARGET_ADDR_SPACE_DEBUG +@hook TARGET_ADDR_SPACE_DIAGNOSE_USAGE + @node Misc @section Miscellaneous Parameters @cindex parameters, miscellaneous diff --git a/gcc/target.def b/gcc/target.def index a4df363698c..4a849227de4 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -3241,6 +3241,20 @@ The result is the value to be used with @code{DW_AT_address_class}.", int, (addr_space_t as), default_addr_space_debug) +/* Function to emit custom diagnostic if an address space is used. */ +DEFHOOK +(diagnose_usage, + "Define this hook if the availability of an address space depends on\n\ +command line options and some diagnostics should be printed when the\n\ +address space is used. This hook is called during parsing and allows\n\ +to emit a better diagnostic compared to the case where the address space\n\ +was not registered with @code{c_register_addr_space}. @var{as} is\n\ +the address space as registered with @code{c_register_addr_space}.\n\ +@var{loc} is the location of the address space qualifier token.\n\ +The default implementation does nothing.", + void, (addr_space_t as, location_t loc), + default_addr_space_diagnose_usage) + HOOK_VECTOR_END (addr_space) #undef HOOK_PREFIX diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 3e089e759ce..65055b4b443 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -1291,6 +1291,15 @@ default_addr_space_debug (addr_space_t as) return as; } +/* The default hook implementation for TARGET_ADDR_SPACE_DIAGNOSE_USAGE. + Don't complain about any address space. */ + +void +default_addr_space_diagnose_usage (addr_space_t, location_t) +{ +} + + /* The default hook for TARGET_ADDR_SPACE_CONVERT. This hook should never be called for targets with only a generic address space. */ diff --git a/gcc/targhooks.h b/gcc/targhooks.h index d6581cfab89..bcec7a3027e 100644 --- a/gcc/targhooks.h +++ b/gcc/targhooks.h @@ -181,6 +181,7 @@ extern rtx default_addr_space_legitimize_address (rtx, rtx, machine_mode, extern bool default_addr_space_subset_p (addr_space_t, addr_space_t); extern bool default_addr_space_zero_address_valid (addr_space_t); extern int default_addr_space_debug (addr_space_t); +extern void default_addr_space_diagnose_usage (addr_space_t, location_t); extern rtx default_addr_space_convert (rtx, tree, tree); extern unsigned int default_case_values_threshold (void); extern bool default_have_conditional_execution (void);