r184493 - Don't allow __attribute__((common)) in C++. PR16330.
Eli Friedman
eli.friedman at gmail.com
Thu Jun 20 15:55:04 PDT 2013
Author: efriedma
Date: Thu Jun 20 17:55:04 2013
New Revision: 184493
URL: http://llvm.org/viewvc/llvm-project?rev=184493&view=rev
Log:
Don't allow __attribute__((common)) in C++. PR16330.
Added:
cfe/trunk/test/SemaCXX/attr-common.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=184493&r1=184492&r2=184493&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jun 20 17:55:04 2013
@@ -1826,6 +1826,8 @@ def err_format_attribute_result_not : Er
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">;
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=184493&r1=184492&r2=184493&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Jun 20 17:55:04 2013
@@ -1746,6 +1746,12 @@ static void handleNoCommonAttr(Sema &S,
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,
Added: cfe/trunk/test/SemaCXX/attr-common.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-common.cpp?rev=184493&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/attr-common.cpp (added)
+++ cfe/trunk/test/SemaCXX/attr-common.cpp Thu Jun 20 17:55:04 2013
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+__attribute__((common)) int x; // expected-error {{common attribute is not supported in C++}}
More information about the cfe-commits
mailing list