]> granicus.if.org Git - clang/commitdiff
c11- Check for c11 language option as documentation says
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 26 Aug 2014 18:13:47 +0000 (18:13 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 26 Aug 2014 18:13:47 +0000 (18:13 +0000)
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

lib/Sema/SemaDecl.cpp
test/CodeGen/ms-anonymous-struct.c
test/Parser/declarators.c
test/Sema/MicrosoftExtensions.c
test/Sema/anonymous-struct-union.c
test/SemaObjC/ivar-lookup.m

index 0079c4925ac1c1a55946dd9432d92221590a43b9..b6c0971619917ff26ef0bbdf02bd99b249a213b6 100644 (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:
index b41caab0309ef16dc49b40519600b6652734197b..ea6b42aff20ac227dc8ed60e2fd4ffed12e08813 100644 (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 }
index 48936d59226968bb6d5a0d6c4abb642d926921ab..3b28c5c2b267929bef5c85590f59ae5a324c7bf8 100644 (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}}
 
 };
 
index 908ec04876e2332c99da34591b079e5259ee3623..b3030fff10f59103e560e16b7410663d02546842 100644 (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
index 26dbeb87f5fab40d5ad0d452da1d7b084312eacf..2d1391133dd3ec907f7bd0f6476bd738b744f6cb 100644 (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;
index 57f432c717a191be63ded6531cfd797d3bc7ec4b..b2a1105f312459712b82a2d68a413703a05f15bd 100644 (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;