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

llvm-svn: 216469
This commit is contained in:
Fariborz Jahanian 2014-08-26 18:13:47 +00:00
parent 5c4f4a6c33
commit 840438bb06
6 changed files with 5 additions and 6 deletions

View File

@ -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:

View File

@ -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 }

View File

@ -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}}
};

View File

@ -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

View File

@ -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;

View File

@ -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;