diff options
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/include/clang/AST/Decl.h | 4 | ||||
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 8 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaType.cpp | 14 | ||||
| -rw-r--r-- | clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p2.cpp | 8 | ||||
| -rw-r--r-- | clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp | 4 | ||||
| -rw-r--r-- | clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp | 2 | 
6 files changed, 30 insertions, 10 deletions
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 841aa3b59c7..7ba2668107d 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -1794,8 +1794,8 @@ public:    }    /// \brief Determine whether this function should be inlined, because it is -  /// either marked "inline" or is a member function of a C++ class that -  /// was defined in the class body. +  /// either marked "inline" or "constexpr" or is a member function of a class +  /// that was defined in the class body.    bool isInlined() const;    bool isInlineDefinitionExternallyVisible() const; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 5330fb39563..1b974b0c024 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -4292,8 +4292,8 @@ def err_defaulted_copy_assign_const_param : Error<    "the parameter for this explicitly-defaulted copy assignment operator is "    "const, but a member or base requires it to be non-const">;  def err_defaulted_copy_assign_quals : Error< -  "an explicitly-defaulted copy assignment operator may not have 'const' " -  "or 'volatile' qualifiers">; +  "an explicitly-defaulted copy assignment operator may not have 'const', " +  "'constexpr' or 'volatile' qualifiers">;  def err_defaulted_move_ctor_params : Error<    "an explicitly-defaulted move constructor must have exactly one parameter">;  def err_defaulted_move_ctor_volatile_param : Error< @@ -4318,8 +4318,8 @@ def err_defaulted_move_assign_const_param : Error<    "the parameter for an explicitly-defaulted move assignment operator may not "    "be const">;  def err_defaulted_move_assign_quals : Error< -  "an explicitly-defaulted move assignment operator may not have 'const' " -  "or 'volatile' qualifiers">; +  "an explicitly-defaulted move assignment operator may not have 'const', " +  "'constexpr' or 'volatile' qualifiers">;  def err_incorrect_defaulted_exception_spec : Error<    "exception specification of explicitly defaulted %select{default constructor|"    "copy constructor|move constructor|copy assignment operator|move assignment " diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 85112dbe21e..480dd3b85a0 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -2325,6 +2325,20 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,        FreeFunction = (DC && !DC->isRecord());      } +    // C++0x [dcl.constexpr]p8: A constexpr specifier for a non-static member +    // function that is not a constructor declares that function to be const. +    if (D.getDeclSpec().isConstexprSpecified() && !FreeFunction && +        D.getName().getKind() != UnqualifiedId::IK_ConstructorName && +        D.getName().getKind() != UnqualifiedId::IK_ConstructorTemplateId && +        !(FnTy->getTypeQuals() & DeclSpec::TQ_const)) { +      // Rebuild function type adding a 'const' qualifier. +      FunctionProtoType::ExtProtoInfo EPI = FnTy->getExtProtoInfo(); +      EPI.TypeQuals |= DeclSpec::TQ_const; +      T = Context.getFunctionType(FnTy->getResultType(),  +                                  FnTy->arg_type_begin(), +                                  FnTy->getNumArgs(), EPI); +    } +      // C++0x [dcl.fct]p6:      //   A ref-qualifier shall only be part of the function type for a      //   non-static member function, the function type to which a pointer to diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p2.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p2.cpp index 25470779e6d..77a3e26de47 100644 --- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p2.cpp +++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p2.cpp @@ -3,6 +3,7 @@  // constexpr functions and constexpr constructors are implicitly inline.  struct S {    constexpr S(int n); +  constexpr int g();    int n;  }; @@ -12,9 +13,14 @@ constexpr S f(S s) {    return s.n * 2;  } +constexpr int S::g() { +  return f(*this).n; +} +  // CHECK: define linkonce_odr {{.*}} @_Z1f1S(  // CHECK: define linkonce_odr {{.*}} @_ZN1SC1Ei( +// CHECK: define linkonce_odr {{.*}} @_ZNK1S1gEv(  int g() { -  return f(42).n; +  return f(42).g();  } diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp index 6b964dba31c..55adbf0c125 100644 --- a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp +++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp @@ -22,7 +22,7 @@ namespace move {    };    struct ConstAssignment { -    ConstAssignment& operator=(ConstAssignment&&) const = default; // expected-error {{an explicitly-defaulted move assignment operator may not have 'const' or 'volatile' qualifiers}} +    ConstAssignment& operator=(ConstAssignment&&) const = default; // expected-error {{an explicitly-defaulted move assignment operator may not have 'const', 'constexpr' or 'volatile' qualifiers}}    };  } @@ -57,6 +57,6 @@ namespace copy {    };    struct ConstAssignment { -    ConstAssignment& operator=(const ConstAssignment&) const = default; // expected-error {{an explicitly-defaulted copy assignment operator may not have 'const' or 'volatile' qualifiers}} +    ConstAssignment& operator=(const ConstAssignment&) const = default; // expected-error {{an explicitly-defaulted copy assignment operator may not have 'const', 'constexpr' or 'volatile' qualifiers}}    };  } diff --git a/clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp b/clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp index 61aee0e4563..9d4443c8878 100644 --- a/clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp +++ b/clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp @@ -35,7 +35,7 @@ struct bad_decls {    bad_decls(volatile bad_decls&) = default; // expected-error {{may not be volatile}}    bad_decls&& operator = (bad_decls) = default; // expected-error 2{{lvalue reference}}    bad_decls& operator = (volatile bad_decls&) = default; // expected-error {{may not be volatile}} -  bad_decls& operator = (const bad_decls&) const = default; // expected-error {{may not have 'const' or 'volatile' qualifiers}} +  bad_decls& operator = (const bad_decls&) const = default; // expected-error {{may not have 'const', 'constexpr' or 'volatile' qualifiers}}  };  struct A {}; struct B {};  | 

