Explorar o código

[hl/c] fix reserved keywords (#11408)

* [tests] update test for 11378

* [hlc] fix reserved keywords
Rudy Ges hai 1 ano
pai
achega
4d72a67e10
Modificáronse 2 ficheiros con 12 adicións e 4 borrados
  1. 2 2
      src/generators/hl2c.ml
  2. 10 2
      tests/misc/hl/reserved-keywords/Macro.macro.hx

+ 2 - 2
src/generators/hl2c.ml

@@ -98,13 +98,13 @@ let keywords =
 	"typeof";
 	(* C11 *)
 	"_Alignas";"_Alignof";"_Atomic";"_Bool";"_Complex";"_Generic";"_Imaginary";"_Noreturn";"_Static_assert";"_Thread_local";"_Pragma";
-	"inline";"restrict"
+	"inline";"restrict";"_restrict"
 	] in
 	let h = Hashtbl.create 0 in
 	List.iter (fun i -> Hashtbl.add h i ()) c_kwds;
 	h
 
-let ident i = if (Hashtbl.mem keywords i) || (ExtString.String.starts_with "__" i) then "_hx_" ^ i else i
+let ident i = if (Hashtbl.mem keywords i) || (ExtString.String.starts_with i "__") then "_hx_" ^ i else i
 
 let s_comp = function
 	| CLt -> "<"

+ 10 - 2
tests/misc/hl/reserved-keywords/Macro.macro.hx

@@ -19,12 +19,12 @@ class Macro {
 			"typeof",
 			// C11
 			"_Alignas", "_Alignof", "_Atomic", "_Bool", "_Complex", "_Generic", "_Imaginary", "_Noreturn", "_Static_assert", "_Thread_local", "_Pragma",
-			"inline", "restrict"
+			"inline", "restrict", "_restrict"
 		];
 
 		var pos = Context.currentPos();
 
-		for (k in keywords)
+		for (k in keywords) {
 			fields.push({
 				pos: pos,
 				name: "_test_" + k,
@@ -32,6 +32,14 @@ class Macro {
 				kind: FVar(macro :String, null)
 			});
 
+			fields.push({
+				pos: pos,
+				name: "_test2_" + k,
+				meta: [{pos: pos, name: ":native", params: [macro $v{'__' + k}]}],
+				kind: FVar(macro :String, null)
+			});
+		}
+
 		return fields;
 	}
 }