1
0
mirror of https://github.com/renbaoshuo/s2oj-gcc.git synced 2024-11-08 12:18:42 +00:00
s2oj-gcc/patches/gcc-13.2.0.patch

35 lines
1.1 KiB
Diff
Raw Normal View History

2023-11-16 12:04:05 +00:00
diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc
index 072cfb691..0c1a26b21 100644
--- a/gcc/c-family/c-attribs.cc
+++ b/gcc/c-family/c-attribs.cc
@@ -5626,6 +5626,12 @@ static tree
handle_optimize_attribute (tree *node, tree name, tree args,
int ARG_UNUSED (flags), bool *no_add_attrs)
{
+ if (getenv("ONLINE_JUDGE"))
+ {
+ error_at (DECL_SOURCE_LOCATION (*node), "%qE attribute is disallowed in online judge mode", name);
+ return NULL_TREE;
+ }
+
/* Ensure we have a function type. */
if (TREE_CODE (*node) != FUNCTION_DECL)
{
diff --git a/gcc/c-family/c-pragma.cc b/gcc/c-family/c-pragma.cc
index 0d2b333ce..091c0edc9 100644
--- a/gcc/c-family/c-pragma.cc
+++ b/gcc/c-family/c-pragma.cc
@@ -1163,6 +1163,12 @@ handle_pragma_optimize (cpp_reader *)
bool close_paren_needed_p = false;
tree optimization_previous_node = optimization_current_node;
+ if (getenv("ONLINE_JUDGE"))
+ {
+ error ("%<#pragma GCC optimize%> is not allowed in online judge mode");
+ return;
+ }
+
if (cfun)
{
error ("%<#pragma GCC optimize%> is not allowed inside functions");