diff options
| author | Anders Carlsson <andersca@mac.com> | 2009-07-07 19:06:02 +0000 |
|---|---|---|
| committer | Anders Carlsson <andersca@mac.com> | 2009-07-07 19:06:02 +0000 |
| commit | 1f9648da17c784e8d1923adc49b2cf5220b7badd (patch) | |
| tree | a5157f194f91843f5b0bf70ba1308ec6ac6d5458 /clang/lib/Sema/SemaExprCXX.cpp | |
| parent | 54731d5cde5712c9c82743b57375090d06130b90 (diff) | |
| download | bcm5719-llvm-1f9648da17c784e8d1923adc49b2cf5220b7badd.tar.gz bcm5719-llvm-1f9648da17c784e8d1923adc49b2cf5220b7badd.zip | |
Some (most) type trait expressions require that the argument passed in is a complete type.
llvm-svn: 74937
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 7afa5941dad..b6c2d0521fe 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -1023,17 +1023,23 @@ Sema::OwningExprResult Sema::ActOnUnaryTypeTrait(UnaryTypeTrait OTT, SourceLocation LParen, TypeTy *Ty, SourceLocation RParen) { - // FIXME: Some of the type traits have requirements. Interestingly, only the - // __is_base_of requirement is explicitly stated to be diagnosed. Indeed, G++ - // accepts __is_pod(Incomplete) without complaints, and claims that the type - // is indeed a POD. + QualType T = QualType::getFromOpaquePtr(Ty); + + // According to http://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html + // all traits except __is_class, __is_enum and __is_union require a the type + // to be complete. + if (OTT != UTT_IsClass && OTT != UTT_IsEnum && OTT != UTT_IsUnion) { + if (RequireCompleteType(KWLoc, T, + diag::err_incomplete_type_used_in_type_trait_expr, + SourceRange(), SourceRange(), T)) + return ExprError(); + } // There is no point in eagerly computing the value. The traits are designed // to be used from type trait templates, so Ty will be a template parameter // 99% of the time. - return Owned(new (Context) UnaryTypeTraitExpr(KWLoc, OTT, - QualType::getFromOpaquePtr(Ty), - RParen, Context.BoolTy)); + return Owned(new (Context) UnaryTypeTraitExpr(KWLoc, OTT, T, + RParen, Context.BoolTy)); } QualType Sema::CheckPointerToMemberOperands( |

