[cfe-commits] r83165 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDecl.cpp test/Sema/address_spaces.c
Tanya Lattner
tonic at nondot.org
Wed Sep 30 13:47:44 PDT 2009
Author: tbrethou
Date: Wed Sep 30 15:47:43 2009
New Revision: 83165
URL: http://llvm.org/viewvc/llvm-project?rev=83165&view=rev
Log:
Add an error for function parameters that have a qualified address space since this is not allowed by the embedded c extension spec.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/address_spaces.c
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=83165&r1=83164&r2=83165&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Sep 30 15:47:43 2009
@@ -571,6 +571,8 @@
"illegal implicit cast between two pointers with different address spaces">;
def err_as_qualified_auto_decl : Error<
"automatic variable qualified with an address space">;
+def err_arg_with_address_space : Error<
+ "parameter may not be qualified with an address space">;
def err_attribute_not_string : Error<
"argument to %0 attribute was not a string literal">;
def err_attribute_section_invalid_for_target : Error<
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=83165&r1=83164&r2=83165&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Sep 30 15:47:43 2009
@@ -3632,7 +3632,18 @@
<< D.getCXXScopeSpec().getRange();
New->setInvalidDecl();
}
-
+
+ // ISO/IEC TR 18037 S6.7.3: "The type of an object with automatic storage
+ // duration shall not be qualified by an address-space qualifier."
+ // Since all parameters have automatic store duration, they can not have
+ // an address space.
+ if (T.getAddressSpace() != 0) {
+ Diag(D.getIdentifierLoc(),
+ diag::err_arg_with_address_space);
+ New->setInvalidDecl();
+ }
+
+
// Add the parameter declaration into this scope.
S->AddDecl(DeclPtrTy::make(New));
if (II)
Modified: cfe/trunk/test/Sema/address_spaces.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/address_spaces.c?rev=83165&r1=83164&r2=83165&view=diff
==============================================================================
--- cfe/trunk/test/Sema/address_spaces.c (original)
+++ cfe/trunk/test/Sema/address_spaces.c Wed Sep 30 15:47:43 2009
@@ -4,7 +4,11 @@
#define _AS2 __attribute__((address_space(2)))
#define _AS3 __attribute__((address_space(3)))
-void foo(_AS3 float *a) {
+void bar(_AS2 int a); // expected-error {{parameter may not be qualified with an address space}}
+
+void foo(_AS3 float *a,
+ _AS1 float b) // expected-error {{parameter may not be qualified with an address space}}
+{
_AS2 *x;// expected-warning {{type specifier missing, defaults to 'int'}}
_AS1 float * _AS2 *B;
@@ -21,7 +25,7 @@
// chosen specifically to overflow 32 bits and come out reasonable
__attribute__((address_space(4294967500))) int *_boundsD; // expected-error {{address space is larger than the maximum supported}}
- *a = 5.0f;
+ *a = 5.0f + b;
}
struct _st {
More information about the cfe-commits
mailing list