Validate attributes on function parameters

Entry point function parameter can only have builtin and location
attributes (unless a disable validation attribute is present). Other
functions cannot have any decorations on their parameters.

Fix parameter creation in the CanonicalizeEntryPointIO transform for a
case where it was not stripping attributes that are not valid for
function parameters.

Change-Id: I000908aa2dc007c52d100c5f65bca051a49bec9a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55863
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
diff --git a/src/resolver/resolver.cc b/src/resolver/resolver.cc
index ce2e608..405f15c 100644
--- a/src/resolver/resolver.cc
+++ b/src/resolver/resolver.cc
@@ -927,15 +927,30 @@
   return true;
 }
 
-bool Resolver::ValidateParameter(const VariableInfo* info) {
+bool Resolver::ValidateParameter(const ast::Function* func,
+                                 const VariableInfo* info) {
   if (!ValidateVariable(info)) {
     return false;
   }
   for (auto* deco : info->declaration->decorations()) {
+    if (!func->IsEntryPoint()) {
+      AddError("decoration is not valid for function parameters",
+               deco->source());
+      return false;
+    }
+
     if (auto* builtin = deco->As<ast::BuiltinDecoration>()) {
       if (!ValidateBuiltinDecoration(builtin, info->type)) {
         return false;
       }
+    } else if (!deco->IsAnyOf<ast::LocationDecoration,
+                              ast::InternalDecoration>() &&
+               !IsValidationDisabled(
+                   info->declaration->decorations(),
+                   ast::DisabledValidation::kEntryPointParameter)) {
+      AddError("decoration is not valid for function parameters",
+               deco->source());
+      return false;
     }
   }
   return true;
@@ -1041,7 +1056,7 @@
   }
 
   for (auto* param : func->params()) {
-    if (!ValidateParameter(variable_to_info_.at(param))) {
+    if (!ValidateParameter(func, variable_to_info_.at(param))) {
       return false;
     }
   }