}
}
+void
+typeresolution_info::mismatch (const binary_expression* e)
+{
+ num_still_unresolved ++;
+
+ if (assert_resolvability)
+ {
+ stringstream msg;
+ msg << _F("type mismatch: left and right sides don't agree (%s vs %s)",
+ lex_cast(e->left->type).c_str(), lex_cast(e->right->type).c_str());
+ session.print_error (SEMANTIC_ERROR (msg.str(), e->tok));
+ }
+}
/* tok token where mismatch occurred
* t1 type we expected (the 'good' type)
}
}
+/* tok token where the mismatch happened
+ * type type we received (the 'bad' type)
+ * decl declaration of mismatched symbol
+ * index if index-based (array index or function arg)
+ * */
+void
+typeresolution_info::mismatch (const token *tok, exp_type type,
+ const symboldecl* decl, int index)
+{
+ num_still_unresolved ++;
+
+ if (assert_resolvability)
+ {
+ cerr << "A mismatch occurred" << endl;
+ // TODO: retrieve from resolved_types vector
+ }
+}
+
+/* tok token where resolution occurred
+ * type type to which we resolved
+ * decl declaration of resolved symbol
+ * index if index-based (array index or function arg)
+ * */
void
-typeresolution_info::resolved (const token*, exp_type)
+typeresolution_info::resolved (const token *tok, exp_type type,
+ const symboldecl* decl, int index)
{
num_newly_resolved ++;
+ // TODO: add to resolved_types vector
}
/* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */
functiondecl* current_function;
derived_probe* current_probe;
+ // Holds information about a type we resolved (see PR16097)
+ struct resolved_type
+ {
+ const token *tok;
+ const symboldecl *decl;
+ int index;
+ resolved_type(const token *ct, const symboldecl *cdecl, int cindex):
+ tok(ct), decl(cdecl), index(cindex) {}
+ };
+
+ // Holds an element each time we resolve a decl. Unique by decl & index.
+ // Possible values:
+ // - resolved function type -> decl = functiondecl, index = -1
+ // - resolved function arg type -> decl = vardecl, index = index of arg
+ // - resolved array/var type -> decl = vardecl, index = -1
+ // - resolved array index type -> decl = vardecl, index = index of type
+ std::vector<resolved_type> resolved_types; // see PR16097
+
void check_arg_type (exp_type wanted, expression* arg);
void check_local (vardecl* v);
- void mismatch (const token* tok, exp_type t1, exp_type t2);
void unresolved (const token* tok);
- void resolved (const token* tok, exp_type t);
void invalid (const token* tok, exp_type t);
+ void mismatch (const binary_expression* e);
+ void mismatch (const token* tok, exp_type t1, exp_type t2);
+ void mismatch (const token* tok, exp_type type,
+ const symboldecl* decl, int index = -1);
+ void resolved (const token* tok, exp_type type,
+ const symboldecl* decl = NULL, int index = -1);
exp_type t; // implicit parameter for nested visit call; may clobber
// Upon entry to one of the visit_* calls, the incoming