[pkg-d-commits] [ldc] 97/149: Prevent duplicate fields for AggregateDeclarations

Matthias Klumpp mak at moszumanska.debian.org
Sun Apr 23 22:37:02 UTC 2017


This is an automated email from the git hooks/post-receive script.

mak pushed a commit to annotated tag v1.2.0
in repository ldc.

commit 1094634364e2977d53f9655c9b07627eb3e494ab
Author: Martin <noone at nowhere.com>
Date:   Thu Feb 9 21:39:51 2017 +0100

    Prevent duplicate fields for AggregateDeclarations
    
    runnable/test13613.d shows that a VarDeclaration may end up multiple times
    in the AggregateDeclaration.fields array (!).
    VarDeclaration.setFieldOffset() is the only other relevant place where
    fields are added, and already skips duplicate occurrences exactly the same
    way.
---
 ddmd/aggregate.d | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/ddmd/aggregate.d b/ddmd/aggregate.d
index 61e31af..014f381 100644
--- a/ddmd/aggregate.d
+++ b/ddmd/aggregate.d
@@ -252,6 +252,17 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
                 return 1;   // unresolvable forward reference
 
             auto ad = cast(AggregateDeclaration)param;
+            version(IN_LLVM)
+            {
+                for (size_t i = 0; i < ad.fields.dim; i++)
+                {
+                    if (ad.fields[i] == v)
+                    {
+                        // already a field
+                        return 0;
+                    }
+                }
+            }
             ad.fields.push(v);
 
             if (v.storage_class & STCref)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git



More information about the pkg-d-commits mailing list