Skip to content

Commit 96280f7

Browse files
make -freflection cc-1 only and only c++26 mode
1 parent f8d2d8a commit 96280f7

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,4 +901,7 @@ def warn_drv_gcc_install_dir_libstdcxx : Warning<
901901
"future releases of the clang compiler will prefer GCC installations "
902902
"containing libstdc++ include directories; '%0' would be chosen over '%1'">,
903903
InGroup<DiagGroup<"gcc-install-dir-libstdcxx">>;
904+
905+
def err_drv_reflection_requires_cxx26 : Error<
906+
"option '%0' is only supported when compiling in C++26 mode">;
904907
}

clang/include/clang/Options/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3696,7 +3696,7 @@ defm application_extension : BoolFOption<"application-extension",
36963696
NegFlag<SetFalse>>;
36973697
defm reflection : BoolFOption<"reflection",
36983698
LangOpts<"Reflection">, DefaultFalse,
3699-
PosFlag<SetTrue, [], [ClangOption, CC1Option],
3699+
PosFlag<SetTrue, [], [CC1Option],
37003700
"Enable C++26 reflection">,
37013701
NegFlag<SetFalse>>, ShouldParseIf<cplusplus.KeyPath>;
37023702
defm sized_deallocation : BoolFOption<"sized-deallocation",

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,11 @@ static bool FixupInvocation(CompilerInvocation &Invocation,
624624
LangOpts.RawStringLiterals = true;
625625
}
626626

627+
if (Args.hasArg(OPT_freflection) && !LangOpts.CPlusPlus26) {
628+
Diags.Report(diag::err_drv_reflection_requires_cxx26)
629+
<< Args.getLastArg(options::OPT_freflection)->getAsString(Args);
630+
}
631+
627632
LangOpts.NamedLoops =
628633
Args.hasFlag(OPT_fnamed_loops, OPT_fno_named_loops, LangOpts.C2y);
629634

0 commit comments

Comments
 (0)