00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "config.h"
00026 #include "system.h"
00027 #include "tree.h"
00028 #include "toplev.h"
00029 #include "cpplib.h"
00030 #include "c-pragma.h"
00031 #include "c-lex.h"
00032 #include "c4x-protos.h"
00033
00034 static int c4x_parse_pragma PARAMS ((const char *, tree *, tree *));
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 #define BAD(msgid, arg) do { warning (msgid, arg); return -1; } while (0)
00060
00061 static int
00062 c4x_parse_pragma (name, func, sect)
00063 const char *name;
00064 tree *func;
00065 tree *sect;
00066 {
00067 tree f, s, x;
00068
00069 if (c_lex (&x) != CPP_OPEN_PAREN)
00070 BAD ("missing '(' after '#pragma %s' - ignored", name);
00071
00072 if (c_lex (&f) != CPP_NAME)
00073 BAD ("missing function name in '#pragma %s' - ignored", name);
00074
00075 if (sect)
00076 {
00077 if (c_lex (&x) != CPP_COMMA)
00078 BAD ("malformed '#pragma %s' - ignored", name);
00079 if (c_lex (&s) != CPP_STRING)
00080 BAD ("missing section name in '#pragma %s' - ignored", name);
00081 *sect = s;
00082 }
00083
00084 if (c_lex (&x) != CPP_CLOSE_PAREN)
00085 BAD ("missing ')' for '#pragma %s' - ignored", name);
00086
00087 if (c_lex (&x) != CPP_EOF)
00088 warning ("junk at end of '#pragma %s'", name);
00089
00090 *func = f;
00091 return 0;
00092 }
00093
00094 void
00095 c4x_pr_CODE_SECTION (pfile)
00096 cpp_reader *pfile ATTRIBUTE_UNUSED;
00097 {
00098 tree func, sect;
00099
00100 if (c4x_parse_pragma ("CODE_SECTION", &func, §))
00101 return;
00102 code_tree = chainon (code_tree,
00103 build_tree_list (func,
00104 build_tree_list (NULL_TREE, sect)));
00105 }
00106
00107 void
00108 c4x_pr_DATA_SECTION (pfile)
00109 cpp_reader *pfile ATTRIBUTE_UNUSED;
00110 {
00111 tree func, sect;
00112
00113 if (c4x_parse_pragma ("DATA_SECTION", &func, §))
00114 return;
00115 data_tree = chainon (data_tree,
00116 build_tree_list (func,
00117 build_tree_list (NULL_TREE, sect)));
00118 }
00119
00120 void
00121 c4x_pr_FUNC_IS_PURE (pfile)
00122 cpp_reader *pfile ATTRIBUTE_UNUSED;
00123 {
00124 tree func;
00125
00126 if (c4x_parse_pragma ("FUNC_IS_PURE", &func, 0))
00127 return;
00128 pure_tree = chainon (pure_tree, build_tree_list (func, NULL_TREE));
00129 }
00130
00131 void
00132 c4x_pr_FUNC_NEVER_RETURNS (pfile)
00133 cpp_reader *pfile ATTRIBUTE_UNUSED;
00134 {
00135 tree func;
00136
00137 if (c4x_parse_pragma ("FUNC_NEVER_RETURNS", &func, 0))
00138 return;
00139 noreturn_tree = chainon (noreturn_tree, build_tree_list (func, NULL_TREE));
00140 }
00141
00142 void
00143 c4x_pr_INTERRUPT (pfile)
00144 cpp_reader *pfile ATTRIBUTE_UNUSED;
00145 {
00146 tree func;
00147
00148 if (c4x_parse_pragma ("INTERRUPT", &func, 0))
00149 return;
00150 interrupt_tree = chainon (interrupt_tree, build_tree_list (func, NULL_TREE));
00151 }
00152
00153
00154
00155 void
00156 c4x_pr_ignored (pfile)
00157 cpp_reader *pfile ATTRIBUTE_UNUSED;
00158 {
00159 }