зеркало из https://github.com/microsoft/clang.git
Emit an extension diagnostic for C99 designated initializers that appear in C++ code
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123582 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
9da95e6eef
Коммит
2d75bbd36e
|
@ -56,6 +56,8 @@ def err_variably_modified_new_type : Error<
|
|||
"'new' cannot allocate object of variably modified type %0">;
|
||||
|
||||
// C99 Designated Initializers
|
||||
def ext_designated_init : Extension<
|
||||
"designated initializers are a C99 feature, accepted in C++ as an extension">;
|
||||
def err_array_designator_negative : Error<
|
||||
"array designator value '%0' is negative">;
|
||||
def err_array_designator_empty_range : Error<
|
||||
|
|
|
@ -1913,6 +1913,11 @@ ExprResult Sema::ActOnDesignatedInitializer(Designation &Desig,
|
|||
Designators.data(), Designators.size(),
|
||||
InitExpressions.data(), InitExpressions.size(),
|
||||
Loc, GNUSyntax, Init.takeAs<Expr>());
|
||||
|
||||
if (getLangOptions().CPlusPlus)
|
||||
Diag(DIE->getLocStart(), diag::ext_designated_init)
|
||||
<< DIE->getSourceRange();
|
||||
|
||||
return Owned(DIE);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||
// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
|
||||
void f1(int i[static 5]) { // expected-error{{C99}}
|
||||
}
|
||||
|
||||
struct Point { int x; int y; };
|
||||
|
||||
Point p1 = { .x = 17, // expected-warning{{designated initializers are a C99 feature, accepted in C++ as an extension}}
|
||||
y: 25 }; // expected-warning{{designated initializers are a C99 feature, accepted in C++ as an extension}} \
|
||||
// expected-warning{{use of GNU old-style field designator extension}}
|
||||
|
|
Загрузка…
Ссылка в новой задаче