On Aug 26, 2014, at 1:15 PM, Richard Smith <[email protected]> wrote:
> On Tue, Aug 26, 2014 at 11:13 AM, Fariborz Jahanian <[email protected]> > wrote: > Author: fjahanian > Date: Tue Aug 26 13:13:47 2014 > New Revision: 216469 > > URL: http://llvm.org/viewvc/llvm-project?rev=216469&view=rev > Log: > c11- Check for c11 language option as documentation says > feature is c11 about nested struct declarations must have > struct-declarator-list. Without this change, code > which was meant for c99 breaks. rdar://18125536 > > This change does not look correct; the same rule existed in C89 and C99 too > (but it was enforced by the grammar in those languages). [Additionally, your > commit message is a bit garbled, you didn't add a new test case, and the only > other information you provide is a link to an Apple-internal bug, so I'm not > even sure what problem you're trying to fix.] Jordan checked and confirmed that rule is not in C99. Test case is simple. This test causes a warning with default language setting C99 (without my patch). static struct S { struct INNER { int totalNumSlots; }; // ... struct INNER externalFlows; } VVVVV; I did not add new test because I changed several tests by either adding -std=c11 or in one case I kept the language default (c99) and removed the warning instead. If this is insufficient I can add a test. But first we need to know if above test case deserves a warning in c99 (and c89), in addition to c11. - Fariborz > > Modified: > cfe/trunk/lib/Sema/SemaDecl.cpp > cfe/trunk/test/CodeGen/ms-anonymous-struct.c > cfe/trunk/test/Parser/declarators.c > cfe/trunk/test/Sema/MicrosoftExtensions.c > cfe/trunk/test/Sema/anonymous-struct-union.c > cfe/trunk/test/SemaObjC/ivar-lookup.m > > Modified: cfe/trunk/lib/Sema/SemaDecl.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=216469&r1=216468&r2=216469&view=diff > ============================================================================== > --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) > +++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Aug 26 13:13:47 2014 > @@ -3450,7 +3450,7 @@ Decl *Sema::ParsedFreeStandingDeclSpec(S > // C11 6.7.2.1p2: > // A struct-declaration that does not declare an anonymous structure or > // anonymous union shall contain a struct-declarator-list. > - if (!getLangOpts().CPlusPlus && CurContext->isRecord() && > + if (getLangOpts().C11 && CurContext->isRecord() && > DS.getStorageClassSpec() == DeclSpec::SCS_unspecified) { > // Check for Microsoft C extension: anonymous struct/union member. > // Handle 2 kinds of anonymous struct/union: > > Modified: cfe/trunk/test/CodeGen/ms-anonymous-struct.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-anonymous-struct.c?rev=216469&r1=216468&r2=216469&view=diff > ============================================================================== > --- cfe/trunk/test/CodeGen/ms-anonymous-struct.c (original) > +++ cfe/trunk/test/CodeGen/ms-anonymous-struct.c Tue Aug 26 13:13:47 2014 > @@ -1,4 +1,4 @@ > -// RUN: %clang_cc1 -fms-extensions -emit-llvm -o - %s | FileCheck %s > +// RUN: %clang_cc1 -std=c11 -fms-extensions -emit-llvm -o - %s | FileCheck %s > > // CHECK: %struct.test = type { i32, %struct.nested2, i32 } > // CHECK: %struct.nested2 = type { i32, %struct.nested1, i32 } > > Modified: cfe/trunk/test/Parser/declarators.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/declarators.c?rev=216469&r1=216468&r2=216469&view=diff > ============================================================================== > --- cfe/trunk/test/Parser/declarators.c (original) > +++ cfe/trunk/test/Parser/declarators.c Tue Aug 26 13:13:47 2014 > @@ -113,7 +113,6 @@ enum E1 { e1 }: // expected-error {{expe > struct EnumBitfield { // expected-warning {{struct without named members is > a GNU extension}} > enum E2 { e2 } : 4; // ok > struct S { int n; }: // expected-error {{expected ';'}} > - // expected-warning@-1 {{declaration does not declare > anything}} > > }; > > > Modified: cfe/trunk/test/Sema/MicrosoftExtensions.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/MicrosoftExtensions.c?rev=216469&r1=216468&r2=216469&view=diff > ============================================================================== > --- cfe/trunk/test/Sema/MicrosoftExtensions.c (original) > +++ cfe/trunk/test/Sema/MicrosoftExtensions.c Tue Aug 26 13:13:47 2014 > @@ -1,4 +1,4 @@ > -// RUN: %clang_cc1 -triple i686-windows %s -fsyntax-only -Wno-unused-value > -Wmicrosoft -verify -fms-extensions > +// RUN: %clang_cc1 -std=c11 -triple i686-windows %s -fsyntax-only > -Wno-unused-value -Wmicrosoft -verify -fms-extensions > > > struct A > > Modified: cfe/trunk/test/Sema/anonymous-struct-union.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/anonymous-struct-union.c?rev=216469&r1=216468&r2=216469&view=diff > ============================================================================== > --- cfe/trunk/test/Sema/anonymous-struct-union.c (original) > +++ cfe/trunk/test/Sema/anonymous-struct-union.c Tue Aug 26 13:13:47 2014 > @@ -1,4 +1,4 @@ > -// RUN: %clang_cc1 -fsyntax-only -verify %s > +// RUN: %clang_cc1 -fsyntax-only -std=c11 -verify %s > struct X { > union { > float f3; > > Modified: cfe/trunk/test/SemaObjC/ivar-lookup.m > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/ivar-lookup.m?rev=216469&r1=216468&r2=216469&view=diff > ============================================================================== > --- cfe/trunk/test/SemaObjC/ivar-lookup.m (original) > +++ cfe/trunk/test/SemaObjC/ivar-lookup.m Tue Aug 26 13:13:47 2014 > @@ -1,4 +1,4 @@ > -// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s > +// RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wno-objc-root-class %s > > @interface Test { > int x; > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
