268 changes: 176 additions & 92 deletions clang/lib/Sema/SemaInit.cpp

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions clang/lib/Sema/SemaOverload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4920,13 +4920,11 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
// Type is an aggregate, argument is an init list. At this point it comes
// down to checking whether the initialization works.
// FIXME: Find out whether this parameter is consumed or not.
// FIXME: Expose SemaInit's aggregate initialization code so that we don't
// need to call into the initialization code here; overload resolution
// should not be doing that.
InitializedEntity Entity =
InitializedEntity::InitializeParameter(S.Context, ToType,
/*Consumed=*/false);
if (S.CanPerformCopyInitialization(Entity, From)) {
if (S.CanPerformAggregateInitializationForOverloadResolution(Entity,
From)) {
Result.setUserDefined();
Result.UserDefined.Before.setAsIdentityConversion();
// Initializer lists don't have a type.
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/TreeTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -2416,7 +2416,7 @@ class TreeTransform {
ExprResult RebuildInitList(SourceLocation LBraceLoc,
MultiExprArg Inits,
SourceLocation RBraceLoc) {
return SemaRef.ActOnInitList(LBraceLoc, Inits, RBraceLoc);
return SemaRef.BuildInitList(LBraceLoc, Inits, RBraceLoc);
}

/// Build a new designated initializer expression.
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/globals.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify -std=c++2a %s


static const unsigned long long scull = 0;
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CXX/expr/expr.const/p2-0x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ namespace LValueToRValueUnion {
extern const U pu;
constexpr const int *pua = &pu.a;
constexpr const int *pub = &pu.b;
constexpr U pu = { .b = 1 }; // expected-warning {{C99 feature}}
constexpr U pu = { .b = 1 }; // expected-warning {{C++20 extension}}
constexpr const int a2 = *pua; // expected-error {{constant expression}} expected-note {{read of member 'a' of union with active member 'b'}}
constexpr const int b2 = *pub; // ok
}
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGenObjCXX/designated-initializers.mm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -triple arm64 %s -verify -emit-llvm -o - | FileCheck %s
// RUN: %clang_cc1 -triple arm64 %s -verify -emit-llvm -o - -Wno-c99-designator | FileCheck %s
// expected-no-diagnostics

// Make sure we don't enter an infinite loop (rdar://21942503)
Expand Down
4 changes: 2 additions & 2 deletions clang/test/PCH/cxx1y-default-initializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ C<int> ci;

static_assert(A{}.z == 3, "");
static_assert(A{1}.z == 4, "");
static_assert(A{.y = 5}.z == 5, ""); // expected-warning {{C99}}
static_assert(A{3, .y = 1}.z == 4, ""); // expected-warning {{C99}}
static_assert(A{.y = 5}.z == 5, ""); // expected-warning {{C++20}}
static_assert(A{3, .y = 1}.z == 4, ""); // expected-warning {{C99}} expected-note {{here}}
static_assert(make<int>().z == 3, "");
static_assert(make<int>(12).z == 15, "");
static_assert(C<int>().c == 0, "");
Expand Down
4 changes: 2 additions & 2 deletions clang/test/Parser/cxx0x-lambda-expressions.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify -std=c++11 %s
// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify -std=c++2a %s
// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify -std=c++11 -Wno-c99-designator %s
// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify -std=c++2a -Wno-c99-designator %s

enum E { e };

Expand Down
6 changes: 3 additions & 3 deletions clang/test/Parser/objc-init.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -pedantic -Wno-objc-root-class %s
// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -x objective-c++ -Wno-objc-root-class %s
// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -x objective-c++ -Wno-objc-root-class -std=c++98 %s
// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -x objective-c++ -Wno-objc-root-class -std=c++11 %s
// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -x objective-c++ -Wno-c99-designator -Wno-objc-root-class %s
// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -x objective-c++ -Wno-c99-designator -Wno-objc-root-class -std=c++98 %s
// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -x objective-c++ -Wno-c99-designator -Wno-objc-root-class -std=c++11 %s
// rdar://5707001

@interface NSNumber;
Expand Down
14 changes: 7 additions & 7 deletions clang/test/Sema/designated-initializers.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ int get8() { ++counter; return 8; }
void test() {
struct X xs[] = {
[0] = (struct X){1, 2}, // expected-note 2 {{previous initialization is here}}
[0].c = 3, // expected-warning{{subobject initialization overrides initialization of other fields within its enclosing subobject}}
[0].c = 3, // expected-warning{{initializer partially overrides prior initialization of this subobject}}
(struct X) {4, 5, 6}, // expected-note{{previous initialization is here}}
[1].b = get8(), // expected-warning{{subobject initialization overrides initialization of other fields within its enclosing subobject}}
[0].b = 8 // expected-warning{{subobject initialization overrides initialization of other fields within its enclosing subobject}}
[1].b = get8(), // expected-warning{{initializer partially overrides prior initialization of this subobject}}
[0].b = 8 // expected-warning{{initializer partially overrides prior initialization of this subobject}}
};
}

Expand Down Expand Up @@ -331,20 +331,20 @@ struct overwrite_string_struct {
char L[6];
int M;
} overwrite_string[] = {
{ { "foo" }, 1 }, // expected-note {{previous initialization is here}}
[0].L[2] = 'x' // expected-warning{{subobject initialization overrides initialization of other fields}}
{ { "foo" }, 1 }, // expected-note{{previous initialization is here}}
[0].L[2] = 'x' // expected-warning{{initializer partially overrides prior initialization of this subobject}}
};
struct overwrite_string_struct2 {
char L[6];
int M;
} overwrite_string2[] = {
{ { "foo" }, 1 }, // expected-note{{previous initialization is here}}
[0].L[4] = 'x' // expected-warning{{subobject initialization overrides initialization of other fields}}
[0].L[4] = 'x' // expected-warning{{initializer partially overrides prior initialization of this subobject}}
};
struct overwrite_string_struct
overwrite_string3[] = {
"foo", 1, // expected-note{{previous initialization is here}}
[0].L[4] = 'x' // expected-warning{{subobject initialization overrides initialization of other fields}}
[0].L[4] = 'x' // expected-warning{{initializer partially overrides prior initialization of this subobject}}
};
struct overwrite_string_struct
overwrite_string4[] = {
Expand Down
7 changes: 2 additions & 5 deletions clang/test/Sema/static-assert.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -std=c11 -fsyntax-only -verify %s
// RUN: %clang_cc1 -std=c99 -pedantic -fsyntax-only -verify=expected,ext %s
// RUN: %clang_cc1 -xc++ -std=c++11 -pedantic -fsyntax-only -verify=expected,ext %s
// RUN: %clang_cc1 -xc++ -std=c++11 -pedantic -fsyntax-only -verify=expected,ext,cxx %s

_Static_assert("foo", "string is nonzero"); // ext-warning {{'_Static_assert' is a C11 extension}}
#ifndef __cplusplus
Expand Down Expand Up @@ -42,10 +42,7 @@ struct A {
}

typedef UNION(unsigned, struct A) U1; // ext-warning 3 {{'_Static_assert' is a C11 extension}}
UNION(char[2], short) u2 = { .one = { 'a', 'b' } }; // ext-warning 3 {{'_Static_assert' is a C11 extension}}
#if defined(__cplusplus)
// ext-warning@-2 {{designated initializers are a C99 feature}}
#endif
UNION(char[2], short) u2 = { .one = { 'a', 'b' } }; // ext-warning 3 {{'_Static_assert' is a C11 extension}} cxx-warning {{designated initializers are a C++20 extension}}
typedef UNION(char, short) U3; // expected-error {{static_assert failed due to requirement 'sizeof(char) == sizeof(short)' "type size mismatch"}} \
// ext-warning 3 {{'_Static_assert' is a C11 extension}}
typedef UNION(float, 0.5f) U4; // expected-error {{expected a type}} \
Expand Down
7 changes: 4 additions & 3 deletions clang/test/SemaCXX/aggregate-initialization.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++2a %s

// Verify that using an initializer list for a non-aggregate looks for
// constructors..
Expand Down
69 changes: 65 additions & 4 deletions clang/test/SemaCXX/c99.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,70 @@
// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
// RUN: %clang_cc1 -fsyntax-only -pedantic -verify=expected,cxx17 -std=c++17 %s
// RUN: %clang_cc1 -fsyntax-only -pedantic -verify=expected,cxx20 -std=c++2a %s

// cxx17-warning@* 0+{{designated initializers are a C++20 extension}}

void f1(int i[static 5]) { // expected-error{{C99}}
}

struct Point { int x; int y; int z[]; }; // expected-warning{{flexible array members are a C99 feature}}

Point p1 = { .x = 17, // expected-warning{{designated initializers are a C99 feature}}
y: 25 }; // expected-warning{{designated initializers are a C99 feature}} \
// expected-warning{{use of GNU old-style field designator extension}}
Point p1 = { .x = 17,
y: 25 }; // expected-warning{{use of GNU old-style field designator extension}}

Point p2 = {
.x = 17, // expected-warning {{mixture of designated and non-designated initializers in the same initializer list is a C99 extension}}
25 // expected-note {{first non-designated initializer}}
};

Point p3 = {
.x = 17, // expected-note {{previous initialization is here}}
.x = 18, // expected-warning {{initializer overrides prior initialization of this subobject}}
};

Point p4 = {
.x = 17, // expected-warning {{mixture of designated and non-designated initializers in the same initializer list is a C99 extension}}
25, // expected-note {{first non-designated initializer}}
// expected-note@-1 {{previous initialization is here}}
.y = 18, // expected-warning {{initializer overrides prior initialization of this subobject}}
};

int arr[1] = {[0] = 0}; // expected-warning {{array designators are a C99 extension}}

struct Pt { int x, y; };
struct Rect { Pt tl, br; };
Rect r = {
.tl.x = 0 // expected-warning {{nested designators are a C99 extension}}
};

struct NonTrivial {
NonTrivial();
~NonTrivial();
};
struct S {
int a;
NonTrivial b;
};
struct T {
S s;
};
S f();

T t1 = {
.s = f()
};

// It's important that we reject this; we would not destroy the existing
// 'NonTrivial' object before overwriting it (and even calling its destructor
// would not necessarily be correct).
T t2 = {
.s = f(), // expected-note {{previous}}
.s.b = NonTrivial() // expected-error {{initializer would partially override prior initialization of object of type 'S' with non-trivial destruction}}
// expected-warning@-1 {{nested}}
};

// FIXME: It might be reasonable to accept this.
T t3 = {
.s = f(), // expected-note {{previous}}
.s.a = 0 // expected-error {{initializer would partially override prior initialization of object of type 'S' with non-trivial destruction}}
// expected-warning@-1 {{nested}}
};
6 changes: 3 additions & 3 deletions clang/test/SemaCXX/constant-expression-cxx11.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -triple x86_64-linux -Wno-string-plus-int -Wno-pointer-arith -Wno-zero-length-array -fsyntax-only -fcxx-exceptions -verify -std=c++11 -pedantic %s -Wno-comment -Wno-tautological-pointer-compare -Wno-bool-conversion
// RUN: %clang_cc1 -triple x86_64-linux -Wno-string-plus-int -Wno-pointer-arith -Wno-zero-length-array -Wno-c99-designator -fsyntax-only -fcxx-exceptions -verify -std=c++11 -pedantic %s -Wno-comment -Wno-tautological-pointer-compare -Wno-bool-conversion

namespace StaticAssertFoldTest {

Expand Down Expand Up @@ -566,7 +566,7 @@ static_assert(fail(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][2] - 2)) == 11, "
expected-error {{static_assert expression is not an integral constant expression}} \
expected-note {{in call to 'fail(zs[1][0][1][0])'}}

constexpr int arr[40] = { 1, 2, 3, [8] = 4 }; // expected-warning {{C99 feature}}
constexpr int arr[40] = { 1, 2, 3, [8] = 4 };
constexpr int SumNonzero(const int *p) {
return *p + (*p ? SumNonzero(p+1) : 0);
}
Expand Down Expand Up @@ -979,7 +979,7 @@ union U {
int b;
};

constexpr U u[4] = { { .a = 0 }, { .b = 1 }, { .a = 2 }, { .b = 3 } }; // expected-warning 4{{C99 feature}}
constexpr U u[4] = { { .a = 0 }, { .b = 1 }, { .a = 2 }, { .b = 3 } };
static_assert(u[0].a == 0, "");
static_assert(u[0].b, ""); // expected-error {{constant expression}} expected-note {{read of member 'b' of union with active member 'a'}}
static_assert(u[1].b == 1, "");
Expand Down
6 changes: 1 addition & 5 deletions clang/test/SemaCXX/constexpr-printing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ expected-error {{constant expression}} \
expected-note {{in call to 'test_printing(12, 3.976200e+01, 3+4i, 1.290000e+01+3.600000e+00i, &u2.T::arr[4], u2.another.arr[2], {5, 1, 2, 3}, {{{}}, {{}}, &u1.T::arr[2]})'}}

struct V {
// FIXME: when we can generate these as constexpr constructors, remove the
// explicit definitions.
constexpr V() : arr{[255] = 42} {}
constexpr V(const V &v) : arr{[255] = 42} {}
int arr[256];
int arr[256] = {[255] = 42}; // expected-warning {{C99}}
};
constexpr V v;
constexpr int get(const int *p) { return *p; } // expected-note {{read of dereferenced one-past-the-end pointer}}
Expand Down
2 changes: 1 addition & 1 deletion clang/test/SemaCXX/cxx0x-initializer-constructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,6 @@ namespace PR11410 {
0, 1
}; // expected-error {{ambiguous}} expected-note {{in implicit initialization of array element 2}}
C c2[3] = {
[0] = 1, [2] = 3
[0] = 1, [2] = 3 // expected-warning {{C99}}
}; // expected-error {{ambiguous}} expected-note {{in implicit initialization of array element 1}}
}
109 changes: 108 additions & 1 deletion clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
// RUN: %clang_cc1 -std=c++2a %s -verify
// RUN: %clang_cc1 -std=c++2a %s -verify=expected,pedantic,override,reorder -pedantic-errors
// RUN: %clang_cc1 -std=c++2a %s -verify=expected,pedantic -Werror=c99-designator -Wno-reorder -Wno-initializer-overrides
// RUN: %clang_cc1 -std=c++2a %s -verify=expected,reorder -Wno-c99-designator -Werror=reorder -Wno-initializer-overrides
// RUN: %clang_cc1 -std=c++2a %s -verify=expected,override -Wno-c99-designator -Wno-reorder -Werror=initializer-overrides
// RUN: %clang_cc1 -std=c++2a %s -verify -Wno-c99-designator -Wno-reorder -Wno-initializer-overrides


namespace class_with_ctor {
struct A { // expected-note 6{{candidate}}
Expand All @@ -21,3 +26,105 @@ namespace class_with_ctor {
C c1 = {{}, {}}; // ok, call default ctor twice
C c2 = {{1, 2}, {3, 4}}; // expected-error 2{{no matching constructor}}
}

namespace designator {
struct A { int x, y; };
struct B { A a; };

A a1 = {
.y = 1, // reorder-note {{previous initialization for field 'y' is here}}
.x = 2 // reorder-error {{ISO C++ requires field designators to be specified in declaration order; field 'y' will be initialized after field 'x'}}
};
int arr[3] = {[1] = 5}; // pedantic-error {{array designators are a C99 extension}}
B b = {.a.x = 0}; // pedantic-error {{nested designators are a C99 extension}}
A a2 = {
.x = 1, // pedantic-error {{mixture of designated and non-designated initializers in the same initializer list is a C99 extension}}
2 // pedantic-note {{first non-designated initializer is here}}
};
A a3 = {
1, // pedantic-note {{first non-designated initializer is here}}
.y = 2 // pedantic-error {{mixture of designated and non-designated initializers in the same initializer list is a C99 extension}}
};
A a4 = {
.x = 1, // override-note {{previous}}
.x = 1 // override-error {{overrides prior initialization}}
};
A a5 = {
.y = 1, // override-note {{previous}}
.y = 1 // override-error {{overrides prior initialization}}
};
struct C { int :0, x, :0, y, :0; };
C c = {
.x = 1, // override-note {{previous}}
.x = 1, // override-error {{overrides prior initialization}} override-note {{previous}}
.y = 1, // override-note {{previous}}
.y = 1, // override-error {{overrides prior initialization}}
.x = 1, // reorder-error {{declaration order}} override-error {{overrides prior initialization}} override-note {{previous}}
.x = 1, // override-error {{overrides prior initialization}}
};
}

namespace base_class {
struct base {
int x;
};
struct derived : base {
int y;
};
derived d = {.x = 1, .y = 2}; // expected-error {{'x' does not refer to any field}}
}

namespace union_ {
union U { int a, b; };
U u = {
.a = 1, // override-note {{here}}
.b = 2, // override-error {{overrides prior}}
};
}

namespace overload_resolution {
struct A { int x, y; };
union B { int x, y; };

void f(A a);
void f(B b) = delete;
void g() { f({.x = 1, .y = 2}); } // ok, calls non-union overload

// As an extension of the union case, overload resolution won't pick any
// candidate where a field initializer would be overridden.
struct A2 { int x, other, y; };
int f(A2);
void g2() { int k = f({.x = 1, 2, .y = 3}); (void)k; } // pedantic-error {{mixture of designated and non-designated}} pedantic-note {{here}}

struct C { int x; };
void h(A a); // expected-note {{candidate}}
void h(C c); // expected-note {{candidate}}
void i() {
h({.x = 1, .y = 2});
h({.y = 1, .x = 2}); // reorder-error {{declaration order}} reorder-note {{previous}}
h({.x = 1}); // expected-error {{ambiguous}}
}

struct D { int y, x; };
void j(A a); // expected-note {{candidate}}
void j(D d); // expected-note {{candidate}}
void k() {
j({.x = 1, .y = 2}); // expected-error {{ambiguous}}
}
}

namespace deduction {
struct A { int x, y; };
union B { int x, y; };

template<typename T, typename U> void f(decltype(T{.x = 1, .y = 2}) = {});
template<typename T, typename U> void f(decltype(U{.x = 1, .y = 2}) = {}) = delete;
void g() { f<A, B>(); } // ok, calls non-union overload

struct C { int y, x; };
template<typename T, typename U> void h(decltype(T{.y = 1, .x = 2}) = {}) = delete;
template<typename T, typename U> void h(decltype(U{.y = 1, .x = 2}) = {});
void i() {
h<A, C>(); // ok, selects C overload by SFINAE
}
}
10 changes: 5 additions & 5 deletions clang/test/SemaCXX/decltype.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Wno-c99-designator %s

// PR5290
int const f0();
Expand Down Expand Up @@ -80,22 +80,22 @@ namespace D5789 {
struct P1 { char x[6]; } g1 = { "foo" };
struct LP1 { struct P1 p1; };

// expected-warning@+3 {{subobject initialization overrides}}
// expected-warning@+3 {{initializer partially overrides}}
// expected-note@+2 {{previous initialization}}
// expected-note@+1 {{previous definition}}
template<class T> void foo(decltype(T(LP1{ .p1 = g1, .p1.x[1] = 'x' }))) {}

// expected-warning@+3 {{subobject initialization overrides}}
// expected-warning@+3 {{initializer partially overrides}}
// expected-note@+2 {{previous initialization}}
template<class T>
void foo(decltype(T(LP1{ .p1 = g1, .p1.x[1] = 'r' }))) {} // okay

// expected-warning@+3 {{subobject initialization overrides}}
// expected-warning@+3 {{initializer partially overrides}}
// expected-note@+2 {{previous initialization}}
template<class T>
void foo(decltype(T(LP1{ .p1 = { "foo" }, .p1.x[1] = 'x'}))) {} // okay

// expected-warning@+3 {{subobject initialization overrides}}
// expected-warning@+3 {{initializer partially overrides}}
// expected-note@+2 {{previous initialization}}
// expected-error@+1 {{redefinition of 'foo'}}
template<class T> void foo(decltype(T(LP1{ .p1 = g1, .p1.x[1] = 'x' }))) {}
Expand Down
3 changes: 1 addition & 2 deletions clang/test/SemaCXX/designated-initializers-base-class.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// RUN: %clang_cc1 %s -std=c++1z -fsyntax-only -verify -Winitializer-overrides
// expected-no-diagnostics

struct B {
int x;
Expand All @@ -9,4 +8,4 @@ struct D : B {
int y;
};

void test() { D d = {1, .y = 2}; }
void test() { D d = {1, .y = 2}; } // expected-warning {{C99 extension}} expected-note {{}}
4 changes: 2 additions & 2 deletions clang/test/SemaCXX/designated-initializers.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Winitializer-overrides %s
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Woverride-init %s
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Wno-reorder -Wno-c99-designator -Winitializer-overrides %s
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Wno-reorder -Wno-c99-designator -Woverride-init %s

template <typename T> struct Foo {
struct SubFoo {
Expand Down
2 changes: 1 addition & 1 deletion clang/test/SemaCXX/eval-crashes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace pr33140_3 {
struct X {
Y_t a;
};
struct X foo[2] = {[0 ... 1] = {.a = (Y_t){.c = 0}}};
struct X foo[2] = {[0 ... 1] = {.a = (Y_t){.c = 0}}}; // expected-warning {{C99 extension}}
}

namespace pr33140_6 {
Expand Down
2 changes: 1 addition & 1 deletion clang/test/SemaCXX/member-init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void g() { f<int>(); } // expected-note {{in instantiation of function template
namespace PR22056 {
template <int N>
struct S {
int x[3] = {[N] = 3};
int x[3] = {[N] = 3}; // expected-warning {{C99 extension}}
};
}

Expand Down
2 changes: 1 addition & 1 deletion clang/test/SemaObjCXX/message.mm
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ + (int *)otherMethod {
#if __cplusplus <= 199711L
// expected-warning@-2 {{'typename' occurs outside of a template}}
#endif
int array[5] = {[3] = 2};
int array[5] = {[3] = 2}; // expected-warning {{C99 extension}}
return [super method];
}
@end
Expand Down
6 changes: 3 additions & 3 deletions clang/test/SemaTemplate/instantiate-c99.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
// RUN: %clang_cc1 -Wno-c99-extensions -Wno-reorder -fsyntax-only -verify %s
// RUN: %clang_cc1 -Wno-c99-extensions -Wno-reorder -fsyntax-only -verify -std=c++98 %s
// RUN: %clang_cc1 -Wno-c99-extensions -Wno-reorder -fsyntax-only -verify -std=c++11 %s

// Test template instantiation for C99-specific features.

Expand Down
4 changes: 2 additions & 2 deletions clang/test/SemaTemplate/instantiate-init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ namespace InitListUpdate {

// Check that an init list update doesn't "lose" the pack-ness of an expression.
template <int... N> void f() {
g(AA{0, [0].n = N} ...); // expected-warning 3{{overrides prior init}} expected-note 3{{previous init}}
g(AA{N, [0].n = 0} ...); // expected-warning 3{{overrides prior init}} expected-note 3{{previous init}}
g(AA{0, [0].n = N} ...); // expected-warning 3{{extension}} expected-note {{here}} expected-warning 3{{overrides prior init}} expected-note 3{{previous init}}
g(AA{N, [0].n = 0} ...); // expected-warning 3{{extension}} expected-note {{here}} expected-warning 3{{overrides prior init}} expected-note 3{{previous init}}
};

void g(AA, AA);
Expand Down