aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2023-08-07 20:13:33 +0200
committerDmitri Gribenko <gribozavr@gmail.com>2023-08-07 20:30:48 +0200
commitbddaa35177861545fc329123e55b6a3b34549507 (patch)
treeca3e4fe74033cd2451baf61bd24ef18425856a35 /clang/lib/Frontend/CompilerInvocation.cpp
parentb8fef7a6d40105ac9bc3bf67268ff1245c4be5c8 (diff)
downloadllvm-bddaa35177861545fc329123e55b6a3b34549507.zip
llvm-bddaa35177861545fc329123e55b6a3b34549507.tar.gz
llvm-bddaa35177861545fc329123e55b6a3b34549507.tar.bz2
Anonymous unions should be transparent wrt `[[clang::trivial_abi]]`.
Anonymous unions should be transparent wrt `[[clang::trivial_abi]]`. Consider the test input below: ``` struct [[clang::trivial_abi]] Trivial { Trivial() {} Trivial(Trivial&& other) {} Trivial& operator=(Trivial&& other) { return *this; } ~Trivial() {} }; static_assert(__is_trivially_relocatable(Trivial), ""); struct [[clang::trivial_abi]] S2 { S2(S2&& other) {} S2& operator=(S2&& other) { return *this; } ~S2() {} union { Trivial field; }; }; static_assert(__is_trivially_relocatable(S2), ""); ``` Before the fix Clang would warn that 'trivial_abi' is disallowed on 'S2' because it has a field of a non-trivial class type (the type of the anonymous union is non-trivial, because it doesn't have the `[[clang::trivial_abi]]` attribute applied to it). Consequently, before the fix the `static_assert` about `__is_trivially_relocatable` would fail. Note that `[[clang::trivial_abi]]` cannot be applied to the anonymous union, because Clang warns that 'trivial_abi' is disallowed on '(unnamed union at ...)' because its copy constructors and move constructors are all deleted. Also note that it is impossible to provide copy nor move constructors for anonymous unions and structs. Reviewed By: gribozavr2 Differential Revision: https://reviews.llvm.org/D155895
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index be53ce3..699b315 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3474,6 +3474,8 @@ void CompilerInvocation::GenerateLangArgs(const LangOptions &Opts,
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "14.0");
else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver15)
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "15.0");
+ else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver17)
+ GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "17.0");
if (Opts.getSignReturnAddressScope() ==
LangOptions::SignReturnAddressScopeKind::All)
@@ -3959,6 +3961,8 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
Opts.setClangABICompat(LangOptions::ClangABI::Ver14);
else if (Major <= 15)
Opts.setClangABICompat(LangOptions::ClangABI::Ver15);
+ else if (Major <= 17)
+ Opts.setClangABICompat(LangOptions::ClangABI::Ver17);
} else if (Ver != "latest") {
Diags.Report(diag::err_drv_invalid_value)
<< A->getAsString(Args) << A->getValue();