r195862 - Adding the Subjects entry back for the noreturn attributes. This caused some test cases to be updated because the original diagnostic was about applying to methods as well as functions, but the semantic checking disallowed methods.

Aaron Ballman aaron at aaronballman.com
Wed Nov 27 10:53:59 PST 2013


Author: aaronballman
Date: Wed Nov 27 12:53:58 2013
New Revision: 195862

URL: http://llvm.org/viewvc/llvm-project?rev=195862&view=rev
Log:
Adding the Subjects entry back for the noreturn attributes. This caused some test cases to be updated because the original diagnostic was about applying to methods as well as functions, but the semantic checking disallowed methods.

Modified:
    cfe/trunk/include/clang/Basic/Attr.td
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp
    cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
    cfe/trunk/test/Parser/cxx0x-attributes.cpp
    cfe/trunk/test/Parser/objcxx11-attributes.mm

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=195862&r1=195861&r2=195862&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed Nov 27 12:53:58 2013
@@ -369,13 +369,13 @@ def CUDAShared : InheritableAttr {
 
 def C11NoReturn : InheritableAttr {
   let Spellings = [Keyword<"_Noreturn">];
-//  let Subjects = SubjectList<[Function], ErrorDiag>;
+  let Subjects = SubjectList<[Function], ErrorDiag>;
   let SemaHandler = 0;
 }
 
 def CXX11NoReturn : InheritableAttr {
   let Spellings = [CXX11<"","noreturn">, CXX11<"std","noreturn">];
-//  let Subjects = SubjectList<[Function], ErrorDiag>;
+  let Subjects = SubjectList<[Function], ErrorDiag>;
 }
 
 def OpenCLKernel : InheritableAttr {

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=195862&r1=195861&r2=195862&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Nov 27 12:53:58 2013
@@ -1672,23 +1672,6 @@ static void handleAnalyzerNoReturnAttr(S
                                   Attr.getAttributeSpellingListIndex()));
 }
 
-static void handleCXX11NoReturnAttr(Sema &S, Decl *D,
-                                    const AttributeList &Attr) {
-  // C++11 [dcl.attr.noreturn]p1:
-  //   The attribute may be applied to the declarator-id in a function
-  //   declaration.
-  FunctionDecl *FD = dyn_cast<FunctionDecl>(D);
-  if (!FD) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type)
-      << Attr.getName() << ExpectedFunctionOrMethod;
-    return;
-  }
-
-  D->addAttr(::new (S.Context)
-             CXX11NoReturnAttr(Attr.getRange(), S.Context,
-                               Attr.getAttributeSpellingListIndex()));
-}
-
 // PS3 PPU-specific.
 static void handleVecReturnAttr(Sema &S, Decl *D, const AttributeList &Attr) {
 /*
@@ -4195,8 +4178,7 @@ static void ProcessDeclAttribute(Sema &S
   case AttributeList::AT_CUDAConstant:handleConstantAttr    (S, D, Attr); break;
   case AttributeList::AT_Constructor: handleConstructorAttr (S, D, Attr); break;
   case AttributeList::AT_CXX11NoReturn:
-    handleCXX11NoReturnAttr(S, D, Attr);
-    break;
+  handleSimpleAttribute<CXX11NoReturnAttr>(S, D, Attr); break;
   case AttributeList::AT_Deprecated:
     handleAttrWithMessage<DeprecatedAttr>(S, D, Attr);
     break;

Modified: cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp?rev=195862&r1=195861&r2=195862&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp (original)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp Wed Nov 27 12:53:58 2013
@@ -13,7 +13,7 @@ void a2 [[noreturn]] () {
 [[noreturn()]] void c(); // expected-error {{attribute 'noreturn' cannot have an argument list}}
 
 void d() [[noreturn]]; // expected-error {{'noreturn' attribute cannot be applied to types}}
-int d2 [[noreturn]]; // expected-error {{'noreturn' attribute only applies to functions and methods}}
+int d2 [[noreturn]]; // expected-error {{'noreturn' attribute only applies to functions}}
 
 [[noreturn]] int e() { b2(); } // ok
 

Modified: cfe/trunk/test/Parser/cxx0x-attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx0x-attributes.cpp?rev=195862&r1=195861&r2=195862&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx0x-attributes.cpp (original)
+++ cfe/trunk/test/Parser/cxx0x-attributes.cpp Wed Nov 27 12:53:58 2013
@@ -78,11 +78,11 @@ class c [[]] [[]] y [[]] [[]];
 class c final [(int){0}];
 
 class base {};
-class [[]] [[]] final_class 
+class [[]] [[]] final_class
   alignas(float) [[]] final // expected-error {{an attribute list cannot appear here}}
   alignas(float) [[]] [[]] alignas(float): base{}; // expected-error {{an attribute list cannot appear here}}
 
-class [[]] [[]] final_class_another 
+class [[]] [[]] final_class_another
   [[]] [[]] alignas(16) final // expected-error {{an attribute list cannot appear here}}
   [[]] [[]] alignas(16) [[]]{}; // expected-error {{an attribute list cannot appear here}}
 
@@ -120,7 +120,7 @@ extern "C++" [[]] { } // expected-error
 
 [[]] using ns::i; // expected-error {{an attribute list cannot appear here}}
 [[unknown]] using namespace ns; // expected-warning {{unknown attribute 'unknown' ignored}}
-[[noreturn]] using namespace ns; // expected-error {{'noreturn' attribute only applies to functions and methods}}
+[[noreturn]] using namespace ns; // expected-error {{'noreturn' attribute only applies to functions}}
 
 using [[]] alignas(4) [[]] ns::i; // expected-error {{an attribute list cannot appear here}}
 using [[]] alignas(4) [[]] foobar = int; // expected-error {{an attribute list cannot appear here}} expected-error {{'alignas' attribute only applies to}}
@@ -146,7 +146,7 @@ template<typename T> using U [[]] = T;
 using ns::i [[]]; // expected-error {{an attribute list cannot appear here}}
 using [[]] ns::i; // expected-error {{an attribute list cannot appear here}}
 using T [[unknown]] = int; // expected-warning {{unknown attribute 'unknown' ignored}}
-using T [[noreturn]] = int; // expected-error {{'noreturn' attribute only applies to functions and methods}}
+using T [[noreturn]] = int; // expected-error {{'noreturn' attribute only applies to functions}}
 using V = int; // expected-note {{previous}}
 using V [[gnu::vector_size(16)]] = int; // expected-error {{redefinition with different types}}
 
@@ -210,16 +210,16 @@ void foo () {
     [[]] continue;
   } while (0);
   [[]] while (0);
-  
+
   [[]] switch (i) {
     [[]] case 0:
     [[]] default:
       [[]] break;
   }
-  
+
   [[]] goto there;
   [[]] there:
-  
+
   [[]] try {
   } [[]] catch (...) { // expected-error {{an attribute list cannot appear here}}
   }
@@ -297,7 +297,7 @@ int v4[2][[gnu::unused]]; // expected-wa
 int v5()[[gnu::unused]]; // expected-warning {{attribute 'unused' ignored}}
 
 [[attribute_declaration]]; // expected-warning {{unknown attribute 'attribute_declaration' ignored}}
-[[noreturn]]; // expected-error {{'noreturn' attribute only applies to functions and methods}}
+[[noreturn]]; // expected-error {{'noreturn' attribute only applies to functions}}
 [[carries_dependency]]; // expected-error {{'carries_dependency' attribute only applies to functions, methods, and parameters}}
 
 class A {

Modified: cfe/trunk/test/Parser/objcxx11-attributes.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objcxx11-attributes.mm?rev=195862&r1=195861&r2=195862&view=diff
==============================================================================
--- cfe/trunk/test/Parser/objcxx11-attributes.mm (original)
+++ cfe/trunk/test/Parser/objcxx11-attributes.mm Wed Nov 27 12:53:58 2013
@@ -13,12 +13,12 @@ void f(X *noreturn) {
   int a[ [noreturn getSize] ];
 
   // ... but is interpreted as an attribute where possible.
-  int b[ [noreturn] ]; // expected-error {{'noreturn' attribute only applies to functions and methods}}
+  int b[ [noreturn] ]; // expected-error {{'noreturn' attribute only applies to functions}}
 
   int c[ [noreturn getSize] + 1 ];
 
   // An array size which is computed by a lambda is not OK.
-  int d[ [noreturn] { return 3; } () ]; // expected-error {{expected ']'}} expected-error {{'noreturn' attribute only applies}}
+  int d[ [noreturn] { return 3; } () ]; // expected-error {{expected ']'}} expected-error {{'noreturn' attribute only applies to functions}}
 
   // A message send which contains a message send is OK.
   [ [ X alloc ] init ];





More information about the cfe-commits mailing list