[cfe-commits] r102390 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDecl.cpp test/SemaObjCXX/ivar-reference-type.mm
Douglas Gregor
dgregor at apple.com
Mon Apr 26 15:14:20 PDT 2010
On Apr 26, 2010, at 3:07 PM, Fariborz Jahanian wrote:
> Author: fjahanian
> Date: Mon Apr 26 17:07:03 2010
> New Revision: 102390
>
> URL: http://llvm.org/viewvc/llvm-project?rev=102390&view=rev
> Log:
> Diagnose declaration of reference typed ivars.
Thanks, Fariborz!
>
> Added:
> cfe/trunk/test/SemaObjCXX/ivar-reference-type.mm
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Sema/SemaDecl.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=102390&r1=102389&r2=102390&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Apr 26 17:07:03 2010
> @@ -1893,6 +1893,8 @@
> def note_member_def_close_match : Note<"member declaration nearly matches">;
> def err_typecheck_ivar_variable_size : Error<
> "instance variables must have a constant size">;
> +def err_ivar_reference_type : Error<
> + "instance variables cannot be of reference type">;
> def err_typecheck_illegal_increment_decrement : Error<
> "cannot %select{decrement|increment}1 value of type %0">;
> def err_typecheck_arithmetic_incomplete_type : Error<
>
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=102390&r1=102389&r2=102390&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Apr 26 17:07:03 2010
> @@ -5875,10 +5875,13 @@
> // validate II.
>
> }
> -
> + if (T->isReferenceType()) {
> + Diag(Loc, diag::err_ivar_reference_type);
> + D.setInvalidType();
> + }
> // C99 6.7.2.1p8: A member of a structure or union may have any type other
> // than a variably modified type.
> - if (T->isVariablyModifiedType()) {
> + else if (T->isVariablyModifiedType()) {
> Diag(Loc, diag::err_typecheck_ivar_variable_size);
> D.setInvalidType();
> }
>
> Added: cfe/trunk/test/SemaObjCXX/ivar-reference-type.mm
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/ivar-reference-type.mm?rev=102390&view=auto
> ==============================================================================
> --- cfe/trunk/test/SemaObjCXX/ivar-reference-type.mm (added)
> +++ cfe/trunk/test/SemaObjCXX/ivar-reference-type.mm Mon Apr 26 17:07:03 2010
> @@ -0,0 +1,5 @@
> +// RUN: %clang_cc1 -fsyntax-only -verify %s
> + at interface A {
> + int &r; // expected-error {{instance variables cannot be of reference type}}
> +}
> + at end
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list