]> granicus.if.org Git - clang/commitdiff
Diagnose an attempt to give a deduction-guide a function body.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 8 Feb 2017 01:27:29 +0000 (01:27 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 8 Feb 2017 01:27:29 +0000 (01:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294397 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDeclCXX.cpp
test/CXX/temp/temp.deduct.guide/p1.cpp

index b04ba2b5ede2f554876d72b0ecd88ce2437852d5..04a404e104d98e58dd6ee7aeef62b7eec8ade450 100644 (file)
@@ -1972,6 +1972,8 @@ def err_deduction_guide_name_not_class_template : Error<
   "cannot specify deduction guide for "
   "%select{<error>|function template|variable template|alias template|"
   "template template parameter|dependent template name}0 %1">;
+def err_deduction_guide_defines_function : Error<
+  "deduction guide cannot have a function definition">;
 
 // C++1y deduced return types
 def err_auto_fn_deduction_failure : Error<
index 1ae89ea89b2d12f59330fb20200b822ec4fd67c0..e3310b60a2dfe9bc15f995d62e91eea179be98f4 100644 (file)
@@ -8129,6 +8129,9 @@ void Sema::CheckDeductionGuideDeclarator(Declarator &D, QualType &R,
 
   // FIXME: Check that the return type can instantiate to a specialization of
   // the template specified as the deduction-guide's name.
+
+  if (D.isFunctionDefinition())
+    Diag(D.getIdentifierLoc(), diag::err_deduction_guide_defines_function);
 }
 
 //===----------------------------------------------------------------------===//
index fb0a26a5c735d650927cd4a44e285147fee6cef9..8dd0720669ae9639fc41ae9daa6a0db2b9548076 100644 (file)
@@ -77,11 +77,11 @@ const volatile static constexpr inline A(int(&)[29]) -> A<int>; // expected-erro
 
 A(int(&)[30]) const -> A<int>; // expected-error {{deduction guide cannot have 'const' qualifier}}
 
-// FIXME: No definition is allowed.
-A(int(&)[40]) -> A<int> {}
-A(int(&)[41]) -> A<int> = default; // expected-error {{only special member functions may be defaulted}}
-A(int(&)[42]) -> A<int> = delete;
-A(int(&)[43]) -> A<int> try {} catch (...) {}
+// No definition is allowed.
+A(int(&)[40]) -> A<int> {} // expected-error {{deduction guide cannot have a function definition}}
+A(int(&)[41]) -> A<int> = default; // expected-error {{deduction guide cannot have a function definition}} expected-error {{only special member functions may be defaulted}}
+A(int(&)[42]) -> A<int> = delete; // expected-error {{deduction guide cannot have a function definition}}
+A(int(&)[43]) -> A<int> try {} catch (...) {} // expected-error {{deduction guide cannot have a function definition}}
 
 #ifdef CLASS
 };