mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 11:42:30 +00:00 
			
		
		
		
	Use [[maybe_unused]] instead of YS_ATTRIBUTE(unused).
[[maybe_unused]] is available since C++17, so this commit adds a polyfill YS_MAYBE_UNUSED. Once we require C++17 we can drop it.
This commit is contained in:
		
							parent
							
								
									118e4caa37
								
							
						
					
					
						commit
						c8c3c7af87
					
				
					 2 changed files with 18 additions and 10 deletions
				
			
		|  | @ -144,6 +144,14 @@ extern Tcl_Obj *Tcl_ObjSetVar2(Tcl_Interp *interp, Tcl_Obj *part1Ptr, Tcl_Obj *p | ||||||
| #  define YS_ATTRIBUTE(...) | #  define YS_ATTRIBUTE(...) | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | #if __cplusplus >= 201703L | ||||||
|  | #  define YS_MAYBE_UNUSED [[maybe_unused]]; | ||||||
|  | #elif defined(__GNUC__) || defined(__clang__) | ||||||
|  | #  define YS_MAYBE_UNUSED __attribute__((__unused__)) | ||||||
|  | #else | ||||||
|  | #  define YS_MAYBE_UNUSED | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
| #if __cplusplus >= 201703L | #if __cplusplus >= 201703L | ||||||
| #  define YS_FALLTHROUGH [[fallthrough]]; | #  define YS_FALLTHROUGH [[fallthrough]]; | ||||||
| #elif defined(__clang__) | #elif defined(__clang__) | ||||||
|  |  | ||||||
|  | @ -589,7 +589,7 @@ with open(outfile, "w") as f: | ||||||
|         if block["type"] in ("match", "code"): |         if block["type"] in ("match", "code"): | ||||||
|             print("  // {}".format(block["src"]), file=f) |             print("  // {}".format(block["src"]), file=f) | ||||||
| 
 | 
 | ||||||
|         print("  void block_{}(int recursion YS_ATTRIBUTE(unused)) {{".format(index), file=f) |         print("  void block_{}(int recursion YS_MAYBE_UNUSED) {{".format(index), file=f) | ||||||
|         current_pattern, current_subpattern = block["pattern"] |         current_pattern, current_subpattern = block["pattern"] | ||||||
| 
 | 
 | ||||||
|         if block["type"] == "final": |         if block["type"] == "final": | ||||||
|  | @ -636,17 +636,17 @@ with open(outfile, "w") as f: | ||||||
|         for s in sorted(const_st): |         for s in sorted(const_st): | ||||||
|             t = state_types[current_pattern][s] |             t = state_types[current_pattern][s] | ||||||
|             if t.endswith("*"): |             if t.endswith("*"): | ||||||
|                 print("    {} const &{} YS_ATTRIBUTE(unused) = st_{}.{};".format(t, s, current_pattern, s), file=f) |                 print("    {} const &{} YS_MAYBE_UNUSED = st_{}.{};".format(t, s, current_pattern, s), file=f) | ||||||
|             else: |             else: | ||||||
|                 print("    const {} &{} YS_ATTRIBUTE(unused) = st_{}.{};".format(t, s, current_pattern, s), file=f) |                 print("    const {} &{} YS_MAYBE_UNUSED = st_{}.{};".format(t, s, current_pattern, s), file=f) | ||||||
| 
 | 
 | ||||||
|         for s in sorted(nonconst_st): |         for s in sorted(nonconst_st): | ||||||
|             t = state_types[current_pattern][s] |             t = state_types[current_pattern][s] | ||||||
|             print("    {} &{} YS_ATTRIBUTE(unused) = st_{}.{};".format(t, s, current_pattern, s), file=f) |             print("    {} &{} YS_MAYBE_UNUSED = st_{}.{};".format(t, s, current_pattern, s), file=f) | ||||||
| 
 | 
 | ||||||
|         for u in sorted(udata_types[current_pattern].keys()): |         for u in sorted(udata_types[current_pattern].keys()): | ||||||
|             t = udata_types[current_pattern][u] |             t = udata_types[current_pattern][u] | ||||||
|             print("    {} &{} YS_ATTRIBUTE(unused) = ud_{}.{};".format(t, u, current_pattern, u), file=f) |             print("    {} &{} YS_MAYBE_UNUSED = ud_{}.{};".format(t, u, current_pattern, u), file=f) | ||||||
| 
 | 
 | ||||||
|         if len(restore_st): |         if len(restore_st): | ||||||
|             print("", file=f) |             print("", file=f) | ||||||
|  | @ -676,7 +676,7 @@ with open(outfile, "w") as f: | ||||||
| 
 | 
 | ||||||
|             print("", file=f) |             print("", file=f) | ||||||
|             print("rollback_label:", file=f) |             print("rollback_label:", file=f) | ||||||
|             print("    YS_ATTRIBUTE(unused);", file=f) |             print("    YS_MAYBE_UNUSED;", file=f) | ||||||
| 
 | 
 | ||||||
|             if len(block["fcode"]): |             if len(block["fcode"]): | ||||||
|                 print("#define accept do { accept_cnt++; on_accept(); } while(0)", file=f) |                 print("#define accept do { accept_cnt++; on_accept(); } while(0)", file=f) | ||||||
|  | @ -684,7 +684,7 @@ with open(outfile, "w") as f: | ||||||
|                 for line in block["fcode"]: |                 for line in block["fcode"]: | ||||||
|                     print("  " + line, file=f) |                     print("  " + line, file=f) | ||||||
|                 print("finish_label:", file=f) |                 print("finish_label:", file=f) | ||||||
|                 print("    YS_ATTRIBUTE(unused);", file=f) |                 print("    YS_MAYBE_UNUSED;", file=f) | ||||||
|                 print("#undef accept", file=f) |                 print("#undef accept", file=f) | ||||||
|                 print("#undef finish", file=f) |                 print("#undef finish", file=f) | ||||||
| 
 | 
 | ||||||
|  | @ -733,13 +733,13 @@ with open(outfile, "w") as f: | ||||||
|             valueidx = 1 |             valueidx = 1 | ||||||
|             for item in block["setup"]: |             for item in block["setup"]: | ||||||
|                 if item[0] == "slice": |                 if item[0] == "slice": | ||||||
|                     print("        const int &{} YS_ATTRIBUTE(unused) = std::get<{}>(cells[_pmg_idx]);".format(item[1], valueidx), file=f) |                     print("        const int &{} YS_MAYBE_UNUSED = std::get<{}>(cells[_pmg_idx]);".format(item[1], valueidx), file=f) | ||||||
|                     valueidx += 1 |                     valueidx += 1 | ||||||
|                 if item[0] == "choice": |                 if item[0] == "choice": | ||||||
|                     print("        const {} &{} YS_ATTRIBUTE(unused) = std::get<{}>(cells[_pmg_idx]);".format(item[1], item[2], valueidx), file=f) |                     print("        const {} &{} YS_MAYBE_UNUSED = std::get<{}>(cells[_pmg_idx]);".format(item[1], item[2], valueidx), file=f) | ||||||
|                     valueidx += 1 |                     valueidx += 1 | ||||||
|                 if item[0] == "define": |                 if item[0] == "define": | ||||||
|                     print("        const {} &{} YS_ATTRIBUTE(unused) = std::get<{}>(cells[_pmg_idx]);".format(item[1], item[2], valueidx), file=f) |                     print("        const {} &{} YS_MAYBE_UNUSED = std::get<{}>(cells[_pmg_idx]);".format(item[1], item[2], valueidx), file=f) | ||||||
|                     valueidx += 1 |                     valueidx += 1 | ||||||
|             print("        if (blacklist_cells.count({})) continue;".format(block["cell"]), file=f) |             print("        if (blacklist_cells.count({})) continue;".format(block["cell"]), file=f) | ||||||
|             for expr in block["filter"]: |             for expr in block["filter"]: | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue