[PATCH] Gracefully (and correctly) handle init of multiple union members
Eli Friedman
eli.friedman at gmail.com
Tue Sep 24 12:07:08 PDT 2013
On Tue, Sep 24, 2013 at 8:04 AM, Matthew Curtis <mcurtis at codeaurora.org>wrote:
> We now emit warnings when doing so and code generation is consistent
> with GCC. Note that the C99 spec is unclear as to the precise
> behavior.
>
> See also ...
> Bug:
> http://llvm.org/bugs/show_bug.**cgi?id=16644<http://llvm.org/bugs/show_bug.cgi?id=16644>and
>
> cfe-dev discussion:
> http://lists.cs.uiuc.edu/**pipermail/cfe-dev/2013-**September/031918.html<http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-September/031918.html>
>
>
>
+ FieldDecl *CFD = ArrayFillerOrUnionFieldInit.dyn_cast<FieldDecl *>();
+ assert((FD == 0 || CFD == 0 || CFD == FD)
+ && "Only one field of a union may be initiazed at a time!");
This will cause an unused variable warning in release builds. Also,
spelling.
diff --git a/test/Sema/designated-initializers.c
b/test/Sema/designated-initializers.c
index 36fa559..be365a0 100644
--- a/test/Sema/designated-initializers.c
+++ b/test/Sema/designated-initializers.c
@@ -1,5 +1,8 @@
// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-unknown-unknown %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -DCHECK_CODEGEN=1 \
+// RUN: -S -emit-llvm -o - 2>&1 | FileCheck %s
Please put a separate code generation test into test/CodeGen. It's okay if
you duplicate the test code.
The approach looks fine.
-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130924/73b3388e/attachment.html>
More information about the cfe-commits
mailing list