On 3/12/26 8:21 AM, Marek Polacek wrote:
On Wed, Mar 11, 2026 at 10:34:21PM -0400, Jason Merrill wrote:
On 3/11/26 8:12 PM, Marek Polacek wrote:
Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
-- >8 --
-freflection is unusable without C++26 so let's not allow it.
Since libcpp only handles the tokens in C++26, agreed.
Same for -fcontracts and C++20.
...but I don't see any similar rationale here; a simple testcase works fine
even in C++98 mode.
OK, let's drop the -fcontracts part. Ok for trunk?
OK.
-- >8 --
-freflection is unusable without C++26 so let's not allow it.
PR c++/124447
gcc/c-family/ChangeLog:
* c-opts.cc (c_common_post_options): Error if -freflection is used
without -std=c++26 or -std=gnu++26.
---
gcc/c-family/c-opts.cc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc
index 1d14eeeb995..9fad71a1eb1 100644
--- a/gcc/c-family/c-opts.cc
+++ b/gcc/c-family/c-opts.cc
@@ -1265,6 +1265,10 @@ c_common_post_options (const char **pfilename)
if (flag_immediate_escalation && cxx_dialect < cxx20)
flag_immediate_escalation = 0;
+ if (flag_reflection && cxx_dialect < cxx26)
+ error ("%<-freflection%> only supported with %<-std=c++26%> or "
+ "%<-std=gnu++26%>");
+
if (num_in_fnames > 1)
error ("too many filenames given; type %<%s %s%> for usage",
progname, "--help");
base-commit: adefcfed81e19aa250f34914182a7c5580dc6e2a