From: Fariborz Jahanian Date: Tue, 26 Aug 2014 18:13:47 +0000 (+0000) Subject: c11- Check for c11 language option as documentation says X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1bd3f7465410d89ce4f0c6db836e6f9f68e688ed;p=clang 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216469 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 0079c4925a..b6c0971619 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -3450,7 +3450,7 @@ Decl *Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, // 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: diff --git a/test/CodeGen/ms-anonymous-struct.c b/test/CodeGen/ms-anonymous-struct.c index b41caab030..ea6b42aff2 100644 --- a/test/CodeGen/ms-anonymous-struct.c +++ b/test/CodeGen/ms-anonymous-struct.c @@ -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 } diff --git a/test/Parser/declarators.c b/test/Parser/declarators.c index 48936d5922..3b28c5c2b2 100644 --- a/test/Parser/declarators.c +++ b/test/Parser/declarators.c @@ -113,7 +113,6 @@ enum E1 { e1 }: // expected-error {{expected ';'}} 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}} }; diff --git a/test/Sema/MicrosoftExtensions.c b/test/Sema/MicrosoftExtensions.c index 908ec04876..b3030fff10 100644 --- a/test/Sema/MicrosoftExtensions.c +++ b/test/Sema/MicrosoftExtensions.c @@ -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 diff --git a/test/Sema/anonymous-struct-union.c b/test/Sema/anonymous-struct-union.c index 26dbeb87f5..2d1391133d 100644 --- a/test/Sema/anonymous-struct-union.c +++ b/test/Sema/anonymous-struct-union.c @@ -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; diff --git a/test/SemaObjC/ivar-lookup.m b/test/SemaObjC/ivar-lookup.m index 57f432c717..b2a1105f31 100644 --- a/test/SemaObjC/ivar-lookup.m +++ b/test/SemaObjC/ivar-lookup.m @@ -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;