Don't allow __attribute__((common)) in C++. PR16330.

llvm-svn: 184493
This commit is contained in:
Eli Friedman 2013-06-20 22:55:04 +00:00
parent 663150f637
commit 6fc7ad1107
3 changed files with 11 additions and 0 deletions

View File

@ -1826,6 +1826,8 @@ def err_format_attribute_result_not : Error<"function does not return %0">;
def err_format_attribute_implicit_this_format_string : Error<
"format attribute cannot specify the implicit this argument as the format "
"string">;
def err_common_not_supported_cplusplus : Error<
"common attribute is not supported in C++">;
def warn_unknown_method_family : Warning<"unrecognized method family">;
def err_init_method_bad_return_type : Error<
"init methods must return an object pointer type, not %0">;

View File

@ -1746,6 +1746,12 @@ static void handleNoCommonAttr(Sema &S, Decl *D, const AttributeList &Attr) {
static void handleCommonAttr(Sema &S, Decl *D, const AttributeList &Attr) {
assert(!Attr.isInvalid());
if (S.LangOpts.CPlusPlus) {
S.Diag(Attr.getLoc(), diag::err_common_not_supported_cplusplus);
return;
}
if (isa<VarDecl>(D))
D->addAttr(::new (S.Context)
CommonAttr(Attr.getRange(), S.Context,

View File

@ -0,0 +1,3 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
__attribute__((common)) int x; // expected-error {{common attribute is not supported in C++}}