Merge remote-tracking branch 'origin/master' into self-hosted-cli
commit
29e0e4088e
|
@ -301,6 +301,15 @@ template <class ELFT> void elf::markLive() {
|
|||
// Follow the graph to mark all live sections.
|
||||
doGcSections<ELFT>();
|
||||
|
||||
// If all references to a DSO happen to be weak, the DSO is removed from
|
||||
// DT_NEEDED, which creates dangling shared symbols to non-existent DSO.
|
||||
// We'll replace such symbols with undefined ones to fix it.
|
||||
for (Symbol *Sym : Symtab->getSymbols())
|
||||
if (auto *S = dyn_cast<SharedSymbol>(Sym))
|
||||
if (S->isWeak() && !S->getFile<ELFT>().IsNeeded)
|
||||
replaceSymbol<Undefined>(S, nullptr, S->getName(), STB_WEAK, S->StOther,
|
||||
S->Type);
|
||||
|
||||
// Report garbage-collected sections.
|
||||
if (Config->PrintGcSections)
|
||||
for (InputSectionBase *Sec : InputSections)
|
||||
|
|
|
@ -11804,7 +11804,8 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
|
|||
}
|
||||
}
|
||||
|
||||
bool comptime_arg = param_decl_node->data.param_decl.is_inline;
|
||||
bool comptime_arg = param_decl_node->data.param_decl.is_inline ||
|
||||
casted_arg->value.type->id == TypeTableEntryIdNumLitInt || casted_arg->value.type->id == TypeTableEntryIdNumLitFloat;
|
||||
|
||||
ConstExprValue *arg_val;
|
||||
|
||||
|
@ -11829,6 +11830,12 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
|
|||
var->shadowable = !comptime_arg;
|
||||
|
||||
*next_proto_i += 1;
|
||||
} else if (casted_arg->value.type->id == TypeTableEntryIdNumLitInt ||
|
||||
casted_arg->value.type->id == TypeTableEntryIdNumLitFloat)
|
||||
{
|
||||
ir_add_error(ira, casted_arg,
|
||||
buf_sprintf("compiler bug: integer and float literals in var args function must be casted. https://github.com/zig-lang/zig/issues/557"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!comptime_arg) {
|
||||
|
|
|
@ -214,7 +214,7 @@ pub const NodeVarDecl = struct {
|
|||
eq_token: Token,
|
||||
mut_token: Token,
|
||||
comptime_token: ?Token,
|
||||
extern_token: ?Token,
|
||||
extern_export_token: ?Token,
|
||||
lib_name: ?&Node,
|
||||
type_node: ?&Node,
|
||||
align_node: ?&Node,
|
||||
|
@ -245,7 +245,7 @@ pub const NodeVarDecl = struct {
|
|||
pub fn firstToken(self: &NodeVarDecl) Token {
|
||||
if (self.visib_token) |visib_token| return visib_token;
|
||||
if (self.comptime_token) |comptime_token| return comptime_token;
|
||||
if (self.extern_token) |extern_token| return extern_token;
|
||||
if (self.extern_export_token) |extern_export_token| return extern_export_token;
|
||||
assert(self.lib_name == null);
|
||||
return self.mut_token;
|
||||
}
|
||||
|
@ -360,6 +360,7 @@ pub const NodeContainerDecl = struct {
|
|||
|
||||
pub const NodeStructField = struct {
|
||||
base: Node,
|
||||
visib_token: ?Token,
|
||||
name_token: Token,
|
||||
type_expr: &Node,
|
||||
|
||||
|
@ -373,6 +374,7 @@ pub const NodeStructField = struct {
|
|||
}
|
||||
|
||||
pub fn firstToken(self: &NodeStructField) Token {
|
||||
if (self.visib_token) |visib_token| return visib_token;
|
||||
return self.name_token;
|
||||
}
|
||||
|
||||
|
@ -494,8 +496,7 @@ pub const NodeFnProto = struct {
|
|||
params: ArrayList(&Node),
|
||||
return_type: ReturnType,
|
||||
var_args_token: ?Token,
|
||||
extern_token: ?Token,
|
||||
inline_token: ?Token,
|
||||
extern_export_inline_token: ?Token,
|
||||
cc_token: ?Token,
|
||||
async_attr: ?&NodeAsyncAttribute,
|
||||
body_node: ?&Node,
|
||||
|
@ -545,9 +546,8 @@ pub const NodeFnProto = struct {
|
|||
|
||||
pub fn firstToken(self: &NodeFnProto) Token {
|
||||
if (self.visib_token) |visib_token| return visib_token;
|
||||
if (self.extern_token) |extern_token| return extern_token;
|
||||
if (self.extern_export_inline_token) |extern_export_inline_token| return extern_export_inline_token;
|
||||
assert(self.lib_name == null);
|
||||
if (self.inline_token) |inline_token| return inline_token;
|
||||
if (self.cc_token) |cc_token| return cc_token;
|
||||
return self.fn_token;
|
||||
}
|
||||
|
@ -1606,7 +1606,7 @@ pub const NodeThisLiteral = struct {
|
|||
pub const NodeAsmOutput = struct {
|
||||
base: Node,
|
||||
symbolic_name: &NodeIdentifier,
|
||||
constraint: &NodeStringLiteral,
|
||||
constraint: &Node,
|
||||
kind: Kind,
|
||||
|
||||
const Kind = union(enum) {
|
||||
|
@ -1620,7 +1620,7 @@ pub const NodeAsmOutput = struct {
|
|||
if (i < 1) return &self.symbolic_name.base;
|
||||
i -= 1;
|
||||
|
||||
if (i < 1) return &self.constraint.base;
|
||||
if (i < 1) return self.constraint;
|
||||
i -= 1;
|
||||
|
||||
switch (self.kind) {
|
||||
|
@ -1652,7 +1652,7 @@ pub const NodeAsmOutput = struct {
|
|||
pub const NodeAsmInput = struct {
|
||||
base: Node,
|
||||
symbolic_name: &NodeIdentifier,
|
||||
constraint: &NodeStringLiteral,
|
||||
constraint: &Node,
|
||||
expr: &Node,
|
||||
|
||||
pub fn iterate(self: &NodeAsmInput, index: usize) ?&Node {
|
||||
|
@ -1661,7 +1661,7 @@ pub const NodeAsmInput = struct {
|
|||
if (i < 1) return &self.symbolic_name.base;
|
||||
i -= 1;
|
||||
|
||||
if (i < 1) return &self.constraint.base;
|
||||
if (i < 1) return self.constraint;
|
||||
i -= 1;
|
||||
|
||||
if (i < 1) return self.expr;
|
||||
|
@ -1683,11 +1683,11 @@ pub const NodeAsm = struct {
|
|||
base: Node,
|
||||
asm_token: Token,
|
||||
is_volatile: bool,
|
||||
template: Token,
|
||||
template: &Node,
|
||||
//tokens: ArrayList(AsmToken),
|
||||
outputs: ArrayList(&NodeAsmOutput),
|
||||
inputs: ArrayList(&NodeAsmInput),
|
||||
cloppers: ArrayList(&NodeStringLiteral),
|
||||
cloppers: ArrayList(&Node),
|
||||
rparen: Token,
|
||||
|
||||
pub fn iterate(self: &NodeAsm, index: usize) ?&Node {
|
||||
|
@ -1699,7 +1699,7 @@ pub const NodeAsm = struct {
|
|||
if (i < self.inputs.len) return &self.inputs.at(index).base;
|
||||
i -= self.inputs.len;
|
||||
|
||||
if (i < self.cloppers.len) return &self.cloppers.at(index).base;
|
||||
if (i < self.cloppers.len) return self.cloppers.at(index);
|
||||
i -= self.cloppers.len;
|
||||
|
||||
return null;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -94,3 +94,13 @@ test "inline function call" {
|
|||
}
|
||||
|
||||
fn add(a: i32, b: i32) i32 { return a + b; }
|
||||
|
||||
|
||||
test "number literal as an argument" {
|
||||
numberLiteralArg(3);
|
||||
comptime numberLiteralArg(3);
|
||||
}
|
||||
|
||||
fn numberLiteralArg(a: var) void {
|
||||
assert(a == 3);
|
||||
}
|
||||
|
|
|
@ -1723,7 +1723,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
|
|||
\\}
|
||||
\\
|
||||
\\export fn entry() usize { return @sizeOf(@typeOf(bar)); }
|
||||
, ".tmp_source.zig:10:16: error: parameter of type '(integer literal)' requires comptime");
|
||||
, ".tmp_source.zig:10:16: error: compiler bug: integer and float literals in var args function must be casted");
|
||||
|
||||
cases.add("assign too big number to u16",
|
||||
\\export fn foo() void {
|
||||
|
|
Loading…
Reference in New Issue