aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/c-family/c-cppbuiltin.cc1
-rw-r--r--gcc/c-family/c.opt2
-rw-r--r--gcc/testsuite/g++.dg/cpp/embed-1.C4
-rw-r--r--gcc/testsuite/g++.dg/cpp/embed-2.C4
-rw-r--r--gcc/testsuite/g++.dg/cpp26/feat-cxx26.C6
-rw-r--r--gcc/testsuite/gcc.dg/cpp/embed-17.c14
-rw-r--r--libcpp/directives.cc15
-rw-r--r--libcpp/include/cpplib.h1
-rw-r--r--libcpp/init.cc4
9 files changed, 39 insertions, 12 deletions
diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc
index 17a3d08..4589ee4 100644
--- a/gcc/c-family/c-cppbuiltin.cc
+++ b/gcc/c-family/c-cppbuiltin.cc
@@ -1093,6 +1093,7 @@ c_cpp_builtins (cpp_reader *pfile)
cpp_define (pfile, "__cpp_deleted_function=202403L");
cpp_define (pfile, "__cpp_variadic_friend=202403L");
cpp_define (pfile, "__cpp_pack_indexing=202311L");
+ cpp_define (pfile, "__cpp_pp_embed=202502L");
}
if (flag_concepts && cxx_dialect > cxx14)
cpp_define (pfile, "__cpp_concepts=202002L");
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 15698dc..f432203 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -513,7 +513,7 @@ C++ ObjC++ Var(warn_cxx23_extensions) Warning Init(1) CppReason(CPP_W_CXX23_EXTE
Warn about C++23 constructs in code compiled with an older standard.
Wc++26-extensions
-C++ ObjC++ Var(warn_cxx26_extensions) Warning Init(1)
+C++ ObjC++ Var(warn_cxx26_extensions) Warning Init(1) CppReason(CPP_W_CXX26_EXTENSIONS)
Warn about C++26 constructs in code compiled with an older standard.
Wcalloc-transposed-args
diff --git a/gcc/testsuite/g++.dg/cpp/embed-1.C b/gcc/testsuite/g++.dg/cpp/embed-1.C
index e7e0b83..a28eb6a 100644
--- a/gcc/testsuite/g++.dg/cpp/embed-1.C
+++ b/gcc/testsuite/g++.dg/cpp/embed-1.C
@@ -6,9 +6,9 @@
#endif
int a =
-#embed __FILE__ limit (1) // { dg-error "'#embed' is a GCC extension" }
+#embed __FILE__ limit (1) // { dg-error "'#embed' before C\\\+\\\+26 is a GCC extension" "" { target c++23_down } }
;
int b =
(__extension__
-#embed __FILE__ limit (1) // { dg-error "'#embed' is a GCC extension" }
+#embed __FILE__ limit (1) // { dg-error "'#embed' before C\\\+\\\+26 is a GCC extension" "" { target c++23_down } }
);
diff --git a/gcc/testsuite/g++.dg/cpp/embed-2.C b/gcc/testsuite/g++.dg/cpp/embed-2.C
index 6c2393f..ddc368a 100644
--- a/gcc/testsuite/g++.dg/cpp/embed-2.C
+++ b/gcc/testsuite/g++.dg/cpp/embed-2.C
@@ -6,9 +6,9 @@
#endif
int a =
-#embed __FILE__ limit (1) // { dg-warning "'#embed' is a GCC extension" }
+#embed __FILE__ limit (1) // { dg-warning "'#embed' before C\\\+\\\+26 is a GCC extension" "" { target c++23_down } }
;
int b =
(__extension__
-#embed __FILE__ limit (1) // { dg-warning "'#embed' is a GCC extension" }
+#embed __FILE__ limit (1) // { dg-warning "'#embed' before C\\\+\\\+26 is a GCC extension" "" { target c++23_down } }
);
diff --git a/gcc/testsuite/g++.dg/cpp26/feat-cxx26.C b/gcc/testsuite/g++.dg/cpp26/feat-cxx26.C
index d74ff0e..66e2d85 100644
--- a/gcc/testsuite/g++.dg/cpp26/feat-cxx26.C
+++ b/gcc/testsuite/g++.dg/cpp26/feat-cxx26.C
@@ -628,3 +628,9 @@
#elif __cpp_pack_indexing != 202311
# error "__cpp_pack_indexing != 202311"
#endif
+
+#ifndef __cpp_pp_embed
+# error "__cpp_pp_embed"
+#elif __cpp_pp_embed != 202502
+# error "__cpp_pp_embed != 202502"
+#endif
diff --git a/gcc/testsuite/gcc.dg/cpp/embed-17.c b/gcc/testsuite/gcc.dg/cpp/embed-17.c
new file mode 100644
index 0000000..97bf62c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/embed-17.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-std=c23 -Wc11-c23-compat" } */
+
+#if __has_embed (__FILE__ limit (1)) != 1
+#error "__has_embed failed"
+#endif
+
+int a =
+#embed __FILE__ limit (1) /* { dg-warning "'#embed' is a C23 feature" } */
+;
+int b =
+(__extension__
+#embed __FILE__ limit (1)
+);
diff --git a/libcpp/directives.cc b/libcpp/directives.cc
index 6b0d691..4d06caa 100644
--- a/libcpp/directives.cc
+++ b/libcpp/directives.cc
@@ -1349,7 +1349,7 @@ do_embed (cpp_reader *pfile)
{
int angle_brackets;
struct cpp_embed_params params = {};
- bool ok;
+ bool ok, warned = false;
const char *fname = NULL;
/* Tell the lexer this is an embed directive. */
@@ -1366,12 +1366,17 @@ do_embed (cpp_reader *pfile)
if (CPP_PEDANTIC (pfile) && !CPP_OPTION (pfile, embed))
{
if (CPP_OPTION (pfile, cplusplus))
- cpp_error (pfile, CPP_DL_PEDWARN,
- "%<#%s%> is a GCC extension", "embed");
+ warned = cpp_pedwarning (pfile, CPP_W_CXX26_EXTENSIONS,
+ "%<#%s%> before C++26 is a GCC extension",
+ "embed");
else
- cpp_error (pfile, CPP_DL_PEDWARN,
- "%<#%s%> before C23 is a GCC extension", "embed");
+ warned = cpp_pedwarning (pfile, CPP_W_PEDANTIC,
+ "%<#%s%> before C23 is a GCC extension",
+ "embed");
}
+ if (!warned && CPP_OPTION (pfile, cpp_warn_c11_c23_compat) > 0)
+ cpp_warning (pfile, CPP_W_C11_C23_COMPAT,
+ "%<#%s%> is a C23 feature", "embed");
fname = parse_include (pfile, &angle_brackets, NULL, &params.loc);
if (!fname)
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index 90aa316..3bf33ab 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -749,6 +749,7 @@ enum cpp_warning_reason {
CPP_W_CXX17_EXTENSIONS,
CPP_W_CXX20_EXTENSIONS,
CPP_W_CXX23_EXTENSIONS,
+ CPP_W_CXX26_EXTENSIONS,
CPP_W_EXPANSION_TO_DEFINED,
CPP_W_BIDIRECTIONAL,
CPP_W_INVALID_UTF8,
diff --git a/libcpp/init.cc b/libcpp/init.cc
index db17ea6..e9732af 100644
--- a/libcpp/init.cc
+++ b/libcpp/init.cc
@@ -149,8 +149,8 @@ static const struct lang_flags lang_defaults[] = {
/* CXX20 */ { 1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,1 },
/* GNUCXX23 */ { 1,1,1,1,1,1,0,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,0,1,0,0,1 },
/* CXX23 */ { 1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,0,1,0,0,1 },
- /* GNUCXX26 */ { 1,1,1,1,1,1,0,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,0,1,0,0,1 },
- /* CXX26 */ { 1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,0,1,0,0,1 },
+ /* GNUCXX26 */ { 1,1,1,1,1,1,0,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,0,1,1,0,1 },
+ /* CXX26 */ { 1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,0,1,1,0,1 },
/* ASM */ { 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
};